108
Chapter 10: Scene Graph Engines
Input and Output Fields
csEngine has input and output fields. csEngine updates its output fields according to the
function carried out by the csEngine. For example, a simple engine might take two
inputs and output the average of the two.
csEngine updates its output fields only under the following conditions:
• Output fields are read.
• Input fields have changed since the output fields were last read.
For example, the input fields might change twice, but if the output fields are read only
after the second change in the input fields, the output fields are updated only once.
Connecting Engines to Other Nodes
You connect an engine to other nodes or engines to create an animation, to cause a chain
reaction of motions, or to cycle through a set of attributes, such as color cycling. You use
csContainer::connect() to make the connections. For example, to make a color
interpolator engine change a specific field in a material, connect the engine’s output field
value to the specific field, as follows:
csColorInterpolator* myEngine = new csColorInterpolator;
csMaterial* rose = new csMaterial;
myEngine->connect(csColorInterpolator::VALUE, rose,
csMaterialDIFFUSE_COLOR);
In this example, myEngine is connected to the color field of the rose object.
Connecting Engines to Other Engines
The output of one engine may also be connected to the input of another engine. For
example, the output value of a csSpline might be connected to the input field of a
csMorphEng, as follows:
csMorphEng3f *morphEngine = new csMorphEng3f;
csSpline *splineEngine = new csSpline;
splineEngine->connect(csSpline::WEIGHT, morphEngine,
csMorphEng3f::WEIGHT);