# 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.

## Recommended Posts

any way of getting world space co-ordinates from a view matrix? should this just be the eye pos vector?

##### Share on other sites
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 on other sites

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

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632993
• Total Posts
3009765
• ### Who's Online (See full list)

There are no registered users currently online

×