For this assignment, I decided to create a scene that mimicked a boss-fight from
Sonic the Hedgehog games.
I figured the nature of this object's motion lended itself well to hierarchal
modeling.
Very often we model scenes that include repeated
instances of very similar shapes, but:
-
The different instances can include displaced, rotated, or
stretched versions of a “master copy”
-
The placement of some instances could be subordinate
to the placement of others
-
In many cases, different instances do not rely on each
other in just a linear/sequential fashion, but there is a
“tree” of dependencies of their respective transforms
Hierarchically dependent transforms are facilitated in
Canvas by the save()/restore() functionality
- Instead of a single chain of transforms (actually single
combined transform representing a chain), Canvas
maintains a stack of composite transforms.
- Issuing transforms, via Canvas commands, appends to the
transform chain at the top of the stack
- The save() command duplicates the top of the stack, and
pushes the duplicate copy down the stack.
- The restore() command pops the transform (transform
chain, or combined transform, in fact) from the stack top.