Blitz3D+ Command Reference

AddAnimSeq ( entity,length )

Parameters

entity - entity handle
length - length of the new sequence, in frames

Description

Adds a new, empty animation sequence to an entity and returns its sequence number.

This is the other half of hand-built animation. SetAnimKey pins poses to frame numbers; AddAnimSeq bakes those keys into a sequence you can actually play, and hands back the number to pass to Animate. Make the length at least as large as the highest frame you keyed, or the end of your move will be cut off.

It works on plain entities too, not just models loaded with LoadAnimMesh. Call it on a cube or a pivot that has no animation of its own and the entity gets an animator from scratch, which is the simplest route to a scripted lift, a rotating door or a camera on rails.

On an entity that already animates, the new sequence is appended after the existing ones, exactly like LoadAnimSeq - so sequence numbers keep counting up and nothing you loaded earlier is disturbed.

See also: SetAnimKey, Animate, LoadAnimSeq, AnimSeq, AnimLength.

Example

; AddAnimSeq Example
; ------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,3,-10

light=CreateLight()
RotateEntity light,45,45,0

ground=CreatePlane()
EntityTexture ground,LoadTexture("media/MossyGround.BMP")

; A bouncing beach ball to animate
ball=CreateSphere(16)
EntityColor ball,255,60,60

; Record the bounce: position the ball along an arc and store one key per frame
For frame=0 To 40
    x#=frame*0.2-4
    y#=Abs(Sin(frame*18))*3+0.5
    PositionEntity ball,x,y,0
    SetAnimKey ball,frame
Next

; AddAnimSeq bakes the recorded keys into an animation sequence of the
; given length and returns the new sequence number
seq=AddAnimSeq(ball,40)

; Play the baked sequence ping-pong, so the ball bounces there and back
Animate ball,2,0.5,seq

While Not KeyDown(1)

    UpdateWorld

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrows: camera   Esc: exit"
    Text 0,20,"AddAnimSeq(ball,40) returned sequence "+seq+"   AnimTime: "+AnimTime(ball)

    Flip

Wend

End

Index