Jump to content

Automaticly align skinned attachments on morphed/deformed meshes - possible?


hen
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.
 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :) 

Link to comment
Share on other sites

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.

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