Mesh based particle lib

Community Forums/Showcase/Mesh based particle lib

RifRaf(Posted 2009) [#1]
Still looking for a new job, so I have alot of time on my hands.. Started a new particle library to complement easybuilder maps/levels.

Its mesh based, using primitives and custom shapes for particles and using no textures at all. Framerates on my test machine are very good and its a 1.6ghz laptop with integrated junk card. I have alot to implement, but will post the library in the archives when its done.

Heres a few test shots, everything aside form the scene is made and managed by the library, even event sounds and effect links.

aparently my webserver is down for some reason.. hopefully it will be back up soon.


http://www.empowergames.com/meshparts.jpg?


Htbaa(Posted 2009) [#2]
Screenshots don't work. Also, you're sure it's a 1.6mhz processor?


RifRaf(Posted 2009) [#3]
back up.. and yeah its a dual core 1.6ghz each core or close to that. and im pretty sure B3D uses just one core.


Stevie G(Posted 2009) [#4]
Looks interesting, all the effects in Polymaniacs are mesh based with no textures. I'm looking forward to having a butchers when you release to see if there's anything I could do better or pick up ideas from.


RifRaf(Posted 2009) [#5]
I doubt you could improve yours based on mine Stevie, i've followed some of your work. Your math skills alone make me green with envy. Wich reminds me.. Could you write up a 3 point version of this code ? Would be usefull for this lib in fact. Thanks in advance .

Function COLORinterpolate( t#, r1,g1,b1 , r2, g2, b2 , r3, g3, b3 , r4, g4, b4 )

	gR = r1 * (1-t)^3 + 3 * r2 * (1-t)^2 * t + 3 * r3 * (1-t) * t^2 + r4 * t^3 
	gG = g1 * (1-t)^3 + 3 * g2 * (1-t)^2 * t + 3 * g3 * (1-t) * t^2 + g4 * t^3 
	gB = b1 * (1-t)^3 + 3 * b2 * (1-t)^2 * t + 3 * b3 * (1-t) * t^2 + b4 * t^3 
	
End Function



Stevie G(Posted 2009) [#6]

Your math skills alone make me green with envy. Wich reminds me.. Could you write up a 3 point version of this code ?



It helps that I studied Maths at uni, although that was a long time ago. From 4 to 3 point bezier is quite simple as you can see:

Function COLORinterpolate( t#, r1,g1,b1 , r2, g2, b2 , r3, g3, b3 )

	gR = r1 * (1-t)^3 + 3 * r2 * (1-t)^2 * t + 3 * r2 * (1-t) * t^2 + r3 * t^3 
	gG = g1 * (1-t)^3 + 3 * g2 * (1-t)^2 * t + 3 * g2 * (1-t) * t^2 + g3 * t^3 
	gB = b1 * (1-t)^3 + 3 * b2 * (1-t)^2 * t + 3 * b2 * (1-t) * t^2 + b3 * t^3 
	
End Function



RifRaf(Posted 2009) [#7]
Thank you


RifRaf(Posted 2009) [#8]
Stevie, sorry to keep this up. But can you Interpolate 3 points and two points without using 4 steps ? doing a 3 step like above 1, 2, 2, 3 means the second step lasts longer.

If not, thanks anyway ill use what you posted.


SLotman(Posted 2009) [#9]
Function COLORinterpolate( t#, r1,g1,b1 , r2, g2, b2 , r3, g3, b3 )

	gR = r1 * (1-t)^3 + 3 * r2 * (1-t)^2 * t + 3 * r2 * (1-t) * t^2 + r3 * t^3 
	gG = g1 * (1-t)^3 + 3 * g2 * (1-t)^2 * t + 3 * g2 * (1-t) * t^2 + g3 * t^3 
	gB = b1 * (1-t)^3 + 3 * b2 * (1-t)^2 * t + 3 * b2 * (1-t) * t^2 + b3 * t^3 
	
End Function


Just a hint: instead of computing this all the time, pre-compute 1-t, (1-t)^2, (1-t)^3, t^2...

Function COLORinterpolate( t#, r1,g1,b1 , r2, g2, b2 , r3, g3, b3 )
Local t1=1-t
Local t12=(t1^2) * t
Local t13=t1^3
Local t3 = t^3
Local t2=t1 * (t^2)

	gR = r1 * t13 + 3 * r2 * t12 + 3 * r2 * t2 + r3 * t3 
        gG = g1 * t13 + 3 * g2 * t12 + 3 * g2 * t2 + g3 * t3 
	gB = b1 * t13 + 3 * b2 * t12 + 3 * b2 * t2 + b3 * t3 
	
End Function


Should be much faster ;)


RifRaf(Posted 2009) [#10]
Yeah, im doing this already. As well as removing the math from a functon and injecting it everywhere its needed in my particle loops , so not to get 100s of calls per loop, as shown here. I continue to do the same for other attributes as well such as scale ect.'

TimeLeft#=(d\timeleft-gametimer)/d\lifetime#
SmallN#=1-timeleft#
Pslot1#=smalln^3 ;+ 3
Pslot2#=smalln^2 * timeleft; + 3
Pslot3#=smalln * timeleft^2
Pslot4#=timeleft^3

;alpha
d\cur_alpha= EmitterAlpha3(d\emitterid) * Pslot1 + 3 * EmitterAlpha2(d\emitterid) * Pslot2# + 3 * EmitterAlpha2(D\emitterid)* Pslot3# + EmitterAlpha(D\EmitterID) * Pslot4# 
If d\cur_alpha<0 Then killflag=1
;color
d\cur_red  = EmitterRed3(d\emitterid) * Pslot1 + 3 * EmitterRed2(d\emitterid) * Pslot2 + 3 * EmitterRed2(D\emitterid) * Pslot3 + EmitterRed(D\EmitterID) * Pslot4 
d\cur_green= EmitterGreen3(d\emitterid) * Pslot1 + 3 * EmitterGreen2(d\emitterid) * Pslot2 + 3 * EmitterGreen2(D\emitterid) * Pslot3 + EmitterGreen(D\EmitterID) * Pslot4 
d\cur_blue = EmitterBlue3(d\emitterid) * Pslot1 + 3 * EmitterBlue2(d\emitterid) * Pslot3 + 3 * EmitterBlue2(D\emitterid) * Pslot3 + EmitterBlue(D\EmitterID) * Pslot4 



RifRaf(Posted 2009) [#11]
Here it is revised wtih interpolation. Thanks for equation. StevieG
Below are the following codeboxes.. Tween include, particle values include, particle system include, and the main test code. Ill upload a zip and link that as well wich will have the code and media used.

I know for a fact there are many improvemesnt to be made, this was flung together , but it works well. If you make improvements please update me.

All in one zip.
Http://www.empowergames.com/rifmeshpart.zip
It has min documentation (flung together remember) so if you dont get how im doing somthing, just ask.

The test program simply shows some of the features such as. Aligning particle effects to meet collision angles, parenting several emitters together, applying paths to emitters and objects that are parents to emitters, as well as showing the visual difference betwen parent and superparent flags. (superparent means every particle is also parented to emitter or main parent). Sound management is integrated into the particle system so you dont have to worry about that at all, you just indicate sounds in the emitter presets

tween include



particle values include. (preset particle effects and one path)


MAIN PARTICLE AND PATH SYSTEM INCLUDE



CODE TO TEST IT ALL



Stevie G(Posted 2009) [#12]
Nice. I like the waterfall effect. Will need to check out the code when I get the chance.


ZJP(Posted 2009) [#13]
Woa!!. Very very nice. Thx
The perfect complement to this
http://www.blitzbasic.com/codearcs/codearcs.php?code=1095

JP


RifRaf(Posted 2009) [#14]
Thanks.

I have to confess I didnt spend much time or effort on setting up elaborate or visually impressive effects, instead its all just test data for the sytems proper function.. ill try to make a few more presets to show off some better visuals if I can get the energy to do that.

It really needs a preset edtior.


ZJP(Posted 2009) [#15]
Do not worry. The examples are easy to understand. Thx again ;-)

JP


Blitzplotter(Posted 2009) [#16]
RifRaf, very interesting lib, I liked the look of the projectiles in your initial imagery.