As described in The Inventor Mentor, all engines have at least one input and one output. The inputs are derived from SoField( C++ | Java | .NET ) (either SoSF or SoMF fields). Outputs are of type SoEngineOutput( C++ | Java | .NET ). In addition, each engine has an evaluate() method, which uses the current input values and produces new output values. The file SoSubEngine.h contains the macros for defining new engine classes. The SO_ENGINE_HEADER() macro declares type identifier and naming variables and methods that all engine classes must support. The macro defines the static variables and methods declared in the SO_ENGINE_HEADER() macro. Other macros useful in creating new engine classes are mentioned in the following sections.
Creating a new engine requires these steps:
Select a name for the new engine class and determine what class it is derived from.
Define and name each input and output of the engine (see Section 6.2, “Defining Inputs and Outputs”).
Define an initClass() method to initialize the type information (see Section 6.3, “Initializing the Engine Class”).
Define an exitClass() method to clean up the type information. In the exitClass() routine of your class, use the macro SO_ENGINE_EXIT_CLASS.
Define a constructor (see Section 6.4, “Defining the Constructor”).
Define a destructor.
Implement an evaluate() method for the engine class (see Section 6.8, “Notification and Evaluation”).
If necessary, implement an inputChanged() method (see the section called “Creating a Fan-in Engine” and the section called “Creating a Second-Ticker Engine”).
Implement a copy() method if the engine contains any nonfield instance data (see Chapter 2, “Creating a Node,” for more information on implementing a copy() method).