Jump to content
  • Advertisement
Sign in to follow this  
jujumbura

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.

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

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


Link to post
Share on other sites
Advertisement
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 this post


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


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


Link to post
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.

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!