Archived

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

Boris Karloff

Rotating the view matrix

Recommended Posts

I was just wondering about this... A lot of people speak of trouble with their lookat and up vectors when looking straight up or down, since these two vectors can''t be parallel to each other... I''m assuming that these people recalculate the view matrix every time the pos, lookat or up vector changes. Wouldn''t it be much easier to just set an initial view matrix to a position of (0,0,0), the lookat vector to (0,0,1) (forward) and the up vector to (0,1,0) (up), and then just multiply that matrix with the required rotation/translation matrices? That way, your two vectors are alway perpendicular, and you''d never have to worry about epsilons and looking straight up and such. Also, it would appear more efficient to multiply a matrix with two other matrices than to call D3DXMatrixLookAtLH... Or is there a better way?

Share this post


Link to post
Share on other sites
Gimbal lock != (up==direction)


Usual way is to simply take the dot product between the **approximate** up vector and the direction vector - if the angle is less than a threshold, swap the components of the up vector - simple.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites