Jump to content
• ### What is your GameDev Story?

• Advertisement

# Camera (Obtain World Matrix)

This topic is 3832 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

I have a camera, that I set pos/lookat/up vectors with. I want to be able to render a box where the camera is. To do this, I want to build a world matrix from the position the camera is at (simple), but I also need the rotation. So, what I have: Pos - position of the camera (translation) Look - look point of the camera. Dir - direction vector (subtracted from pos and normalized) Up - my up vector. View matrix So, to get a world matrix with rotation, should I calculate it based on my direction vector and try to figure out some calculation that way, or is it easy to get that from the view matrix (maybe invert it) Not sure. Any thoughts? Thanks

#### Share this post

##### Share on other sites
Advertisement
Just invert your view matrix.

#### Share this post

##### Share on other sites
The inverse of the view matrix is the camera's world-space matrix. You can use that to transform the box. Of course you'd need a second camera, because if you always rendered a box where the first camera was, and you were always rendering the scene from the point of view of that camera, then you'd always have this box in your face [grin]

#### Share this post

##### Share on other sites
MJP,
Thanks, I probably should have just tried, that lol!

Zipster,
Of course! :)

Thanks,
Jeff.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement
• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• ### Popular Now

• 12
• 11
• 15
• 11
• 11
• Advertisement
• ### Forum Statistics

• Total Topics
634149
• Total Posts
3015835
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!