Vizard 8 » Reference » Flow control » Actions » Node commands as actions
8.0

Node commands as actions

The vizact library also contains many single command actions. These actions are simply standard node3d commands which can be treated as actions. To create a single command action, simply add the node3d command after vizact.method. For instance, <node3d>.texture would become vizact.method.texture, <node3d>.visible would become vizact.method.visible, and so on. The arguments to these actions are exactly the same as the arguments to the regular commands.

 

Let's say you wanted to create an action that would toggle the visibility of an object every time the spacebar is pressed. You would simply create an action to wait for the space key and an action to toggle the visibility of a node, then you would add these actions to an action sequence which repeats forever:

ToggleVisible = vizact.sequence( [vizact.waitkey(' '), vizact.method.visible(viz.TOGGLE)], viz.FOREVER)
node.addAction(ToggleVisible)

Animated actions with vizact.mix

In the code above, the visible command is called once when the action sequence executes. With some node commands it's possible to create custom animations with repeated calls. For example, the thickness of 3D text can be modified using the text3D.setThickness command. Calling this command every frame with increasing values will result in text that grows in size. To create this animated action we can use the vizact.mix command.

 

First, a 3D text node and mix object are added. For the mix object a start value (0.1), end value (1.0), and duration (1 second) are specified:

# Add 3D text
text = viz.addText3D('WorldViz',pos=(0,1.5,6),color=viz.ORANGE)
text.alignment(viz.ALIGN_CENTER)

# Add mix object
mix = vizact.mix(0.1, 1.0, time=1.0)

Next, the mix object is passed to setThickness to create the action:

thick = vizact.method.setThickness(mix)

Now, when the action is applied to the text object the setThickness command will execute every frame until the mix conditions are complete:

text.addAction(thick)

See also

In this section:

Action Basics

Action synchronization and management

Sequences

Dynamic parameters

Creating your own actions

Actions command table

Other sections:

Tutorial: Using actions

Task basics

Director basics

Timer basics

Animation path basics

Event Basics

Example scripts:

Actions

Event callbacks