January 16, 2021, 09:40:22 PM

Author Topic: How do I animate a b3d character? OR export correctly in Fragmotion to Md2?.  (Read 2429 times)

Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
I can happily animate some OLD Md2 models that I downloaded some time back, and they work great..but I only have a few models and I am sick of them!!!!..

So what I have done is rig a model..animate it in Mixamo... convert it to an >> Fbx 2009 <<
format, then load it into Fragmotion.
So far so good...all the animation works fine in fragmotion.
However, when I export them as MD2 models and load them into Blitz3d..there are no errors...the code runs but the model is not there. I have a script to move the camera around to make sure... I have also scaled the model up and    nothing.             
So I must be doing something incorrectly in Fragmotion. I have looked at videos on Youtube with no success.

Well.. I did the same above...this time exporting the models from Fragmotion as .B3d , and they DO show up in Blitz3d but I can't find code to animate them.
So I need to Either solve the Md2 export problem in Fragmotion, or work out the animation code using B3d.... the below is what I have tried with b3d.. any ideas anyone?... I have looked all over google and come up empty.
Code: BlitzBasic
  1. ; mag is my character
  2. mag=LoadAnimMesh("idleM.b3d")
  3. PositionEntity mag,512,1,2
  4. ScaleEntity mag,1,1,1
  5. RotateEntity mag,0,90,0
  6. EntityColor mag,Rnd(255),Rnd(255),Rnd(255)
  8. While Not KeyHit (1)
  9. ;Cls
  10. a=a+1
  11. If KeyDown(17) MoveEntity camera,0,0,+.5
  12. If KeyDown(31) MoveEntity camera,0,0,-.5
  13. If KeyDown(32) TurnEntity camera,0,-1,0
  14. If KeyDown(30) TurnEntity camera,0,1,0
  16. If a>120 a=0
  17. ;AddAnimSeq(mag,1)
  18. Animate mag,1,1,a,15       ; I know this is wrong, but I don't know where to go from here!.
  20. RenderWorld
  21. Flip
  22. Wend
  23. End

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1128
A tip about Fragmotion and Blitz3d :

usually i model / rigg / skin / animate, in fragmotion, with a scale of 100 fragunits = 1.0 blitzunit, and when i import the mesh in Blitz3d i scale it by 0.01 (using scaleentity, not scalemesh! (for rigged skinned meshes))

You can use the rigged skinned mesh (b3d) provided here :,4353.0.html
to do some tests...

It is a bad practice to use several different tools to export / import your mesh, because some importers/exporters may have errors / missing properties...

(btw, you need to add updateworld() to update animations / skinned meshes)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
Hi RemiD,
              Firstly thank you. I downloaded the example. It's weird all the BB files that I try to run...look like they load then disappear without a result... so for a while now I have been writing my code..copying it all into a text file.. reloading Blitz3d, and copying it back in.

So I can't see the actual code to the example you linked.

BUT I got the animation working with my dodgy code above!, which is a start!

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1128
the code example demonstrates 2 ways to animate a rigged skinned mesh :
->by using the animate() function and letting Blitz3d handle the rest, easier but more limited
->by setting the specific animframe, which is more flexible, but require more understanding
in any case, you need to use updateworld() to update the positions/orientations of joints/bones and of vertices...

i don't know about your problem with bb files, maybe it is because of your anti malwares software ?
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
I re-installed Blitz3d and all files now load properly again, thank god. Cheers for your help again too RemiD, you rock man!.

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  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's the link

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 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 !!!!!
Code: BlitzBasic
  1. Graphics3D 1024,768,32,0
  2. SeedRnd MilliSecs() camera = CreateCamera() light = CreateLight () HidePointer
  3. player=CreateCube() ScaleEntity player,1,3,1 PositionEntity player,512,1,2
  4. PositionEntity camera,512,5,-30 EntityParent camera,player
  5. ground=CreatePlane() PositionEntity ground,0,0,0 ScaleEntity ground,2000,1,2000 EntityColor ground,120,200,120
  6. site=CreateCube() ScaleEntity site,.2,.2,.2 PositionEntity site,512,1,10 EntityColor site,255,0,0 EntityParent site,player
  7. ;PLAYER
  8. man=LoadAnimMesh("idle.b3d")
  9. PositionEntity man,512,1,-20
  10. ScaleEntity man,.1,.1,.1
  11. RotateEntity man,0,90,0
  12. EntityColor man,Rnd(255),Rnd(255),Rnd(255)
  14. While Not KeyHit (1)
  15. ;Cls
  16. a=a+1
  17. If KeyDown(17) MoveEntity player,0,0,+.5
  18. If KeyDown(31) MoveEntity player,0,0,-.5
  19. If KeyDown(32) TurnEntity player,0,-1,0
  20. If KeyDown(30) TurnEntity player,0,1,0
  21. If a>340 a=0            ; used this as a timer to start/loop the animation
  22. Animate man,1,.2,a   ; the .2 here is the animation speed
  24. UpdateWorld
  25. RenderWorld
  26. Flip
  27. Wend
  28. End

Offline Naughty Alien

  • Hero Member
  • *****
  • Posts: 701
..keep in mind that B3D animation precision is float point, while MD2 integer precision, which will result in 'wobbling' of your character, if that is okay, ill continue with MD2, otherwise, stay away..

Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
I have only had experience with Md2 until today, and I didn't know about the precision potentially being a problem.
I don't understand why it is tho that Fragmotion (for me anyway) can export my characters as Md2...but they wont show up in Blitz3d...and Blitz doesn't report any errors...the program just runs with ..I guess invisible characters?... any ideas on this as I would also prefer to keep using the Md2 format as well.

Offline Naughty Alien

  • Hero Member
  • *****
  • Posts: 701
..wobbling related to MD2 format is not an error, its just visual artifact where vertices of your character moving around and visually making character looks weird a bit because of fact that repositioning of vertices is done on integer values..thats all..MD3 solved that problem (float point)..

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1128
there is no reason to not use a mesh format with joints/bones and skinned vertices (like b3d) nowadays, you can animate many without any slowdowns...
also if you want to be able to merge several parts (bodyparts /clothes / armors) to make one character/vehicle, or if you want to set others meshes as childs of a joint (for example a weapon), with a b3d mesh (or rather a mesh with joints/bones and skinned vertices), you can, with md2 it will be complicated...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
Code: BlitzBasic
  2. Graphics3D 1024,768
  3. SetBuffer BackBuffer()
  4. AppTitle "robot animation"
  5. ;CAMERA
  6. camera=CreateCamera()
  7. PositionEntity camera,0,10,-15
  8. ;LIGHT
  9. light=CreateLight()
  10. RotateEntity(light,90,0,0)
  12. Const kup=17
  13. Const kdown=31
  14. Const kLeft=32
  15. Const kright=30
  16. Const klshift=42
  17. ;PLAYER
  18. robot=LoadAnimMesh("robot2.b3d")
  19. ScaleEntity robot,.1,.1,.1
  20. EntityParent camera,robot
  21. PositionEntity robot,0,0,0
  22. ;Animations
  23. idle=ExtractAnimSeq(robot,28,206)
  24. walking=ExtractAnimSeq(robot ,1,27)
  25. running=ExtractAnimSeq(robot ,207,232)
  26. shooting=ExtractAnimSeq(robot ,233,268)
  27. die1=ExtractAnimSeq(robot ,269,407)
  28. die2=ExtractAnimSeq(robot ,408,485)
  29. ;Box
  30. box=CreateCube()
  31. PositionEntity box,10,0,40
  32. ScaleEntity box,1,5,1
  35. ;Gun
  36. ;gun=CreateCube()
  37. ;PositionEntity gun,1.3,2,0
  38. ;ScaleEntity gun,.1,.1,.3
  39. ;EntityParent gun,robot
  40. ;EntityColor gun,255,0,0
  43. ;GROUND
  44. ground=CreateTerrain (512)
  45. PositionEntity ground,-500,-5,-500
  46. EntityColor ground,120,120,120
  47. ScaleEntity ground,10,15,10
  48. walk=False
  49. speed=.6
  51. While Not KeyDown(1) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  56. If KeyDown(kup)    MoveEntity robot,0,0,0+speed
  57. If KeyDown(kdown)  MoveEntity robot,0,0,0-speed
  58. If KeyDown(kleft)  TurnEntity robot,0,-1,0
  59. If KeyDown(kright) TurnEntity robot,0,1,0
  60. If KeyDown(klshift) speed=1 Else speed=.6
  61. If KeyDown (kup) Or KeyDown(kdown) Or KeyDown(kleft) Or KeyDown(kright) Or KeyDown(klshift) Then
  62.  walk=True
  63. Else
  64.  walk=False
  65.  Animate robot,1,1,idle,20
  66. EndIf
  68. If AnimTime(robot) =>AnimLength(robot)-1
  70. If walk=True
  72. Animate robot,1,1,walking
  73. Else walk=False Animate robot,1,1,idle,20
  74. EndIf
  75. EndIf
  78. If KeyDown(klshift) And KeyDown(kup) Animate robot,1,1,running
  81. UpdateWorld
  82. RenderWorld
  83. Flip
  84. Wend
  85. End

I must be missing a step. I have not used the b3d format before and having trouble changing animations, where my character will not stand idle until I press the forward key..then he will play the entire animation of idle and finally start walking like he should. Can anyone see where I have gone wrong?.

Offline Derron

  • Hero Member
  • *****
  • Posts: 3331
@ phodiS
wrap your code around the code-blocks to keep indentation - appending the language you used allows for syntax highlighting:


Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
Thanks Derron, I have gone back and edited my posts. Much better cheers.

Offline RemiD

  • Hero Member
  • *****
  • Posts: 1128
after having tried different methods, what i find the most easy / clear method is to use a "states system"

so for each moving animating entity you have a variable to store its state.
then, depending on the previous state, and depending on the input (for player) or AI (for bots) you determine the current state.
then depending on the current state you apply the corresponding movement / translation and play the corresponding animation...
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
I have attached a copy of my animated robot model, that semi works here. I would love to get it under a state machine control...but even getting him to animate in the first place is a lot trickier than I expected.
As you can see from the project so far, he starts in Idle mode... then walks forward fine as you press forward...will enter the fire animation when space is pressed... but
what I can't figure out is how to stop the last animation take your finger off the walk button...he keeps going with the walk animation etc etc... my best lame attempt
ended with the following code to stop him from walking...

if not keydown(kup) walk = false
if not keyhit(kup) walk=false

...tried them both by themselves then together with no joy. I thought for sure would have sent him back to idle but doesn't.
 Is there another way?

Offline phodiS

  • Jr. Member
  • **
  • Posts: 52
A big shout out to markcwm for helping me out with writing the code for moving an animated character properly in Blitz3d.
Feel free to download my little animated robot that now has working code for animating Mixamo models correctly :)
I think this is such a great start to anyone wanting to make a 3rd/1st person game now with good character animations.
Hope this helps someone. :) 


SimplePortal 2.3.6 © 2008-2014, SimplePortal