#### Archived

This topic is now archived and is closed to further replies.

# View Matrix. Help needed

This topic is 5816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, Perhaps this question will seem really dumb to a lot of people but I´m very confused with the View Matrix inner workings... I´m using directx and I can set a View Matrix Transform by calling the SetTransform method of the Dx8 Device. What I don´t undestand is this: I have read that the first three columns in the matrix are axis(representing camera space?), is this true? I mean, following what I read first row is Right, second up and third the look at vector, which represents the 3 local camer axis. When at first I tried to make my own camera class what I did was move the world in the opposite sense the camera was moving( I read this I don´t know where too), so, I ask myself: we give dx a view matrix based on this three vectors, so... is dx calculating the right values to get the world moving the way I did at first (opposite to the camera)?. Ummmm... sorry if this is a bit messed, but what I really hate is to write about something I don´t really know how it works. Thanks. HexDump.

##### Share on other sites
A camera (view matrix) is no different than an object matrix (world matrix)

A matrix consists of the following fields.

rx ux fx 0ry uy fy 0rz uz fz 0px py pz 0

You will have your positional information on the bottom, and the location which the camera is facing in the R/U/F fields (right, up, forward angles)

The FOV, aspect ratio, zbuffer planes are stored in the projection matrix, so you won''t see anything regarding that in the view matrix. The viewmatrix is just as you see above, direction + positional vectors of the camera.

To convert the camera/view matrix into World space, you need to inverse it.

D3DXMatrixInverse();

After Inversing it, you should see where its facing/located in the world.

To move the camera around, you would do something like this:

D3DXMatrixTranslation(&tempMatrix, x,y,z);
D3DXMatrixMultiply(&camera, &camera, &tempMatrix);

or

D3DXMatrixYawPitchRoll(&tempMatrix, x,y,z);
D3DXMatrixMultiply(&camera, &camera, &tempMatrix);

You make a movement or rotation matrix by itself, then multiply it to the "real" camera matrix.

Make sure you Identity the Camera matrix when when you start up the program.

Thats all you need to do with the camera. Pretty simple actually.

To move objects around in the world, you make all objects (meshes) with its center point at 0,0,0.

Then you do the same thing with the world matrix to position/direction the object in the world. Then draw it.

Typically for every frame,

You modify the camera matrix as needed.
Set the view(camera) matrix.
For each object in the world...
Modify the object matrix as needed.
Set the world(object) matrix.
Draw object.
next

I dont know if this helps, its actually pretty easy once you get the hang of it.

1. 1
2. 2
Rutin
23
3. 3
4. 4
frob
16
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632579
• Total Posts
3007169

×