Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86453135
ParticleWin.pde
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Oct 6, 14:22
Size
1 KB
Mime Type
text/x-c++
Expires
Tue, Oct 8, 14:22 (2 d)
Engine
blob
Format
Raw Data
Handle
21259674
Attached To
rBAFOURPROJECT InfoVisuGit
ParticleWin.pde
View Options
class ParticleWin {
Mover emitter;
ArrayList<smallP> list=new ArrayList<smallP>();
float ttl=1;//time to live
float size=20;
float f;
float timeInterval;
float prevF;
PShape p=new PShape();
ParticleWin(Mover m) {
emitter=m;
p = createShape();
p.beginShape(TRIANGLES);
p.vertex(0, 0, 0);
p.vertex(size, 0,0);
p.vertex(size, -size, size);
p.vertex( 0,0, size);
p.vertex(0, -size, 0);
p.vertex(size, -size, 0);
p.endShape();
p.setStroke(false);
}
void updateNdraw(){
if (frameCount-prevF>=timeInterval*frameRate && !shiftMod) {
timeInterval=random(0.01,0.05);
prevF=frameCount;
list.add(new smallP(emitter.location.copy()));
}
ArrayList<smallP> toBeDestroyed=new ArrayList<smallP>();
for(smallP sp:list){
sp.updateNdraw();
if(sp.isDead()){
toBeDestroyed.add(sp);
}
}
list.removeAll(toBeDestroyed);
}
class smallP{
PVector loc;
PVector speed;
PVector rotation;
PVector rotationSpeed;
float ttl=100;
color c;
smallP(PVector loc){
this.loc=loc;
speed=new PVector(random(-1,1),random(-1,1),random(-1,1));
rotation=new PVector(random(-PI,PI),random(-PI,PI),random(-PI,PI));
rotationSpeed=new PVector(random(-0.2,0.2),random(-0.2,0.2),random(-0.2,0.2));
c=color((int)random(50,200),(int)random(50,200),(int)random(50,200));
}
void updateNdraw(){
ttl--;
speed.x+=random(-1,1);
speed.y+=random(-1,1);
speed.z+=random(-1,1);
rotation.add(rotationSpeed);
loc.add(speed);
gameSurface.pushMatrix();
gameSurface.translate(loc.x,-plate_t+min(-loc.z,0),loc.y);
gameSurface.rotateX(rotation.x);
gameSurface.rotateY(rotation.y);
gameSurface.rotateZ(rotation.z);
p.setFill(c);
gameSurface.shape(p);
gameSurface.emissive(0);
gameSurface.popMatrix();
}
boolean isDead(){
return ttl<0;
}
}
}
Event Timeline
Log In to Comment