Animation Tutorial (for Blitz 3d): REAL Animation

Blitz3D Forums/Blitz3D Beginners Area/Animation Tutorial (for Blitz 3d): REAL Animation

En929(Posted May) [#1]
I admit that I'm no expert, but I made an easy to follow animation tutorial below. I had the HARDEST time trying to figure out AND find out how to get my Animated .b3d Mesh fimstrip to work properly and without the hiccups and errors that I kept getting. But, I FINALLY did it (congratulations to me)!!! So thus, I'm just posting my final code here in case somebody else would need help with those things.

Afterall, animations are a VERY important part of game development. I found that these days in many game development tutorials whether it involves a programming language or game engines, animations are not usually covered enough. Many only show how to move shapes and put colors on screen and that's usually it! But man, to make the games of one's dreams, people need to know how to have characters/meshes/sprites on screen running, jumping, shooting, climbing, fighting, etc. That's what got us all into video games right?

Thus, I put this here!! I think I might even make a youtube video for visual/audio learners too. And this is all from a beginners perspective (because again, I'm no expert. I'm still learning too)! And in some case it can takes a beginner to show other beginners.

Thus, I hope that this code below helps somebody out!




Graphics3D 640,480,0,2
SetBuffer BackBuffer()

;Here's the normal routine stuff

camera=CreateCamera()
PositionEntity camera,0,20,-100 ; 

AmbientLight 132,132,132
light=CreateLight()
LightRange light,20
RotateEntity light,90,0,0



; Here, I load the animed mesh. Note: ALL of my animations
; Are on this SINGLE ".b3d" animation filmstrip.
; I made my animations in an online program
; called "Mixamo" and I put my separate animations
; all together onto ONE filmstrip via a
; program called "Fragmotion!"


man = LoadAnimMesh("Henry2.b3d")



;Now, I give ALL of my animations a name
;and I give the beginnings, ends
;and locations of WHERE my animations are
;on the filmstrip. For example, 
;my "Idle" animation STARTS at frame 
;3 of my single film strip and ENDS at 4, etc.
;I did the same procedure for my "Walking" and 
;my "Punching" animations too.


Idle = ExtractAnimSeq(man,3, 4)
Walking = ExtractAnimSeq(man,3, 30)
Punching = ExtractAnimSeq(man,31, 99)



;Position, Scale, and Rotate object as you please:

ScaleEntity man, 3, 3, 3
RotateEntity man,0,0,0 
PositionEntity man, -0,-200,600




;Game loop and where the action begins.

While Not KeyDown(1)
	

;Starts and Stops the Walking Animation
;if the UP arrow key is pressed.

	If KeyDown(200) 
		WalkingStarts = True
		
		Text 0,20,"Walking"
		
	Else  
		
		WalkingStarts = False

	End If
	
	

;Starts and Stops the Punching Animation
;if the "A" key is pressed.

	
	If KeyDown(30) 
		PunchStarts = True
		
		Text 0,20,"Punching"


	Else  
		
		PunchStarts = False

	End If




;Does the actual "walking" animation when the time is right (I think):

If AnimTime(man) => AnimLength(man)-1
	
		If WalkingStarts = True
			Animate man,1,1,Walking,10.0
			
	
			
			
		End If
End If
		
	
	

;Does the actual "punching" animation when the time is right:

If AnimTime(man) => AnimLength(man)-1	
	
	If PunchStarts = True
			Animate man,1,1,Punching,10.0
			
	
			
			
		
	End If

EndIf 



	
;If neither the punch nor walking animation is going, then
;go to the idle animation. I guess your
;animations filmstrip HAS TO keep running in some fashion, or
;your animation code would act funny like it did for me.
;So, this might be the secret ingrediant for getting
;your animations to work properly.	

	
If Not WalkingStarts Or PunchStarts Then 
	
	
	
		Animate man,1,1,Idle,10.0
	
EndIf 
	


	UpdateWorld 
	RenderWorld 


	
Flip
Wend







RemiD(Posted May) [#2]
thanks for sharing...

but, a slight critic/suggestion :
the structure of your mainloop should rather look like this :
;getinput

;update bots states depending on their previous states and their sensors/ai logic

;update player state depending on his previous state and input

;update bots and player turns/moves/animations (turnentity(), moveentity(), animateentity())

;detect collisions and repositionning (with ellipsoids and collidables (updateworld(), countcollisions(), collisionentity()) or with linepicks and pickables (linepick(), pickedentity()))

;render the scene (renderworld())

because with your current structure, you are playing and rendering the animations of the previous frame...


En929(Posted May) [#3]
Oh ok thanks for the info RemiD. I'll keep that in mind. As I said, I'm no expert LOL. I'm always opened to improve. Thanks again!


Blitzplotter(Posted May) [#4]
Mixamo looks intriguing... Can you make you're Henry2.b3d available somehow, thanks for sharing.


GW(Posted May) [#5]
I spent a lot of time dealing with the mixamo to b3d pipeline.
the short answer is:
upload mesh to mixamo and rig it.
pick animations and export as fbx
use the free fbx converter from autodesk to convert to fbx2006
import mesh into fragmotion
merge all the animations in fragmotion
load textures and uv map if needed and apply texture to surface
export .b3d
side Note:
blitz3d works well
openb3d works, but shadows are rotten
xors3d mangles the mesh
If you want to use the animated model in Atomic,Unity,Xenko,Leadwerks,lumberyard ect. there are some extra steps. (i've done all these too)
and btw, Don't export from Pacemaker!


Rick Nasher(Posted May) [#6]
I second that, wanna see what's going on. :-)


Blitzplotter(Posted May) [#7]
@GW, thanks for the info on your export - import process, I might give it a whirl this weekend.