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:
a,b,c,d,e,f,g,h
: floating-point input values
(all initially 0 by default).
A,B,C,D,E,F,G,H
: 3D vector input values
(all initially 0 0 0 by default).
expression
: a string representing the mathematical
expression to calculate (initially "" by default).
There are also some temporary variables that you can use to store intermediate calculations:
ta,tb,tc,td,te,tf,tg,th
: floating-point temporary
variables.
tA,tB,tC,tD,tE,tF,tG,tH
: 3D vector temporary
variables.
The important output fields are:
oa,ob,oc,od
: floating-point output values.oA,oB,oC,oD
: 3D vector output values.
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:
TimeCounter
engine counts from 0 to 399 for a
total of 400 steps. The square has 4 sides of length 100. This
allows us to use the output
field to generate a
traversal of all four sides, as long as we do a little calculation
to determine the current position.
a
input field of the Calculator
engine
is connected to the output
output field of the
TimeCounter
engine. This value is used to determine
which side (numbered 0, 1, 2, 3) the cone is currently traversing
(stored in ta
) and the relative position along that side the
cone should be (stored in tb
). These are used to determine
the coordinates of the transformation (stored in tc
and
td
). Finally, the Calculator
's output
field oA
is a vector containing the results of the
calculations performed, and will be used to translate (move) the
cone to the desired position.
expression
field can consist of either a single
string enclosed in double quotes ("), or a sequence of such strings
separated by commas (,) and enclosed in square brackets ([,]).
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.