A SERVICE OF

logo

108
Chapter 10: Scene Graph Engines
Input and Output Fields
csEngine has input and output elds. csEngine updates its output elds 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 elds only under the following conditions:
Output elds are read.
Input elds have changed since the output elds were last read.
For example, the input elds might change twice, but if the output elds are read only
after the second change in the input elds, the output elds 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 specic eld in a material, connect the engines output eld
value to the specic eld, 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 eld 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 eld of a
csMorphEng, as follows:
csMorphEng3f *morphEngine = new csMorphEng3f;
csSpline *splineEngine = new csSpline;
splineEngine->connect(csSpline::WEIGHT, morphEngine,
csMorphEng3f::WEIGHT);