One Lonely Tree
Magnus Ma
CSC471 - Introduction to Computer Graphics
Dr. Wood
Spring 2006
- Close up of the Lonely Tree
Background
The One Lonely Tree is made up of a trunk, branches and leaves. Just like a tree in
real life, the trunk is the lowest and widest part of the tree so it could support
the branches and leaves. The branches grow upwards and outwards away from the trunk.
The leaves grow on the furthest part of the branches.
- The calmness, peacefulness, and the loneliness of a tree
Data Structure
The tree is built using hierarchical modeling. A binary tree data structure keeps
track of the rotation and translation relative to its parent. Obviously the root of
the binary tree is the trunk and its children are branches. As the branches gets further
away from the root, the branches gets smaller in size.
- Shows the binary tree data structure visually
Drawing the Tree
Drawing the hierarchical modeling requires using a recursive function. By using
the binary tree data structure, the tree is easily drawn recursively.
The program draws each branch and its child by traversing through the binary tree.
Once it reaches the last child, the leaves then gets drawn.
Randomizing for a Natural Look
Each branch’s data structure consists of a Z-axis rotation and Y-axis rotation.
Each child is randomly set with a Z and Y value within 0-45 degrees of rotation.
The range in degrees makes the branch look like it grew upwards and outwards.
By using hierarchical modeling, the branches will look more upwards and outwards
with each generation.
The actual implementation of the tree consists of 6 binary trees spread out evenly to
give the tree's fullness.
- 6 binary trees each with 5 generations
(2^5=32 total children for each binary tree)
- Compared to a binary tree, looks like real tree now
Adding Fake Wind for a More Realistic Look
Animating the movement of the branches requires an extra component to the data structure.
The wind component keeps track of how much to rotate the Z and Y rotations.
If this extra component was not added, the branches will rotate all around like a wheel,
which does not look natural at all.
Instructions
Keys:
- W - moves forwards
- S - moves backwards
- A - moves left
- D - moves right
- 1 - decrease 1 generation
- 2 - increase 1 generation
- 3 - toggles leaves
- 4 - toggles wind
Download: One Lonely Tree - includes textures used
|