Game Development Reference
In-Depth Information
treeClone.setLocalTranslation(location);
treeNode.attachChild(treeClone);
9. After parsing the whole terrain, tell the treeNode field to batch its contents to
optimize the performance and then attach it to the supplied Spatial .
10. Now, create an application class to test this. It's recommended that you use a test
case such as TestTerrainAdvanced to get a start.
11. Create a new Node class called worldNode , which we attach to rootNode
and then attach the terrain to.
12. Then, create a new TreeControl class and load and set a suitable model that
we can use as treeModel .
13. Finally, add the TreeControl class to worldNode .
After running the application, we will see trees spread out across the terrain—in valleys as
well as on top of the mountains. Depending on the environment, trees might not grow on
mountains. If we don't want this, we can add a simple check in the TreeControl class.
By adding a field called treeLimit , we can clamp the growth of the tree above a cer-
tain height; also, make sure the terrainHeight field is lower than the value supplied
from fractalSum .
Search WWH ::




Custom Search