Blitz3D+ Command Reference

MD2AnimTime# ( md2 )

Parameters

md2 - md2 entity handle

Description

Returns the exact frame position an md2 model is currently at.

The value is a float, because md2 playback blends between whole frames rather than snapping to them: a model part-way between frames 3 and 4 returns something in the range 3 to 4. That fractional part is the blend amount.

Reading it lets you time gameplay to the animation - firing a shot at the frame the arm reaches forward, or checking whether a one-shot attack has passed the point of no return. Since md2 animations are frame ranges rather than named clips, comparing the time against the range you passed to AnimateMD2 is the usual way to know where you are within a move.

This is the md2 counterpart to AnimTime; the two are not interchangeable, and each only works on its own kind of model.

See also: MD2AnimLength, MD2Animating, AnimateMD2, LoadMD2, AnimTime.

Example

; MD2AnimTime Example
; -------------------

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

camera=CreateCamera()

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

; Load the md2 model and apply its texture
gargoyle=LoadMD2("media/Gargoyle/Gargoyle.md2")
garg_tex=LoadTexture("media/Gargoyle/Gargoyle.bmp")
EntityTexture gargoyle,garg_tex

; Face the gargoyle towards the camera
PositionEntity gargoyle,0,-45,100
RotateEntity gargoyle,0,180,0

; Loop the wing-flap frames 32-46
AnimateMD2 gargoyle,1,0.1,32,46

While Not KeyDown(1)

    UpdateWorld

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,1
    If KeyDown(208) Then MoveEntity camera,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"
    ; MD2AnimTime reports the exact frame position, e.g. 33.5 means the
    ; model is morphing halfway between frames 33 and 34
    Text 0,20,"MD2AnimTime(gargoyle) = "+MD2AnimTime(gargoyle)

    Flip

Wend

End

Index