[quote]Fantastic vegetation. I’ve been recently looking into that. What technique did you use for the grass and trees? That’s exactly the look I wanted to go for in my app. Any pointers would be great. Keep it up, it’s starting to look fantastic.
[/quote]
This could get lengthy, but here we go:
There are two similar systems in place, one for the trees and other “big” items (like buildings and so) and one for the tile decoration.
Whenever the user moves to a new tile, the engine scans the closest tiles with a simple for (x=-n; x<n; x++) for (y=-n; y<n; y++) for trees.
For each tile that contains a tree, it calculates how far away it is from the tile the user and how many tree neighbors it has.
If the ratio of neighbors versus distance is over a certain threshold, AND the tree is on an “odd” tile (odd==((x+y)&1)), that tree is ignored. (effectively “trimming” dense forests when they are far away that you don’t notice the difference)
Then a new Random is created with xsomePrime+ysomeOtherPrime as the seed, and a new Tree object is created based on that Random object. This will ensure that a tree on a specific tile will always look the same without me ever having to store that information. Information like offset within the tile, rotation, size and color is generated.
That Tree object is then added to a SortedSet, sorted by distance.
The rendering loop iterates over the set, checks if the tile the tree is on is visible, and renders the tree if it is. The first trees up to a certain limit are rendered in high detail mode (right now just a cross of three polygons. Will be full models later), and the rest are rendered in low detail mode (billboards). When more than the maximum number of trees has been rendered, the iterator exits.
Tile decorations work almost the same, with the exception of the texture of the tile deciding what types of decorations will be added to it. The amount of decorations added to a tile depends on the distance to that tile, with the biggest decorations being added first.