|
|
|
| |
Billboarding Tutorial
Where is the Object?
When an object is placed in the world using translations and rotations it becomes hard to find its world coordinates. In this section a simple technique to find the whereabouts in world coordinates of an object is presented. It is assumed that the object is rendered in the local origin. The technique tells you where the local origin is in world coordinates.
Again we have to look at the modelview matrix. The position of the local origin in camera's coordinates is know, it is the v vector of the figure bellow. But since the local origin's position is dependent on both the camera's position and orientation, one can't just add that position to the camera position.
What is needed is to reverse the orientation of the camera back to a coordinate system with axis aligned with the world coordinate system, then we can add the camera position to the object's position relative to the camera. This sum will provide the position of the object in world coordinates.
In order to reverse the orientation of the camera we use the inverse of M1. As mentioned before, the inverse of M1 is the transpose.
The object's position in world coordinates is therefore given by the expression
objPosWC = camPos + M1T * V
where camPos is the camera position in world coordinates, and M1T is the transpose of M1.
|