ok i'm completely stumped now, everything I do seems to get stuck on the first frame of the animation. I've tried so many different options and all it's done is confuse me ;-)
Anyway here's my complete code, please excuse the mess:
; 3D MODEL VIEWER
;------------------------------------------------------
; INITIAL SETUP
;------------------------------------------------------
Graphics3D 800,600,0,2
SetBuffer BackBuffer ()
AppTitle "Character Animation Test"
;------------------------------------------------------
; Constants and Global
;------------------------------------------------------
Global MseX, MseY, LastX, LastY, MoveX#, MoveY# ;mouse
Global PSpeedX# = 0
Global MXSpeed#
Global MYSpeed#
Global MZSpeed#
Global SpeedLeft# = 0
Global SpeedRight# = 0
Const Accel# = 0.002
Const Decel# = 0.002
Const TSpeed# = 0.052
Global Obj
;------------------------------------------------------
; Create camera and pivot elements
;------------------------------------------------------
Pivot1 = CreatePivot ()
Pivot2 = CreatePivot (Pivot1)
cam = CreateCamera (Pivot2)
CameraClsColor cam,80,110,130
PositionEntity cam, 0, 0, -7
PointEntity cam, pivot2
RotateEntity Pivot2, 10, 0, 0
;------------------------------------------------------
; Create 3D elements
;------------------------------------------------------
Light = CreateLight ()
RotateEntity Light, 30,30,0
FloorTex = LoadTexture ("Character\Stone_Floor.jpg")
ScaleTexture FloorTex, 5, 5
ground = CreatePlane ()
EntityTexture ground, FloorTex
mirror = CreateMirror (ground)
EntityColor ground, 40, 120, 100
MoveEntity ground, 0, -1.25, 0
EntityAlpha ground, 0.75
CreatePrimitives ()
;------------------------------------------------------
; Load 3D character and Animations
;------------------------------------------------------
Dude = LoadAnimMesh ("Character\luigi.b3d", Pivot1)
ScaleEntity Dude, 0.01, 0.01, 0.01
TurnEntity Dude, 0, 90, 0
MoveEntity Dude, 0, -1.25, 0
; Load Character Animations
LoadAnimSeq Dude, "Character\idle_empty.b3d" ; IDLE - Sequence 1
LoadAnimSeq Dude, "Character\walk_empty.b3d" ; WALK - Sequence 2
Char_Idle = 1
Char_Walk = 0
;------------------------------------------------------
; MAIN GAME LOOP
;------------------------------------------------------
While Not KeyDown (1)
; Press W to toggle Wireframe
If KeyHit (17) : w = 1 - w : WireFrame w : End If
; Press the LEFT ARROW KEY to move the character left
If KeyDown (203)
SpeedLeft = SpeedLeft + Accel
If SpeedLeft => TSpeed Then SpeedLeft = TSpeed
Else
If SpeedLeft => TSpeed Then SpeedLeft = TSpeed
SpeedLeft = SpeedLeft - speedLeft/20
If SpeedLeft < 0.01 Then SpeedLeft = 0
End If
; Press the RIGHT ARROW KEY to move the character right
If KeyDown (205)
SpeedRight = SpeedRight + Accel
If SpeedRight => TSpeed Then SpeedRight = TSpeed
Else
SpeedRight = SpeedRight - SpeedRight/20
If SpeedRight < 0.01 Then SpeedRight = 0
End If
CharX# = (SpeedRight - SpeedLeft)
; Move the character
MoveEntity Pivot1, CharX, 0, 0
If Char_Idle = 1
Animate Dude, 1, 0.46, 1, 8
End If
UpdateWorld
RenderWorld
; Text elements here
Text 10, 10, "CharX: " + Abs(CharX)
Text 10, 25, "Anim Frame: " + AnimTime (Dude)
Flip
Wend
End
;------------------------------------------------------
; FUNCTIONS
;------------------------------------------------------
Function CreatePrimitives ()
For i = 1 To 100
Obj = Rand(1,4)
Select Obj
Case 1
Obj = CreateCone (12)
Case 2
Obj = CreateSphere (12)
Default
Obj = CreateCube ()
End Select
EntityColor Obj, Rand(100,200), Rand(100,200), Rand(150,250)
ScaleR# = Rand(1,2)
ScaleEntity Obj, 1, ScaleR, 1
PositionEntity Obj, Rand(-20,120), ScaleR#/2 , Rand(1.5,60)
Next
End Function
Here's a link to the character files used:
Animate_Character.zipAny help here would be most appreciated! :-)