I have uploaded a first version of my new IrrEdit 1.5 plugin yesterday: Random Forest (http://bulletbyte.de/products.php?sub=irr&show=rafo). It's a simple plugin where you define an area and some other parameters, hit a button and have a whole lot of trees planted there by random.
This is how it works:
- add a scenenode (e.g. empty scenenode) and give it a unique name
- optional: add a terrain. Make sure the terrain is in the scenegraph before the random forest scenenode. This is important because on loading the scene the terrain must already be there so that the random forest node can find it
- add a random forest node
- add template trees as children of this scenenode
- define the area you want the trees to be in
- click the "plant trees" checkbox
- defined area is split into small segments
- a random number is used to find out whether or not a tree is to be planted in every segment
- if this is true the exact tree position is determined by random
- one of the trees is picked from the template node
- the tree is planted
You can specify a terrain scenenode to be used, and all trees will get an appropriate height position. If no terrain scenenode is specified all trees are in the same height. There is also a "resize" attribute to variy the size of the trees. You specify how many percent the size may vary (i.e. if you enter "0.25" the tree size may range from 25% smaller to 25% bigger (scale 0.75 to 1.25))
There are some parameters you can specify:
- threshold: for tree generation a random number between 0 and 1000 is picked. If this number is bigger than the threshold a tree is planted
- you can specify your own seed for the random generation
If you store your scene the trees won't be stored, only the parameters used to generate the forest. I added an own random number generator to the plugin from a random tutorial on the web so that I (hopefully) get the same random number sequence on all computers and compilers (I don't want to rely on the rand() function, implementations may vary between compilers I guess). This way of saving the forest reduced the filesize of the scene file from 1.5 MB to 50 KB in a test I made. You can still have the trees serialized though, there is an option for that.
I hope this plugin will be useful to some people here.
This is a first version, there are still some things to come:
- add an "clear forest" option. Now it's only possible to plant the trees, but they can't be removed
- add a "forest border" so that you can see where your forest will be
