Jump to content
  • Advertisement
Sign in to follow this  
ramy

calculating look direction from rotation

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

Hey guys, i was wondering how to calculate the look direction vector from a rotation x, y, z vales i have. i have looked to this thread http://www.gamedev.net/community/forums/topic.asp?topic_id=352932 and i am having problems. I understand that i should be using Spherical-to-Cartesian conversion as the member stated, but its not working with me. NVector3 vDiff = NVector3(view.x, view.y, view.z); float XRot = atan2(-vDiff.y, sqrt(vDiff.x*vDiff.x + vDiff.z*vDiff.z)); float YRot = atan2(vDiff.x, vDiff.z); float sx = sinf(XRot); float cx = cosf(XRot); float sy = sinf(YRot); float cy = cosf(YRot); float x = sy*cx; float y = -sx; float z = cy*cx; view.x = x; view.y = y; view.z = z; is there anything im doing wrong? But im wondering where does the rotation x y z values come in here? btw im using Direct3D. thanks [Edited by - ramy on October 2, 2007 4:26:24 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you are using left-handed coordinate system this works fine, otherwhise you probably have to multiply focusLength with -1.

Vector3 lookAt = new Vector3(0, 0, this.focusLength);
lookAt.TransformCoordinate(Matrix.RotationYawPitchRoll(this.rotation.Y, this.rotation.X, 0));
lookAt += this.location;
return lookAt;

Share this post


Link to post
Share on other sites
what is the focus length?

actually im implementing as what i wrote in the post, and its not working, maybe its my custom rotation control i implemented :S not sure how to check

[Edited by - ramy on October 2, 2007 4:24:51 PM]

Share this post


Link to post
Share on other sites
yup, thanks a million. it worked out for me. plus my visuals were miss leading, so its all ok now =D

thanks Chimaira

[Edited by - ramy on October 2, 2007 4:18:31 PM]

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.

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!