Jump to content

Morphing Objects


hcmetal
 Share

Recommended Posts

Hi everyone.

I have been trying to create a swaying curtain (indulging myself with archviz cliche :)) in babylon js.

After digging around the internet and the forum, I realized that advanced cloth / soft body simulation is not yet possible in babylon right now (please corret me if I'm wrong).

I studied RaananW's wonderful cloth physics simulation demo and achieved interesting results. However, with higher subdivisions (100 by 100 for example),  the simulation is very slow.

So I came up with the idea of trying to achieve a simpler, pre-baked vertex animation using Morph in babylon.

I simulated the curtain cloth in 3ds max, baked the animation onto the mesh, and created a sequence of meshes as morph targets.

They look like this in max:

curtainsmax.jpg.24a4ac287fa13f262d06e9d2a7999ca1.jpg

The simulated meshes are exported into a single .babylon file.

The first curtain is used as the main mesh and visible in the scene, the other curtains are used as morph targets and invisible.

Playground:

https://playground.babylonjs.com/#H1VSP6#1

Now I'm having two problems morphing the curtain in babylon:

1. Some of the faces of the mesh rotates in a funny way during the morph, like this:

curtainsbabylon.jpg.1560f184e5931ceae2b2bd24f0509fd6.jpg

I'm not sure if this is a problem with the meshes exported from max or the Morph function itself.

Here is one of them, fresh out of max: curtain100.obj

2. How to chain the morphs, from one target to the next, so we can have a longer and more interesting animation?

Hope someone can point me to the right direction.

Thanks a lot!

Edit:  Here is the .babylon file incase the CDN doesn't work:

curtains.zip

 

Link to comment
Share on other sites

I do not use BJS morphing, but I know what is a problem with morphing in general, that you are at least partially experiencing.  Unless you animate every frame, or have some kind of rate algorithm for every vertex, morphing is linear.  This can produce some interpolated frames which are wrong for the real world.

Here is an here of converting finger gestures to morph targets.  Do some gestures, THEN increase the morph time.  It is harder to un-see after slowing down something which looks 'fine' prior.  Fingers do not actually bend like that. 

In this specific example, I have made the trade-off of ditching like 40 bones, but cannot do slow morphs.  With drapes / cloth in general, it looks really impressive to slow things down.  I cannot help you, but hope at least your question was solved.

Link to comment
Share on other sites

@Sebavan, thanks for your help! I'm a total beginner to programming and your code has taught me something cool with the time control function.

Going further, I would like to change the morphing effect from:

"0-1-0-2-0-3-0-4-0-5-0"

to:

"0-1-2-3-4-5-4-3-2-1-0"

Maybe I can set up a sequency of morphs like "0-1", "1-2", etc and try to hide the "0" at the end frame of the "0-1" morph and display the "1-2" morph and so on.

Hope I am making sense here.:D

I will give it a try soon.

Link to comment
Share on other sites

@JCPalmer, thanks for your insight. I agree with your idea about morphing. 

For me, morphing is a "last-resort" method when other options are not viable.

In this particular case, if the curtain is in the background and serving as a secondary element, loosing some realism may be acceptable.

If one day Babylon has native soft body simulation (praying for it...), I can do without all this morphing. Too much importing and exporting with 3ds max, haha.

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