Sign in to follow this  
MARS_999

PHysX help with rotation of trigger shape

Recommended Posts

I have a trigger box shape that I am trying to rotate to match my .3ds model. The model is being rotated with a call to glRotatef(). I can't get the shape to match the same rotation, I can rotate it but not get it to match. //rotate trigger to match model NxShape*const* shapes = actor->getShapes(); NxU32 nShapes = actor->getNbShapes(); while(nShapes--) { NxMat34 pose = shapes[nShapes]->getGlobalPose(); Matrix4x4 m; pose.getColumnMajor44(m.matrix); m *=powerUpRotationMatrix;//this matrix holds the rotation pose.setColumnMajor44(m.matrix); shapes[nShapes]->setGlobalPose(pose); } I am hoping for something simpler that deals with PhysX directly. Like glRotatef() and in degrees so I can just send in the same value. As below static float angle = 0.0f; ++angle; glRotatef(angle, 0.0f, 1.0f, 0.0f) what do I need to do to the shape to send in angle? Thanks

Share this post


Link to post
Share on other sites
Something along the lines of this should do it

static float angle(0.0f);
++angle;

NxQuat q;
q.fromAngleAxis (angle, NxVec3(0, 1, 0));

//direct
actor->setGlobalOrientationQuat (q);

//or if you're working with an extracted desc
desc.localPose.M.fromQuat (q);



Share this post


Link to post
Share on other sites
jezham thanks for the reply. I am not sure what is wrong, but the trigger box shapes go crazy when the box has rotated a couple rotations... The box expands...

[Edited by - MARS_999 on May 9, 2008 9:35:07 PM]

Share this post


Link to post
Share on other sites
In theory that shouldn't happen ;)
are you keeping angle within it's range, eg

while (angle >= 360.0f) angle -= 360.0f;

I know OpenGL isn't fussy, but perhaps PhysX is?


edit: I am wondering now (as unable to check at this time) if angle should be represented in radians? If so, just multiply it by (pi / 180.0)

Share this post


Link to post
Share on other sites
Quote:
Original post by jezham
In theory that shouldn't happen ;)
are you keeping angle within it's range, eg

while (angle >= 360.0f) angle -= 360.0f;

I know OpenGL isn't fussy, but perhaps PhysX is?


edit: I am wondering now (as unable to check at this time) if angle should be represented in radians? If so, just multiply it by (pi / 180.0)


Yeah I check the angle limit with

++angle;
if(angle > 360.0f)
angle = 0.0f;

I don't know if it needs radians or not, I am at work and will try when I get home. 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