Placing trees and bushes in an editor is fine for many types of games. There are many cases where you need objects to be in a very specific spot. When it comes to large-scale outdoor games, you might want to have a way of placing common objects in an automatic way, at least as a base. An artist or designer might then move items around to suit the needs of the game.
In this recipe, we'll create one such way that places trees using noise. Once the base is in, we'll take a look at how the pattern can be varied with different settings.
To produce automatic trees' distribution, perform the following steps:
We get right to the center of the things. Create a new class called
TreeControl
that extendsAbstractControl
.Add a
TerrainQuad
field calledterrain
, aFractalSum
field calledfractalSum
, aSpatial
field calledtreeModel
, and aBatchNode
field calledtreeNode
.Override the
setSpatial
method. Here, we declaretreeNode
.Then, assuming that the supplied...