# 15.1. Introduction to Engines

In earlier chapters, you've created scene graphs with 3D objects that responded to user events. The 3D objects themselves were fixed, and they moved only in response to user interaction or to sensor activity. In this chapter, you'll learn about a new class of object, called engines, that allows you to encapsulate both motion and geometry into a single scene graph. Just as you would connect a real-world engine to other equipment to spin a flywheel or turn a fan belt, you “wire” engine objects into the scene database to cause animated movement or other complex behavior in the scene graph. Engines can also be connected to other engines so that they move or react in relation to each other, and eventually make changes to the Inventor database.

As a simple example, consider a scene graph that describes the geometry for a windmill. You can attach an engine object that describes the rotation of the windmill blades and performs an incremental rotation of the blades in response to time. This scene graph, including the engine, can be saved in an Inventor file. Whenever the scene graph is read in, the windmill is displayed and the blades animate. Both the geometry and the behavior are described by the nodes and engines in the scene graph.

A more complex example would involve wiring two objects together. For example, you might create a scene with a car whose motion is based on an engine object. A second engine could look at the car's motion and turn that information into camera motion so that the camera could follow the moving car. Or you might wire two engines together so that one engine affects the activity of the other engine. In the case of the windmill, you could connect a second engine in front of the rotation engine to filter time so that the windmill blades rotate only between the hours of nine in the morning and five at night.

In some cases, you could use either a sensor or an engine to create a certain effect. Table 15.1, “Comparison of Sensors and Engines” compares sensors and engines to help you weigh the trade-offs between the two.

Table 15.1.  Comparison of Sensors and Engines

Sensors

Engines

Are part of the application (are not written to file)

Are part of the scene graph (can be read from file and written to file)

Have user-defined callback functions

Have built-in functions

Allow explicit control over order of firing

Are evaluated automatically

Can be attached to any kind of field (field data sensors)

Have inputs and outputs of a fixed type

Can affect objects outside the scene graph

Can affect only other nodes or engines in a scene graph