Author Topic: How to rotate 3D object?  (Read 5896 times)

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
How to rotate 3D object?
« 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?
         

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: How to rotate 3D object?
« Reply #1 on: September 08, 2010, 06:10:50 am »
I assume the back of the box looks different than the front?
« Last Edit: September 08, 2010, 06:14:28 am by paulscode »

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
Re: How to rotate 3D object?
« Reply #2 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
« Last Edit: September 08, 2010, 08:10:28 am by jumong »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How to rotate 3D object?
« Reply #3 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.

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
Re: How to rotate 3D object?
« Reply #4 on: September 08, 2010, 08:38:33 am »
I did, but nothing changed...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How to rotate 3D object?
« Reply #5 on: September 08, 2010, 08:53:45 am »
Can you post the complete code?

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
Re: How to rotate 3D object?
« Reply #6 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));
}

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: How to rotate 3D object?
« Reply #7 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How to rotate 3D object?
« Reply #8 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).