Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

_DarkWIng_

Quaternion (look at function)

This topic is 6016 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

Can someone please give me a function that rotates quaternion so it faces some direction in space. So far I got this but it doesn''t work very well. It starts "shaking" very badly when it should stand still.. kind like pulse effect.. alternating small + and - rotation... void UCamera::SetDirection( const UVector &dir ) { if ( dir.IsZero() == true ) return; UVector adjustVec( dir.x, dir.y, dir.z ); adjustVec.Normalize(); float rotAngle = arccos( (-frontVector) % adjustVec ); // dot product UVector rotAxis = frontVector * adjustVec; // cross product if ( rotAxis.IsZero() == true ) { rotAxis = upVector; } UQuaternion rotQuat; rotQuat.SetAxisAngle( rotAxis.x, rotAxis.y, rotAxis.z, rotAngle ); rotation.PostMultiply( rotQuat ); RebuildVectors(); } There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites
Advertisement
sorry I can''t help you with your code, but there''s a new Game Programming Tutorial on NeHe''s site that demonstrates quaternion rotations.


------------------------------------------------------------
Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
------------------------------------------------------------

Share this post


Link to post
Share on other sites
wojtos: I know alot about quaternion rotations but this tutorial is not exacley the best. I just need this function or someone to tell me what is wrong with mine.

There are more worlds than the one that you hold in your hand...

Share this post


Link to post
Share on other sites

  • 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!