; CountAnimSeqs 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") ; The bundled fox arrives with three named clips baked into the file 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 ; Ask the model how many clips it brought with it - never hard-code this total=CountAnimSeqs(fox) seq=0 Animate fox,1,0.6,seq While Not KeyDown(1) ; [ / ] step through every sequence the model reported If KeyHit(26) seq=seq-1 If seq<0 Then seq=total-1 Animate fox,1,0.6,seq EndIf If KeyHit(27) seq=seq+1 If seq>total-1 Then seq=0 Animate fox,1,0.6,seq EndIf 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,"[ / ] : previous / next clip Arrows: camera Esc: exit" Text 0,20,"CountAnimSeqs(fox) = "+total+" now playing sequence "+seq ; Every clip the file provided, listed by number and name For i=0 To total-1 Text 0,60+i*20," sequence "+i+": "+AnimSeqName$(fox,i) Next Flip Wend End