xz oriented quad following camera(quaternion,matrix)

Started by
2 comments, last by filousnt 15 years, 10 months ago
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
Advertisement
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.
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.
When using the inverse of your suggested matrix, it works fine. Thx

This topic is closed to new replies.

Advertisement