How do I animate a b3d character? OR export correctly in Fragmotion to Md2?.

Started by phodiS, November 05, 2018, 15:42:54

Previous topic - Next topic

phodiS

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 down..re-colored    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) Select

; mag is my character
mag=LoadAnimMesh("idleM.b3d")
PositionEntity mag,512,1,2
ScaleEntity mag,1,1,1
RotateEntity mag,0,90,0
EntityColor mag,Rnd(255),Rnd(255),Rnd(255)

While Not KeyHit (1)
;Cls
a=a+1
If KeyDown(17) MoveEntity camera,0,0,+.5
If KeyDown(31) MoveEntity camera,0,0,-.5
If KeyDown(32) TurnEntity camera,0,-1,0
If KeyDown(30) TurnEntity camera,0,1,0

If a>120 a=0
;AddAnimSeq(mag,1)
Animate mag,1,1,a,15       ; I know this is wrong, but I don't know where to go from here!.

RenderWorld
Flip
Wend
End


RemiD

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 :
https://www.syntaxbomb.com/index.php/topic,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)

phodiS

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!

RemiD

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 ?

phodiS

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 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 !!!!!
Code (BlitzBasic) Select

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


 

Naughty Alien

..keep in mind that B3D animation precision is float point, while MD2 integer precision, which will result in 'wobbling' of your character surface..so, if that is okay, ill continue with MD2, otherwise, stay away..

phodiS

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.

Naughty Alien

..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)..

RemiD

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...

phodiS

Code (BlitzBasic) Select


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
;PLAYER
robot=LoadAnimMesh("robot2.b3d")
ScaleEntity robot,.1,.1,.1
EntityParent camera,robot
PositionEntity robot,0,0,0
;Animations
idle=ExtractAnimSeq(robot,28,206)
walking=ExtractAnimSeq(robot ,1,27)
running=ExtractAnimSeq(robot ,207,232)
shooting=ExtractAnimSeq(robot ,233,268)
die1=ExtractAnimSeq(robot ,269,407)
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
walk=False
speed=.6

While Not KeyDown(1) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


;CONTROLS

If KeyDown(kup)    MoveEntity robot,0,0,0+speed
If KeyDown(kdown)  MoveEntity robot,0,0,0-speed
If KeyDown(kleft)  TurnEntity robot,0,-1,0
If KeyDown(kright) TurnEntity robot,0,1,0
If KeyDown(klshift) speed=1 Else speed=.6
If KeyDown (kup) Or KeyDown(kdown) Or KeyDown(kleft) Or KeyDown(kright) Or KeyDown(klshift) 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
Else walk=False Animate robot,1,1,idle,20
EndIf
EndIf


If KeyDown(klshift) And KeyDown(kup) Animate robot,1,1,running


UpdateWorld
RenderWorld
Flip
Wend
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?.


Derron

@ phodiS
wrap your code around the code-blocks to keep indentation - appending the language you used allows for syntax highlighting:




bye
Ron

phodiS

Thanks Derron, I have gone back and edited my posts. Much better cheers.

RemiD

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...

phodiS

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 ...eg 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?

phodiS

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. :)