RyanONeill1970

Scaling a Solid Particle System mesh in one go

Recommended Posts

I have an arc camera attached and have removed the mousewheel zooming from it.

Instead I've intercepted the mousewheel event and I'm trying to scale all of the particles via the parent mesh so that the scene stays the same, but the particles all zoom in / out.

Before sps.setParticles is called I update the mesh property scalingDeterminant to try and zoom it, but I'm not seeing any effect. I may be doing this completely the wrong way but can't find anyone else scaling the mesh after initialisation (I'm doing it this way to avoid enumerating the particles as I thought it might be more efficient).

I've modded a project in the playground so you can see what I'm trying  -> https://www.babylonjs-playground.com/#ML2LR9#4

Any advice for a noob?

Thanks in advance

Ryan

Share this post


Link to post
Share on other sites

Thank you Jerome, that looks like I can work with that.

I was trying to cheat by bypassing vector creation before.

One more question, I'd like to cull the particles that are on the outside of an invisible box in the centre of the screen.

For example, zooming in / out with the mousewheel makes them grow or shrink (by scaling them) and also does not draw the particles outside the central box.

Is there a preferred method for doing this? Just a few keywords to read up on would be very helpful.

Regards

Ryan

Share this post


Link to post
Share on other sites

Hi R... welcome to the forum.  I'm certainly no pro at SPS, but I have some experience in standard particles.

One of the settings on particles... is emitBox.  Essentially, the two values define a box.  The numbers are DISTANCES.

SO, picture this.  Set particle emitter location to center of box.... probably a vector3.  ParticleSystem emitters are allowed to be actual mesh, mesh-shape, or simple vector3.

Now set your particle emitBox values... to define an emitBox that is somewhat smaller than the box you are hiding the particles-within.

Be sure to set your directions... "wide open"... usually dir1 = -1, -1, -1... and dir2 = 1, 1, 1.

Now... set your particle max-lifeTime LOW, and emitPower/speed... low, too.  Likely, gravity off.  Demo:  https://www.babylonjs-playground.com/#1NXKLI#18  See how it maintains a box shape, easily hidden inside another box.

When you get everything just right, you should see particles flying very short distances from a box-shape inside the other box... and they don't live long enough (low max-lifeTime) to protrude outside-of the hiding box. 

Give it a spin, play with emitBox sizes and particle max lifeTime, etc.  Might be some useful things found.

PS:  Somebody once made particles emit from vertices... but I'm pretty sure they were really drunk at the time.  :)  That PG link might be a memory leaker... probably due-to negative scaling of a sphere or something.  It seems to operate slower and slower, over time.  hmm.  Might be asking too much of my girlie-man CPU.

ALSO: https://www.babylonjs-playground.com/#1NXKLI#13 - that's a 6-plane box with long particle maxLifeTime... but maxEmitPower is low low low.  Plus it has a custom updater - sparkler.  :)  Sparticles. 

Share this post


Link to post
Share on other sites

Cool! 

Hey, there's a new feature for standard particles... called shape emitters.  I forgot to mention them.

Here's a little "box-shape" demo... a modification of the box-emitter demo from the docs.

https://www.babylonjs-playground.com/#MRRGXL#14

That causes the particles to hold a fairly rigid shape... without the use of emitBox settings.  It seems emitBox settings are ignored... when using these "shape emitters".

Ok bye again.  :)

 

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.