AddAnimSeq.bb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ;Create 3d animation example
  2. ;Set up a simple nice looking level
  3. Graphics3D 640,480
  4. camera=CreateCamera()
  5. PositionEntity camera,0,12,-12
  6. RotateEntity camera,35,0,0
  7. light=CreateLight(2)
  8. PositionEntity light,1000,1000,-1000
  9. ground=CreatePlane(2)
  10. EntityAlpha ground,0.5
  11. EntityColor ground,0,0,255
  12. mirror=CreateMirror()
  13. ;Lets make a bouncing ball that squashes on impact with the floor.
  14. ball=CreateSphere(16)
  15. EntityShininess ball,1
  16. EntityColor ball,255,0,0
  17. ; Lets animate him and "record" the 3D animation for later playback
  18. bloat#=0 : flatten#=0 : ypos#=10
  19. For frame=1 To 10
  20. ;Drop the ball from height 10 to 2
  21. ypos = ypos - spd#
  22. spd#=spd#+.2
  23. PositionEntity ball,0,ypos,0
  24. ScaleEntity ball,1+bloat,1+flatten,1+bloat
  25. ;If the ball is low enough make it look increasingly squashed
  26. If frame>8
  27. bloat=bloat+1.5
  28. flatten=flatten-.25
  29. Else
  30. flatten=flatten+.05
  31. EndIf
  32. ;Record the frame!
  33. SetAnimKey ball,frame
  34. Next
  35. ;Now we need to add the frames we've just made to the sequence of "film"!
  36. seq = AddAnimSeq(ball,frame-1) ; total number of frames
  37. ;Play it back ping-pong!
  38. Animate ball,2,0.15
  39. While Not KeyHit(1)
  40. UpdateWorld
  41. RenderWorld
  42. Flip
  43. Wend
  44. End