Sign in to follow this  

calculating look direction from rotation

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

This topic is 3863 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.

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