CS 638 -
Virtual Garden Project
by Mikhail Radomyselskiy
(mradomys@stevens.edu)
|
Sources |
|
Plants, Fractals, and Formal Languages Wildwood: The Evolution of L-System Plants for Virtual Environments |
| Motivation and Background |
Modeling of 3D scenes often requires plants and trees. 3D modeling of plants is often a tedious process that is not based on any real-life process. General plant modeling has usually been accomplished with L-Systems which are fractal-like systems which recursively define plant growth and allow the plants to iteratively grow more and more complex. Traditionally L-Systems have been implemented in 2 dimensions. However, some recent papers have suggested using 3D L-Systems to model 3-dimensional plants. An L-System consists of a set of substitution rules (usually just one) which represent the plant. The rules consist of commands similar to the LOGO language and places where the rule can be inserted at the next iteration. In this particular implementation, F stands for moving forward, '/' and '\' for rotating a particular number of degrees, and '[' + ']' for branching (so if we open a branch and close it we are back to the point where the branch started). So a string like A=FA/AF would draw a line up, and a line sideways. When we iterate, we would get FFA/AF/FA/AFF. And so on, substituting the original rule for A everytime. The idea to move to 3D is not an original one, but not a lot of standard implementations exist for it. All that the system has to have in order to be 3D is an additional pair of commands such as '+' and '-' for rotating in another axis in addition to '/' and '\'. While 3d L-Systems partly resolve the problem, they require knowing the correct axioms/rules for the right effect. Thus the designed is again faced with trial and error problem. The solution in this case, much like in many other technological advances, is taken from observing nature. The technique suggested by the Wildwood paper is to take two L-systems (either designed or randomly generated) and to "breed" them to create a new L-System. This "breeding" would be a simulation of the natural evolution process in nature. The "breeding" would occur by randomly selecting segments from either plant (meaning fragments of the strings representing the plants) and also allowing for possibility of mutation (that is introduction of random strings into the offspring). So the idea is to create an application that would allow random generation of samples and "breeding" to achieve the desired plant without the complexity of 3D modeling or trial and error with L-System strings. Summary: |
| General Project Description |
This approach is very similar to genetic algorithms and in fact it is the exact application of the genetic algorithm in finding the 'right' plant. Genetic algorithms also generate a sample set of answers and select the 'best' by using a fitness function that is applied to every answer. The 'best' answers are then cross-bred and a new set of samples is generated. This process continues until a good enough answer is reached. This is exactly what virtual garden does, except the sample set consists of different L-systems and the fitness function could be just selection by user (in addition to other automated fitness functions). Virtual Garden first of all implements a frame work to display 3D L-Systems from a given rule using Direct X. This is done by generating primitives for every command (so movement forward would be a cut-off cone and leafs are simple diamond shapes). Also a matrix stack structure is implemented for branches. The primary feature of the application of course is the plant breeding part. Once a sample is generated using the Setup screen by either random generation or mutation of an original formula (see documentation below), the user is able to select the next pair of plants to breed (or the fitness function selects automatically). The "breeding" is again accomplished by a technique similar to Wildwood. However, in order to increase visual appeal, a restraint is placed on what segments of each L-System can be selected. Only entire branches are selected from each system. This still ensures proper cross-breeding but it also prevents the appearing of unlikely odd-looking systems (this has been determined by trial and error). The user repeats this process until a desired plant is produced at which point the plant can be seen in different number of iterations and it can be exported to 3D modeling software to be placed in a scene. Summary: - Fast, easy, and 3D rather than previous related work dealing with
2D evolving plants |
| Implementation |
|
Virtual Garden is implemented using DirectX 9.0 and
Visual C++. The following steps are needed for generating the plants. In the first screen the user can select the parameters of the process: Sample Generation: The sample generation is either made from a base rule (which is mutated to produce different samples) or the samples are completely randomly generated Probability of mutation: This is the probability that a segment is not selected from either parent but is instead randomly generated. This can be observed by selecting Base Rule generation and choosing a high probability of mutation. Fitness function: By default the two "best" samples are selected by the user. This is the hand bred fitness function. The other choices are Tall (the more the distance between the lowest and highest polygon the better the sample), Short (the opposite of tall), and Radius (the wider the distance between rightmost and leftmost polygons the better the sample). Appearance: The user can choose the color of branches and leaves( leaves are determined by being the last 'F' in either a branch or the entire rule). Also the primitive shape of the leaves can be selected as well as the number of iterations at which to display each system (don't set this too high since 8 systems will be displayed at once) |
|
|
|
Once the plants are generated, their individual rules are shown
underneath and they can be viewed from different viewpoints. Two are selected for cross breeding by double clicking on them (or automatically if fitness function is set to something other than hand bred). If the user decides that a match is found, the Done button will select one plant to be exported. |
|
|
|
On the export screen, the user can set a different number of iterations
(increasing or decreasing model complexity) and finally click export to export the model in VRML format. |
|
|
|
|
| Results |
|
The results are much better than Wildwood in terms of
their visual appeal since Wildwood implementation did not place any restraints on how new samples are generated. So it is possible to produce very realistic looking plants using this tool. Another positive result is the easy of use of Virtual Garden because of its express-like interface which allows plant generation in a quick succession of steps. |
| Download: SOURCE WIN32 EXECUTABLE |