For one of my prototype B3D landscape systems, I was dividing the terrain into a grid, and then pre-generating and storing the following information for each cell:
* Central coordinates
* Random coordinate offset values for each foliage item
* Foliage type for each set of offset values
* Foliage scaling, rotation and tilting for each instance
I used a pre-generated heightmap to determine the type of foliage (if any) that existed in a cell. A different heightmap was used to determine foliage density.
This method, while probably not the most optimal, constructed a reasonably realistic landscape. It also had the added benefit of a ‘built-in’ LOD system – for the immediate cells around the player’s position I created the relevant sprites/meshes, the rest, beyond the player’s visibility, I destroyed.
My biggest problem was performance. All the creating and deleting of entities reduced the frame-rate considerably. On its own it was acceptable, but when I factored in the other calculations that must be done in the main loop (enemy AI, collisions, etc) it was just too slow.
I tried another technique, based on Banshee’s suggestions, I think, whereby the foliage instances were hidden, rather than destroyed, when they moved out of the player’s visibility range. They were later ‘shifted’ into a new position and unhidden if a foliage item of the same type came into the player’s view. I can’t remember why, but I hit a barrier with this technique. At that point I more or less gave up on B3D, due to the size my project had attained.
Incidentally, if you want heightmap generating code for your experiments, see my sig…
EDIT: Clarification: When I mention foliage ‘type’, I mean a byte or integer ID number. NOT a sprite/mesh instance.
* Central coordinates
* Random coordinate offset values for each foliage item
* Foliage type for each set of offset values
* Foliage scaling, rotation and tilting for each instance
I used a pre-generated heightmap to determine the type of foliage (if any) that existed in a cell. A different heightmap was used to determine foliage density.
This method, while probably not the most optimal, constructed a reasonably realistic landscape. It also had the added benefit of a ‘built-in’ LOD system – for the immediate cells around the player’s position I created the relevant sprites/meshes, the rest, beyond the player’s visibility, I destroyed.
My biggest problem was performance. All the creating and deleting of entities reduced the frame-rate considerably. On its own it was acceptable, but when I factored in the other calculations that must be done in the main loop (enemy AI, collisions, etc) it was just too slow.
I tried another technique, based on Banshee’s suggestions, I think, whereby the foliage instances were hidden, rather than destroyed, when they moved out of the player’s visibility range. They were later ‘shifted’ into a new position and unhidden if a foliage item of the same type came into the player’s view. I can’t remember why, but I hit a barrier with this technique. At that point I more or less gave up on B3D, due to the size my project had attained.
Incidentally, if you want heightmap generating code for your experiments, see my sig…
EDIT: Clarification: When I mention foliage ‘type’, I mean a byte or integer ID number. NOT a sprite/mesh instance.