www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: jumong on September 08, 2010, 04:30:05 am

Title: How to rotate 3D object?
Post by: jumong on September 08, 2010, 04:30:05 am
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?
         
Title: Re: How to rotate 3D object?
Post by: paulscode on September 08, 2010, 06:10:50 am
I assume the back of the box looks different than the front?
Title: Re: How to rotate 3D object?
Post by: jumong on September 08, 2010, 08:06:37 am
Yes, front color is white and back color is black...

Thank you for your replay, I always thanks for your help
Title: Re: How to rotate 3D object?
Post by: EgonOlsen on September 08, 2010, 08:27:13 am
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.
Title: Re: How to rotate 3D object?
Post by: jumong on September 08, 2010, 08:38:33 am
I did, but nothing changed...
Title: Re: How to rotate 3D object?
Post by: EgonOlsen on September 08, 2010, 08:53:45 am
Can you post the complete code?
Title: Re: How to rotate 3D object?
Post by: jumong on September 08, 2010, 09:14:28 am
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));
}
Title: Re: How to rotate 3D object?
Post by: paulscode on September 08, 2010, 11:32:48 am
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.
Title: Re: How to rotate 3D object?
Post by: EgonOlsen on September 08, 2010, 12:05:01 pm
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).