Author Topic: About setting rotation correctly in 3d with physics.(Solved)  (Read 1880 times)

Offline Wolf17

  • int
  • **
  • Posts: 77
    • View Profile
About setting rotation correctly in 3d with physics.(Solved)
« on: February 24, 2013, 08:44:03 am »
Hello!

    I have a problem in rotating my 3d box object in proportional to the jbox2d physics engine's box rotation. The rotation and translation of the physics shape is correct and my 3d box's translation are correct.But I'm messing with the rotation of my 3d box along its axis. It keeps rotating even if the rotation of the physics object has stopped and even rotates unrealistically fast or slow any time. I have never used a physics engine  before so maybe I am doing it in the wrong way. Can anybody tell me how to make it proportional.
   
« Last Edit: February 24, 2013, 08:37:50 pm by Wolf17 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: About setting rotation correctly in 3d with physics.
« Reply #1 on: February 24, 2013, 08:13:18 pm »
Are you using rotateMesh()? If so, don't do it. If not, just post the section of your code that does the rotation.

Offline Wolf17

  • int
  • **
  • Posts: 77
    • View Profile
Re: About setting rotation correctly in 3d with physics.
« Reply #2 on: February 24, 2013, 08:36:44 pm »
 hello Egon!

         I have Solved the problem Sir. Previously I was using  obj3d.rotateZ(physicsangle)   in the game loop  .I solved  it simply by using the object3d's rotation matrix to get updated in  game loop by setting it with the radians of physics update
                     
                       
Code: [Select]
                        Matrix mat=rov.getRotationMatrix();
mat.set(0,0 , -((float) Math.cos(angle)));
mat.set(0,1 ,((float) Math.sin(angle)));
mat.set(1,0 , -(float) Math.sin(angle));
mat.set(1,1 , -(float)Math.cos(angle));

rov.setRotationMatrix(mat);
.

   
     
« Last Edit: February 24, 2013, 09:01:38 pm by Wolf17 »