Vizard 7 » Tutorials & Examples » Getting your feet wet » Animating 3D Models
7.6

Tutorial: Animating 3D Models

There are a number of ways to animate objects using Vizard's built-in animation commands. Let's add some plants using loops like we did in the last section and store them in a list:

import viz

#Enable full screen anti-aliasing (FSAA) to smooth edges
viz.setMultiSample(4)

viz.go()

#Increase the Field of View
viz.MainWindow.fov(60)

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

piazza = viz.addChild('piazza.osgb')

plants = []
for x in [-3, -1, 1, 3]:
    for z in [4, 2, 0, -2, -4]:
        plant = viz.addChild('plant.osgb',cache=viz.CACHE_CLONE)
        plant.setPosition([x,0,z])
        plants.append(plant)

Add the following action related code and then run the script. You should see all the plants spinning in place:

import vizact
spin = vizact.spin(0,1,0,15)

for plant in plants:
    plant.addAction(spin)

The first line imports the vizact library which includes many commonly used actions. The second line defines a spin action. In this case, the parameters specify that the 3D model should rotate about the Y axis at a speed of 15 deg/sec. The <node3D>.addAction command applies that action to a specific model.

Launch into a new world

Creating a new Script

Setting the Scene

Moving the Viewpoint

Manipulating 3D Models

Animating 3D Models

Timer Events

Adding Avatars

Inserting User Interaction