Jump to content

Skeleton animation not applied to mesh


Fedor
 Share

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

Link to comment
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...

Link to comment
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.

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