Jump to content

Problem animation rotation mesh with skeleton from Blender to Babylon


Zino54220
 Share

Recommended Posts

Hi everyone,

First, thanks to Babylon.js!It has many potential!

Now, my problem...

I'm a programmer and I try to create a 3D game with Babylon.js on a wamp server and Blender v2.67.

I'm learning how to create basic mesh and animation and how export it into Babylon.js.

When I import a basic mesh (like a cube...) linked to many rotation keyframes (in blender...), there is no problem when playing animation in Blender and Babylon.The mesh spins well to the center of the mesh... See the files RotaInBlender.gif and RotaInBabylon.gif...

 

In Blender :

post-6162-0-61661700-1389360683.gif

 

In Babylon :

post-6162-0-97033000-1389360681.gif

When I import the same mesh linked to a skeleton and repeat the process of the creation of the rotation keyframes (linked to the skeleton this time...),there is no problem in Blender but the animation in Babylon.js is not the same... See the files RotaInBlenderWithSkel.gif and RotaInBabylonWithSkel.gif...

 

In Blender :

post-6162-0-11012600-1389360684.gif

 

In Babylon :

post-6162-0-75914500-1389360682.gif

 

It's like the mesh doesn't spin but turn around a new offset center but I don't understand because the center of the bone is the same that the mesh center in Blender!

I see many options to repeat the process of the creation of the rotation keyframes in Blender with different properties "Rotation Mode" like : XYZ Euler, Axis, Quaternion(WXYZ)... but always the same result.

What i'm doing wrong please ?

I can send file .blend or .babylon if anyone want help me.

Thanks you for your help, i real need it!

:)

PS :

Sorry for my bad english, i'm French and it's my first forum...
 

Link to comment
Share on other sites

Hi Zino,

 

I haven't played with animations so far with BabylonJS but like you suggested there could be an offset. The pivotMatrix could be different than the identity matrix or the positions of the vertices are not expressed in the correct space. (or the skeleton, but I have no idea how it's used in BabylonJS)

 

Yes it could be helpful if you could share your files. Not sure I will have look on them over the week-end but I may be able to read them on Monday or someone else will fix the issue before that.

 

Here are two of my answers to other posts where vertices and pivot are discussed:

 

http://www.html5gamedevs.com/topic/2864-how-to-set-meshs-center-and-how-to-setphysicsstate-at-heightmap/?p=18572

http://www.html5gamedevs.com/topic/2872-basic-math-knowledge-for-video-games/?p=19594

Link to comment
Share on other sites

Hi and thanks for your reply gwenael.

 

Here, my files :

 

files_cubes.zip

 

Blender file is "cube.blend" and the Babylon file is "cube.babylon". (Captain obvious... ^^ )

 

The file "cube.babylon" was generated with the exporter "io_export_babylon.py" from babylon v 1.7.3.

 

I'll try soon the function "setPivotMatrix(...)" and will inform you.

 

PS :

 

Thanks again ! :)

 

Link to comment
Share on other sites

Sounds like you didn't create vertex groups.  

 

Okay, so let's say you have a cube with a bone, like this:

 

post-5799-0-50517700-1389487678.png

 

And you want it to rotate as follows (I'm assuming you've done the keyframe animation):

 

 

(just to see the rotation better, I threw in a texture of Kesha and I--please don't hold that against me haha)

 

The trick is to select the armature and the cube, then Ctrl-P followed by selecting "Armature Deform with Automatic Weights".  This will create the vertex groups for you. It looks like this after you Ctrl-P:

 

post-5799-0-06127100-1389488166.png

 

Then export as .babylon

 

Good luck.  Let me know if that helped. 

 

- Nick

 

p.s., I remember one last thing when you play the animation, you have to set start=0 and end=100:

 scene.beginAnimation(Skeletons[0], 0, 100, true, 1);

 

p.p.s, I remembered also that you should bake the translation, rotation, and scaling into the vertices--so that the parent transformation matrix = Identity matrix. To do so, with the cube selected in object mode, type: ctrl-A > Location then ctrl-A > Rotation & Scale

rotatingcube.zip

Link to comment
Share on other sites

You brought my answered, ProfessorF!

 

It was :

 

p.p.s, I remembered also that you should bake the translation, rotation, and scaling into the vertices--so that the parent transformation matrix = Identity matrix. To do so, with the cube selected in object mode, type: ctrl-A > Location then ctrl-A > Rotation & Scale

 

So, when you have link your skeleton and the mesh, created your rotation keyframes, you need to apply the precedent steps  like say Nick ;)  and it's done!

 

PS :

 

Thanks you very much to Gwenael & ProfessorF for their devotion to the community !

 

 

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...