[Up] [Previous] [Next]

10.1.3 Calculator Engines

Calculator engines do exactly what it sounds like they do: they calculate things. They don't animate anything per se, but they are useful for controlling the behaviour of other nodes by allowing you to use simple mathematical expressions for transforming the values connected to the input fields into the desired value to be sent to the Calculator engine's output fields, and hence to any nodes connected to those output fields.

The important input fields are:

There are also some temporary variables that you can use to store intermediate calculations:

The important output fields are:

Example

Here is a complete Inventor .iv file for an example that combines Calculator and TimeCounter engines to make a cone slide around a square path. Just cut and paste the text into a file named test.iv and then do ivview -q test.iv:

#Inventor V2.0 ascii

Separator {
    PerspectiveCamera {
        position    50 20 250
    }
    Translation {
        translation 0 0 0 =
	    Calculator {
		a    0 =
		    TimeCounter {
			min          0
			max	     399
			frequency    0.1
		    }
		    . output
		expression [
		    "ta=floor(a/100)",
		    "tb=a - ta*100",
		    "tc=(ta<1)?tb:(ta<2)?99:(ta<3)?(99 - tb):0",
		    "td=(ta<1)?0:(ta<2)?tb:(ta<3)?99:(99 - tb)",
		    "oA=vec3f(tc,0,td)"]
	    } . oA
    }
    Cone {
        bottomRadius 10
        height 20
    }
}

You should note several things about this example:

More Information

More information about Calculator engines is available in chapter 13 of Inventor Mentor. If you are going to use this type of engine, you are strongly advised to read the man page for SoCalculator. It describes the kinds of expressions you are allowed to use.


MIT home page HTML written and maintained by Reid M. Pinchback (reidmp@mit.edu)
Last modified 96/06/11; copyright © 1996 MIT