Archived

This topic is now archived and is closed to further replies.

xeos

Implementing Dynamic Height Maps?

Recommended Posts

I''m trying to implement a dynamic height map engine (similar to Chris Sawyer''s Tycoon series). I have done plenty of thought about the subject, and I thought that I should post my ideas here for a bit of "industry scrutiny". Here goes.... My terrain is made up of squares: X--X--X | | | X--X--X | | | X--X--X Each "X" represents a point which can be manipulated. These 9 points are stored floats within a class CSquare. My terrain class, CTerrain, creates an array of these based upon the size of the map specified in the level file. We call: CSquare *** m_aSquares = new CSquare[HEIGHT][WIDTH]; Next comes the initialization. We grab all the heights from the level file, the we''re ready to draw! We first find the square which will be shown in the middle of the screen. Then, based upon the zoom level, we calculate the maximum number of squares which COULD be shown, then we draw them all. Well... what do you think? Have I missed anything crucial? Or is there too much overhead for this system? All thought, comments and anything else are more than welcome! Simon Wilson

Share this post


Link to post
Share on other sites
Perhaps CSqaure[length][width] would make more sense, since it stores the heights

You could drop the third* if you want:
    
CSqaure** squares=0;
squares = new CSquare*[lenght];
for(int i=0;i<length;i++)
squares<i> = new CSquare;

//...

for(int i=0;i<length;i++)
delete squares[i];
delete[] squares;


From the square in the middle & the res/window size, calculate the visible length & width so you know exactly what squares are shown. (might be off a little on the edges, let the clipper get em)

Share this post


Link to post
Share on other sites