hcmetal Posted September 8, 2018 Share Posted September 8, 2018 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: 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: 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 Quote Link to comment Share on other sites More sharing options...
Gijs Posted September 9, 2018 Share Posted September 9, 2018 Hi hcmetal, Regarding problem 1, from the inspector in the playground, you can see that curtain1 has some faces meshed in a different way. Here is curtain0: And here's curtain1: So that's why those faces are rotating. NasimiAsl and hcmetal 1 1 Quote Link to comment Share on other sites More sharing options...
hcmetal Posted September 10, 2018 Author Share Posted September 10, 2018 @Gijs, thanks for your help. I will check the simulation and the obj exporter and try to fix the faces. The inspector tool in PG is very convenient. Cheers! NasimiAsl, Gijs and GameMonetize 3 Quote Link to comment Share on other sites More sharing options...
hcmetal Posted September 12, 2018 Author Share Posted September 12, 2018 First problem solved. When importing the curtain objects back into max (to use the babylon export extension), there is a little check box: 'Retriangulate Polygons'. Uncheck it, no more wierd face re-mesh. Updated PG: https://playground.babylonjs.com/#H1VSP6#2 Now, onto the second challenge... Quote Link to comment Share on other sites More sharing options...
Sebavan Posted September 12, 2018 Share Posted September 12, 2018 The morph manager supports several entries which can all be combined. As a sample (it looks terrible but you could grasp the code to mix the targets: https://playground.babylonjs.com/#H1VSP6#4 Hope that helps hcmetal 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 12, 2018 Share Posted September 12, 2018 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. hcmetal 1 Quote Link to comment Share on other sites More sharing options...
hcmetal Posted September 13, 2018 Author Share Posted September 13, 2018 @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. I will give it a try soon. Quote Link to comment Share on other sites More sharing options...
hcmetal Posted September 13, 2018 Author Share Posted September 13, 2018 @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. 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.