Jump to content
  • Advertisement
Sign in to follow this  
Daggerbot

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

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!