Ooops
February 27, 2021, 03:18:13 AM

Author Topic: [bb] .b3d Animation using ExtractAnimSeq by Ricky Smith [ 1+ years ago ]  (Read 796 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : .b3d Animation using ExtractAnimSeq
Author : Ricky Smith
Posted : 1+ years ago

Description : I wrote this really to view Psionics animated Ninja model and to see how the ExtractAnimSeq command worked in Blitz. I have never used this command in anger before as I havent had an animated model to work with. Many Thanks to Psionic for donating his work.
Use the 'Q' and 'W' keys to change from the normal walk anim to the stealth anim - the rest of the keys can be used to transpose to the one-shot animation sequences or the looping idle sequences. You can rotate and raise lower the head using the cursor keys.
The head rotation can go a bit mad at times because some  animation sequences use head rotation as well - it works best in the walk sequence.
Have Fun !


Code :
Code: BlitzBasic
  1. ; ID: 660
  2. ; Author: Smiff
  3. ; Date: 2003-04-25 21:21:11
  4. ; Title: .b3d Animation using ExtractAnimSeq
  5. ; Description: An Example of using The ExtractAnimSeq Command
  6.  
  7. ;**********************************************************************************
  8. ;
  9. ;       B3D Animation Example using ExtractAnimSeq ------------------- Rik Smiff April 2003
  10. ;
  11. ;
  12. ;   Use Keys Q through to  X  to transpose  animation sequences.
  13. ;
  14. ;       Use the Cursor Keys to Pitch and Yaw the Ninjas Head
  15. ;   - this will blend with the currently running animation
  16. ;  
  17. ;   You will need the B3D Animated Ninja Model "Ninja.b3d"
  18. ;   Kindly  donated by Psionic available at
  19. ;  
  20. ;   http://www.psionic3d.co.uk
  21.  
  22. ;   Many Thanks to Psionic.
  23.  
  24.  
  25. ;  Animation Frames
  26. ;
  27. ; 1-14      Walk (normal)
  28. ; 15-30     Stealth Walk
  29. ; 32-44     Punch And swipe sword
  30. ; 45-59     Swipe And spin sword
  31. ; 60-68     Overhead twohanded downswipe
  32. ; 69-72         Up To block position (play backwards To Lower sword If you want)
  33. ; 73-83         Forward kick
  34. ; 84-93     Pick up from Floor (Or down To crouch at frame 87)
  35. ; 94-102        Jump
  36. ; 103-111       Jump without height (For programmer controlled jumps)
  37. ; 112-125       High jump To Sword Kill (Finish em off move??)
  38. ; 126-133       Side Kick
  39. ; 134-145       Spinning Sword attack (might wanna speed this up in game)
  40. ; 146-158       Backflip
  41. ; 159-165       Climb wall
  42. ; 166-173       Death 1 - Fall back onto ground
  43. ; 174-182       Death 2 - Fall forward onto ground
  44. ; 184-205       Idle 1 - Breathe heavily
  45. ; 206-250       Idle 2
  46. ; 251-300       Idle 3
  47. ;**********************************************************************************
  48.  
  49. Graphics3D 800,600
  50. SetBuffer BackBuffer()
  51. camera=CreateCamera()
  52. MoveEntity camera,0,3,0
  53. CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
  54. AmbientLight 255,255,255
  55.  
  56. ;********** Load Model  and Prepare Animation Sequences
  57.  
  58. Global ninja=LoadAnimMesh("ninja4.b3d"); This will load All Frames into Sequence 0
  59. Global walk=ExtractAnimSeq (ninja,0,14); Extract frames 0 to 14 into Sequence 1 - the value 1 is assigned to the Global walk
  60. Global stealth=ExtractAnimSeq (ninja,15,30); Extract frames 15 to 30 into Sequence 2 - the value 2 is assigned to the Global stealth
  61. Global punch_swipe=ExtractAnimSeq (ninja,32,44); And so on extracting each set of frames into a seperate sequence
  62. Global swipe_spin=ExtractAnimSeq (ninja,45,59); and assigning the sequence number to a global variable.
  63. Global overhead=ExtractAnimSeq (ninja,60,68)
  64. Global block=ExtractAnimSeq (ninja,69,72)
  65. Global fwd_kick=ExtractAnimSeq (ninja,73,83)
  66. Global pickup=ExtractAnimSeq (ninja,84,93)
  67. Global jump=ExtractAnimSeq (ninja,94,102)
  68. Global jump_static=ExtractAnimSeq (ninja,103,111)
  69. Global jump_kill_sword=ExtractAnimSeq (ninja,112,125)
  70. Global sidekick=ExtractAnimSeq (ninja,126,133)
  71. Global spin_sword_attack=ExtractAnimSeq (ninja,134,145)
  72. Global backflip=ExtractAnimSeq (ninja,146,158)
  73. Global climb_wall=ExtractAnimSeq (ninja,159,165)
  74. Global death_fall_back=ExtractAnimSeq (ninja,166,173)
  75. Global death_fall_fwd=ExtractAnimSeq (ninja,174,182)
  76. Global idle_breathe_heavy=ExtractAnimSeq (ninja,184,205)
  77. Global idle_2=ExtractAnimSeq (ninja,206,250)
  78. Global idle_3=ExtractAnimSeq (ninja,251,300)
  79. Global crouch=ExtractAnimSeq (ninja,84,87)
  80. ;
  81. ;locate the head bone in the model and assign it to the Global 'head'
  82. Global head=FindChild(ninja,"Joint7")
  83.  
  84. ;State values
  85. Global s_walk=0
  86. Global s_stealth=1
  87.  
  88. ;Head rotation Variables
  89. Global headyaw,headpitch
  90. Global state
  91. Const transpose = 40
  92. ;Position the model
  93. MoveEntity ninja,0,0,7
  94. ScaleEntity ninja,0.5,0.5,0.5
  95. RotateEntity ninja,0,180,0
  96. ;************** Main Loop ***********************************
  97. While Not KeyHit(1)
  98.  
  99.  
  100.  
  101.  
  102. ; Get Cursor Key Input for Manual Head Rotation
  103. If KeyDown(203) Then headyaw=headyaw+1:If headyaw > 90 Then headyaw = 90
  104. If KeyDown(205) Then headyaw=headyaw-1: If headyaw < -90 Then headyaw = -90
  105. If KeyDown(200) Then headpitch=headpitch+1: If headpitch > 30 Then headpitch= 30
  106. If KeyDown(208) Then headpitch=headpitch-1 : If headpitch < -45 Then headpitch= -45
  107.  
  108.  
  109. ; Get Key Input for Animation sequence change
  110. If KeyHit(16)  Then  Animate ninja,1,0.1,walk,transpose:state=s_walk
  111. If KeyHit(17)  Then  Animate ninja,1,0.1,stealth,transpose:state=s_stealth
  112. If KeyHit(18)  Then  Animate ninja,3,0.1,punch_swipe,transpose
  113. If KeyHit(19)  Then  Animate ninja,3,0.1,swipe_spin,transpose
  114. If KeyHit(20)  Then  Animate ninja,3,0.1,overhead,transpose
  115. If KeyHit(21)  Then  Animate ninja,3,0.1,block,transpose
  116. If KeyHit(22)  Then  Animate ninja,3,0.1,fwd_kick,transpose
  117. If KeyHit(23)  Then  Animate ninja,3,0.1,pickup,transpose
  118. If KeyHit(24)  Then  Animate ninja,3,0.1,jump,transpose
  119. If KeyHit(25)  Then  Animate ninja,3,0.1,jump_static,transpose
  120. If KeyHit(30)  Then  Animate ninja,3,0.1,jump_kill_sword,transpose
  121. If KeyHit(31)  Then  Animate ninja,3,0.1,sidekick,transpose
  122. If KeyHit(32)  Then  Animate ninja,3,0.1,spin_sword_attack,transpose
  123. If KeyHit(33)  Then  Animate ninja,3,0.1,backflip,transpose
  124. If KeyHit(34)  Then  Animate ninja,1,0.1,climb_wall,transpose
  125. If KeyHit(35)  Then  Animate ninja,3,0.1,death_fall_back,transpose
  126. If KeyHit(36)  Then  Animate ninja,3,0.1,death_fall_fwd,transpose
  127. If KeyHit(37)  Then  Animate ninja,1,0.1,idle_breathe_heavy,transpose
  128. If KeyHit(38)  Then  Animate ninja,1,0.1,idle_2,transpose
  129. If KeyHit(45)  Then  Animate ninja,1,0.1,idle_3,transpose
  130. If KeyHit(44)  Then  Animate ninja,3,0.1,crouch,transpose
  131.  
  132.  
  133.  
  134. If Not Animating(ninja) Then
  135.  
  136.                 If state=s_walk Then Animate ninja,1,0.1,walk,40
  137.                 If state=s_stealth Then  Animate ninja,1,0.1,stealth,40
  138.  
  139. End If
  140.  
  141.  
  142. UpdateWorld
  143.  
  144. ;Update head rotation
  145. TurnEntity head,headpitch,headyaw,0
  146.  
  147. RenderWorld
  148. Flip
  149.  
  150. Wend


Comments :


IKG(Posted 1+ years ago)

 This is very helpful for me. Thanks!


panton(Posted 1+ years ago)

 WOOw good job


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal