Animating with Expressions - The Begginers Basics

By Michael Malinowski

For this we will begin to look at the benefits of using reasonably basic expressions to automate animation within XSI. Although daunting to begin with it is actually quite simple to begin with.
We will start by creating an object which will bounce at a speed and height defined by a series of controls we will also create.

Creating our controls.
The controls are nothing more than objects we put into the scene, they will be the controls as the moving objects will take on properties from these to calculate where it is supposed to move to. So lets start by creating 2 implicit spheres. Name the first one "speed_control" and the second one "bounce_control". You can use any object, I just choose implicits as they do not render.

Now create a polygon mesh / sphere, this will be the only object that we attach expressions to. Call this one "Bouncy_Ball"

Making sure we have the bouncy ball selected click on the "selection" button in the selection panel, this will show all the property sets of the bouncy ball, we need to view the local transform properties within the kinematics properties. Kinematics being the scale, rotation and position of the sphere.
You will now see the property page of the local transform values, you can set expressions on any animatable parameter, but for this we will begin by choosing the Y axis on the position section.
Right click the animate button and choose set expression.
Here comes the part where we actually learn something. First of all its important to understand how XSI calls upon properties and the way it is written. For instance to call on the value of the position along the X axis that the speed control is currently at, it would be written like this :

Speed control.kine.local.posx

Put simply, first we define which object we want to call a value from, this time being the speed control, then we need to start defining the route we need to go to find the value, so we tell it we are looking in the kinematics properties (shortened by typing "kine", followed by the local transform properties (shortened by "local") finally selecting the actual value field we are taking our figure from, this time being posx, short for position X.
Once you understand that its simple to make objects copy values over from each other, you could set up manual constraints through expressions and then add, subtract, multiply or divide through other parameters.

For this tutorial however we want the ball to bounce up and down without actually having to hand animate anything within the scene. This is where we all wish we actually listened in our math classes back at school!
XSI understands functions such as sine and cosine, which makes our job much easier, as these create a wave pattern which alternates from one to zero and back again.
We may as well see this in practise to fully understand what's going on, so with the bouncy balls local transform property page still open right click the Y axis and choose "set Expression".
This will open an expression editor. This is where we type what we want it to do, copy this into the editor:

Sin (fc * 20 ) * 10

If you press the play button you will see the sphere start bouncing up and down. The Sin function allows the values to pass from one to zero then back again, the FC is the animated function curve that all the animation in xsi is controlled by, the 20 is the distance the ball will move leaving the 10 being the speed in which the ball will travel at, by changing the figures we can immediately change the animation that is effecting the movement.
So by using that expression and knowing what we learned about taking values from other objects we can create our controllers. Try this.

Sin ( fc * bounce_Control.kine.local.roty ) * 10

With that set as the expression you should be able to rotate the bounce_control object to effect the distance the ball moves.
Now by changing the 10 to read "speed_control.kine.local.roty" we have full control of the bouncing of our ball through the rotation of our control objects! This saves repetitive animation time, its certainly useful when it comes to animating things such as car wheels etc.


I hope you found this tutorial of some use, if you spot any errors throughout it then please let me know...