important question about terrain handling

Started by
0 comments, last by Krylloan 19 years, 6 months ago
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
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.

This topic is closed to new replies.

Advertisement