# So I guess I know less about matrix transformations than I thought...

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

## Recommended Posts

The title is somewhat explanatory. I know how to build matrices for all of the common transformations (translation, rotation around a fixed or arbitrary axis, scaling) and how to multiply matrices. Now that I'm writing some code for a [very] simple 3D engine, I'm not sure how to use this knowledge. Let's say I have two classes: camera and object. A camera has the properties: position and rotation (yaw, pitch, roll). An object has the properties: position, rotation, and scale. Each of these properties can be represented as a 3-part vector of floating point values. I'm completely stumped on how to use this information to properly build a model/view matrix. I've played around with the order of transformations a bit, but I have so far only ended up with weird, distorted geometry and blank screens. I've been googling unsuccessfully, as I'm not even sure which keywords to search for. Is there a guide on this topic somewhere that you can point me to? Or an obvious solution that will make me question my intelligence? Any help is appreciated.

Camera
- World coordinates (x, y, z)
- Rotation (yaw, pitch, roll)

Object
- World coordinates (x, y, z)
- Rotation (yaw, pitch, roll again?)
- Scaling (x, y, z)

##### Share on other sites
It's simple. All you need to do is create a "world" matrix for you camera using the position and rotation, and then you can invert it to create a "view" matrix.If you think about this it makes sense: a world matrix takes coordinates from "local to the object space" to "world space", and a view matrix takes things from "world space" to "local to the camera space". So naturally the inverse of a camera's world matrix accomplishes that. Once you have your "world" and "view" matrices, you multiply them to get your traditional OpenGL "modelview" matrix (also referred to as "worldview" in most cases).

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013603
×