Sign in to follow this  

xz oriented quad following camera(quaternion,matrix)

This topic is 3477 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 quad ( pos(0,0,0), normal(0,1,0) ) that is oriented in xz ( by 45 deg in model space ). Camera is above it by a given elevation ( change with cam movements ). The quad must always follow camera ( xz axis only, x(1,0,0) z(0,0,1) ). the orientation of the quad in xz (45 deg) must remain the same when view from camera. visual example : Free Image Hosting at www.ImageShack.us I can access camera orientation (quaternion), position (vector3) and view matrix(directx matrix). How can i build a matrix that makes the quad fulfill all the conditions ? Thx

Share this post


Link to post
Share on other sites
I hope I understood your desire correctly. The following steps assume that the camera is given w.r.t. the global co-ordinate frame, and that the model should be given in that frame.

Convert the quaternion to a matrix and isolate the "front" orientation vector from it. Set its y component to 0 and re-normalize the result (of course, you have to catch the cases when looking straight up or down since then the said vector is 0). Use this vector and the original orientation vector of the plane (i.e. those denoting the principal direction of the corner you want to look at coarsly) inside a dot-product and cross-product to compute an axis/angle pair for a rotation matrix. Then isolate the position from the camera and again set the y co-ordinate to 0 (assuming that 0 is the height level of the plane). Compute a translation matrix from that vector. Then concatenate both new matrices to yield in the model-to-global transformation.

Share this post


Link to post
Share on other sites
thx for the answer. The orientation that result from your suggestion has a fixed y angle and we can look around xz like a lighthouse lamp. I am looking for
the opposite : xz angle is fixed and we can look around y angle like a big wheel. Sorry that my first post isn't as understandable as it should be.

Share this post


Link to post
Share on other sites

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