Controlling Imported Animantions

The following types of animations can be exported with OSG models from 3ds Max and played in Vizard:

  • Transform:  Animations based on translation, rotation, and scale
  • UV: Animations based on changing texture coordinates
  • OSG sequence: Mesh animations that cycle through a series of saved meshes, one for each frame


Open the model in Inspector to verify the animation(s) play correctly. Make sure 'Animations' is enabled in the status bar.

The animation interface in Vizard is the same for all the animation types mentioned above. Use the following commands to get animation information and control animations. The node argument is used to reference a specific animation when the model contains multiple animations. If an animation name is specified in the node argument the command will only be applied to that animation. Otherwise, the command will be applied to all the model's animations:

Command
 <node3d>.getAnimationDuration(node='', op=OP_DEFAULT)
 <node3d>.getAnimationFrame(node='', op=OP_DEFAULT)
 <node3d>.getAnimationFrameCount(node='', op=OP_DEFAULT)
 <node3d>.getAnimationLoopMode(node='', op=OP_DEFAULT)
 <node3d>.getAnimationSpeed(node='', op=OP_DEFAULT)
 <node3d>.getAnimationState(node='', op=OP_DEFAULT)
 <node3d>.getAnimationTime(node='', op=OP_DEFAULT)
 <node3d>.setAnimationFrame(frame, node='', op=OP_DEFAULT)
 <node3d>.setAnimationLoopMode(loopMode, node='', op=OP_DEFAULT
 <node3d>.setAnimationSpeed(speed, node='', op=OP_DEFAULT)
 <node3d>.setAnimationState(state, node='', op=OP_DEFAULT)
 <node3d>.setAnimationTime(time, node='', op=OP_DEFAULT)

 

Animation Loop Modes viz.OFF, viz.LOOP, viz.SWING
Animation States viz.PLAY, viz.STOP, viz.PAUSE

 

Example

''' 
1 - Pause the banner animation 
2 - Play the banner animation 
3 - Pause all animations 
4 - Play all animations 
5 - Change the walk animation speed 
'''import viz
import vizact
import vizinfo

viz.setMultiSample(8)
viz.fov(60)
viz.go()

vizinfo.InfoPanel()

viz.move([0,0,-5])

# Add piazza model 
model = viz.addChild('piazza.osgb')

# Add piazza animations 
animations = viz.add('piazza_animations.osgb')

vizact.onkeydown('1',animations.setAnimationState,viz.PAUSE,node='banner_sequence')
vizact.onkeydown('2',animations.setAnimationState,viz.PLAY,node='banner_sequence')
vizact.onkeydown('3',animations.setAnimationState,viz.PAUSE)
vizact.onkeydown('4',animations.setAnimationState,viz.PLAY)
vizact.onkeydown('5',animations.setAnimationSpeed,3.0,node='walk')

avatar = viz.addAvatar('vcc_male2.cfg')
avatar.setParent(animations,node='walk')
avatar.state(2)

 

FBX Models

In addition to OSG model animations, there is partial support for transform based animations imported with FBX models. OSG animations are set to play by default. Use the node3d.setAnimationState command to start playing an FBX animation. In addition, both the file name + animation name must be passed as the node argument for all the commands listed above:

model = viz.addChild('model.fbx')
# Start playing animation
model.setAnimationState(viz.PLAY,node='model.fbx::Take 001')
# Double the animation speed
model.setAnimationSpeed(2.0,node='model.fbx::Take 001')