Fedor

Skeleton animation not applied to mesh

Recommended Posts

Hi,

What I am trying to do here is a bit too complex to simulate it in a playground. I hope i can explain it.

I have a mesh that was build from raw vertices and polygon data. I have added the bones weights and indices. I am sure these two arrays are fine, they come from the same original model as the vertices and polygons. I have checked this too.

// The code to add the indices and weights to the mesh
base_model.mesh.setVerticesData(BABYLON.VertexBuffer.MatricesIndicesKind, base_model.bonesIndices, true);
base_model.mesh.setVerticesData(BABYLON.VertexBuffer.MatricesWeightsKind, base_model.bonesWeights, true);

I then load a skeleton - also from the same origin, so the bones indices match those in the indices array. The skeleton is attached to the mesh.

When I rotate bone #0, the entire mesh rotates accordingly. No surprises there, and to me this is proof that the weights and indices are effective. when I scale the bones, parts of the body also scale.

Now, when I rotate bone#1- upper leg -, nothing at all happens. And nor does rotating the other bones have any effect.

//The rotation command I use: 
rig.bones[1].rotate(BABYLON.Axis.X, .01, BABYLON.Space.WORLD, base_model.mesh);

screenshot #1: you can see the bone rotates, but the mesh does nothing.

screenshot #2: this is the original model, that does rotate the leg with the bone.

screenshot #3: rotating bone #0 rotates the entire model.

 

I know I am doing something strange here, but I assure you it is necessary to the application I am working on. I hope any of you have some suggestions where to look for an answer.

 

Schermafdruk van 2017-06-02 09-29-55.png

Schermafdruk van 2017-06-02 09-28-52.png

Schermafdruk van 2017-06-02 08-49-46.png

Share this post


Link to post
Share on other sites

I noticed something interesting: when iterating through all the bone indices and set the first of every four indices to 1, the entire mesh is deforming (messy but that was to be expected.)

So I checked if there were no #1 indices in there at the start, but there are, and they do have significant weight. 

I then tested rotating some other bones, and quite a few of them do get the mesh deformed...

Share this post


Link to post
Share on other sites

I would get a very simple 2 bone model working the traditional way and then recreate it using the technique you are using now.  You should then be able to identify what is going on by comparing the two meshes.  It will also be much easier to put this on the PG so that others can play with your code.

Share this post


Link to post
Share on other sites

Hi DK & rest,

I figured it out... it had something to do with that other question: 

Once I detected a callback was broken somewhere in the middle, I was well on my way fixing it. It now works. 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.