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

Started by
0 comments, last by MJP 13 years, 3 months ago
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)
Advertisement
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).

This topic is closed to new replies.

Advertisement