Blitz3D+ Command Reference

LoadAnimSeq ( entity,file$ )

Parameters

entity - handle of an animated entity
file$ - model file to take the animation from

Description

Appends the animation from a file onto an already-loaded animated entity, and returns the number of the sequence that was added.

This is how you build a character out of one model and many animation files: load the body once with LoadAnimMesh, then load walk, run, jump and die as separate files. Only the animation is taken from each file - the geometry in it is ignored - so the animation files can be small.

Sequences are numbered from 0, and the model file you loaded first supplies sequence 0. Each LoadAnimSeq adds the next number, and that is the number you pass to Animate. Keep the returned values in variables named after the moves and your animation code stays readable.

The skeleton in the animation file has to match the one in the model, node for node and name for name - which in practice means exporting them all from the same rig. If it does not match, the entity will not move as expected.

The entity must already have animation of its own, so load it with LoadAnimMesh rather than LoadMesh. The command returns -1 if the file could not be loaded.

See also: LoadAnimMesh, Animate, AnimSeq, AddAnimSeq, PlayAnim.

Example

; LoadAnimSeq Example
; -------------------

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

camera=CreateCamera()
PositionEntity camera,0,2,-6
RotateEntity camera,12,0,0

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

; A grassy paddock for the fox to roam
ground=CreatePlane()
EntityTexture ground,LoadTexture("media/MossyGround.BMP")

; Load the rigged fox; its own file provides sequences 0, 1 and 2
fox=LoadAnimMesh("../../../samples/glTF/assets/Fox/Fox.glb")
If fox=0 Then RuntimeError "Could not load Fox.glb: "+ModelLoadError()

; Shrink the fox to game scale (the file is modelled about 100 units tall)
FitMesh fox,-0.8,0,-0.8,1.6,1.6,1.6,True

; LoadAnimSeq appends animation from another file to an existing entity and
; returns the new sequence number. Here we append from the same file, so the
; fox ends up with a second copy of its clips as sequences 3, 4 and 5.
extra=LoadAnimSeq(fox,"../../../samples/glTF/assets/Fox/Fox.glb")

; Play the appended sequence
Animate fox,1,1,extra

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,"LoadAnimSeq returned sequence "+extra+", now playing sequence "+AnimSeq(fox)

    Flip

Wend

End

Index