# world coordinates relative to the origin...

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

## Recommended Posts

Good afternoon folks. I have a general question today about drawing the contents of your world and the camera relative to the origin in 3D coordinate space. The way I see it, there would be two ways to do it: 1) Absolute coordinates. If your character is in location (300, 10, 250), then you move your camera to look at that point from a near distance. All other objects are rendered in their absolute coordinates as well. So, if a tree is +50 from the character in the Z direction, it gets drawn at (300, 10, 300). 2) Relative coordinates. If your character is in location (300, 10, 250) he still gets drawn at the origin, and the camera still looks at the origin from a nearby distance. Everything else gets translated outward from the origin by their distance to the character. So, if a tree is +50 from the character in the Z direction, it gets drawn at (0, 0, 50). Please note that I am not taking into account any kind of frustrum culling, Octree culling, or any other kind of polygon selection here, I'm referring only to things that you already know are visible. I'm just wondering whether people set up their DirectX world space in absolute coordinates that the game state maintains, or in relative coordinates derrived from the characters distance to objects in the game state. Is there any conventional wisdom about this? Mike

##### Share on other sites
I think it really depends on the scale of your world. If the world is relatively small so that the numerical precision you get while rendering is not an issue, then absolute coordinates will work out just fine and are certainly simpler to use. For my current project I am doing this.

If the world is large, you begin to run into issues with numerical precision and need to do something else. At that point everything should be drawn relative to the camera, and all positions should be shifted before they are rendered. This is definately true for any type of terrain rendering, since landscapes tend to span quite far.

##### Share on other sites
Ahh interesting. So a float eventually becomes too small to span the distance from one end of your map to the other in the game state?

##### Share on other sites
Assuming you don't have problems with numerical precision (which most people don't have to worry about), the standard way of doing it is to represent the locations and orientations of all objects in world coordinates. The location orientation of the camera is also represented in world coordinates.

When rendering, as an initial step, a transformation matrix is computed which transforms world coordinates into camera-relative coordinates (aka view or camera space). This is matrix is usually called the "view" matrix. You simply hand the view matrix to the renderer and it does the transformations of all the objects as part of the rendering pipeline.

##### Share on other sites
There's nothing stopping you from getting the same precision with absolute coordinates. You could do a check every so often to determine the distance the camera is from the world origin. If it's incredibly far, you could move everything in your world to the point where the camera rests at 0,0,0. This could be an external operation that happens all at once, rather than having objects always moving even when still.

It could still bite you if you're not careful, though. My current project would be a nightmare to add this to. World coordinate data is absolutely everywhere.

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633321
• Total Posts
3011351
• ### Who's Online (See full list)

There are no registered users currently online

×