View, World & Projection Matrices

Started by
1 comment, last by lauris71 12 years ago
Hi!

I'm struggling to understand to goal of the mentioned matrices. I only know the meaning behind the World matrix. If I get that right that looks something like this:
Every model has it's own coordinate system wich occasionally may differ from the one we use on our programs. With the WorldMatrix we can convert the model's vertices to our world position with a simple multiplication: mul(vertex.position, worldMatrix);

Now with the other two I have no idea what to do. Could someone give me a slight explanation what are they good for and why?

Thanks,
Joe
Advertisement
Model (or world) matrix is used for transforming an individual node or object within the world. View matrix is for transforming the world relative to the camera view, so that the objects that are supposed to be visible as determined by the camera are transformed into the view frustum. The projection matrix is responsible for "flattening" the visible frustum and fitting it to the device coordinates of the screen.
You can think about the view matrix the following way:
Camera is just one object in your world. I.e. it has it's own local coordinate system (0 is at camera center, Z axis is oriented in camera direction, X is usually horizontal). Let's call it camera matrix.
Now camera matrix would allow you to transform camera vertexes to world coordinate system. But you need to do the reverse - transform world vertexes to camera coordinate system (the projection to 2D image happens relative to camera, not world).
For that you use the inverse of camera matrix - what is called the view matrix.

Projection is special kind of matrix, which transforms everything in the view frustum of camera into standardized clip space. To be more precise, it is not pure matrix multiplication but multiplication followed by perspective division. As a result the view frustum of camera will be converted to unit cube (-1,-1,-1 - 1,1,1 in case of OpenGL). At that stage polygons are clipped (regions outside of cube removed) and then rasterized to 2D.
Lauris Kaplinski

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/

This topic is closed to new replies.

Advertisement