Skip to content
Häfner edited this page Dec 13, 2021 · 2 revisions

In this scope we define an animation a time depended change that has a certain duration, a start and end, and can be triggered anytime. The simplest example is a path animation, where a object is translated and rotated along a given path, for a certain duration. More complex animations can change material and geometry of an object, or control the application flow and trigger events. The possibilities are endless, the common aspect to animations is essentially that they do not depend on the frame-rate.

Path Animations

First define a B-Spline path, just define some poses in space. Then call animate on your object.

path = VR.Path()
path.addPoint([0,0,0], [0,0,-1], [0,0,0], [0,1,0]) # position, direction, color, up-vector
path.addPoint([0,2,0], [1,0,0], [0,0,0], [0,1,0])
path.compute(16) # tessellate paths, subdivisions per segment between two points

myObject.animate(path, 3, 1, True) # animate on path, for 3s, start after 1s, orient the object along the path

Callback Animation

First define a callback, then instantiate an animation.

def doSomething(t):
    mat = myObject.getMaterial()
    mat.setDiffuse([t, 1-t, 0])

anim = VR.Animation('myAnim')
anim.setCallback(doSomething)
anim.setDuration(3) # 3s
anim.start()
Clone this wiki locally