More than Two Colors for Particle Effects

Right now, a particle can only transition from a start color to an end color over its lifespan.  I think that it would be advantageous if we looked into providing a way to use multiple colors over the lifespan of a particle.  To do this, the color arguments for building a particle mesh would probably have to be moved from start and end fields to an array, or provide an array option that is used if its populated instead of start and end colors.  The continuum of color change along the lifespan of a particle appears to be controlled in the ParticleAppearanceRamp class and other classes that merely reference or set the colors. 



I haven't gotten fully into the trenches with this yet, but I'm wondering how many others would like to have this option when working with particles.  If there's enough interest, I'd like to work with others to make it happen for the betterment of jME rather than just providing my idea of how to do it and saying "here guys and gals, have fun!"  after its done (my way) – the later of which I'd do, of course, if no one else has interest.  I mean, I want my particles to be able to cycle through all colors of the rainbow before they die! :wink:



Anyway, if you're interested in this modification to the current particle system, let's get the convo going and figure out the best way to make it happen!

How is ParticleAppearanceRamp and RampEntry not giving you the ability to set multiple colors along the lifespan of the particle?

i was just looking up renanses post about that a while ago  :slight_smile:

http://blog.renanse.com/2007/12/particle-boost.html

renanse said:

How is ParticleAppearanceRamp and RampEntry not giving you the ability to set multiple colors along the lifespan of the particle?


Granted, I'm not the expert here and I just started looking into how to make something like this happen, but if there's currently a way to set up a ParticleFactory (by hand -- I don't use the particle renderer) so that its particles move from blue to green to white to red over their lifespans, its not clear.  If there is, then perhaps I just need a little direction as to how to do it ;)  And if there's not, then that's what I'm talking about.

These two lines (where mesh is a built ParticleFactory):

mesh.setStartColor( new ColorRGBA( 1.0f, 1.0f, 1.0f, 1.0f ) );
mesh.setEndColor( new ColorRGBA( 0.6f, 0.2f, 0.0f, 0.0f ) );

are where the two values are set that determine the starting color and ending color of a particle over its lifespan, interpolated in a linear fashion over the time of its life.  To be clear, I would like to be able to use two or more color-points along the lifespan of a particle so that each and every color specified is hit.  If there's a way to insert other values into the continuum between startColor and endColor, then it is ~that~ part which is not obvious in the tests or anything that I've seen on the forums.
ashtonv said:

if there's currently a way to set up a ParticleFactory (by hand -- I don't use the particle renderer) so that its particles move from blue to green to white to red over their lifespans, its not clear.


By "particle renderer" do you mean the editor tool?  If it is in the editor, you can also do it by hand.  But basically the way it works is that the ParticleSystem lays out the values in the particle ramp + the start and end values as a time line.  Each RampEntry can influence all or none of a handful of properties (such as size, color, spin, etc.)  The particle is interpolated during its life between the previous and next entries (using start and end as the first and last entries.)

So, in other words, yes... using the current system you can set it up to "move from blue to green to white to red".  You can also set it up to move from one part of a texture to the next (to do texture animations) or one size to the next (grow, shrink, grow...) etc. etc.

Sorry – I meant "particle editor" (I was going to say "renParticleEditor", then changed my mind and "editor" was replaced by "renderer" in what I wrote).


renanse said:

But basically the way it works is that the ParticleSystem lays out the values in the particle ramp + the start and end values as a time line.  Each RampEntry can influence all or none of a handful of properties (such as size, color, spin, etc.)   The particle is interpolated during its life between the previous and next entries (using start and end as the first and last entries.)

So, in other words, yes... using the current system you can set it up to "move from blue to green to white to red".  You can also set it up to move from one part of a texture to the next (to do texture animations) or one size to the next (grow, shrink, grow...) etc. etc.


All right then!  So the question comes down to ~how~ to insert RampEntries not covered by the given fields into an a ParticleSystem.  Can you provide a slice of code or direct me to a resource that shows how to set up something simple like "red to white to blue"?  I'm sure that all the other areas that can be affected by the RampEntries will also become clear after that.

Thanks!

ashtonv said:

Can you provide a slice of code or direct me to a resource that shows how to set up something simple like "red to white to blue"?  I'm sure that all the other areas that can be affected by the RampEntries will also become clear after that.

Thanks!


Sure no problem.  I've just uploaded an example to the Ardor3D project.  You should be able to get an idea of how to do it in jME from there, looking particularly at the initExample method.  See here.
renanse said:

ashtonv said:

Can you provide a slice of code or direct me to a resource that shows how to set up something simple like "red to white to blue"?  I'm sure that all the other areas that can be affected by the RampEntries will also become clear after that.

Thanks!


Sure no problem.  I've just uploaded an example to the Ardor3D project.  You should be able to get an idea of how to do it in jME from there, looking particularly at the initExample method.  See here.


Now how did I know that you were gonna post something about ~this~ over ~there~? ; - )

I will check it out!  Thanks!

Indeed, this works like a charm!  Thanks again for the pointer, renanse!