SetAnimKey.htm 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>SetAnimKey entity,frame[,pos_key][,rot_key][,scale_key]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. entity - entity handle <br />
  13. frame - frame of animation to be used as anim key <br />
  14. pos_key (optional) - true to include entity position information when setting key. Defaults to true. <br />
  15. rot_key (optional) - true to include entity rotation information when setting key. Defaults to true. <br />
  16. scale_key (optional) - true to include entity scale information when setting key. Defaults to true.
  17. </td>
  18. </tr>
  19. </table>
  20. <h1>Description</h1>
  21. <table>
  22. <tr>
  23. <td>
  24. Sets an animation key for the specified entity at the specified frame. The entity must have a valid animation sequence to work with. <br />
  25. <br />
  26. 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.
  27. </td>
  28. </tr>
  29. </table>
  30. <h1><a href=../3d_examples/SetAnimKey.bb>Example</a></h1>
  31. <table>
  32. <tr>
  33. <td>
  34. ;Create 3d animation example <br />
  35. <br />
  36. ;Set up a simple nice looking level <br />
  37. Graphics3D 640,480 <br />
  38. camera=CreateCamera() <br />
  39. PositionEntity camera,0,12,-12 <br />
  40. RotateEntity camera,35,0,0 <br />
  41. light=CreateLight(2) <br />
  42. PositionEntity light,1000,1000,-1000 <br />
  43. ground=CreatePlane(2) <br />
  44. EntityAlpha ground,0.5 <br />
  45. EntityColor ground,0,0,255 <br />
  46. mirror=CreateMirror() <br />
  47. <br />
  48. ;Lets make a bouncing ball that squashes on impact with the floor. <br />
  49. ball=CreateSphere(16) <br />
  50. EntityShininess ball,1 <br />
  51. EntityColor ball,255,0,0 <br />
  52. <br />
  53. ; Lets animate him and "record" the 3D animation for later playback <br />
  54. bloat#=0 : flatten#=0 : ypos#=10 <br />
  55. <br />
  56. For frame=1 To 10 <br />
  57. ;Drop the ball from height 10 to 2 <br />
  58. ypos = ypos - spd# <br />
  59. spd#=spd#+.2 <br />
  60. PositionEntity ball,0,ypos,0 <br />
  61. ScaleEntity ball,1+bloat,1+flatten,1+bloat <br />
  62. <br />
  63. ;If the ball is low enough make it look increasingly squashed <br />
  64. If frame>8 <br />
  65. bloat=bloat+1.5 <br />
  66. flatten=flatten-.25 <br />
  67. Else <br />
  68. flatten=flatten+.05 <br />
  69. EndIf <br />
  70. <br />
  71. ;Record the frame! <br />
  72. SetAnimKey ball,frame <br />
  73. Next <br />
  74. <br />
  75. ;Now we need to add the frames we've just made to the sequence of "film"! <br />
  76. seq = AddAnimSeq(ball,frame-1) ; total number of frames <br />
  77. <br />
  78. ;Play it back ping-pong! <br />
  79. Animate ball,2,0.15 <br />
  80. While Not KeyHit(1) <br />
  81. UpdateWorld <br />
  82. RenderWorld <br />
  83. Flip <br />
  84. Wend <br />
  85. End
  86. </td>
  87. </tr>
  88. </table>
  89. <br>
  90. <a target=_top href=../index.htm>Index</a><br>
  91. <br>
  92. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=SetAnimKey&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  93. </html>