void ofApp::setup(){ ofSetVerticalSync(false); ofSetFrameRate(60); // Create 3 particle emitters emitters = {ParticleEmitter(), ParticleEmitter(), ParticleEmitter()}; // Setup the particle emitters for(auto& e : emitters){ e.setup(); } // Setup the curl noise with the number of particles we want curlNoise.setup(1024*256); // Set the noise turbulence curlNoise.setTurbulence(0.3); renderShader.load("shaders/render_vert.glsl", "shaders/render_frag.glsl"); // Add 'lifespan' and 'emitterId' attributes to the particle vbo // (see the shaders for how to use these) curlNoise.setAttributes(renderShader); // Setup GUI parameters.add(curlNoise.parameters); for(auto& e : emitters){ parameters.add(e.parameters); } gui.setup(parameters); gui.add(fps.setup("Fps:", "")); gui.minimizeAll(); }
void makeSprinkler () { particleSystem.removeAllEmitters(); double startOffset; double sideOffset; double sideOffsetRange = 0; double angle = 90; double angleDiff = 360.0 / emitterCount; double sideBetweenEmitters = sideOffsetRange / emitterCount; if (emitterCount % 2 == 0) { startOffset = ((emitterCount / 2) - 0.5) * emitterSpacing; sideOffset = ((emitterCount / 2) - 0.5) * sideBetweenEmitters; } else { startOffset = ((emitterCount - 1) / 2) * emitterSpacing; sideOffset = ((emitterCount / 2) - 0.5) * sideBetweenEmitters; } Vector3 emitterLocation = Vector3(-startOffset, -20.0, 0); Vector3 betweenEmitters = Vector3(emitterSpacing, 0, 0); sideOffset = -sideOffset; for (int i = 0; i < emitterCount; i++) { emitterLocation.y = -20 + sin(angle * (M_PI / 180)) * sprinkerHeight; particleSystem.addEmitter(ParticleEmitter(emitterLocation, Vector3(0.0, -20.0, sideOffset))); emitterLocation.addSelf(betweenEmitters); sideOffset += sideBetweenEmitters; angle += angleDiff; } }
void makeFountain () { emitterSpacing = 0; particleSystem.removeAllEmitters(); Vector3 emitterLocation = Vector3(0, 0, 0); double sideOffsetRange = 50; for (int i = 0; i < emitterCount; i++) { particleSystem.addEmitter(ParticleEmitter(emitterLocation, Vector3(0.0, -30.0, -sideOffsetRange * std::cos(((360 / emitterCount) * i) * (M_PI / 180))))); } }