Jump to content

  • Log In with Google      Sign In   
  • Create Account

PhysX - rotate object (DynamicBody)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Martin Perry   Members   -  Reputation: 1343

Like
0Likes
Like

Posted 20 May 2012 - 06:09 AM

Hi,

I am using PhysX and I need to rotate object with mouse movement around its axis. Every object in my scene has its own coordinates Up, Forward, Right for calculating movements and velocity.
If I rotate object, i rotate those vectors as well.

//angle - mouse change angle in rads
Quaternion quat = Quaternion::Rotation(moveUp, angle);  
moveRight = Vector3::TransformNormal(moveRight, quat);
moveForward = Vector3::TransformNormal(moveForward, quat);

But now for PhysX part. Object rotates correctly, if I use setGlobalPose and manually set rotation. Hovewer, that messed up physics and interactions. So I tried to rotate object with addTorque. But that produces wrong result. Object and my vectors are incorrect. Object rotation is different, so if I move object in direction of "forward" it goes other way, than object is really heading.
How to deal it and achieve correct rotation ?

I have calculated change in angular velocity
dOmega = Vector3::Normalize(moveUp) * angle / deltaTime
But what should I do next... ? Something with "rigidBody.getMassSpaceInertiaTensor", but I am not really sure... physics is not my strongest field Posted Image

Thanks

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS