Jump to content

Attach skinned mesh


hen
 Share

Recommended Posts

Well hen, you can approach it from at least two ways.

1. If you are using a modeler like Blender, you can attach more than one mesh to a rig. See my "Blue Lady" - the hat/hair and the dress are separate meshes from the body - all attached to the same rig

2. Use the "attachToBone" and "detachFromBone" methods in BJS - see here

cheers, gryff :)

Link to comment
Share on other sites

@gryff  What i want to do is like point 1. 

Actually i loaded our characters wich have a separate body and head like that.

The problem appears with props such as hair, cloths etc. wich i need load at runtime from different asset files (overall its about 600 props and raising).
Of course these are bound to the same bones/skin with the same bindpose and 100% compatible with the character skeleton.

Question is how i could append those to the characters skin at runtime?
I was trying just to do something like hairmesh.parent = character; hairmesh.skeleton = character.skeleton; 

But no luck with that.. its offset after doing that.

Link to comment
Share on other sites

7 minutes ago, Dad72 said:

You can do it like this:


hairmesh.attachToBone(skeleton.bones[7], character);

 

Yes i did found this function, but thats for static props attached to a single bone.

My problem is with skinned meshes wich need to append to the whole skeleton.

2016-01-21 18_25_30.png

Link to comment
Share on other sites

3 minutes ago, Dad72 said:

I believe that Babylon can not even do that. this must be done directly with the 3Ds max or Blender editor.
Morphing also is not yet supported if you want to deform the face for facial expressions.

Morphing could be (hopefully) done just by modifying the vert positions.

 

For skinned meshes there is a function that sounds like it should do what i want:

applySkeleton(skeleton) → Mesh

Update the vertex buffers by applying transformation from the bones

 

But no luck with that... the whole mesh dissappears after doing that.
I had such a nice run with babylon.. now stucked with the basics :(

Link to comment
Share on other sites

7 minutes ago, Deltakosh said:

yep.. this should be the same thing as your second example.

 

but not sure to understand because your head already has the same skeleton in your example:

http://www.babylonjs-playground.com/#SQ8ZI#9

Oh wait... does that mean the mesh is automaticly using the skeleton of its parent?
This doesnt make any sense to me. But as seen here it might works http://www.babylonjs-playground.com/#SQ8ZI#10


 

Link to comment
Share on other sites

2 minutes ago, Deltakosh said:

Nope it does not. But what I can see is that a skeleton is assigned to the head as well in your file.

 

Where does this file come from?

Exported from 3ds max.

If its not sharing the skeleton. It would mess up when the animation on the body changes right?

Link to comment
Share on other sites

25 minutes ago, Deltakosh said:

They are not sharing the same skeleton (see console output here: http://www.babylonjs-playground.com/#SQ8ZI#11)

But skeletons have the same animations (are they duplicate in 3dsmax?) so this works well actually ;D

Yes, but to come back to the original question.
How could i make the head, body and jeans from the example use the same skeleton?
There is no reason to have a skeleton for each, that just costs performance and the binding would break once i switch the animation.

At runtime this doesnt work at all, because the animation of all the skeletons is not sync.

Link to comment
Share on other sites

8 minutes ago, Deltakosh said:

then my answer is: mesh.skeleton = otherMesh.skeleton

As long as the skeleton CAN be applied

Yes i would think it works like that, but as shown in the first playground i posted, this does break the skinning.
So we do have body and head here with exactly the same skeleton, but when i make the head using the bodys skeleton it breaks.

When doing the same in three.js it works like:

skin.bind(skeleton, parentSkin.matrix.clone());

Maybe the parent matrix must be applied as well?

Link to comment
Share on other sites

I think I understand the issue: as the head is the child of the body, you need to have a different skeleton because of the root matrix associated with the skeleton

Skeleton applied to body use an identity root matrix whereas you need to cancel parent matrix for the head

So in your case the easy way would be to stay like you are in latest PG: have a separate but synchronized skeletons

does it make sense?

Link to comment
Share on other sites

18 minutes ago, Deltakosh said:

I think I understand the issue: as the head is the child of the body, you need to have a different skeleton because of the root matrix associated with the skeleton

Skeleton applied to body use an identity root matrix whereas you need to cancel parent matrix for the head

So in your case the easy way would be to stay like you are in latest PG: have a separate but synchronized skeletons

does it make sense?

Hum.. i understand.

Problem is:
30 characters * 5 skinned props = 180 animated skeletons in the scene, wich could be just 30.

Is it maybe possible to transfer the root matrix to the child?

 

But that doesnt seem to be the prob.. here a example where the pants is not child of the body: http://www.babylonjs-playground.com/#SQ8ZI#15

Link to comment
Share on other sites

10 minutes ago, Deltakosh said:

(I'm thinking out loud :))

For the pants, can you try to unlink them in 3dsmax, I mean: export them with no parent in 3dsmax.

I suspect that because pants or head are exported with a parent, this changes their matrices. This could impact how the skeleton will control it then

The pants is exported only with the skeleton. 
Without skeleton doesnt work, the 3ds max exporter drops an error then.

I compared the body and pants skeleton and the only difference is in skeleton._transformMatrices.

So i tried: 
var transformMat = jeans.skeleton.getTransformMatrices(); 
jeans.skeleton = bodyMesh.skeleton;
jeans.skeleton._transformMatrices = transformMat;

That doesnt change it for some reason.
Seems like something is overriding the _transformMatrices property.

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