How to use Neo-lsystem

As you can see in the picture here below. There is a button named [Seed] to freeze a shape. You have to know that the values of this button are not saved in the definition file with the extension "*.def" wich are created when you push the button [Save] after having entered a name.

The graphic user interface
back to the top

The working area
Divide the Blender main screen into, at least, three windows :
A TOP VIEW of the leaves / A CAMERA VIEW of the tree / A TEXT EDITOR window with the part of the script.
You can, if necessary, create an additional window. Either a Button window to work on the materials or an UV/Image editor to work on the UV texture.
Working screen retour vers le haut

First of all, you have to check that the objects you want to hang to the plant structure are ready to be used by the script, that is to say :
  • You have the shapes (meshes objects) that you want ( be careful, do not add too much vertices to your mesh models).
  • These meshes are uvmapped with a picture containing an alpha layer, like the one you see in the picture below.

Fig.3) An (RGBA) TGA file loaded in blender UV/Image editor.
(the background will be treated as a transparent one).
back to the top

If not already done you must do it before anything else.
Just follow explanations of the section Preparing the work.

Preparing the work
We start by preparing the meshes models that will be duplicated by the script. We can transform the existing ones or add our own creations.
To transform the existing meshes you have to go in edit mode, [Tab] key in Blender. Once in edit mode, we can add vertices, move them to change the shapes, or select all vertices with the [A] key, and then, rotate or grabb the whole vertices of the leaf mesh according to its center.
Be careful :
Too numerous vertices can make the script crash or may lead to a jumble of vertices instead of the expected mesh.

Fig.4) Working on the objects in edit mode.
back to the top
However, do it with moderation, because the location of the models affects the place where the duplicates will be created around the branches. it is recommanded that almost a few vertices wich represent the attach of fruit or leaves to the branch should be located to the center of the object.

If we stick to these rules the result must be correct. If it isn't the case just return into edit mode to correct the vertices locations. For the trials, it is also recommended to create a limited number of leaves. To do so, choose Active point type and a multiplication factor for [Repeat] equal to 1.
Once the meshes are completed we realise the UV mapping of the objects.
Fig.5) Doing the UV mapping, in edit mode too.

Creating a plant model
We place the mouse cursor over the text editor window and we launch the script with the [ALT]+[P] key combination. The text window becames a script one and the User Graphic Interface is displayed.
  • To create a plant, we use the [GENERATE] button. As long as the [Seed] value is at zero the script choose a new seed randomly each time you click on [GENERATE].
  • The ideal process is to start by choosing a particular seed, then doing the setting of the options ( see first part: L-System ) and then clicking on [GENERATE] to launch the calculation of the plant structure. But if we forgot to choose a seed before changing the settings it isn't critical. We can easily finish the construction of the plant with the different settings and then choose the seed and click on [GENERATE]. The only difference is that the plant will be again modified a last time after having clicked on [GENERATE].
  • When we are satisfied with the resulting shape, we save the settings used to obtain it.
  • We enter a name "name.def" in the field located between [LOAD] and [SAVE]. We advice to indicate the number of the chosen seed in the name of the model file. For example, AppleTree_Seed6.def.
  • Then we LeftMouseClick on [SAVE]. back to the top
Well, we now have a particular model created with a particular seed. The seed number 6.
Don't lose sight of the aim : keeping a shape structure in order to add fruit, flowers etc, in addition to leaves.

Doing the tree and its leaves
  • We load the definition file ".def" (we have to enter the name plus extension at the end of the path) and we LeftMouse Click on [LOAD].
  • We set the [Seed] value on the one we have chosen to create the tree model, in our example it is [Seed 6].
  • We then click on [GENERATE] to obtain exactly the same tree we had.
  • We can now activate the creation of the leaves by clicking on [Add Leaves], the button goes down, we choose a model of leaf by entering the name of the mesh concerned in the [leafobj:] field.
  • We click on [GENERATE].
  • A tree appears in the Camera view window.
    It is built with the definition file *.def, the seed 6 and the model of leaf we have chosen.

    generating leaves
retour vers le haut We select the mesh we've just created, we do a copy of it with [Maj+D]. The copy is active, we move it immediately into another layer with the [M] key. We can rename this copy "foliage" for example. Never do a copy with (Alt+D) wich shares the data of the meshes. You would be suprised to discover after step2, that the foliage you moved into the other layer has became apple fruits.

Doing the tree and its fruit
We choose another model of object, in the example an apple, we enter the name of the mesh, we called it "Pom".
It is recommended to avoid changing anything else but the type of mesh model. Because even if the seed value is locked the different options affect more or less the structure of the plant and so the additionnal objects (fruit) will not be rightly placed around the branches. For the need of the demonstration, i changed the type of organisation for the leaves by choosing a model in the menu opened with this button :
LeafChoice (See this page for the different types of leaves).
but it affects sligthly the orientation of the branches.
I also changed the [Repeat] value but the more you increase the number of leaves the more the tree will be scaled down.
So in your case do not change anything but the [leafobj:].
Attention : the script will probably take a longer time to generate the fruit.

It may happen that the generated meshes are no more linked to their material, they are then displayed in grey when the 3D view is on the solid mode (see picture below). This may happen either because we duplicated the mesh or because we created a specific material for fruit. This is our case here.

The solution is to go into the shader context [F5] to retie the link. We unroll the menu in the panel Link and Materials and we choose the material we used to mapp the apple.

The fruit mesh appears in the 3D view.
It is built with the model *.def already used for the foliage, the seed 6 (value also used for the foliage) and the object model called "Pom".

generating fruits
As soon as we have the final fruit mesh, we can assign it a Subsurf modifier (here below on the right) to make it smoother. Because we remember that this final mesh has been created with a low poly model. Thus the result is a rather angular mesh object (see the left picture below) and we can not leave it as it is.
fruits just smoothed fruits Subsurf
We can also rename this mesh, for example "Apples".
To finish the work we can also rename the final plant structure (trunk + branches) we call it "Apple-Tree".
The last thing to do is to bring back the foliage we put in another layer during step one.
we have not modified it, thus it is always at the place it has been created.
We now have a tree loaded with fruit. We can do a render with [F12].
The picture here below perfectly show what may happen when we change the values of the other options after having chosen the new object for fruit.
For the foliage, [Repeat 3] and the type of organisation is [2+2Perpend.].
For the apple fruits, [Repeat 1] and the type of organisation is [EndPoint].
We can clearly see that the foliage is not correctly placed on the branches.

We can also open another blender instance, create a new blend file, and from this new blend file import the different meshes, trunk, foliage and fruit. We then understand the utility of having renamed the different resulting objects in the original file. We can use the [SHIFT+F1] key combination, the usual command to import data from another blend file, then once into the File Browser select the original file, goes into the Object directory and select the meshes to import, "trunk mesh", "leaves mesh" and "fruit mesh".
apples+Leaves zoom
Last things.
If it remains a few elements of the foliage or of the fruit mesh that are not correctly located around the branches. You can still adjust them manually. In Edit mode, we select those we want to grabb with the [L] key and we use the [G] key to move them. neo adjust fruits
© MF Soler - Examples realised with Neo-lsystem from JM Soler.