How to rotate 3D object?

Started by jumong, September 08, 2010, 04:30:05 AM

Previous topic - Next topic

jumong

I wanna rotate my 3D object
I did follow
boxgfx = Loader.load3DS(res.openRawResource(R.raw.obj), 50)[0];
boxgfx.setTexture("bw2");
boxgfx.rotateX((float)Math.PI);
boxgfx.translate(vec3d);
boxgfx.build();

but object doesn't rotate
What am I doing wrong?
         

paulscode

#1
I assume the back of the box looks different than the front?

jumong

#2
Yes, front color is white and back color is black...

Thank you for your replay, I always thanks for your help

EgonOlsen

Try something else as rotation angle (like PI/2) and see what happens. Rotations definitely work as they are an essential part of the whole thing...so either something with your code or with your model is fishy.

jumong


EgonOlsen


jumong

My full code

      public void onSurfaceCreated(GL10 gl, EGLConfig config) {
         TextureManager.getInstance().flush();
         world = new World();
         res = getResources();

         TextureManager.getInstance().addTexture("bw2",
               new Texture(res.openRawResource(R.raw.bw2)));

         boxgfx = Loader.load3DS(res.openRawResource(R.raw.obj), 50)[0];
         boxgfx.setTexture("bw2");
         boxgfx.rotateX((float) Math.PI/2);

                        boxgfx.translate(new SimpleVector(0,0,0));

         world.getCamera().setPosition(150, -50, -5);
         cameraPosition = new Vector3f(150, -50, -5);

         cameraTargetPosition = new Vector3f(0, 0, 0);
         world.getCamera().lookAt(0,0,0);

         Light light = new Light(world);
         light.setPosition(new SimpleVector(-200, -50, 80));
}

paulscode

A couple of things I noticed are that you haven't called 'build' on the object nor added it to the world.  Are you able to see the object at all?  As I mentioned in a previous thread, I haven't used the AE version of jPCT yet, but I would guess those are still required steps.

EgonOlsen

build() will happen automagically if you don't it on your own. However, adding to the world is required of course. The complete Activity code would be helpful. Please use code-Tags to post code (That's that # thing above the textarea).