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

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 on other sites
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.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 13
• 14
• 45