Jump to content

Particle System issue?


Ahiru
 Share

Recommended Posts

When I define a Particle System, but do not start it, something weird happened: http://www.babylonjs-playground.com/#1PGAPW#25

 

As soon as one of the PS is started (line 121) - everything is fine and back to normal - what happens here?

 

Even starting, but setting the Emit-Rate to 0 does not help: http://www.babylonjs-playground.com/#1PGAPW#26

 

P.S.: Just found out - reloading the PG helps, if the scene starts blank with no particle-system, there is no problem. - BUT once started, then comment the particle-system.start() out and run the playground again leads to problems. - Strange??

Edited by Ahiru
Link to comment
Share on other sites

Hi A.  First, allow me to apologize for the bad docs at http://doc.babylonjs.com/tutorials/12._Particles in the speed/strength area.  The format/conversion of the .md file... to html file... went to hell somewhere in there.  It might be related to the old bullet list failures we've seen around here, and the "last item in bullet list" problems we've also seen.

 

AND... long ago, I reworded these docs a bit... to make it easier to understand. (Using terms like strength and speed.)  I was young and naive when I did those word adjustments.  :)  

 

To correct that... particles have no speed, strength, or velocity.  Bad term usage on my part.  :)  Maybe.  Not sure.  "Strength == "Power"?  hmm.

 

All in all, particles seem to use a derived value called scaledDirection as their value of flight advancement.

 

Can you rewrite your question... using terms like emitRate and emitPower, and maybe give use some line numbers and maybe a smaller PG?  (thx)

 

 

Docs:  Be aware that the stream is no longer continuous. This is a one-shot particle emission, so this function overrides the previous “emitRate” parameter.

 

I fooled around with this a bit (I turned-off ship impulsing, in that one).  You can see the one-shot-then-dispose activity of .manualEmitCount... when you run it.  There might be an issue with .emitRate.  I tested with a .manualEmitCount set to a value, AND re-disabled with a -1.   I haven't deduced much at all, yet. 

 

Manual emits are one-shots, so the PS does it's spurt at runtime, and then stops and disposes the PS.   Thus,  all future ship-control keypresses... have no particles.  This is to be expected with manualEmitCounts !=  -1.  Irrelevant, as you are not looking for manual emit counts.  I just came across this stuff when I started researching emitRate and emitPower stuff.

 

In general, PS.emitRate seems to be ignored... and maybe this is what you are pointing-out.  It might be stuck at its default rate of 10.

 

Ok, I'm entangled in about 20 different directions today, but I'll continue sniffing this, and maybe others will, as well.  Points of interest seem to be https://github.com/BabylonJS/Babylon.js/blob/master/src/Particles/babylon.particleSystem.js#L103 and https://github.com/BabylonJS/Babylon.js/blob/master/src/Particles/babylon.particleSystem.js#L173

Link to comment
Share on other sites

http://www.babylonjs-playground.com/#1MON6F#21

 

I only worked-with the WASD keys... lines 205 - 256.  I removed the FOR loop in each key processor... because... I don't think you want to increase the emitRate on ALL engines... in a function that deals with only ONE engine. 

 

In line 209... I'm only increasing the emitRate on engine[0].  In 219... only engine[1].  In 229, only engine[2].  Lines 239 and 249 both set engine[3] emitRates. 

 

I didn't do anything with the "roll" area, but it has the same issue.  BUT, with roll, you are using many/all engines at the same time, so maybe THERE... increasing the emitRate of ALL engines as the key is held... is the correct activity.

 

I also removed a strange for-loop in lines 199-203.  And, I installed an "all engines to zero emitRate" FOR-loop in the onKeyUp lines 177-179.

 

Take a drive of the wasd keys and maybe watch the console.  Now, the longer you hold the key, the higher the emitRate for that engine.  I'm not sure if that is what your goal is, but it appears emitRate is working fine.  We are seeing it increase by +20 at every repeated keypress processing.

 

And, the ship's impulsing is still disabled in line 194... so folks should activate that line and then press RUN... if they want to go flying. 

 

Cool code and project, Ahiru!  Fun!  I hope I'm being helpful, somehow.  Be well!

 

PG and this post... updated at 10:46... an hour after initial post.

Link to comment
Share on other sites

 

Can you rewrite your question... using terms like emitRate and emitPower, and maybe give use some line numbers and maybe a smaller PG?  (thx)

 

 

I will start with rephrasing my question (much smaller I can't do the playground, because than it won't move to see the effect :P - Ignore lines >280 that's only camera-stuff)

 

So - point is, that I want the particles to simulate the engine thrust as you might imagine. "s" will have all engines blow directly backwards, the other keys will also let all engines fire (so it was intentionally to have all engines running), but they will turn a small angle to make the ship turn (the angle you can set in line 54). To make the ship turn a 1 degree angle is enough, but to make it visible, that the engines blow in a different direction I decided to blow the particles in a 45 degree angle.

 

Now to the problem (which you can't see, when you don't move the ship, so deactivating 194 is a bit contra-productive :P):

 

- Speed up a bit (hold "s" for a moment") and then turn the ship around around 180 degrees.

- Now accelerate again and you will see, that the ship is faster than it's own engine-particles (which in space without wind should not happen?) 

  - So, the particles leave the back of the ship with the same speed as they would when the ship does not move. In fact though they should have the speed of the emitter PLUS their leaving speed, shouldn't they? - I mean, if I can throw a ball with 30 km/h, but stand on a pickup that goes with 100 km/h and throw forward ....... the ball will fly 130 km/h FORWARD, not as my particles here with -70 km/h, so backwards.

 

Hope it makes it somewhat more clear?  

Link to comment
Share on other sites

Ahh, I think emitPower is what we want, not emitRate.  EmitRate is an amount, not a speed, me thinks.  And I think this can be visualized if we place the fighter over a textured or wireframed ground, temporarily.

 

Yuh, yuh, yuh... sorry for the misunderstanding, and thanks for the clarification.  I'll keep experimenting.  If you do some, too, could you keep me updated here?  thx.

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