//-------------------------------------------------------------- void particleManager::keyPressed(ofKeyEventArgs &args){ if( args.key == '1'){ currentMode = PARTICLE_MODE_ATTRACT; currentModeStr = "1 - PARTICLE_MODE_ATTRACT: attracts to mouse"; } if( args.key == '2'){ currentMode = PARTICLE_MODE_REPEL; currentModeStr = "2 - PARTICLE_MODE_REPEL: repels from mouse"; } if( args.key == '3'){ currentMode = PARTICLE_MODE_NEAREST_POINTS; currentModeStr = "3 - PARTICLE_MODE_NEAREST_POINTS: hold 'f' to disable force"; } if( args.key == '4'){ currentMode = PARTICLE_MODE_NOISE; currentModeStr = "4 - PARTICLE_MODE_NOISE: snow particle simulation"; resetParticles(); } if( args.key == ' ' ){ resetParticles(); } }
ParticleEmitter::ParticleEmitter(GLuint textureId, float3 color, float3 velocity, float3 force, float scale, float fuzziness, float speed, unsigned maxParticles) : m_maxParticles(maxParticles), m_textureID(textureId), m_speed(speed), m_fuzziness(fuzziness), m_scale(scale), m_color(color), m_velocity(velocity), m_force(force) { m_textureID = textureId; m_particles = new Particle[maxParticles]; resetParticles(); for (unsigned i = 0; i < m_maxParticles; ++i) m_particles[i].active = false; m_activeParticles = 0; }
//-------------------------------------------------------------- void testApp::keyPressed(int key){ // if( key == '1'){ // currentMode = PARTICLE_MODE_ATTRACT; // currentModeStr = "1 - PARTICLE_MODE_ATTRACT: attracts to mouse"; // } // if( key == '2'){ // currentMode = PARTICLE_MODE_REPEL; // currentModeStr = "2 - PARTICLE_MODE_REPEL: repels from mouse"; // } // if( key == '3'){ // currentMode = PARTICLE_MODE_NEAREST_POINTS; // currentModeStr = "3 - PARTICLE_MODE_NEAREST_POINTS: hold 'f' to disable force"; // } // if( key == '4'){ // currentMode = PARTICLE_MODE_NOISE; // currentModeStr = "4 - PARTICLE_MODE_NOISE: snow particle simulation"; // resetParticles(); // } if( key == ' ' ){ resetParticles(); } }
//#define TEST_COUNTER //-------------------------------------------------------------- void testApp::setup(){ #ifdef TEST_COUNTER ofSetLogLevel(OF_LOG_SILENT); cout << "Start test Count 10000" << endl; cout << "--------------------------------------------------------------" << endl; for(int i = 0 ; i < 10000 ; i++) { stateMachine.getSharedData().load(); cout << "Count = "<< stateMachine.getSharedData().counter <<endl; stateMachine.getSharedData().counter+=1; stateMachine.getSharedData().save(); } cout << "End test Count 10000" << endl; cout << "--------------------------------------------------------------" << endl; std::exit(0); #endif ofEnableSmoothing(); ofEnableAlphaBlending(); ofSetVerticalSync(true); glDisable(GL_DEPTH_TEST); ofxXmlSettings xml = stateMachine.getSharedData().xml; if(xml.loadFile(settingFileName)) { if(xml.pushTag("DATA")) { stateMachine.getSharedData().bDebug = xml.getValue("DEBUG", true); float width = xml.getValue("WIDTH", 1280); float height = xml.getValue("HEIGHT", 720); sndPlayer.loadSound(xml.getValue("SOUND_PATH", "sounds/Zone 5 - Door Creak, scream and witchly laugh.wav")); sndPlayer.setLoop(true); sndPlayer.play(); stateMachine.getSharedData(). wRatio = width/1920; stateMachine.getSharedData(). hRatio = height/1080; ofSetFullscreen(xml.getValue("FULLSCREEN", 0)); ofSetWindowShape(width, height); stateMachine.getSharedData().path_to_save = xml.getValue("CAPTURE_PATH", "./captures"); stateMachine.getSharedData().filesXml.loadFile(stateMachine.getSharedData().path_to_save+"/files.xml"); if(!stateMachine.getSharedData().filesXml.pushTag("XML")) { stateMachine.getSharedData().filesXml.addTag("XML"); stateMachine.getSharedData().filesXml.pushTag("XML"); } stateMachine.getSharedData().numDigi = xml.getValue("DIGI", 5); stateMachine.getSharedData().font.loadFont(xml.getValue("FONT_PATH", "fonts/LunacyMore.ttf"),xml.getValue("FONT_SIZE", 128)); ofDirectory dir; if(dir.listDir(stateMachine.getSharedData().path_to_save)<1) { dir.createDirectory(stateMachine.getSharedData().path_to_save); } xml.popTag(); } } else { ofLog(OF_LOG_ERROR,"Faile to load "+ settingFileName); } // // setup shared data ofxControlPanel::setBackgroundColor(simpleColor(30, 30, 60, 100)); ofxControlPanel::setTextColor(simpleColor(240, 50, 50, 255)); stateMachine.getSharedData().panel.setup(ofGetWidth(),ofGetHeight()); stateMachine.getSharedData().panel.loadFont("MONACO.TTF", 8); stateMachine.getSharedData().panel.addPanel("General", 4,false); ofxControlPanel::setBackgroundColor(simpleColor(60, 30, 30, 100)); stateMachine.getSharedData().panel.addPanel("FaceTracking", 5, false); ofxControlPanel::setBackgroundColor(simpleColor(60, 30, 30, 100)); stateMachine.getSharedData().panel.addPanel("FaceTracking0", 4, false); ofxControlPanel::setBackgroundColor(simpleColor(60, 30, 30, 100)); stateMachine.getSharedData().panel.addPanel("FaceTracking1", 4, false); ofxControlPanel::setBackgroundColor(simpleColor(70, 70, 30, 100)); stateMachine.getSharedData().panel.addPanel("FaceMapEdit", 4, false); ofxControlPanel::setBackgroundColor(simpleColor(30, 30, 30, 100)); //some dummy vars we will update to show the variable lister object appFrameRate = ofGetFrameRate(); stateMachine.getSharedData().panel.setWhichPanel("General"); stateMachine.getSharedData().panel.setWhichColumn(0); stateMachine.getSharedData().panel.addChartPlotter("some chart", guiStatVarPointer("app fps", &appFrameRate, GUI_VAR_FLOAT, true, 2), 200, 50, 200, 5, 80); vector<string> loglevel; loglevel.push_back("OF_LOG_VERBOSE"); loglevel.push_back("OF_LOG_NOTICE"); loglevel.push_back("OF_LOG_WARNING"); loglevel.push_back("OF_LOG_ERROR"); loglevel.push_back("OF_LOG_FATAL_ERROR"); loglevel.push_back("OF_LOG_SILENT"); stateMachine.getSharedData().panel.addTextDropDown("LogLevel","LogLevel", 0, loglevel); // initialise state machine stateMachine.addState(new IndexState()); stateMachine.addState(new SelectPlayerState()); stateMachine.addState(new CaptureState()); stateMachine.addState(new EditState()); stateMachine.addState(new EndState()); stateMachine.addState(new LicenseState()); stateMachine.changeState(xml.getValue("DATA:INIT_STATE", "IndexState")); stateMachine.getSharedData().panel.loadSettings("settings.xml"); stateMachine.getSharedData().panel.hide(); // if(!stateMachine.getSharedData().bDebug) // { //// stateMachine.getSharedData().panel.unregisterKeyboardEvent(); // } stateMachine.getSharedData().numPlayer = 1; for(int i = 0 ; i < NUM_SEQ ;i++) { image[i].loadSequence("images/bat/bat_", "png", 0, 154, 5); image[i].setFrameRate(60); } int num = 3000; stateMachine.getSharedData().p.assign(num, Particle()); resetParticles(); }
//-------------------------------------------------------------- void ofApp::setup(){ //------------------------- int num = 1500; p.assign(num, demoParticle()); currentMode = PARTICLE_MODE_NEAREST_POINTS; resetParticles(); ofBackground(100, 100, 100); vidGrabber.setVerbose(true); vidGrabber.setup(vidX,vidY); // setup live video grabbing colorImg.allocate(vidX,vidY); // color image display grayImage.allocate(vidX,vidY); // grayscale display grayBg.allocate(vidX,vidY); // contour image grayDiff.allocate(vidX,vidY); // b/w differencing image bLearnBakground = true; threshold = 80; ofSetVerticalSync(true); bSendSerialMessage = false; ofSetLogLevel(OF_LOG_VERBOSE); int baud = 9600; serial.setup("/dev/cu.usbmodem1411", baud); nTimesRead = 0; nBytesRead = 0; readTime = 0; memset(bytesReadString, 0, 4); font.load("NADISN__.TTF", 12); font2.load("NADISN__.TTF", 24); _i = ofClamp(i, 0, 14); mov1.load("hel-0world.mp4"); mov1.setLoopState(OF_LOOP_NORMAL); mov1.play(); music1.load("1.wav"); music2.load("2.wav"); music3.load("3.wav"); music4.load("4.wav"); music5.load("5.wav"); music6.load("6.wav"); music7.load("7.wav"); music8.load("8.wav"); music9.load("9.wav"); music10.load("10.wav"); music11.load("11.wav"); music12.load("12.wav"); music13.load("11.wav"); music14.load("12.wav"); music15.load("13.wav"); music1.play(); music2.play(); music3.play(); music4.play(); music5.play(); music6.play(); music7.play(); music8.play(); music9.play(); music10.play(); music11.play(); music12.play(); music13.play(); music14.play(); music15.play(); music1.setPaused(true); music2.setPaused(true); music3.setPaused(true); music4.setPaused(true); music5.setPaused(true); music6.setPaused(true); music7.setPaused(true); music8.setPaused(true); music9.setPaused(true); music10.setPaused(true); music11.setPaused(true); music12.setPaused(true); music13.setPaused(true); music14.setPaused(true); music15.setPaused(true); img1.load("01.png"); img2.load("02.png"); img3.load("03.png"); img4.load("04.png"); img5.load("05.png"); img6.load("06.png"); img7.load("07.png"); img8.load("08.png"); img9.load("09.png"); img10.load("10.png"); img11.load("11.png"); img12.load("12.png"); img13.load("13.png"); }
void testApp::keyPressed(int key){ if( key == ' ' ){ resetParticles(); } }