; ClearAnimRootMotion Example ; --------------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,3,-8 RotateEntity camera,15,0,0 light=CreateLight() RotateEntity light,45,45,0 ground=CreatePlane() EntityTexture ground,LoadTexture("media/MossyGround.BMP") ; A courier robot: a named pivot with a cube body courier=CreatePivot() NameEntity courier,"CourierRoot" body=CreateCube(courier) ScaleEntity body,0.4,0.4,0.6 PositionEntity body,0,0.4,0 EntityColor body,60,220,255 ; Author a patrol animation whose keys carry the robot 8 units along X PositionEntity courier,-4,0,0 SetAnimKey courier,0 PositionEntity courier,4,0,0 SetAnimKey courier,60 patrol=AddAnimSeq(courier,60) PositionEntity courier,-4,0,0 ; Extract root motion without applying it: the movement is stripped from ; the pose, so the robot animates on the spot while deltas are reported extracting=True SetAnimRootMotion courier,"CourierRoot",False,False,False ; Play the patrol ping-pong CrossFadeAnim courier,patrol,0,2 While Not KeyDown(1) ; Space toggles extraction. ClearAnimRootMotion switches it off again: ; the authored movement returns to the pose (the robot shuttles about) ; and the reported deltas drop to zero. If KeyHit(57) extracting=1-extracting If extracting Then SetAnimRootMotion courier,"CourierRoot",False,False,False Else ClearAnimRootMotion courier EndIf UpdateWorld ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,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,"Space: toggle extraction Arrows: camera Esc: exit" If extracting Then Text 0,20,"Extracting: robot stays put, deltas reported" Else Text 0,20,"ClearAnimRootMotion called: animation moves the robot again" Text 0,40,"Root delta X: "+AnimRootMotionX(courier) Flip Wend End