Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

perlin is working

  • Loading branch information...
commit 3ae95ae721b385edd787cc0c62af5068bba15a6c 1 parent 1eb4600
@obviousjim authored
View
1  CloudsChaos/src/CloudInterludeForcePerlin.h
@@ -26,6 +26,7 @@ class CloudInterludeForcePerlin : public CloudInterludeForce {
void applyForce(vector<CloudInterludeParticle>& particles){
currentOffset += speed;
+ currentOffset = 0;
for(int i = 0; i < particles.size(); i++){
ofVec3f& pos = particles[i].position;
// particles[i].force += ofVec3f(ofSignedNoise(pos.x/density, pos.y/density, pos.z/density, currentOffset)*amplitude,
View
2  CloudsChaos/src/CloudInterludeParticleGenerator.h
@@ -17,7 +17,7 @@ class CloudInterludeParticleGenerator {
CloudInterludeParticleGenerator(){
birthRate = 10;
lifespan = 200;
- numToBear = 0;
+ numToBear = ofRandom(0,1);
//setup forces
}
View
45 CloudsChaos/src/testApp.cpp
@@ -2,6 +2,7 @@
//--------------------------------------------------------------
void testApp::setup(){
+ ofEnableAlphaBlending();
ofSetFrameRate(60);
ofBackground(30);
@@ -28,7 +29,7 @@ void testApp::setup(){
timeline.setDurationInFrames(500);
timeline.setOffset(ofVec2f(0,0));
- int absoluteMaxParticles = 100000;
+ int absoluteMaxParticles = 1000000;
depthImages.setup();
timeline.setPageName("Source");
timeline.addElement("Depth", &depthImages);
@@ -37,15 +38,15 @@ void testApp::setup(){
timeline.addKeyframes("Edge Snip", "edgesnip.xml", ofRange(0, sqrtf(2000) ), sqrtf(2000));
timeline.addPage("Particles");
- timeline.addKeyframes("Max Particles", "maxParticles.xml", ofRange(1000, absoluteMaxParticles) );
- timeline.addKeyframes("Birthrate", "particleBirthrate.xml", ofRange(.1, sqrtf(10)) );
+ timeline.addKeyframes("Max Particles", "maxParticles.xml", ofRange(10, absoluteMaxParticles) );
+ timeline.addKeyframes("Birthrate", "particleBirthrate.xml", ofRange(.001, .01) );
timeline.addKeyframes("Lifespan", "particleLifespan.xml", ofRange(2, 300) );
timeline.addKeyframes("Lifespan Variance", "particleLifespanVariance.xml", ofRange(0, 100) );
timeline.addKeyframes("Drag Force", "particleDragFroce.xml", ofRange(0, 1.0), 0);
timeline.addPage("Perlin");
timeline.addKeyframes("Perlin Amplitude", "perlinAmplitude.xml", ofRange(1, sqrtf(200)) );
- timeline.addKeyframes("Perlin Density", "perlinDensity.xml", ofRange(100, sqrtf(2000)));
+ timeline.addKeyframes("Perlin Density", "perlinDensity.xml", ofRange(0, sqrtf(2000)));
timeline.addKeyframes("Perlin Speed", "perlinSpeed.xml", ofRange(0, sqrtf(5)), 0);
timeline.addPage("Attractors");
@@ -120,8 +121,8 @@ void testApp::update(){
meshForce->attractScale = timeline.getKeyframeValue("Mesh Attract");
//GENERATOR
- float birthRate = powf(timeline.getKeyframeValue("Birthrate"), 2);
- float lifeSpan = timeline.getKeyframeValue("Lifespan");
+ float birthRate = timeline.getKeyframeValue("Birthrate");
+ float lifeSpan = timeline.getKeyframeValue("Lifespan");
float lifeSpanVariance = timeline.getKeyframeValue("Lifespan Variance");
int maxParticles = timeline.getKeyframeValue("Max Particles");
@@ -130,6 +131,11 @@ void testApp::update(){
// }
totalParticles = 0;
+ for(int i = 0; i < emmiters.size(); i++){
+ emmiters[i].birthRate = 0;
+ totalParticles += emmiters[i].particles.size();
+ }
+
for(int i = 0; i < renderer.getTotalPoints(); i++){
CloudInterludeParticleGenerator& g = emmiters[i];
bool valid = renderer.isVertexValid(i);
@@ -140,11 +146,12 @@ void testApp::update(){
g.lifespanVariance = lifeSpanVariance;
g.position = renderer.getMesh().getVertex( renderer.vertexIndex(i) );
g.remainingParticles = maxParticles - totalParticles;
+ //g.remainingParticles = maxParticles - g.particles.size();
}
- else{
- g.birthRate = 0;
- }
- g.update();
+ }
+
+ for(int i = 0; i < emmiters.size(); i++){
+ emmiters[i].update();
}
//put the particles in the mesh;
@@ -253,11 +260,17 @@ void testApp::copyVertsToMesh(){
float color = emmiters[i].particles[v].energy / emmiters[i].particles[v].initialEnergy;
meshColors[meshIndex] = ofFloatColor(color,color,color,color);
meshIndex++;
-// if(meshIndex == meshVertices.size()){
-// return;
-// }
+ if(meshIndex == meshVertices.size()){
+ ofLogError("exceeded max particles");
+ return;
+ }
}
}
+
+ memset(&(meshColors[meshIndex].r), 0, sizeof(ofFloatColor)*(meshColors.size()-meshIndex));
+// for(int i = meshIndex; i < meshVertices.size(); i++){
+//
+// }
}
//--------------------------------------------------------------
@@ -291,6 +304,12 @@ void testApp::keyPressed(int key){
if(key == 'R'){
cam.reset();
}
+
+ if(key == 'K'){
+ for(int i = 0; i < emmiters.size(); i++){
+ emmiters[i].particles.clear();
+ }
+ }
}
//--------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.