Creating Animated Foliage
GameCore provides a number of options with regards to animated objects, such as Foliage (Tree's, Grass, etc).
This tutorial provides a walkthrough of the basics of using the default surface properties system to implement animated foliage useful for Grass, Tree's and other similar types of objects.
Procedural Vertex Animation
This can be a stand alone tutorial but it is best used in conjunction with the Object Spawner tutorial, that can be found here:
http://www.gamecore3d.com/forums/index.php/topic,652.0.html (or in the online documentation soon).
Okay, the procedural vertex animation is a quick way to get things moving without having to do a series of custom animations. I will be exclusively using it in this tutorial to make grass and trees move, but the same process could be applied to any object with surface properties (water, ect.).
To address something from the spawner tutorial, I talked about how you can eliminate some of the 'popping' that happens when an object is spawned. It's called the Alpha Test Dissolve. What this does is 'grows' and 'shrinks' the spawn at distances to keep spawned layers from magically appearing and disappearing when you move the camera position. It?s a neat feature and its a simple check box in the surface properties of the object. I hope everyone has been using the practice of creating a inventory world for spawned objects, because this is where it?s going to come in real handy. So once an object is loaded into the inventory world (or game world if your a masochist) simply select it and on the panel window select Object Surfaces to pull up the dialog box. (If the Object Surfaces floating dialog does not automatically pop up, select the object under Object Surfaces Panel and click the Edit Surface button)

In the Object Surfaces floating dialog box about 1/3 of the way down are three tabs (Basic, Extended, and Advanced). Most of what we will be doing is under the Advanced tab, but I should mention, under the basic tab, there is the Blend Mode drop-down box. When working with grass or trees (or anything with an alpha in general) it is best to set this to Alpha Test, this will help keep the 'stack' in line and produce better alpha blends.

Okay, back to the tabs. In Object Surfaces, under the Advanced tab, we have three new tabs just below Advanced (Options, UV Coords, and Deform). The vertex animation is handled under the Deform tab, but we need to address the other tabs first.
The Options tab has a list of options for the surface, most are self explanatory. The two to concern yourself with here are Double-Sided, which will make sure your textures appear on both sides of the plane, and Alpha Test Dissolve, which helps reduce the 'popping' effect of spawners.
The UV Coords, is used for positioning and scaling a texture map and can tweak a texture's animation (not the vertex animation, the texture itself).
The important one, for this tutorial, is the Deform tab. This is the breath of life to your objects (without having to do all the breathing yourself). The first thing you see under the Deform tab is the Type of deformation, there are three: Wave, Sway and Swing.

In basic terms its best to think of the three option associated to object they would be used for, without bogging you down with technicals.
Wave ? Water, ripples in height and width
Sway ? Grass, sort of a meandering around a pivot point circularly
Swing ? Tree, a 'spring' effect on a rooted object, like a slinky or pendulum
Layer is next on the tab (and this is the part that confused me the most at first) this is NOT referring to the associated terrain layer the object is spawned on, this is layers of deformation. There can be up to four and to create a natural animation it is best to use them.
Under that are your deform sliders: Intensity, Speed, X scale, and Z scale
Intensity is how 'hard' your object will operate under the deform type. In my grass example notice the intensity is set at 0.010, this gets it moving just a little. If I cranked that up to 2 I basically get a pinwheel of grass (not so natural).
Speed is how fast your object deforms within your intensity guidelines.
X and Z scale are how far and object will deform along that vector.
Play around with all these settings to get an animation that seems right to you. Remember that you have been augmenting only the first layer of the deform. If you did just the one deform on the grass and exported it and loaded it into your game world, you would have a bunch of nice looking, moving grass. Unfortunately every grass object you spawned is moving exactly the same! This is where the Layers come in handy. Set different deforms on each layer, not drastically different, just enough to create random variety of the vertex animation on your spawned objects. The first layer of the deform is the one that will be multi-passed, but the others will add to the variety.
You can repeat this process on a tree you have in your inventory world, just remember to change the Type to swing everything else is basically the same.
I have a few tips for trees (or really any object that will have vertex animation applied to it). If you have been using mutli sub-object materials then things like a tree will have multiple surface properties. This palm tree has a different surface property for the trunk and for the treetop. By setting up our object like this we can apply different deformations to different parts of the object. In this case, the tree trunk would barely move while the tree top could be bustling in the wind, this technique will help create a more believable vertex animation.
For More Information:
Editor Walkthrough : Game Editor : Properties Panels : Object Surfaces
GameCore Basics : Creating your Worlds : Surface & Material Editing
GameCore Basics : Creating your Worlds : Procedural Geometry / Object Spawners
Printer-friendly version- Login to post comments
- PDF version
