character animation question

Blitz3D Forums/Blitz3D Beginners Area/character animation question

Hi,
I'm trying to make some tests about character animation, my character should walk, run, sit, bend, and too many more actions, which one could be the method that i must use?

I made my character using bones in format b3d

Should I use only one animesh for all the animations? or diferent b3d files each one having an animated action?

I don't have any program to create md2 files, at the time, I'll have to use b3d files

regards
Santiago

PS: if anyone knows any sample code that I could use, so I can learn, I would apreciate it... thanks

it's been atleast a couple years since i've used Blitz3D, but this is some code i had lying around on the HD. it should help you out.


;**********************************************************************************
; 
;	B3D Animation Example using ExtractAnimSeq ------------------- Rik Smiff April 2003
;
;
;   Use Keys Q through to  X  to transpose  animation sequences.
;
;	Use the Cursor Keys to Pitch and Yaw the Ninjas Head 
;   - this will blend with the currently running animation
;   
;   You will need the B3D Animated Ninja Model "Ninja.b3d"
;   Kindly  donated by Psionic available on the Blitz forum.
;   or
;   www.psionic3d.co.uk
;   Many Thanks to Psionic for his Model - there arent too many animated B3d's out there to play with


; Extract from Ninja.txt by Psionic - Animation Frames
;
; 1-14	    Walk (normal) 
; 15-30	    Stealth Walk
; 32-44	    Punch And swipe sword
; 45-59	    Swipe And spin sword
; 60-68	    Overhead twohanded downswipe
; 69-72  	Up To block position (play backwards To Lower sword If you want)
; 73-83 	Forward kick
; 84-93	    Pick up from Floor (Or down To crouch at frame 87)
; 94-102	Jump
; 103-111	Jump without height (For programmer controlled jumps)
; 112-125	High jump To Sword Kill (Finish em off move??)
; 126-133	Side Kick
; 134-145	Spinning Sword attack (might wanna speed this up in game)
; 146-158	Backflip
; 159-165	Climb wall
; 166-173	Death 1 - Fall back onto ground
; 174-182	Death 2 - Fall forward onto ground
; 184-205	Idle 1 - Breathe heavily
; 206-250	Idle 2
; 251-300	Idle 3
;**********************************************************************************

Graphics3D 800,600
SetBuffer BackBuffer()
camera=CreateCamera()
MoveEntity camera,0,3,0
CameraViewport camera,0,0,GraphicsWidth(),GraphicsHeight()
AmbientLight 255,255,255

;********** Load Model  and Prepare Animation Sequences

Global ninja=LoadAnimMesh("ninja.b3d"); This will load All Frames into Sequence 0
Global walk=ExtractAnimSeq (ninja,0,14); Extract frames 0 to 14 into Sequence 1 - the value 1 is assigned to the Global walk
Global stealth=ExtractAnimSeq (ninja,15,30); Extract frames 15 to 30 into Sequence 2 - the value 2 is assigned to the Global stealth
Global punch_swipe=ExtractAnimSeq (ninja,32,44); And so on extracting each set of frames into a seperate sequence 
Global swipe_spin=ExtractAnimSeq (ninja,45,59); and assigning the sequence number to a global variable.
Global overhead=ExtractAnimSeq (ninja,60,68)
Global block=ExtractAnimSeq (ninja,69,72)
Global fwd_kick=ExtractAnimSeq (ninja,73,83)
Global pickup=ExtractAnimSeq (ninja,84,93)
Global jump=ExtractAnimSeq (ninja,94,102)
Global jump_static=ExtractAnimSeq (ninja,103,111)
Global jump_kill_sword=ExtractAnimSeq (ninja,112,125)
Global sidekick=ExtractAnimSeq (ninja,126,133)
Global spin_sword_attack=ExtractAnimSeq (ninja,134,145)
Global backflip=ExtractAnimSeq (ninja,146,158)
Global climb_wall=ExtractAnimSeq (ninja,159,165)
Global death_fall_back=ExtractAnimSeq (ninja,166,173)
Global death_fall_fwd=ExtractAnimSeq (ninja,174,182)
Global idle_breathe_heavy=ExtractAnimSeq (ninja,184,205)
Global idle_2=ExtractAnimSeq (ninja,206,250)
Global idle_3=ExtractAnimSeq (ninja,251,300)
Global crouch=ExtractAnimSeq (ninja,84,87)
;
;locate the head bone in the model and assign it to the Global 'head'
Global head=FindChild(ninja,"Joint7")
 
;Head rotation Variables
Global headyaw,headpitch
Global state
Const transpose = 40
;Position the model 
MoveEntity ninja,0,0,7
ScaleEntity ninja,0.5,0.5,0.5
RotateEntity ninja,0,180,0
;************** Main Loop ***********************************
While Not KeyHit(1)




; Get Cursor Key Input for Manual Head Rotation
If KeyDown(203) Then headyaw=headyaw+1:If headyaw > 90 Then headyaw = 90
If KeyDown(205) Then headyaw=headyaw-1: If headyaw < -90 Then headyaw = -90
If KeyDown(200) Then headpitch=headpitch+1: If headpitch > 30 Then headpitch= 30
If KeyDown(208) Then headpitch=headpitch-1 : If headpitch < -45 Then headpitch= -45


; Get Key Input for Animation sequence change
If KeyDown(16) And latch_key_Q = False Then  Animate ninja,1,0.1,walk,transpose:latch_key_Q = True:state=0
If Not KeyDown(16) Then latch_key_Q = False
If KeyDown(17) And latch_key_W = False Then  Animate ninja,1,0.1,stealth,transpose:latch_key_W = True:state=1
If Not KeyDown(17) Then latch_key_W = False
If KeyDown(18) And latch_key_E = False Then  Animate ninja,3,0.1,punch_swipe,transpose:latch_key_E = True
If Not KeyDown(18) Then latch_key_E = False
If KeyDown(19) And latch_key_R = False Then  Animate ninja,3,0.1,swipe_spin,transpose:latch_key_R = True
If Not KeyDown(19) Then latch_key_R = False
If KeyDown(20) And latch_key_T = False Then  Animate ninja,3,0.1,overhead,transpose:latch_key_T = True
If Not KeyDown(20) Then latch_key_T = False
If KeyDown(21) And latch_key_Y = False Then  Animate ninja,3,0.1,block,transpose:latch_key_Y = True
If Not KeyDown(21) Then latch_key_Y = False
If KeyDown(22) And latch_key_U = False Then  Animate ninja,3,0.1,fwd_kick,transpose:latch_key_U = True
If Not KeyDown(22) Then latch_key_U = False
If KeyDown(23) And latch_key_I = False Then  Animate ninja,3,0.1,pickup,transpose:latch_key_I = True
If Not KeyDown(23) Then latch_key_I = False
If KeyDown(24) And latch_key_O = False Then  Animate ninja,3,0.1,jump,transpose:latch_key_O = True
If Not KeyDown(24) Then latch_key_O = False
If KeyDown(25) And latch_key_P = False Then  Animate ninja,3,0.1,jump_static,transpose:latch_key_P = True
If Not KeyDown(25) Then latch_key_P = False
If KeyDown(30) And latch_key_A = False Then  Animate ninja,3,0.1,jump_kill_sword,transpose:latch_key_A = True
If Not KeyDown(30) Then latch_key_A = False
If KeyDown(31) And latch_key_S = False Then  Animate ninja,3,0.1,sidekick,transpose:latch_key_S = True
If Not KeyDown(31) Then latch_key_S = False
If KeyDown(32) And latch_key_D = False Then  Animate ninja,3,0.1,spin_sword_attack,transpose:latch_key_D = True
If Not KeyDown(32) Then latch_key_D = False
If KeyDown(33) And latch_key_F = False Then  Animate ninja,3,0.1,backflip,transpose:latch_key_F = True
If Not KeyDown(33) Then latch_key_F = False
If KeyDown(34) And latch_key_G = False Then  Animate ninja,1,0.1,climb_wall,transpose:latch_key_G = True
If Not KeyDown(34) Then latch_key_G = False
If KeyDown(35) And latch_key_H = False Then  Animate ninja,3,0.1,death_fall_back,transpose:latch_key_H = True
If Not KeyDown(35) Then latch_key_H = False
If KeyDown(36) And latch_key_J= False Then  Animate ninja,3,0.1,death_fall_fwd,transpose:latch_key_J = True
If Not KeyDown(36) Then latch_key_J = False
If KeyDown(37) And latch_key_K = False Then  Animate ninja,1,0.1,idle_breathe_heavy,transpose:latch_key_C = True
If Not KeyDown(37) Then latch_key_K = False
If KeyDown(38) And latch_key_L = False Then  Animate ninja,1,0.1,idle_2,transpose:latch_key_Z = True
If Not KeyDown(38) Then latch_key_L = False
If KeyDown(45) And latch_key_X = False Then  Animate ninja,1,0.1,idle_3,transpose:latch_key_X = True
If Not KeyDown(45) Then latch_key_X= False
If KeyDown(44) And latch_key_Z = False Then  Animate ninja,3,0.1,crouch,transpose:latch_key_Z = True
If Not KeyDown(44) Then latch_key_Z = False


If Not Animating(ninja) Then 

		If state=0 Animate ninja,1,0.1,walk,40
		If state=1 Animate ninja,1,0.1,stealth,40

End If


UpdateWorld

;Update head rotation
TurnEntity head,headpitch,headyaw,0

RenderWorld
Flip

Wend





i believe this is the model : http://www.psionic3d.co.uk/gallery/displayimage.php?album=2&pos=5

hope this helps.

thanks!...

i make this test, and works..

humano = loadanimmesh("b3d\stand.b3d")

a_1 = LoadAnimSeq (humano, "b3d\walk.b3d")
a_2 = LoadAnimSeq (humano, "b3d\stand.b3d")

while ...

if n = 0 then animate humano,a_1 ,.5,.1 < i change the las variable
if n = 100 then animate humano,a_1 ,.5,1 < i change the las variable
n = n +1
if n > 200 then n = 0

loop

another question...

i made it using the ninja example..

but my b3d file has some problem..
the body mesh doesn't move attached to the bones animation...
i used skin to the bones animation..

what i must do?

now, if i findchild a bone, and turn the bone, the bodymesh turns fine..

sorry my english..



it has to be rigging/skinning issue if you have used 3dsmax..it also may be way you export out of 3dsmax trough pipeline..make sure that you have settings like this



i found another post with the same problem..

i trying with the configuration you post in the image, but no changes in blitz...

i go to try with 3dsmax7.. maibe is the 9 version the problem...

thanks!..

..try to findchild your main animation root node and Animate it as an entity...

i go to try that... thanks..

when i export with pipeline, the preview works perfect, the human move with the bones animation...

so, if the b3d preview works, the problem is in the code... someone know what code use pipeline on the preview program?..

i post the code i use...
thanks alien...

here the b3d file...
http://www.latatoy.com.ar/temp/temp4.rar


THIS CODE IS FIXED!!!! NOW THE HUMAN MOVES AND BONES TOO..... THANKS TO ALL

graphics3d 1024,768,0,2

e# = .01

cam = createcamera()
camerarange cam,.1,1000
positionentity cam,2,2,-3


luz = createlight(2)
positionentity luz,100,100,100
lightrange luz,100

createmirror()
piso = createplane(8)
entityalpha piso,.6
;t_piso = loadtexture("maps\piso.jpg")
;entitytexture piso,t_piso
hidepointer

;OLD FAIL CODE BONES MOVE BUT NOT CHARACTER

;player = loadanimmesh("b3d\temp4.b3d")
;scaleentity player,e,e,e
;Global a_saluda=ExtractAnimSeq (player,0,130)
;global a_corre=ExtractAnimSeq (player,25,45)
;Animate player,1,.23,a_saluda,2

;THE CODE FIXED, THE BONES MOVE; AND THE HUMAN WITH FINDCHILD TOO.
;fix start
        player = loadanimmesh("b3d\temp.b3d")
        scaleentity player,e,e,e
        Global a_saluda=ExtractAnimSeq (player,0,130)
	Global a_corre=ExtractAnimSeq (player,25,45)
	h = findchild(player,"human")              ;findchild human mesh
	Animate player,1,.23,a_saluda,2
	Animate h
;fix end 
 

while not keyhit(1)

	pointentity cam,player

updateworld
renderworld


	
	
 	If KeyDown (200) Or KeyDown (17) Then vel# = -.03
	If KeyDown (208) Or KeyDown (31) Then vel# = .03
 	If KeyDown (203) Then late# = + 2
   If KeyDown (205) Then late# = - 2
   if keyhit (57) then  animate c,1 ,.5,3,0
   	
	turnentity player,0,late,0
	moveentity player,0,0,vel#

	vel# = 0
	late = 0
	

flip
wend
end