Followers 0

# What objects do I use matrices for?

## 4 posts in this topic

So, I've been looking alot into matrices lately. I understand all the "math-parts" regarding multiplying, adding them together and all that stuff. What I can't seem to get a grasp of is when do I use them correctly? I know that they are very effective when it comes to camera's. But do I also use them for models?

So that I have a position vector and a rotation vector, load them into a Float buffer and do glLoadMatrix('floafbuffer'); for every model/object that I want to render aswell? Or do I not need to use matrices for theese stuff?

If so, what do I use them for? Only cameras?

Im using Java with OpenGL btw. (LWJGL)

EDIT: I accidentaly posted this in Math and Physics, I meant to post it in "For Beginners". So if any moderator sees this, could you please move it? Thanks! Edited by Slushy
0

##### Share on other sites
That is really helpful, thanks alot! I'll have to read up on some further stuff regarding world/local/image coordinates but thanks again! Edited by Slushy
0

##### Share on other sites
The three transforms:

World - Changes the vertices from local space to world space. This assigns a position/rotation/scale to the model in the world space. It can be thought of as placing an object in a room.
View - Changes the vertices from world space to 'camera' space. This essentially changes everything so that the camera is the origin. It can be thought of as positioning the camera to look at the object.
Projection - This is the weird one. The camera angle creates a sort of rectangular cone shape. In order to get pixel colors we want that to be a 3D rectangle. In other words we want the near plane of the frustum (the visible area) to have the same width and height of the far plane of the frustum. The result is that things nearer to the camera get stretched a bit so they look closer. Once this is done the graphics hardware can look in straight lines from the center of where each pixel maps to the near plane to the same x/y coordinate on the far plane and if there's an intersection then we fetch a color value for the point on the polygon where the intersection occurs.

Since these transforms can all be described as matrices they can all be multiplied to get a single matrix that can correctly perform all three steps on each vertex in the model.

Here's a Microsoft article that discusses it a bit:

[url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb206269%28v=vs.85%29.aspx"]http://msdn.microsof...9(v=vs.85).aspx[/url]

You could also use matrices or quaternions to implement complicated rotations in three dimensional space, such as for a flight simulator or spacecraft simulator where where you have to compound several angles/vectors together. Edited by Khatharr
1

##### Share on other sites
[quote name='Khatharr' timestamp='1352577261' post='4999709']
The three transforms: ....
[/quote]

Wow, yet again. That is extremely helpful! I can't believe the help im getting out of this forum, greatly appreciated. Thanks again! [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
0

## Create an account

Register a new account