jerome Posted February 4, 2016 Share Posted February 4, 2016 Hi folks, Well, it's not yet a feature (soon), neither a complete demo, neither a project. It's probably an upcoming feature. As you know, you can populate so far a SPS with some mesh models with the method sps.addShape(model, number). This means that you create number particles with the shape of the mesh model. Soon, you will have also the ability to build a SPS from a given mesh. This means, the SPS will digest the mesh, decompose it in many particles under the hood and set them at the same location that the original mesh facets. Example (click on the mesh to blow it -did you notice that I liked to blow things up ?-): http://www.babylonjs-playground.com/#YCEMR#1 Here, you've got a box that my SPS digests at the line 153 (don't care about the rest of the code for now) : sps.digest(model, {}); The box is digested and the SPS will then have as many triangular particles than the original box facets. If you want each particle to be composed by more than one mesh facet (for big meshes for example), you can specify it with the parameter facetNb: sps.digest(model, {facetNb: 2}); This means each particle is now built by 2 mesh facets, so in our former example with quads instead of triangles : http://www.babylonjs-playground.com/#YCEMR#2 Obviously this works (or should) with any mesh type : http://www.babylonjs-playground.com/#YCEMR#3 the same with particles sized to 64 facets : http://www.babylonjs-playground.com/#YCEMR#4 Torus knot ? baoomm : http://www.babylonjs-playground.com/#YCEMR#5 Maybe the number of facets per particle doesn't make much sense to you and you would prefer to define the number of particles instead. This is possible, just use the parameter number: sps.digest(model, {number: 20}); This will decompose the whole into almost 20 (20 or 21) particles depending on the initial number of the mesh facets. line 152 : http://www.babylonjs-playground.com/#YCEMR#6 Does it work with imported meshes also ? yes, sir (beware, this is CPU intensive and I noticed that the PG has side effects on the perfs because it runs faster off the PG) : http://www.babylonjs-playground.com/#YCEMR#7 no idea of an URL CORS friendly to download the Dude in the PG. http://www.babylonjs-playground.com/#YCEMR#10 Is this compatible with the addShape() method ? yes, sir : take a look at the line 153 here : http://www.babylonjs-playground.com/#YCEMR#8 First, I add one box particle, then I digest a box mesh (quads), then I re-add a box particle. My SPS should then have : 2 box particles and 6 quad particles, ok ? Set the cam beneath the box and blow it towards the sky, you will see the quad particles and 2 boxes falling back to the ground. Right, now you know how this work (or should work). But what is this for ? It could be used to build easily a SPS from any mesh as I explained. Then you can, at the particle level (the one you chose : facer, several facets, a tenth of the mesh, a third of the mesh, half of the mesh, etc), morph the mesh, distord it, twist it, vaporize it, liquefy it, blow it, etc [EDIT] I really need to blow a spherical harmonic ribbon, just for fun ! [EDIT 2] oh, and I forgot to say you can digest several meshes in the SPS or even the same mesh several times : http://www.babylonjs-playground.com/#YCEMR#9 line 153 : torus knot digested twice with different particle numbers Boz, Temechon, GameMonetize and 3 others 6 Quote Link to comment Share on other sites More sharing options...
jerome Posted February 5, 2016 Author Share Posted February 5, 2016 PRed [EDIT] and documented Quote Link to comment Share on other sites More sharing options...
Boz Posted February 5, 2016 Share Posted February 5, 2016 Waw !! It looked promising when I saw the "BABOOM" demo with sub-meshes, but this one is crazy, so much ideas & opportunites O: boom = true; I like it, all is said jerome 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted February 5, 2016 Author Share Posted February 5, 2016 Happy that it boots your imagination Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 8, 2016 Share Posted February 8, 2016 Wait till I add physics to that demo jerome 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted February 8, 2016 Author Share Posted February 8, 2016 I don't know anything about physics, but can we set an impostor to something else than a mesh ? (solid particles) Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 8, 2016 Share Posted February 8, 2016 You'll have to wait and see :-) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted February 8, 2016 Author Share Posted February 8, 2016 It's wonderful when the doc is updated so frequently : http://doc.babylonjs.com/overviews/Solid_Particle_System#digest-a-mesh Available yet in the preview version, have fun Quote Link to comment Share on other sites More sharing options...
jerome Posted February 12, 2016 Author Share Posted February 12, 2016 I just added a new parameter called delta. If you digest a mesh specifying some facetNb value to build each particle with facetNb facets, you can add some little randomness with delta. Each particle will then have a random size between facetNb and facetNb + delta facets. This is useful to simulate more real mesh decomposition as things aren't composed by identical subparts. sps.digest(mesh, {facetNb: 10, delta: 40}); // each particle size will be randomly between 10 and 50 facets Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Temechon Posted February 12, 2016 Share Posted February 12, 2016 Merge inprogress... Should be up in 5 minutes! Quote Link to comment Share on other sites More sharing options...
jerome Posted February 12, 2016 Author Share Posted February 12, 2016 thank you now documented on-line here : http://doc.babylonjs.com/overviews/Solid_Particle_System#digest-a-mesh [EDIT] + PG example : http://www.babylonjs-playground.com/#HDHQN (the delta feature will work as soon as it is pushed in the PG engine) adam 1 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.