numAnimations()
Purpose
Find the length of a 3D animation
Description
Some 3D models contain animation sequences. This finds the number of animations within a given 3D model
Syntax
count = numAnimations( object )
Arguments
object handle of the animated 3D object
count number of animations in the model
Example
cb = loadModel( "Kat Deak/Colin" )
pointLight( { 0.5, 1.3, 2 }, white, 4 )
setAmbientLight( { 0.5, 0.5, 0.5 } )
colin = placeObject( cb, { 0, 0, 0 }, { 1, 1, 1 } )
setCamera( { 0, 10, 10 }, { 0, 5, 0 } )
animcount = numAnimations( colin )
animID = 0
animframe = 0
loop
clear()
c = controls( 0 )
if c.up then // up to increase animation id
animID += 1
sleep( 0.3 )
endIf
if c.down then // down to decrease animation id
animID -= 1
sleep( 0.3 )
endIf
animID = clamp( animID, 0, animcount - 1 )
animLength = animationLength( colin, animID )
animframe = animframe + 1 / 60
if animframe >= animlength then
animframe = 0
endIf
updateAnimation( colin, animID, animframe )
drawObjects()
printAt( 0, 0, "Use up/down arrows to change ID: ", int( animID ) )
printAt( 0, 1, "length: ", animlength, " frame: ", animframe )
update()
repeat
Associated Commands