inspired by
http://www.esenthel.com/forum/showthread...wParticles
hello guy, here to talk about the RawParticles!
what is it ? RawParticles is pretty much a lighter version of Particles and for that reason have better performance.
there's little to no information in tutorials, and forum discussion.
here is my little 2 cents to help the next person interested by this
What i tried to do is to set some particles to immitate rain
it is fairly easy and looks like particles in the idea.
First i set up my class that will carry rawparticles information as i like to do.
Code:
class MyRawParticlesAttributs
{
// save pos for next frame update as we dont want to reset pos every frame.
flt posx;
flt posy;
flt posz;
Color myColor;
flt myRadius;
void SetRandom() // used at creation / respawn. can be improve to create particles where rain drop down.
{
posx=RandomF(Plr.pos().x-100, Plr.pos().x+100);
posy=RandomF(Plr.pos().y+50, Plr.pos().y+100);
posz=RandomF(Plr.pos().z-100, Plr.pos().z+100);
int randomLight=Random(150, 200); int randombrightness=Random(150, 255);
myColor=Color(randomLight, randomLight, randomLight, randombrightness);
myRadius=RandomF(0.3, 1);
}
void SetLinear() // linear update of the particle
{
posy-=Time.rd()*50;
posx-=0;
posz-=0;
}
}
C int MyRawParticleArrayNumber=5000; // setting up n° of particles wanted
RawParticles RawParticles_Atmo;
RawParticles.Particle particleArray[MyRawParticleArrayNumber];
MyRawParticlesAttributs particleArrayAttribut[MyRawParticleArrayNumber];
in create anywhere in your code : just set it up for the update to work correctly
Code:
RawParticles_Atmo.palette(false).create(UID(2049046545, 1233068177, 1469235131, 745495318));
REP(MyRawParticleArrayNumber)particleArrayAttribut[i].SetRandom();
nb: i couldnt get palette(true) to work for some reason, so i used RM_BLEND instead.
Put this in your game update
Code:
REP(MyRawParticleArrayNumber)
{
particleArrayAttribut[i].SetLinear();
if(particleArrayAttribut[i].posy<=Game.World.hmHeight(Vec2(particleArrayAttribut[i].posx, particleArrayAttribut[i].posz)))
{
particleArrayAttribut[i].SetRandom();
}
particleArray[i].radius = particleArrayAttribut[i].myRadius;
particleArray[i].vel = Vec(0, 0, 0); // do not care about vel
particleArray[i].color = particleArrayAttribut[i].myColor;
particleArray[i].pos = Vec(particleArrayAttribut[i].posx, particleArrayAttribut[i].posy , particleArrayAttribut[i].posz);
}
RawParticles_Atmo.set(&particleArray[0], MyRawParticleArrayNumber);
nb : confusing about how to set them correctly, might be wrong. might be right.
in drawing
Code:
case RM_BLEND:
{
RawParticles_Atmo.draw();
}break;
some images :
Quote:
please let me know if anything is wrong/needs improvement
added a link to EE project here :
http://www.filedropper.com/rawparticles
thanks !