Jump to content
  • Advertisement
Sign in to follow this  
tomer_sh

important question about terrain handling

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

Hi all! I have an engine, that loads a terrain out of a heightmap. It is composed out of 2D array. How would I sort it accuartely. Given a position in the map (X , Y), and a degree of Y-rotation. are there any methods besides BSP, Z-sorting and Z-Buffer?? Cheers, Tomer

Share this post


Link to post
Share on other sites
Advertisement
Sort? I assume you want to know what polygons to draw first?

This is very easy. Start at the edges and work towards the XY position of the viewer. So if you have a 10x10 matrix and you are at point x=3,y=4, draw the columns(y=vertical) in this order: 0, 1, 2 (starting at 0, moving toward eye), 9, 8, 7, 6, 5, 4, 3 (starting at 9, moving toward eye). For each column, draw the tiles(the map squares) in this order: 0, 1, 2, 3(starting at 0 moving toward eye), 9, 8, 7, 6, 5, 4 (starting at 9, moving toward eye).

The rotation can be ignored, as it does not affect how far away things are.

This ensures a correct back-to-front drawing order. If you need efficiency you will need to do some culling of tiles. The first step here can be to find the most northerly, southerly, easterly and westerly tiles that could possibly be drawn, and start at those points instead of the edges.

If this is the first thing you draw, there is no need to do depth testing. However, you still want to be writing the depth values to the Z-buffer if you plan on using Z-buffering for the things you draw on top of the map.

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.

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!