GLBasic forum

Main forum => Beta Tests => Topic started by: MrTAToad on 2012-May-20

Title: Particle Editor
Post by: MrTAToad on 2012-May-20
This is Matt Bennett's Particle particle editor (http://www.matibee.co.uk/wpsite/code/mbm-framework/downloads) converted to GLBasic by yours truly :)

It does run somewhat faster than the original of course - I may put it a proper frame rate limiting system rather than calculating the differences between two GETTIMERALL calls (like in the original).  Everything in the original is included.

By the way, once you've chosen a background, it can't currently be removed  :whistle:

The following instructions are from the original instruction file :

Point weight
The "weight" of each particle. Negative values will cause the particles
to rise. Positive values will cause them to fall.

Point scale Min / Point scale Max
The range for the scale of each individual particle when it is spawned.

Scale factor
The factor by which the particle scale changes every second.

Rotation factor
The factor (in degrees) by which the particle rotation changes every second.

Emitter Cone
The angular range of the emitter. An explosion might use a full 360° whereas a booster rocket might use just 20°.

Emit Min Distance/ Emit Max Distance
The distance range a particle will spawn from the actual emitter position (in pixels).

Velocity Min / Velocity Max
The velocity range for each particle as it's spawned.

Red / Red Factor, Green / Green Factor, Blue / Blue Factor
Each color channel (RGBA) has an initial value and a factor by which  it can change over one second.
To start with full alpha, Alpha = 1.0, to fade alpha over 2 seconds,  Alpha Factor = 0.5
Particles "die" when their alpha value or scale drops to zero.

Burst Count
The number of particles emitted per "Burst". Bursts are usually restricted to 20 per second to ensure frame rates do not affect the
particle emitter results.

X Handle / Y Handle
The handle position for the image. Important if the particles rotate.
Note that the GLBasic value usage is slightly different to the original, whereby this is value is now an offset from the centre of the image, rather than from the top-left of the image

Alpha Blend
This is another difference - the sign of this value is used to define how alpha bending is used.  For values > 0, additive alpha blending is used, for < 0, Interpolated alpha blending  is used whilst with 0, no alpha blending is used

Image file
The bitmap file used to create the particles.  Only PNG files can be used

All the original example files are included.

Click on "SAVE" to save your settings in the Particles directory, "LOAD" to load them in, "IMAGE" to select a graphic (this will overwrite the current one), "UPDATE" to update any modified values (this is needed after changing anything) and "BACKGROUND" to select a background...

I'll release the code in a day or so...

The program can be downloaded from http://dl.dropbox.com/u/25216439/TestParticleEmitter.app.rar


[attachment deleted by admin]
Title: Re: Particle Editor
Post by: mentalthink on 2012-May-20
I comment in another Post... I think it´s a very impressive tool, but I think it´s more friendly can change the values whit Sliders or another method, than put manually... like in the 3D soft, in most cases in some plugins or some parts they put sliders.... and well... if you permet if was mine the application I add something, like AUTO-UPDATE or NOT...

Very cool,cool tool!!!...

PS: Only a question MRTAtoad, what´s it´s alpha Factor (perhaps an internal multiplier for Alpha?¿).
Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-20
I had though about using sliders when I started the conversion process, but as you can see, it allows values with up to 9 DP, which would mean it would be rather tricky getting that accuracy with a slider - and a very small value does make a lot of difference!

The Alpha factor is the speed at which the alpha value is updated.

Auto updating could be done, but then I would need to check for a keypress for all the text boxes...

Glad you like it!
Title: Re: Particle Editor
Post by: mentalthink on 2012-May-20
Ok , Mrtatoad, perhaps for the Sliders if you put some buttons whit multipliers, for works in combination¿?...

Only a one suggention more, you can make the sprites appears whitout have to put the mouse over the black area... whit this mode it´s more quickly change and show the changes...

Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-20
Good idea - would be worth doing!
Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-20
I've started to change some of the input boxes to sliders to start with.
Title: Re: Particle Editor
Post by: mentalthink on 2012-May-20
Waiting for look...  :nw:
Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-20
Okay - give this one a go.

I would have liked a few more sliders, but I found out that when using DDGui sliders, a MINVAL of < 0 can't be used :)

Link : http://dl.dropbox.com/u/25216439/TestParticleEmitter.app.rar
Title: Re: Particle Editor
Post by: mentalthink on 2012-May-21
Hi MrTatoad, it´s  very nice things... you program can do...

I a few seconds I do this... and I like me...

The Sliders, it´s very usefull whit the automatic update, you can see perfectly what are you doing... I think make Sliders in all, can be fabolous...






[attachment deleted by admin]
Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-21
Glad you like it!

I'm putting in some more sliders and will hopefully upgrade the buttons to icons
Title: Re: Particle Editor
Post by: Ian Price on 2012-May-21
Sliders - that's how we roll! :P

Title: Re: Particle Editor
Post by: bigsofty on 2012-May-21
Good stuff, well done!  :good:

Strangely enough I had been in the process of converting the exact same lib, I got as far as the particle system but not the MaxGUI util.

This should save me that that job, that's a nice surprise!  :)
Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-21
Even better Sliders :

Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-21
Hopefully this is the last main update - let me know if there are any problems.

Link : http://dl.dropbox.com/u/25216439/TestParticleEmitter.app.rar
Title: Re: Particle Editor
Post by: Slydog on 2012-May-22
Looks amazing!  :good:

You could have both sliders and text boxes.
When sliding, show its current value in the text box.
And when entered directly into a text box, update its corresponding slider.

And, if you want to allow negative values, just set and scale the slider properly.
If you want between -10 and +10 (that's 21 unique values), just set the slider from 0 to 20.
Then to calculate the actual value, subtract 10.

Can't wait to play with this.
Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-22
What I did is use tooltips, so the value is displayed once you move the mouse over it...  Might get it formatted though.

And it is available for download already!
Title: Re: Particle Editor
Post by: MrTAToad on 2012-May-22
One (final) update, and thats to format the tooltip text

Link : http://dl.dropbox.com/u/25216439/TestParticleEmitter.app.rar

[attachment deleted by admin]
Title: Re: Particle Editor
Post by: Albert on 2012-Jun-13
Download link broken :(

I've used an older version found on my HDD.
Created a fire effect, similar to what you can see in my board game: Draco. ( http://www.youtube.com/watch?v=KHr3v7eDXKg )
Download: https://dl.dropbox.com/u/292449/glbasic/particle/dracofire.zip
(https://dl.dropbox.com/u/292449/glbasic/particle/dracofire1.jpg) (https://dl.dropbox.com/u/292449/glbasic/particle/dracofire2.jpg)

I'm missing a lot of features, like:
set min, max of starting rotation
set min/max of rotation during lifetime
set lifetime of all particles
set min/max of starting blend (alpha)
Title: Re: Particle Editor
Post by: MrTAToad on 2012-Jun-13
Fortunately, I uploaded it to the Showroom here : http://www.glbasic.com/showroom.php?site=games&game=particleeditor&lang=en
Title: Re: Particle Editor
Post by: Albert on 2012-Jun-13
Thank you!
Title: Re: Particle Editor
Post by: MrTAToad on 2012-Jun-13
No problem!
Title: Re: Particle Editor
Post by: Albert on 2012-Jun-14
Some bugs in the editor:
- When you save out your current settings, there are some typo in the savefile, like: particle_particles_per_burst= (should be emitter_particles_per_burst), and blend4mode (should be blendmode)
- All the sliders are hard to controll, I cannot set them to 0 (zero)
- also they cover too large interval:
* (-1024-1024) should be (-100-100) and
* (-32-32) for rgb factors? should be float and (-1.0-1.0)
* also Red/Blue/Green should be float and (0-1.0)
* and the order should be Red/Green/Blue
- also write out float to R/G/B to the save file.
- Slider of Alpha Blend can be set (-1, 0, 1) but the particle editor (and the attached TParticleEmitter.gbas) excepts (0, 1, 2)
Title: Re: Particle Editor
Post by: MrTAToad on 2012-Jun-14
I'll check that line.

The parameter ranges are all correct.   Zero is usually in the middle.  The RGB order is kept to makntain compatability with the original program.
Title: Re: Particle Editor
Post by: Albert on 2012-Jun-14
MrT: Cool stuff. Within a couple of secs I managed to create my particle fire I wanted to. Cool, and thank you again!
But: there are these bugs I mentioned, and they are present in the latest version.
Now I downloaded the "original" particle editor, and it's behaves mostly different than yours. Also it's uses float (0.0-1.0) for red, green, blue components.
I cannot imagine a situation where you want use 1024 for Point weight or 32.0 for Red factor or -20 for alpha factor. The -1.0 - 1.0 intervallum seems more reasonable to me.
Title: Re: Particle Editor
Post by: MrTAToad on 2012-Jun-14
My one uses floating values for the RGB colour.  No point writing it out as you can't use 127.5 colour.

Did fix the writing line error though.

I find the original behaves mostly similar to mine...
Title: Re: Particle Editor
Post by: MrTAToad on 2012-Jun-14
Quote from: MrTAToad on 2012-Jun-14
My one uses floating values for the RGB colour.  No point writing it out as you can't use 127.5 colour.

Did fix the writing line error though - just need to update the Showroom now

As the source code is provided, you can always make the changes yourself :)