Sign in to follow this  
Martin Perry

PhysX - rotate object (DynamicBody)

Recommended Posts

Martin Perry    1553
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.

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

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
[code]
dOmega = Vector3::Normalize(moveUp) * angle / deltaTime
[/code]
But what should I do next... ? Something with "rigidBody.getMassSpaceInertiaTensor", but I am not really sure... physics is not my strongest field [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this