How to EASILY use MIXAMO animations in Blitz3d!!
Attention! 👉Starting November 2024, BlitzCoder.org will now be BlitzBasic.org.
Tweet 3d fbx models tutorials
I FINALLY MIGHT have something here of VALUE to help someone with. And IT IS AWESOME!!... (to me anyways) :P
You can literally animate a character into the game in less than a minute!...
I have had a GREAT amount of success today... I have worked out how to download and use any Mixamo animation with my models (or just Mixamo's models for that matter) straight into Blitz3d. It's easy when you know how, and I realize someone might get some use out of this!...As if you are like me and have not yet learned how to animate!!! there are HUNDREDS of free animations just waiting to be used :)
So I am going to type out how to do it! And hopefully this will help someone get some good stuff into their game!>
Go to Mixamo.com sign up etc log in...
pick a model...or upload your own... then pick an animation. You must save this as an
FBX file ... not the Unity FBX as it doesn't work.
You will need a very small free program called FBX Converter 2013.3
...here's the link
https://www.autodesk.com/developer-network/platform-technologies/fbx-converter-archives
Run this program and drag/drop your mixamo FBX character into the source file converter slot... then under "DESTINATION FORMAT", you must select >> FBX 2009 << or this won't work. Save it into your current Blitz3d project folder.
Then I import the model into Fragmotion...and delete the "Default" animation, leaving the mixamo.com animation in it's glory.
From here just export the character as a .B3d and its done.
You guys probably know the rest...but for anyone who doesn't... this is some of my really BAD code lol.. but it works
.errr I still have not tried texturing a character yet... I'll get there.
I wish I had have known how to do this weeks ago as NOW I can have really nice characters running around in my game :) SO COOL !!!!!
Graphics3D 1024,768,32,0
SeedRnd MilliSecs() camera = CreateCamera() light = CreateLight () HidePointer
player=CreateCube() ScaleEntity player,1,3,1 PositionEntity player,512,1,2
PositionEntity camera,512,5,-30 EntityParent camera,player
ground=CreatePlane() PositionEntity ground,0,0,0 ScaleEntity ground,2000,1,2000 EntityColor ground,120,200,120
site=CreateCube() ScaleEntity site,.2,.2,.2 PositionEntity site,512,1,10 EntityColor site,255,0,0 EntityParent site,player
;PLAYER
man=LoadAnimMesh("idle.b3d")
PositionEntity man,512,1,-20
ScaleEntity man,.1,.1,.1
RotateEntity man,0,90,0
EntityColor man,Rnd(255),Rnd(255),Rnd(255)
While Not KeyHit (1)
;Cls
a=a+1
If KeyDown(17) MoveEntity player,0,0,+.5
If KeyDown(31) MoveEntity player,0,0,-.5
If KeyDown(32) TurnEntity player,0,-1,0
If KeyDown(30) TurnEntity player,0,1,0
If a>340 a=0 ; used this as a timer to start/loop the animation
Animate man,1,.2,a ; the .2 here is the animation speed
UpdateWorld
RenderWorld
Flip
Wend
End
Hey phodis,
nice work and thanks for sharing. Where do you get your animations from?
Hi there, if you just go to www.mixamo.com (you will have to create an account)... then you instantly have all their models... or you can drag and drop your own into their webpage for it to be rigged.
I made an animation sequence today by downloading several of their animations... then I went into Fragmotion and appended all of them together
<<
this guy shows how to link multiple downloaded animations into Fragmotion REALLY FAST.
<<this guy basically did everything I did!!!.... after spending countless hours messing around to try and put it all together I found his video... shows all the Blitz3d code too
It's a lot of fun.... but I am having trouble with the animation commands... heck It was EASY using md2 models.... but for some reason when I export th MD2 format from Fragmotion the models don't show up in blitz3d... there are no errors
mind you..it's just like they are invisible..
I really need help with the b3d ~animating~ part... even after following the 2nd youtube video above, it's not working for me. Even when I copy the code line per line the simple print text if you are walking wont display!!..
I have spent HOURS on just getting this far with my code below... PLEASE feel free to fix it :P and repost here, as I am so close to getting it right. To be honest it's looking pretty promising.
Graphics3D 1024,768
SetBuffer BackBuffer()
AppTitle "Robot animation"
;CAMERA
camera=CreateCamera()
PositionEntity camera,0,20,-35
;LIGHT
light=CreateLight()
RotateEntity(light,90,0,0)
Const kup=17
Const kdown=31
Const kLeft=32
Const kright=30
box=CreateCube()
PositionEntity box,10,0,40
ScaleEntity box,1,5,1
;PLAYER
robot=LoadAnimMesh("therobot.b3d")
ScaleEntity robot,.1,.1,.1
EntityParent camera,robot
;Animations
idle=ExtractAnimSeq(robot,1,179)
walking=ExtractAnimSeq(robot,180,206)
running=ExtractAnimSeq(robot,207,234)
shooting=ExtractAnimSeq(robot,235,270)
die=ExtractAnimSeq(robot,394,532)
;GROUND
ground=CreateTerrain (512)
PositionEntity ground,-500,-5,-500
EntityColor ground,120,120,120
ScaleEntity ground,10,15,10
walk=False
While Not KeyDown(1) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
If walk=False
Animate robot,1,.5,idle
EndIf
;CONTROLS
If KeyDown(kup) MoveEntity robot,0,0,+.5
If KeyDown(kdown) MoveEntity robot,0,0,-.5
If KeyDown(kleft) TurnEntity robot,0,-1,0
If KeyDown(kright) TurnEntity robot,0,1,0
If KeyDown (kup) Or KeyDown(kdown) Or KeyDown(kleft) Or KeyDown(kright) Then
walk=True
Else walk=False Animate robot,1,1,idle,20
EndIf
If AnimTime(robot) =>AnimLength(robot)-1
If walk=True
Animate robot,1,1,walking
EndIf
EndIf
UpdateWorld
RenderWorld
Flip
Wend
End
Crap!... sorry I can't upload my project file!!.. at least I don't know how to. I just looked over the FAQs here, and it looks like it's video and code uploads only ~at least from what I saw.
I hope this helps someone...and if anyone does know how to refine... the above code ... please please go for it my head is spinning :)
Also as a hint ... if you are selecting a Mixamo animation that MOVES from its spot... eg walking...
make sure to tick the box next to your character that says "IN PLACE" otherwise in Blitz3d it will cause weird camera jumping.!
This is really nice phodis! thanks for sharing yes, you can't go wrong with Fragmo and Blitz3D, the only downside is the added root bone on each save, but so far it is not an issue, at least on most cases.
As for file uploads, I tried to search for flexible and better solutions out there and so far spotted a few good external file services to integrate to the site. Expect this to be added as a new feature or option on the next site update/announcement. cheers.
That would be handy RonTek, I have a nice little character I modeled myself and would like to share it if anyone was interested.
The animations work really smooth and look great...it's just the switching between them that has baffled me.
On another topic, I was wondering if you are still working on the new version of Blitz3d? :)
Great! In the meantime, here's one of the file upload service that I got to try a few days ago. I will have this added in the FAQ while I work on the dialog and integration.
Ah yes, still working on it and should have an update when I get a chance.
Coolness... well lets try the upload thing :P
this is a test of my animated character... PLEASE!!.. :) if anyone knows how to sort out the animation controls please show me how as I am really having trouble with this.
Cheers Rontek
Hi phodis,
just a quick suggestion, simplify your code if something repeatedly isn't working, so just create a copy and edit out the code you're not sure about. I'll have a look at it in a bit.
Hi markcwm,
the code below (part of the zip file above) is the easiest way I can come up with to try and
end the walking animation releasing the walk key.... he is supposed to become Idle.
God, I mustn't be far off here!!!. I have tried everything I know, but cannot progress past this point.
While Not KeyDown(1)
If KeyDown(kdown) Or KeyDown(kleft) Or KeyDown(kright) Or KeyDown(kup)
walk=True
Else
walk=False ;<<<<<<<<<<<<<<<<<<<<<<<<<<< I tried to make this as simple as I could
;<<<<<<<<<<<<<<<<<<<<<<<<<<< where is the keys are not hit, he is supposed
;CONTROLS ;<<<<<<<<<<<<<<<<<<<<<<<<<<< to stop animating what he is doing then
If KeyDown(kdown) MoveEntity robot,0,0,0-speed ; Start the idle animation below.
If KeyDown(kleft) TurnEntity robot,0,-1,0
If KeyDown(kright) TurnEntity robot,0,1,0
;run
If KeyDown(klshift) And KeyDown(kup)
speed=10
Animate (robot,1,1,running)
Else speed=.6
EndIf
EndIf
If KeyHit(kup)
Animate (robot,1,1,walking)
EndIf
If KeyDown(kup)
MoveEntity robot,0,0,0+speed
EndIf
If KeyHit(57)
speed=0
Animate (robot,1,1,shooting)
EndIf
If walk=False ;<<<<<<<<<<<<<<<<<<<<<<<<<< But even when no keys are hit/pressed
;If Not Animating(robot) ; the current animating continues..ignoring
Animate (robot,1,1,idle) ; the ( walk = false ) trigger completely...
EndIf ; I really don't understand why this doesn't work!.
EndIf
Hi phodis,
how did you get on with this? I have worked on your code tonight and fixed the bugs. Here's what I did.
First you had key code inside another key code which is a bad idea as this will just disable your code, what you want to do is use more variables to tell you the state of things and enable or disable code on a given state. The next issue was Animate needs called once or you just get the first frame, so I used an initialize variable "startidle" which is then reset once the animation starts. Also, using "If Not Animating" won't work as this is always true. Then I use "startrun" in the same way and it's used to know whether walk or run animation is played. Last, the walk/run animations still played if left/right keys only were down, so "walk" is reset if up/down keys are not pressed.
That's about it, it is okay code and you should be able to expand on it without much trouble.
Graphics3D 1024,768
SetBuffer BackBuffer()
AppTitle "robot animation"
;CAMERA
camera=CreateCamera()
PositionEntity camera,0,10,-15
;LIGHT
light=CreateLight()
RotateEntity(light,90,0,0)
Const kup=17
Const kdown=31
Const kLeft=32
Const kright=30
Const klshift=42
Const kspace=57
Const kesc=1
;PLAYER
robot=LoadAnimMesh("robot2.b3d")
ScaleEntity robot,.1,.1,.1
EntityParent camera,robot
PositionEntity robot,0,0,0
;Animations
Global idle=ExtractAnimSeq(robot,28,206)
Global walking=ExtractAnimSeq(robot ,1,27) ;walk=26
Global running=ExtractAnimSeq(robot ,207,232) ;run=26
Global shooting=ExtractAnimSeq(robot ,233,268)
Global die1=ExtractAnimSeq(robot ,269,407)
Global die2=ExtractAnimSeq(robot ,408,485)
;Box
box=CreateCube()
PositionEntity box,10,0,40
ScaleEntity box,1,5,1
;Gun
;gun=CreateCube()
;PositionEntity gun,1.3,2,0
;ScaleEntity gun,.1,.1,.3
;EntityParent gun,robot
;EntityColor gun,255,0,0
;GROUND
ground=CreateTerrain (512)
PositionEntity ground,-500,-5,-500
EntityColor ground,120,120,120
ScaleEntity ground,10,15,10
Global walk=False
Global speed#=.6
Global startidle=1
Global startrun=0
While Not KeyDown(kesc) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
If KeyDown(kdown) Or KeyDown(kleft) Or KeyDown(kright) Or KeyDown(kup)
walk=True
If KeyDown(kdown) Or KeyDown(kup)
startidle=1
startrun=0
If KeyDown(klshift)
startrun=1
EndIf
Else
walk=False
EndIf
Else
walk=False
EndIf
;walk
If KeyDown(kdown) Then MoveEntity robot,0,0,0-speed
If KeyDown(kleft) Then TurnEntity robot,0,-1,0
If KeyDown(kright) Then TurnEntity robot,0,1,0
If KeyDown(kup) Then MoveEntity robot,0,0,0+speed
If KeyHit(kup) Or KeyHit(kdown)
If startrun=0
Animate (robot,1,1,walking)
Else
Animate (robot,1,1,running)
EndIf
EndIf
;run
If KeyDown(klshift) ;And KeyDown(kup)
speed=10/5
Else
speed=.6
EndIf
;EndIf
If KeyHit(kspace)
speed=0
Animate (robot,1,1,shooting)
EndIf
If walk=False
If startidle=1 ;Not Animating(robot)
Animate (robot,1,1,idle)
startidle=0
EndIf
EndIf
UpdateWorld
RenderWorld
Text 0,0,"Debug: walk="+walk+" Animating(robot)="+Animating(robot)+" speed="+speed+" startrun="+startrun+" startidle="+startidle
Flip
Wend
End
Hi markcwm, I have been literally coming here everyday in the hope I could get an answer on this as I have tried dailey with no success to get it to run with my own code.
There has been three times when using Blitz3d that I call landmarks in progress.. 1 terrain generation with height placement of objects... 2 Shooting in a direction with bullets that end at range... and now this!.
Your code is GREATLY recieved !!.. What this means is I can finally make some good stuff in Blitz3d :) :)
Hopefully anyone else that was wondering how to go about this will see it too!. Cheers for your response.... now I have to get some work done :P
Hi phodis,
okay, yes good coding is hard but if you can break it down one at a time into logical steps, it won't be so confusing.
I just realized my code has some major flaws, so I've got a new version here and I consider this more or less finished now, except for one minor bug where when you unpress shift it resets the idle animation but this is barely noticeable. The main changes I added was die animations, reset from death, and fixed a bug when unpressing shift didn't return to idle from running.
Graphics3D 1024,768
SetBuffer BackBuffer()
AppTitle "robot animation"
;CAMERA
camera=CreateCamera()
PositionEntity camera,0,10,-15
;LIGHT
light=CreateLight()
RotateEntity light,90,0,0
Const kup=17
Const kdown=31
Const kleft=32
Const kright=30
Const klshift=42
Const kspace=57
Const kesc=1
Const k1=2
Const k2=3
Const kr=19
;PLAYER
robot=LoadAnimMesh("robot2.b3d")
ScaleEntity robot,.1,.1,.1
EntityParent camera,robot
PositionEntity robot,0,0,0
;Animations
Global idle=ExtractAnimSeq(robot,28,206)
Global walking=ExtractAnimSeq(robot,1,27)
Global running=ExtractAnimSeq(robot,207,232)
Global shooting=ExtractAnimSeq(robot,233,268)
Global die1=ExtractAnimSeq(robot,269,407)
Global die2=ExtractAnimSeq(robot,408,485)
;Box
box=CreateCube()
PositionEntity box,10,0,40
ScaleEntity box,1,5,1
;Gun
;gun=CreateCube()
;PositionEntity gun,1.3,2,0
;ScaleEntity gun,.1,.1,.3
;EntityParent gun,robot
;EntityColor gun,255,0,0
;GROUND
ground=CreateTerrain(512)
PositionEntity ground,-500,-5,-500
EntityColor ground,120,120,120
ScaleEntity ground,10,15,10
Global speed#=1
Global turn#=1
Global walk=0
Global startidle=1
Global startrun=0
Global stoprun=0
Global startmove=0
Global alive=1
While Not KeyDown(kesc) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
If alive=1
;walk/run
startrun=0
If KeyDown(kdown) Or KeyDown(kleft) Or KeyDown(kright) Or KeyDown(kup)
walk=1
If KeyDown(kdown) Or KeyDown(kup)
startidle=1
If KeyDown(klshift)
startrun=1
EndIf
Else
walk=0
EndIf
Else
walk=0
EndIf
;move
If KeyDown(kdown)
MoveEntity(robot,0,0,0-speed)
EndIf
If KeyDown(kleft)
TurnEntity(robot,0,-turn,0)
EndIf
If KeyDown(kright)
TurnEntity(robot,0,turn,0)
EndIf
If KeyDown(kup)
MoveEntity(robot,0,0,speed)
EndIf
;animate
If KeyDown(kdown) Or KeyDown(kup)
startmove=startmove+1
Else
startmove=0
EndIf
If startmove=1
If startrun=0
Animate(robot,1,1,walking)
Else
Animate(robot,1,1,running)
EndIf
EndIf
;shoot
If KeyHit(kspace)
speed=0
Animate(robot,1,1,shooting)
EndIf
;run
If KeyDown(klshift)
If walk=1
speed=2
turn=2
Endif
If KeyDown(kdown) Or KeyDown(kup)
stoprun=1
EndIf
Else
If walk=1
speed=1
turn=1
EndIf
If stoprun=1
stoprun=0
If startidle=0
startidle=1
EndIf
EndIf
EndIf
EndIf
;die
If KeyHit(k1)
speed=0
alive=0
Animate(robot,3,1,die1)
EndIf
If KeyHit(k2)
speed=0
alive=0
Animate(robot,3,1,die2)
EndIf
;reset
If KeyHit(kr)
alive=1
walk=0
startidle=1
startmove=0
EndIf
;idle
If walk=0
If startidle=1
Animate(robot,1,1,idle)
startidle=0
EndIf
EndIf
UpdateWorld
RenderWorld
Text 0,0,"WASD: walk, LShift: run, 1/2: die, R: reset"
Text 0,20,"walk="+walk+" speed="+speed+" turn="+turn
Text 0,40,"startidle="+startidle+" startrun="+startrun+" stoprun="+stoprun+" startmove="+startmove+" alive="+alive
Flip
Wend
End
WoW, cheers again markcwm, today I made 5 new characters (for a medival game I have been wanting to make for a while), and I put them all through Mixamo this afternoon... Can't believe its so fast and easy..and free :)
Tomorrow I am going to be putting a few of them into Blitz.
Luckily applying animation to the AI will require a LOT less work!.. but the player control is really where the action is; and your code has made it a lot easier to understand. This has been an awesome day :D
Ok well here is my latest attempt!... Bugs me how the trees dont seem to want to spawn in random locations ON the ground, but it will do for now.
I have hit yet another snag. The animations work wonderfully!, I have a 3d heightmap terrain going....but I am stuck!!!...
Literally stuck... IE he won't move!!!!... This is a new character in 3d/Mixamo animation... I have listed all his animations for anyone that wants him to mess around with...low res tho..which I kinda like!.
Download and give it a try; and as a special today!!!!...I have decided...err ~any help will generously not be turned away :)
link https://gofile.io/?c=ynENMf
Cheers guys.
EDIT: >> Ok, I tried using the TED editor that I downloaded from this site in the tools area and it works great. I now have a mesh landscape I can play on :) (So I don't need to solve the above problem).. ALSO :)
as a bonus I can easily set up gravity doing it this way too!.
I have managed to set up quite a nice little scene in TED, ... with objects like trees/fences etc..and am working on exporting it to be used in Blitz3d. This is probably a stupid question, but has
anyone used TED to export the entire scene including the scenery objects ..err maybe all merged together into the one mesh..is this even possible with TED?... I have seen a few mesh joining editors around but
it would be convenient to be able to do it with the actual editor. Anyway am off to do some homework on this (youtube etc) and will post back here if I get a solution.
This post has been really helpful, unfortunately using FBX Convertor.... it gives error of Parameters. Googled, explains the model is too new to be converted?? I'm using Mixamo.
No matter which version of fbx I choose from Mixamo or FBX Convertor it either does not convert or when it does the animations don't transfer over or show in FragMotion.
Any help please?
Many Thanks
unfortunately using FBX Convertor.... it gives error of Parameters. Googled, explains the model is too new to be converted??
you'd expect that there are some sweeping changes with Mixamo since this post was made 3 years ago.
perhaps try also using the fragmotion version before the latest which I see is 1.36.
Thanks, I got it working.. Not done any Blitz for a bit (real life takes over) But I got models and multiple animations working. It's pretty awesome, shame limited to the mixamo models though.
if you are sure that your model has 'bones' (joints) and skinned vertices and animations and that you have exported the b3d correctly ( fragmotion 1.3.4 works well on my side ).
but the model don't show up in blitz3d, it may be a scaling issue.
here is a bb code to debug your b3d model inside blitz3d :
https://www.blitzcoder.org/forum/topic.php?id=1445&post=1
afaik it was removed due to instability with importing and exporting assets.
It was supported on older versions with FBX 2009/2010 as mentioned by OP.
Reply To Topic (minimum 10 characters)
Please log in to reply