Tutorial 6: Sequences and
TerrainMorphs
- Sequence model
- Terrain Morphing
We'll get back to Mesh's soon.
Hang in there...a little more foundation work. For now, we want to flatten
a square of terrain if the user left-shift clicks on the terrain.
Back in Tutorial 3 we changed
the height of the terrain. Lilith is a geo-morphing engine...there should
be a better way to change the terrain than grid point by grid point? Indeed
there is. The TerrainMorph.
The TerrainMorph is a
change in terrain over time. Lilith includes a volcano, a land bridge,
a pit, and a flattening morph. TerrainMorphs can include light,
particle, and other effects as well. They are an easy way to use,
reuse, and create complex terrain animations and special effects.
TerrainMorphs are themselves
a child of the more general Sequence, which is a general effect
over time.
TerrainMorphs and Sequences
are fire and forgot. They are new'd, passed to Lilith, and forgotten
about...unless you want notifications. All sequencers are Publishers
(see tutorial 3) so just declare yourself
a Listener and AddListener if you want events back from a Sequence.
Also, all terrain height
changes will result in messages from the TerrainMesh class via the
TerrainListener interface.
In this example the "Game"
class is a Flatten listener - FlattenMorphListener - but the callback
is ignored for now.
Tutorial 6: Create a Flatten
sequence
The actual code for this is
quite modest:
FlattenMorph* flattenMorph = new FlattenMorph( bounds, object.Intersection().z ); flattenMorph->publish.AddListener( this ); lilith->AddSequence( flattenMorph );
Conclusion
Left-click to summon meteors
and chew up the terrain. Shift-left-click to flatten it out. Indulge your
meglomania!
|