dxSetAnimKey(entity%,frame#,pos_key%,rotation_key%,scale_key%)

Parameters

entity - entity handle
frame - frame of animation to be used as anim key
pos_key (optional) - true to include entity position information when setting key. Defaults to true.
rot_key (optional) - true to include entity rotation information when setting key. Defaults to true.
scale_key (optional) - true to include entity scale information when setting key. Defaults to true.

Description

Sets an animation key for the specified entity at the specified frame. The entity must have a valid animation sequence to work with.

This is most useful when you've got a character, or a complete set of complicated moves to perform, and you want to perform them en-masse.

Example

;Create 3d animation example

;Set up a simple nice looking level
dxGraphics3D 640,480
camera=dxCreateCamera()
dxPositionEntity camera,0,12,-12
dxRotateEntity camera,35,0,0
light=dxCreateLight(2)
dxPositionEntity light,1000,1000,-1000
ground=dxCreatePlane(2)
dxEntityAlpha ground,0.5
dxEntityColor ground,0,0,255
mirror=CreateMirror()

;Lets make a bouncing ball that squashes on impact with the floor.
ball=dxCreateSphere(16)
dxEntityShininess ball,1
dxEntityColor ball,255,0,0

; Lets dxAnimate him and "record" the 3D animation for later playback
bloat#=0 : flatten#=0 : ypos#=10

For frame=1 To 10
;Drop the ball from height 10 to 2
ypos = ypos - spd#
spd#=spd#+.2
dxPositionEntity ball,0,ypos,0
dxScaleEntity ball,1+bloat,1+flatten,1+bloat

;If the ball is low enough make it look increasingly squashed
If frame>8
bloat=bloat+1.5
flatten=flatten-.25
Else
flatten=flatten+.05
EndIf

;Record the frame!
dxSetAnimKey ball,frame
Next

;Now we need to add the frames we've just made to the sequence of "film"!
seq = dxAddAnimSeq(ball,frame-1) ; total number of frames

;Play it back ping-pong!
dxAnimate ball,2,0.15
While Not dxKeyHit(1)
dxUpdateWorld
dxRenderWorld
dxFlip
Wend
End

Index