hen Posted January 21, 2016 Share Posted January 21, 2016 How can i attach multiple skinned meshes (props) to the same skeleton? Quote Link to comment Share on other sites More sharing options...
gryff Posted January 21, 2016 Share Posted January 21, 2016 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 Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 @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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 21, 2016 Share Posted January 21, 2016 You can do it like this: hairmesh.attachToBone(skeleton.bones[7], character); Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 21, 2016 Share Posted January 21, 2016 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. Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 21, 2016 Share Posted January 21, 2016 You may have found a bug. try to replicate your example on the playground and Deltakosh could see if there is a problem or not. Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 Ok... here is some playground... http://www.babylonjs-playground.com/#SQ8ZI#6 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 I'm wondering if your questions is not just about calling mesn.skeleton = skeleton on multiple meshes? (which is supported) Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 2 minutes ago, Deltakosh said: I'm wondering if your questions is not just about calling mesn.skeleton = skeleton on multiple meshes? (which is supported) Like head.skeleton = body.skeleton? That actually breaks the skin matrix.. http://www.babylonjs-playground.com/#SQ8ZI#8 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 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 Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 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? Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 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 Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 then my answer is: mesh.skeleton = otherMesh.skeleton As long as the skeleton CAN be applied Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 Actually no, I'm wrong. Skeletons contain only non-mesh data So applying the skeleton to the head should work as long as the skeleton contains the bones expected by the head Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 (just wondering if 3js clone the skeleton when you do skin.bind) Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 21, 2016 Share Posted January 21, 2016 (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 Quote Link to comment Share on other sites More sharing options...
hen Posted January 21, 2016 Author Share Posted January 21, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.