Jump to content

SPS.digest(mesh)


jerome
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

 

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