PhysX - rotate object (DynamicBody)

Started by
-1 comments, last by Martin Perry 11 years, 11 months ago
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 smile.png

Thanks

This topic is closed to new replies.

Advertisement