Jump to content

mesh based particle system


jerome
 Share

Recommended Posts

Remember this Jahow's post : http://www.html5gamedevs.com/topic/15154-mesh-based-particle-system/?p=87260

 

Well, this titillated me ...

So I decided to meet the challenge with the help of LOD features (thanks again to Raanan for the explanations).

 

iiihhhaaaaa : http://www.babylonjs-playground.com/#2KSQ1R#50

 

Just wait for few seconds until the skull is decimated (I love this word), then click ok

120 skulls emitted at 60 fps in Chrome here

 

line 36 : skull number

 

 

BTW, before using the decimation (what a word), with the full original skull, it worked at 60 fps with up to 6 skulls only.

Link to comment
Share on other sites

hehe.  Excellent demo, as always.  Decimation rocks, eh?  What an algorithm!

 

Hey Jerome... J-Harvey... Rome-u-lator... J-man... J-willikers...  umm...

 

...they have a "thing" in 3D Max... called a 'particle deflector'.

 

http://webpages.charter.net/wingthing/img/dflctrfun01.jpg

 

http://webpages.charter.net/wingthing/img/dflctrfun02.jpg

 

I know you Babylonified the cannonball shot/bounce parabola thing... and that was great!  Now, do you think you can make it so that ANY mesh... can also be a particle deflector?  Same energy after the deflection, no mesh-rotation consideration needed... just treat each particle like a cannonball ground-bounce (with any-angle ground, though, erf).  Ya think?  We got particles... we got Jerome tubes used as deflectors (particle pipes)... we got fluid dynamics 101.  YAY!

 

We would want to make sure that heightMaps can be particle deflectors, too... so we can spray particles into the mountains, and watch them avalanche and bury our town in lava, ash, gravel, snow, or UPS boxes.  (How haphazardly I use the term "we", eh?)

 

Wow, three posts at :38.  HOT topic!  :)

Link to comment
Share on other sites

Well... if you use the SPS, it is physics agnostic AND customizable.

So yes, this is feasable as we've got access to each particle position in the updateParticle(particle) method

 

The hard thing then is to implement the right physics by your own unless you use an all ready physics engine to manage collisions to the other shapes in the scene and set, say, an box impostor par particle.

Link to comment
Share on other sites

Nah... ya just use your orthogonals like ya did with cannonball bounce.   You treat each particle, no matter it's shape... like a sphere.  If it intersects with a mesh that has its .isDeflector = true; ... you can find the point of intersect, grab a normal from the deflector, hypotenuse it with the current particle direction, and rhombus that puppy * -1.  Easy! 

 

No physics... just cannonball bounce... but with a ground bounce point that could be angled somehow.  Wow!  You can do it, J.  I know ya can.  Its just cannonball bounce... sort of.  Maybe.  :)

 

None of your particles have .ellipsoids, do they?  brt brt brt, danger, Will Robinson!  We don't have easy intersection checking, then.  hmm.

Link to comment
Share on other sites

Oh, I know.  When a mesh.isDeflector... it engages a "watch for particles hitting me" system... and IT throws the particle away from itself at a um... proper rebound angle... same energy.  YEAH!!  The mesh deflector does the work!  It opens up a panel on the particle, and turns a screw, which re-targets the particle!  WOW!!!  COOOOOL!

Link to comment
Share on other sites

I'll think about it... It should be feasable. Actually, if you want to implement only one kind of physics (say, a collision and/or gravity) to a given situation only, it's quite simple. The tough thing is to implement a model what works for any king of forces, acceleration and environment.

When I did the tube cannon and the bouncing ball, I knew the ball would bounce on an horizontal ground only and would fall from the sky with an initial speed in the gravity field with no other force.

So I just hard coded this : a ballistic trajectory with a collision on an horizontal plane. This means an equation on y coordinate only.

 

If we know the deflector, what force apply to particles, we can hard code this quite easily. This won't adjust then to any other case. 

Link to comment
Share on other sites

BTW, to have the skull emitter running, I had to fix some little bugs in the SPS (because the skull lacks some data I was expecting like uvs or so, need to check).

So this means that I need to test the SPS addShape() method with many other meshes than BJS built-in ones, like imported .babylon format meshes or blender format meshes.

As I don't know anything about blender, could someone please give a mesh (or an URL to a CORS enabled mesh resource) exported from Blender ?

Something not too big in term of vertices/indices please (hundreds max would be nice) else I will have to ... DECIMATE (oh god) it

Link to comment
Share on other sites

Coloes enough to the kitten cannon I imagined: http://www.babylonjs-playground.com/#2KSQ1R#53 :P

 

But I kind of lost the eyes of the bunny somehow. And I didn't figure out how to adjust the life time of a particle bunny. I don't want them to disappear so fast. (But didn't read any documentation yet, just playing around ;) )

Link to comment
Share on other sites

Actually, the particle are recycled when they touch the ground (y < 0  line 54) and then re-emitted.

If you want the particle to go higher, change the initial max velocity var v value  line 35.

 

This behavior  and these properties are not proper to the SPS object.

SPS doesn't know anything about particle emission, life, or recycling. It is agnostic.

It just handles the creation of the mesh containing the particles and give access then to them with SPS.updateParticle(particle) what is called on each particle by SPS.setParticles()

 

Quite simple, isn't it ?

 

I guess the eyes are another different mesh in the imported file.

Link to comment
Share on other sites

just comment the mesh.freezeNormals() and the normals will be recomputed each frame  ;)

line 72

 

but 32K vertices and 136K indices... beware of your CPU capacity !

or lower the number of rabbits

or ... DECIMATE them ! (niiiiarrrrk niiiiaaaarrrkkk)

Link to comment
Share on other sites

  • 2 months later...

you can't

 

The SPS is a single mesh, so it's built once for all with a unique (complex) process. You first declare what shapes and how many you want in it, then you build it... like you would bake a cake :D

Thus, it has the number of vertices, indices, uvs computed from all what you just added before its baking.

 

However you can ever add more particles (or shapes) than you need when starting and just then"disable" -not to show, or shrink or make invisble or outside the fustrum, etc- them by id, shapes, whatever, in the updateParticle(), call until you need them back

Link to comment
Share on other sites

  • 1 month later...

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