hen Posted October 24, 2016 Share Posted October 24, 2016 Hey all, as some of you already know, we are working on to port a three.js game to babylon.js since a while. One part of the app is a player character editor that involves morphing to the body and head mesh. With the old three.js version we did use morphtargets on the head and a optimized skeleton to scale bones for the body. Reason to morph the body by using bones was that attachments such as cloths are automaticly aligned to the applied changes. Actually with babylon we went running in to the problem that the bone size is part of the animation take matrix like explained in this thread: Morphing the body like we do with the face mesh is of course the better solution, because the design can be more detailed compared to the bone solution. Just this does not align skinned attachments. I created a demo playground http://www.babylonjs-playground.com/#GXIPL#7 that shows the problem at the belly area (if it doesnt load you might need to set a higher timeout). Im wondering if someone has an idea how this could be solved without to create extra morphs for each cloth item. Cheers Hen Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 24, 2016 Share Posted October 24, 2016 Hello not sure to understand the problem with matrix and bone. Even in 3js every bone only has a single matrix. can you elaborate more on a simpler example about your issue? Quote Link to comment Share on other sites More sharing options...
hen Posted October 24, 2016 Author Share Posted October 24, 2016 3 minutes ago, Deltakosh said: Hello not sure to understand the problem with matrix and bone. Even in 3js every bone only has a single matrix. can you elaborate more on a simpler example about your issue? Hi Deltakosh, the difference to 3js is that they have a scale property on the bones. So i can just do something like bone[index].scale.y = value to change the size. When i manipulate the matrix in babylon like that, it breaks on the next animation frame unlike i run this before every render shown in that other threads demo. My old skeleton has a tricky skinning designed to change the character size, muscles, belly and others without to break the look of animations by scaling the bones within a specific range. The playground i posted above does apply only morphs for the same approach, but as you can see with the increased belly morph, clothings do not align like they would do when doing the same with bone scaling. I would be happy with any kind of solution for this problem either if its doing it by bones or somehow with body morphs or maybe something i just dont know yet. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 24, 2016 Share Posted October 24, 2016 Ok understood. @adam will soon publish an update to add bone.rotate (and I guess he could easily add bone.scale as well) Quote Link to comment Share on other sites More sharing options...
adam Posted October 25, 2016 Share Posted October 25, 2016 21 hours ago, Deltakosh said: (and I guess he could easily add bone.scale as well) Should this be a function like this: bone.scale(x, y, z); or bone.scale(Vector3); also, should I add an optional param for dontScaleChildren or scaleChildren. If so, what should it default to? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 25, 2016 Share Posted October 25, 2016 I would say don't by default Quote Link to comment Share on other sites More sharing options...
hen Posted October 25, 2016 Author Share Posted October 25, 2016 1 hour ago, adam said: Should this be a function like this: bone.scale(x, y, z); or bone.scale(Vector3); also, should I add an optional param for dontScaleChildren or scaleChildren. If so, what should it default to? Hey adam, first of all thank you for helping out! Having a dontScaleChildren param would be really perfect. Will this create a scaling property on the bones? I just ask because somehow i have to get the data of the current xyz scalings before changing them. Big thanks again! Hen Quote Link to comment Share on other sites More sharing options...
adam Posted October 25, 2016 Share Posted October 25, 2016 My plan was just to make the function: bone.scale(x, y, z, scaleChildren = false) Quote Link to comment Share on other sites More sharing options...
hen Posted October 25, 2016 Author Share Posted October 25, 2016 35 minutes ago, adam said: My plan was just to make the function: bone.scale(x, y, z, scaleChildren = false) No worries, i can keep records of the scalings on another layer. It will be interesting how you do it, because until yesterday i thought this is mission impossible with how bones/animation work Quote Link to comment Share on other sites More sharing options...
adam Posted October 28, 2016 Share Posted October 28, 2016 This was a lot harder than I thought it would be. The issue was maintaining the correct scale when rotating. I finally figured it out and will submit a PR tonight or tomorrow. I'm adding a Bone.getScale() and a Bone.getScaleToRef(vec) so that you don't have to keep track it of it in your code. Quote Link to comment Share on other sites More sharing options...
adam Posted November 1, 2016 Share Posted November 1, 2016 Bone.setScale demo: http://www.babylonjs-playground.com/#I6RJJ#46 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.