Showing posts with label 3D. Show all posts
Showing posts with label 3D. Show all posts

Tuesday, May 13, 2008

Camera and Transform Matrices in Papervision3D

I've had some troubles to fully understand the matrices system in Papervision3D: between the view matrix, the transform, the camera eye, etc, etc...
But I think I've got it now. All you need to know in order to make transformations between world and camera coordinate systems is this formula:

o.view = camera.eye * o.transform

In other words, any DisplayObject3D o has a transform matrix that represents its transformation in the world coordinate system. It also has a view matrix that represents its transformation in the camera coordinate system. The camera's eye matrix allows to pass from the world to the camera coordinate system. In papervision3D:

o.view.calculateMultiply(camera.eye, o.transform);

will compute your object's updated view matrix. In the other direction:


o.transform.calculateMultiply( invEye, o.view);

will update the object's transform according to its view matrix. Note that invEye is the inverse of camera.eye.

One last piece of advice: I've noticed that modifying a view matrix alone doesn't change anything. If you modify the view, you need to update the transform according to the second formula.