entity - entity handle length - |
Creates an animation sequence for an entity. This must be done before any animation keys set by dxSetAnimKey can be used in an actual animation however this is optional. You may use it to "bake" the frames you have added previously using dxSetAnimKey. Returns the animation sequence number added. |
;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 |