Terrain: Adding and destroying on the fly

I've got a few questions about creating and adding to terrain pages.



I'm going to be working on a system that makes use of streaming height data from a server to describe a landscape to the client. I've built a wrapper for the terrainPage class, this wrapper will handle the multiple states and phases of each terrain page.



My real problem is in the concept of creating, modifying, and adding to terrain pages themselves.



Should I be creating 9 TerrainPage objects to show my landscape, and then manually deleting them as the player gets too far from them as I stream the now-nearby heightmaps? Or should I be doing something differently?



Can someone explain this concept a little bit more in-depth to me?

Hi and welcome to the forums :slight_smile:



I would keep a pool (or concrete number) of TerrainPages around then just update those as needed…

basixs said:

Hi and welcome to the forums :)

I would keep a pool (or concrete number) of TerrainPages around then just update those as needed...


Thanks. I've been lurking for a few months...

What do you mean keep a concrete number? For instance, when I unload a group, move them to the side that the player's viewport is moving toward and then refresh the height data?

Well, you mentioned 9 of them so that makes me think you are 'rolling your own' terrain system w/ a grid setup (like tic-tac-toe).  I needed to do to the same thing a while ago, and I found that you can create a fairly simple and quick system that 'reuses' 9 terrain pages. (hint only 3 OR 5 pages need to be updated when 'changed')

basixs said:

Well, you mentioned 9 of them so that makes me think you are 'rolling your own' terrain system w/ a grid setup (like tic-tac-toe).  I needed to do to the same thing a while ago, and I found that you can create a fairly simple and quick system that 'reuses' 9 terrain pages. (hint only 3 OR 5 pages need to be updated when 'changed')


Ah, I see.

HS <- HeightMap Size * Tile Size
WX <- 0
WY <- 0
X <- Player X
Y <- Player Y

IF X>WX+(HS/2) OR X<WX-(HS/2) THEN
   CALL refig()
END
IF Y>WY+(HS/2) OR Y<WY-(HS/2) THEN
  CALL refig()
END
WX <- ceil(floor(Player X/(HS/2))/2)
WY <- ceil(floor(Player Y/(HS/2))/2)

Good stuff. It just hit me that I am going to be streaming my heightmap data from the server, so I am going to want to create a threaded networking application to handle data interpretation seperately from my render loop... I've got some work to do. Thanks!