About setting rotation correctly in 3d with physics.(Solved)

Started by Wolf17, February 24, 2013, 08:44:03 AM

Previous topic - Next topic

Wolf17

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.
   

EgonOlsen

Are you using rotateMesh()? If so, don't do it. If not, just post the section of your code that does the rotation.

Wolf17

#2
 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
                     
                       
                        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);
.