Jump to content
  • Advertisement
Sign in to follow this  
Mort

PhysX problem with NxActor.setGlobalOrientationQuat

This topic is 3492 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 recently started using PhysX to add better physics simulations to my graphics engine. However I'm experiencing some strange problems when rotating an actor, by calling MyNxActor.setGlobalOrientationQuat(). The call appears to work fine with certain quaternions, but with other quaternions the result becomes corrupted. I will show a snippet of my code first: WCHAR sBuffer[200]; // I read some quaternion values from a 3D object in my graphics engine and apply the values to a NxQuat PhysX quaternion. NxQuat Quaternion; Quaternion.setXYZW(m_pEngineObject->QuaternionX, m_pEngineObject->QuaternionY, m_pEngineObject->QuaternionZ, m_pEngineObject->QuaternionAngle); swprintf_s(sBuffer, 200, L"1) X: %2.3f Y: %2.3f Z: %2.3f W: %2.3f\n", Quaternion.x, Quaternion.y, Quaternion.z, Quaternion.w); OutputDebugString(sBuffer); // The quaternion is applied to my NxActor ( m_pPhysicsActor is of type NxActor* ). m_pPhysicsActor->setGlobalOrientationQuat(Quaternion); // I then retrieve the newly applied quaternion again to check if it has the same value as previously. NxQuat RetrievedQuaternion = m_pPhysicsActor->getGlobalOrientationQuat(); swprintf_s(sBuffer, 200, L"2) X: %2.3f Y: %2.3f Z: %2.3f W: %2.3f\n", RetrievedQuaternion.x, RetrievedQuaternion.y, RetrievedQuaternion.z, RetrievedQuaternion.w); OutputDebugString(sBuffer); The code has been enriched with some debug statements that allow me to monitor the quaternion values I put into the NxActor and the quaternion values I retrieve from the actor again. I will show the debug output below, to demonstrate the values put into and read again from the NxActor. Notice how the values appear correct to begin with and then suddenly become incorrect. If you are very sharp at math, you may see that what is happening between each iteration is that the actor is being rotated 1 degree around the X axis. The error begins ocurring after the actor has been rotated to -90 degrees around the X axis (The second sample below here shows -90 degrees). Debug output values: 1) X: -0.694 Y: 0.000 Z: 0.000 W: 0.720 2) X: -0.694 Y: 0.000 Z: 0.000 W: 0.720 3) X: -0.694 Y: 0.000 Z: 0.000 W: 0.720 1) X: -0.700 Y: 0.000 Z: 0.000 W: 0.714 2) X: -0.700 Y: 0.000 Z: 0.000 W: 0.714 3) X: -0.700 Y: 0.000 Z: 0.000 W: 0.714 1) X: -0.706 Y: 0.000 Z: 0.000 W: 0.708 2) X: -0.706 Y: 0.000 Z: 0.000 W: 0.708 3) X: -0.704 Y: 0.000 Z: 0.000 W: 0.709 1) X: -0.710 Y: 0.000 Z: 0.000 W: 0.703 2) X: -0.710 Y: 0.000 Z: 0.000 W: 0.704 3) X: -0.707 Y: 0.000 Z: 0.000 W: 0.706 1) X: -0.713 Y: 0.000 Z: 0.000 W: 0.700 2) X: -0.711 Y: 0.000 Z: 0.000 W: 0.702 3) X: -0.704 Y: 0.000 Z: 0.000 W: 0.707 1) X: -0.710 Y: 0.000 Z: 0.000 W: 0.701 2) X: -0.706 Y: 0.000 Z: 0.000 W: 0.705 3) X: -0.688 Y: 0.000 Z: 0.000 W: 0.718 1) X: -0.694 Y: 0.000 Z: 0.000 W: 0.712 2) X: -0.687 Y: 0.000 Z: 0.000 W: 0.720 3) X: -0.649 Y: 0.000 Z: 0.000 W: 0.749 1) X: -0.655 Y: 0.000 Z: 0.000 W: 0.743 2) X: -0.644 Y: 0.000 Z: 0.000 W: 0.755 3) X: -0.576 Y: 0.000 Z: 0.000 W: 0.805 1) X: -0.583 Y: 0.000 Z: 0.000 W: 0.799 2) X: -0.574 Y: 0.000 Z: 0.000 W: 0.812 3) X: -0.477 Y: 0.000 Z: 0.000 W: 0.872 You may have noticed that although the previously shown code only shows debug lines 1 and 2, debug line 3 is shown too. Line 3 shows the actor quaternion value, after running a scene simulation. The actor itself is a NxBox without a body and should not be affected by the scene simulation. Can anyone tell me if I am doing anything wrong or if the MyNxActor.setGlobalOrientationQuat() does indeed contain an error ?

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!