|
3D DTIFS is a demo of a method for creating a 3D Dragon Tree from the use of IFS.
The tree is actually only the stem and scaled and rotated copies of the stem in a number levels, (18). In the last six levels the colour blends from brown to green to make it look like leafs. At first the tree is initiated by choosing the number of branches per node. Then the transformation-rules are randomized, one rule per branch respective. Then the transformations starts. Origo for the room/space is where the stem meets the ground and there is the center of rotation. The function first randomizes a point at the stem, (angle & heigth), then the point is written to the scene. This point is then scaled and rotated¹ according to the rule, (that is one of the 2 - 6 branches) choosen by random by the system, (a new random is choosen for every iteration). After scale - rotate the point is translated by the full lengt of the stem² and then written to the scene again and one iteration of the system is done. It does this for all 18 levels before a new point of the stem is choosen and transformed.
¹ Rotations: The rotation is first done around the z-axis, 0 to 150 degrees to make it lean, (when the angle is randomized initially the priority is set so the lower values are prefered, (RND*RND*RND). Then the branch is rotated around the y-axis 0 to 360 degrees to it's choosen side of the stem.
² This will make the initial stem, now scaled and rotated, become one of the branches in the first node. If it is done twice? It will become a branch of the first node of one the branches in the first node of the tree =) A.S.O.
Click to download the latest version: 3D DTIFS.zip
Screenshots from the program: Later!
To run the demo you will need Win32 & DirectX, (my Win98se uses DirectX version 9.0c and it works fine), I'm using DirectX SDK version 5 for development, (only small parts of Direct-draw is used to create a view-port, (screen) and get a pointer to the video memory at the graphics card). It also needs a bit (like 40 megs) of free memory to run, (used for the pretty large image & Z-buffers)).
SunCode
See also:
Images:
A Dragon Tree:

A dragon
curve tree. (click to enlarge)
Scaled & cropped: