here is a short preview of a small app that I use to test a component that I am currently designing to create forests.
Here, the trees are palm trees, homebrewed tree model.
The forest component is useable under Urho3D like any other component:
... Node* node = scene_->CreateChild("Palm forest"); palmForest = node->CreateComponent<Forest>(); palmForest->Init(scene_, "Models/PalmTree.mdl", 200, 800); ...
Then, some parameters can be set like the inner radius, the outer radius, the spread angle and the sector. The model file (with its materials and texture) is also specified, along with the maximum number of trees to place.
Each tree is randomly vertically scaled using a scaling factor that has a default value but that can also be altered.
Finally, each tree is randomly rotated around the Y axis.
The component will try to put as much trees as possible in the area defined by the parameters (or by the default ones if no specific parameter is modified). This means that since each tree needs a space around it (another parameter that can be specified), there might be some situations where all the requested trees cannot be inserted and the component returns with the actual number of trees it has successfully put.
Another constraint is that the scene shall contain one terrain (otherwise nothing will be done). The component will land each tree on the terrain taking into account the terrain height at the tree location.
As you can see, the palm tree is not fully finished, and I plan to design other type of trees to create forests with different densities of trees.