Jump to content
  • Advertisement
Sign in to follow this  
TheUmpteenth

World space from view matrix

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

Advertisement
The world space coordinates of what? The camera?

The eye position is (usually) the position of the camera in world space.


If you have an arbitrary position or direction in camera (view) space that you want in world space, transform by the inverse of the view matrix. Saying "View matrix" on its own isn't really descriptive enough; re-write it as "World space To View space transformation matrix" and it should be more apparent what transforming something by the inverse of that matrix will do.

Share this post


Link to post
Share on other sites
Thanks for the quick reply

Quote:

The world space coordinates of what? The camera?


yes, the camera.

I want to make something follow the camera, so I need to be able to access its position.

my Veiw Matrix is an ordinary RULP matrix (Right, Up, Lookat, Position)
the four vectors are also stored separately, as the view matrix stores the dot product of position and the other 3 vectors in the P vector slot.

so the eye pos should be the camera's position and if I want to pass it out to make something follow the camera, this should do it?

Share this post


Link to post
Share on other sites
If you need access to the "base" data elsewhere in your application it's common practice to just cache it somewhere for later retrieval.

Your approach is more like what you'd use if your code doesn't create the matrix and you have no access to the original data.

It's worth considering two things:

  • "I want to make something follow the camera" - you're obviously tying your simulation and presentation layers. This isn't always a good design philosophy. Equally, duplication isn't so good, but this might be an early sign that you need to consider your architecture.

  • Attempting to decompose transformation matrices can be an involved process - both in code form (easy to introduce bugs) and for the actual hardware (can require a lot of calculations). Doing this for each and every "get" of your camera's location may not be a good idea when a simple refactoring could allow you to fetch 3 float's from memory.

    hth
    Jack

    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.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!