12. Animated Meshes
Animated meshes are an entirely different "animal" altogether and we will be just scratching the surface of possibilities. Animated meshes usual contain several frames/sequences (idle, walk, jump, etc) that must be "extracted". These extracted sequences must be played at the appropriate time and can be sped up or slowed down, played in reverse, looped, etc. We will be keeping it simple here and just extract the walking sequence.

Many FREE animated meshes can be found within the Blitz3D example folders or online (HERE and HERE).
Don't forget the accompanying textures!

If you haven't already downloaded the tutorial files do so now, unzip to your desktop and OPEN up lesson12.bb, functions12.bb, and loadworld12.bb (below) and RUN / LAUNCH the lesson12.bb program by pressing the ROCKET ICON

and you should see this...


Here's the CODE (NEW CODE is BOLD) with explanatory comments!
lesson12.bb

...
While QUIT = False
   MoveAnts() ;Just keep the ants moving
   ...
Wend
...


functions12.bb

...
Function MoveAnts()
   For Ant.AMesh = Each AMesh
      
; turn the ant a bit on the y-axis and move forward (z)
      TurnEntity Ant\ID,0,.1,0
      MoveEntity Ant\ID,0,0,.1
      
; reposition on the Terrain
      ex#=EntityX(Ant\ID):ez#=EntityZ(Ant\ID)
      PositionEntity Ant\ID,ex,TerrainY( land,ex,0,ez ),ez
   Next
End Function

...


loadworld12.bb

...
Type AMesh ; New TYPE for our animated ants
   Field ID
End Type

...
; Load 50 ant copies, extract walking animation (frames 1-9)
; Randomly color, position, point at player (cam1), start animation

ant1 = LoadAnimMesh("ant01.b3d")
ExtractAnimSeq (ant1,1,9)
ScaleEntity ant1, .3, .3, .3
EntityAutoFade ant1, 50, 60

For c=1 To 50
   Ant.AMesh = New AMesh
   Ant\ID= CopyEntity (ant1)
   EntityColor Ant\ID, Rand(50,200),Rand(50,200),Rand(50,200)
   x=Rand(-100,100):z=Rand(-100,100)
   PositionEntity Ant\ID,x, TerrainY( land, x ,0, z ), z
   PointEntity Ant\ID, cam1
   Animate Ant\ID,1,.2, 1
Next
FreeEntity ant1
; Clears memory of ant template
. . .


THE FINAL CHALLENGE!!!
Can you figure out how to shoot the ants?
What if YOU were the ant?
Find/import other animated meshes?