Archived

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

UnIcron

cube maps again

Recommended Posts

UnIcron    122
I''ve been trying to get cubic environment mapping to work and I have a couple of questions. Generating the textures was easy, but rotating the texture matrix so that the textured object looked right with a changing eye position had me stuck for a while. According to the extension registry, "The rotation can be computed based on two vectors: 1) the direction vector from the cube map center to the eye position (both in world coordinates), and 2) the cube map orientation in world coordinates. The axis of rotation is the cross product of these two vectors; the angle of rotation is the arcsin of the dot product of these two vectors." Could someone please give me a more detailed explanation of how this is supposed to work? In particular, what is the one vector that is supposed to represent the cube map''s orientation? Since I didn''t understand this explanation, I came up with my own solution, and I would like someone to tell me if it''s "right". What you want is for the texture to rotate in exactly the opposite way that the eye orientation rotates. The modelview matrix after a call to gluLookAt contains rotation and translation information. First get rid of the translation information by setting those cells to 0. You''re left with a matrix that can be expressed as some rotation matrix R about some angle t. What you want is R(-t). Fortunately, R(-t) = R-1 and R-1 = RT. So, all you have to do now is find the transpose of the modelview matrix sans translation information, and that is the proper texture matrix. Is this right? Any help clearing up misconceptions would be appreciated.

Share this post


Link to post
Share on other sites