AddTrack
 
 
 

AddTrack

Introduced

v1.0

Description

Creates a track for the specified animation mixer. Tracks are the clip containers used to sequence clips in the animation Mixer. There are five types of tracks in the mixer: animation, shape, audio, animation layer and cache.

Scripting Syntax

oReturn = AddTrack( Model, [Compound], [Type], [Name], [InsertPosition] );

Return Value

Returns the Track object.

Parameters

Parameter Type Description
Model String The model to add the track to.
Compound String The compound container (track owner) to add this track to.
Type Integer Type of mixer track to add.

Default Value: Determine track type from context.

Possible Values:

Description:

0 Animation track
1 Shape track
2 Audio track
3 Image track (not supported)
4 Switching track (not supported)
5 Animation Layer track
6 Cache track
7 Speech track
8 Shot track
Name String Name of the new track.
InsertPosition Integer Which track to insert this one on top of

Examples

1. VBScript Example

'
' This example builds a simple keyframed animation, puts it in an
' Action and instantiates it on the mixer, transitioning to a second
' (static) clip.
'
posParams = "/kine.local.posx,kine.local.posy,kine.local.posz"
' Create the object for our example.
set oSphere = CreatePrim( "Sphere", "MeshSurface" )
' Animate it and store an Action for the motion.
SetPositionKey oSphere, 1, -5, -5, 0
SetPositionKey oSphere, 30, 5, 5, 0
set oSourceAnim1 = StoreAction( , oSphere & posParams, 2, "Diagonal", True, 1, 30 )
' Store another source which is a static snapshot.
Translate oSphere, -5, 5, 0, siAbsolute, siView, siObj, siXYZ
set oSourceAnim2 = StoreAction( , oSphere & posParams, 1, "Static", True, 1, 10 )
' Create a track for the clips.
set oTrackAnim = AddTrack( oSphere, , 0, "SimpleAnim" )
' Instantiate the animation sources onto the track.
set oClipAnim1 = AddClip( "Scene_Root", oSourceAnim1, , oTrackAnim, 1 )
set oClipAnim2 = AddClip( "Scene_Root", oSourceAnim2, , oTrackAnim, 91 )
' Put a transition between the two clips.
AddTransition oClipAnim1, oClipAnim2, 0
'==================================================
' Helper method to key an object somewhere at a given frame.
'==================================================
sub SetPositionKey( in_oObj, in_frame, in_posX, in_posY, in_posZ )
        Translate in_oObj, in_posX, in_posY, in_posZ, siAbsolute, siParent, siObj, siXYZ
        SaveKey in_oObj & posParams, in_frame
end sub

2. VBScript Example

' This example demonstrates several mixer-related commands.  It
' makes a couple of shape keys and instantiates them on the mixer,
' transitioning between them.  Then it takes the shape animation,
' puts it into a compound clip and finally adds a bit more shape
' animation inside the compound.
' Create the object for our example.
set oSphere = CreatePrim( "Sphere", "MeshSurface" )
' Store a couple of shape keys (we use the temporarily-applied bulge
' just to have an interesting shape for the second key.
set oSourceShape1 = StoreShapeKey( oSphere, , siShapeLocalReferenceMode )
set oBulge = ApplyOp( "Bulge", oSphere, 3, siPersistentOperation )
set oSourceShape2 = StoreShapeKey( oSphere, , siShapeLocalReferenceMode )
DeleteObj oBulge
' Create a temporary track to put the clips onto.
set oTrackTemp = AddTrack( oSphere, , 1 )
' Instantiate the shape sources onto the track.
set oClipShape1 = AddClip( "Scene_Root", oSourceShape1, , oTrackTemp, 1 )
set oClipShape2 = AddClip( "Scene_Root", oSourceShape2, , oTrackTemp, 90 )
' Put a transition between the two clips.
AddTransition oClipShape1, oClipShape2, 0
' Create a track for a shape compound, then put the two
' shape clips into it.
set oTrackCpd = AddTrack( "Scene_Root", , 1, "ForCompound" )
set oCompound = CreateCompound( "Scene_Root", oClipShape1 & "," & oClipShape2, _
        , oTrackCpd, 1, "MyCompound" )
' Add a new track inside the shape compound, on which
' we will instantiate a couple more sources.  Note that
' we insert it before the other track in the compound,
' so it will appear first.
set oTrackInsideCpd = AddTrack( "Scene_Root", oCompound, , "Extras", 0 )
set oClipShape1 = AddClip( "Scene_Root", oSourceShape2, , oTrackInsideCpd, 30 )
set oClipShape2 = AddClip( "Scene_Root", oSourceShape1, , oTrackInsideCpd, 50 )
SetValue oClipShape2 & ".actionclip.timectrl.scale", 0.5
SetDefaultWeight oClipShape1, siWeightGaussian, 0
SetDefaultWeight oClipShape2, siWeightGaussian, 0
' Get rid of this temporary track...
DeleteObj oTrackTemp