Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

PHysX help with rotation of trigger shape

This topic is 3870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
That is a no on the fix.

fromAngleAxisFast takes radians as an argument. fromAngleAxis takes degrees. I see the angle if its over 360 get modulus performed on it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!