15.2. General Uses of Engines

Engines are generally used in two different ways:

Figure 15.1, “ Mechanisms Made from a Set of Link Classes ” and Figure 15.2, “ Objects That Use Engines for Animation and Placement show applications that use engines. In Figure 15.1, “ Mechanisms Made from a Set of Link Classes ”, four different classes of links are created—struts, hinges, cranks, and double struts. Engines are used to connect links end-to-end. The objects in Figure 15.2, “ Objects That Use Engines for Animation and Placement use engines to edit transform nodes that animate the animals and objects in the scene.

Mechanisms Made from a Set of Link Classes

Figure 15.1.  Mechanisms Made from a Set of Link Classes


Objects That Use Engines for Animation and Placement

Figure 15.2.  Objects That Use Engines for Animation and Placement


As shown in Example 15.1, “ Using the Real-Time Global Field later in this chapter, you can connect parts of a scene to a clock so that animation in the scene occurs in relation to changes in time. Example 15.6, “ Using a Calculator Engine shows an example of constraints, where the movement of an object is constrained to a set path.

You can think of an engine as a black box that receives input values, performs some operation on them, and then copies the results into one or more outputs. Both the inputs and the outputs of the engine can be connected to other fields or engines in the scene graph. When an engine's output values change, those new values are sent to any fields or engines connected to them.

An engine, shown in Figure 15.3, “ Anatomy of an Engine, has inputs derived from SoField( C++ | Java | .NET ) and outputs derived from SoEngineOutput( C++ | Java | .NET ). Each engine evaluates a built-in function when its input values change. The resulting output values are then sent to all fields and engines connected to that engine. Because SoEngine( C++ | Java | .NET )is derived from the SoBase( C++ | Java | .NET ) class, it includes methods for reading and writing to files.

Anatomy of an Engine

Figure 15.3.  Anatomy of an Engine


For example, the engine shown in Figure 15.3, “ Anatomy of an Engine could represent SoComposeVec4f( C++ | Java | .NET ), an engine that creates an SoMFVec4f( C++ | Java | .NET ) object. It has four inputs of type SoMFFloat( C++ | Java | .NET ) and one output of typeSoMFVec4f( C++ | Java | .NET ). This engine composes the four inputs into one SoMFVec4f( C++ | Java | .NET ) output.