View, World & Projection Matrices,
Members - Reputation: 110
Posted 18 April 2012 - 04:17 PM
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?
Crossbones+ - Reputation: 3133
Posted 18 April 2012 - 04:36 PM
Members - Reputation: 841
Posted 19 April 2012 - 08:15 AM
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.
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/