//-------------------------------------------------------------- void ofApp::setup(){ ofLogLevel(OF_LOG_VERBOSE); ofLogToConsole(); sliderInt = 100; color = ofColor::blue; cursor = ofPoint(ofGetWindowWidth() / 2 - sliderInt / 2, ofGetWindowHeight() / 2 - sliderInt / 2); }
//-------------------------------------------------------------- void testApp::setup(){ ofSetWindowTitle("Sender"); ofSetWindowPosition(0, 0); ofSetFrameRate(30); ofLogLevel(OF_LOG_WARNING); grabber.initGrabber(640, 480); sender.setup(grabber.getWidth(), grabber.getHeight(), "127.0.0.1"); }
// ------------------------- start it up ---------------------------- int main( int argc, // Number of strings in array argv char *argv[], // Array of command-line argument strings char *envp[] ) { ofAppGlutWindow window; #ifdef TARGET_OSX window.setGlutDisplayString("rgba double samples>=8 depth"); #endif projectorConfiguration projConfig; showDefinition show; // TODO: make command line parameter for this ofLogLevel(OF_LOG_VERBOSE); int primaryScreenWidth = GetSystemMetrics(SM_CXSCREEN); int primaryScreenHeight = GetSystemMetrics(SM_CYSCREEN); int virtualScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); int virtualScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); // get parameter: which configuration to load -> = name of folder // if no parameter specified, then create a default configuration if(argc == 1) { projConfig.setName("Default"); projConfig.setWindowWidth(primaryScreenWidth); projConfig.setWindowHeight(primaryScreenHeight); projConfig.initialize(primaryScreenWidth, primaryScreenHeight, virtualScreenWidth, virtualScreenHeight); projConfig.allocateViewports(1); projConfig.getProjView(0).proj.name = "Single"; projConfig.getProjView(0).index = 0; projConfig.getProjView(0).setViewport(0, 0, primaryScreenWidth, primaryScreenHeight); show.addMovie("movies/oefentrap-uvtemplate_2.mov", "oefentrap"); show.addPicture("pictures/oefentrap-stonesandgrass.png", "stone and grass"); } else { string configName(argv[1]); if(configName == "FourViewTest") { float vpWidth = (float)primaryScreenWidth/2; float vpHeight = (float)primaryScreenHeight/2; projConfig.setName("FourViewportsSingleScreen"); projConfig.setWindowWidth(primaryScreenWidth); projConfig.setWindowHeight(primaryScreenHeight); projConfig.initialize(primaryScreenWidth, primaryScreenHeight, virtualScreenWidth, virtualScreenHeight); projConfig.allocateViewports(4); projConfig.getProjView(0).proj.name = "Top left"; projConfig.getProjView(0).index = 0; projConfig.getProjView(0).setViewport(0, 0, vpWidth, vpHeight); projConfig.getProjView(1).index = 1; projConfig.getProjView(1).proj.name = "Top right"; projConfig.getProjView(1).setViewport(vpWidth, 0, vpWidth, vpHeight); projConfig.getProjView(2).index = 2; projConfig.getProjView(2).proj.name = "Bottom left"; projConfig.getProjView(2).setViewport(0, vpHeight, vpWidth, vpHeight); projConfig.getProjView(3).index = 3; projConfig.getProjView(3).proj.name = "Bottom right"; projConfig.getProjView(3).setViewport(vpWidth, vpHeight, vpWidth, vpHeight); projConfig.setViewToCalibrate(0); show.addMovie("movies/fingers.mov", "fingers"); show.addPicture("pictures/oefentrap-stonesandgrass.png", "stone and grass"); } else { projConfig.initialize(primaryScreenWidth, primaryScreenHeight, virtualScreenWidth, virtualScreenHeight); projConfig.loadConfiguration(configName); show.load(configName); // Poco::XML::NodeIterator it(pDoc, Poco::XML::NodeFilter::WhatToShow::SHOW_ELEMENT); //Poco::XML::Node* pNode = it.nextNode(); //while (pNode) //{ // std::cout<<pNode->nodeName()<<":"<< pNode->nodeValue()<<std::endl; // pNode = it.nextNode(); //} // default, single monitor configuration: one projector, one screen //projConfig.initialize(1); //projConfig.getProjView(0).viewport.x = 0; //projConfig.getProjView(0).viewport.y = 0; //projConfig.getProjView(0).viewport.width = ofGetWidth(); //projConfig.getProjView(0).viewport.height = ofGetHeight(); //projConfig.setViewToCalibrate(0); // testing: four projector views on a single monitor } } // todo: production: // multiple views laid out on large extended desktop //ofSetupOpenGL(&window, 1024, 768, OF_FULLSCREEN); ofSetupOpenGL(&window, projConfig.getWindowWidth(), projConfig.getWindowHeight(), OF_WINDOW); ofRunApp(new testApp(projConfig, show)); }
//-------------------------------------------------------------- void testApp::setup(){ ofLogLevel(OF_LOG_NOTICE); ofEnableAlphaBlending(); ofEnableSmoothing(); spot = 0; nbLedProjector = 34; //dmx.connect("tty.usbserial-EN086808"); // use the name // to see the permanent path of your device: $ sudo udevadm info --query=all --name=ttyUSB0 // use the "by-id" path, ie. serial/by-id/usb-9710_7720-if00-port0 // if not found but works with sudo: // sudo usermod -a -G dialout minad // minad is the name of user you're running // then: // sudo chmod a+rw /dev/ttyUSB0 dmx.connect("/dev/serial/by-id/usb-ENTTEC_DMX_USB_PRO_EN086808-if00-port0"); // use the name dmx.setChannels(45*3); reconnectDmxDelay = 0; #ifdef SHADER_RENDERING //display.setup("imgs/sub", nbLedProjector); display.setup("imgs/realistes_cropped", nbLedProjector); #endif //ofSetWindowShape(base.getWidth(), base.getHeight()); //ofSetWindowShape(800, 600); int width = 1327; int height = 747; ofSetWindowShape(1327, 747); ofEnableAlphaBlending(); spots.resize(nbLedProjector); float step = 1./(nbLedProjector+1); for (int i = 0; i < (int) spots.size(); i++){ spots[i].set(0); } dmxChannels.resize(nbLedProjector); dmxChannels[0].push_back(1); dmxChannels[1].push_back(4); dmxChannels[2].push_back(7); dmxChannels[2].push_back(10); dmxChannels[3].push_back(13); dmxChannels[4].push_back(16); dmxChannels[4].push_back(19); dmxChannels[5].push_back(22); dmxChannels[6].push_back(25); dmxChannels[6].push_back(31); dmxChannels[7].push_back(28); dmxChannels[8].push_back(34); dmxChannels[9].push_back(37); dmxChannels[10].push_back(40); dmxChannels[11].push_back(43); dmxChannels[12].push_back(46); dmxChannels[13].push_back(49); dmxChannels[14].push_back(52); dmxChannels[14].push_back(55); dmxChannels[14].push_back(58); dmxChannels[15].push_back(61); dmxChannels[15].push_back(64); dmxChannels[15].push_back(67); dmxChannels[16].push_back(70); dmxChannels[17].push_back(73); dmxChannels[18].push_back(76); dmxChannels[19].push_back(79); dmxChannels[20].push_back(82); dmxChannels[21].push_back(85); dmxChannels[22].push_back(88); dmxChannels[23].push_back(91); dmxChannels[24].push_back(94); dmxChannels[24].push_back(97); dmxChannels[25].push_back(100); dmxChannels[25].push_back(103); dmxChannels[26].push_back(106); dmxChannels[27].push_back(109); dmxChannels[27].push_back(112); dmxChannels[28].push_back(115); dmxChannels[29].push_back(118); dmxChannels[29].push_back(121); dmxChannels[30].push_back(124); dmxChannels[31].push_back(127); dmxChannels[32].push_back(130); dmxChannels[33].push_back(133); ofBackground(0); gaussienne.resize(500); for (int i = 0; i < (int) gaussienne.size(); i++){ gaussienne[i] = (i < (int)gaussienne.size()/2) ? 255./(gaussienne.size()/2)*i : 255./(gaussienne.size()/2)*(gaussienne.size()-i); } bFirst = false; bLast = false; //movers.resize(16); /* for (unsigned int i = 0; i < movers.size(); i++){ movers[i].setup(); //movers[i].setMass(ofRandom(0.5, 2)); movers[i].setMass(ofRandom(0.1, 4)); //movers[i].setMass(0.1); //movers[i].setDensity(0.01); //movers[i].setMass(1); movers[i].setLocation(ofRandom(-1,2)*width, 0); } */ yoff = ofRandom(0, 1000); yoff_inc = 0.005; yoff_inc = 0.3; float dim = 16; float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; float length = 320-xInit; float sliderWidth = 200; gui = new ofxUICanvas(0,0,length+xInit*2.0,height); gui->addWidgetDown(new ofxUILabel("MILLE TEMPS", OFX_UI_FONT_LARGE)); gui->addSpacer(length, 2); gui->addWidgetDown(new ofxUILabel("ASPECT", OFX_UI_FONT_MEDIUM)); gui->addSlider("ECLAIRAGE PUBLIQUE", 0, 255, 255, sliderWidth, dim); gui->addSpacer(length, 2); gui->addWidgetDown(new ofxUILabel("NUAGES", OFX_UI_FONT_MEDIUM)); gui->addRangeSlider("intensite_", 0, 100, &gaussian_intensity_min, &gaussian_intensity_max , sliderWidth, dim); gui->addRangeSlider("largeur_", 0.1, 20, &sd_min, &sd_max, sliderWidth, dim); gui->addSlider("probabilite_presence", 0, 100, &cloudProbability, sliderWidth, dim); gui->addSpacer(length, 2); gui->addWidgetDown(new ofxUILabel("VIE INTERIEURE", OFX_UI_FONT_MEDIUM)); gui->addSlider("vitesse", 0.001, 0.020, &yoff_inc, sliderWidth, dim); gui->addSlider("largeur", 0.3, 0.01, &xoff_inc, sliderWidth, dim); gui->addSlider("intensite", 0, 100, &tourbillons_intensite, sliderWidth, dim); gui->addSpacer(length, 2); gui->addWidgetDown(new ofxUILabel("VENT", OFX_UI_FONT_MEDIUM)); gui->addWidgetDown(new ofxUIRotaryCircleSlider("R2SLIDERCIRCLEROTARY", ofPoint(0,60), ofPoint(0,360), &wind, dim*8)); gui->addSlider("vitesse (en km/h)", 0, 200, &wind_speed, 200, dim); gui->addSpacer(length, 2); gui->addWidgetDown(new ofxUILabel("TEMPERATURE", OFX_UI_FONT_MEDIUM)); gui->addSlider("temperature", -5, 40, &temperature, sliderWidth, dim); gui->addSlider("saturation", 0, 100, &colorSaturation, sliderWidth, dim); gui->addSpacer(length, 2); gui->addWidgetDown(new ofxUILabel("ENSOLEILLEMENT", OFX_UI_FONT_MEDIUM)); gui->addSlider("pyranometre", 0, 1, &pyranometre, sliderWidth, dim); /* gui->setWidgetPosition(OFX_UI_WIDGET_POSITION_RIGHT); gui->addSlider("BGG", 0, 255, backgroundColor.g, sliderWidth, dim); gui->addSlider("BGB", 0, 255, backgroundColor.b, sliderWidth, dim); */ ofAddListener(gui->newGUIEvent,this,&testApp::guiEvent); gui->loadSettings("GUI/guiSettings.xml"); gui2 = new ofxUICanvas(width- (length+xInit*2.0),0,width, height); gui2->addWidgetDown(new ofxUILabel("SIMULATION", OFX_UI_FONT_LARGE)); gui2->addSpacer(length, 2); gui2->addSlider("Play X", 1, 100, &simSpeed, 95, dim); gui2->addSlider("Pixel To World", 1, 100, &coefPixelToRealWorld, 95, dim); gui2->addSlider("Friction", 0.000, 0.01, &frictionCoef, 95, dim); //gui2->addSlider("Play X", 1, 100, &simSpeed, 95, dim); gui2->addLabelToggle("SENSORS", &bUseSensors, true); gui2->addLabelToggle("DMX", &bUseDmx, true); gui2->loadSettings("GUI/guiSettings2.xml"); metakPro.setup(); ofAddListener(metakPro.NEW_SENSORDATA,this,&testApp::onNewSensorData); metakPro.log(); //metakPro.replay("test.log"); oscReceiver.setup(6666); }
//-------------------------------------------------------------- void Grabber::setup() { gdata = new GlobalData(); gdata->loadCalibData("settings.xml"); ofLogLevel(OF_LOG_VERBOSE); //ofLogToFile("client_log.txt", false); setupGui(); downsampling = 4; switch(gdata->sys_data->logLevel) { case 0: ofSetLogLevel(OF_LOG_VERBOSE); break; case 1: ofSetLogLevel(OF_LOG_NOTICE); break; case 2: ofSetLogLevel(OF_LOG_WARNING); break; case 3: ofSetLogLevel(OF_LOG_ERROR); break; case 4: ofSetLogLevel(OF_LOG_FATAL_ERROR); break; case 5: ofSetLogLevel(OF_LOG_SILENT); break; default:ofSetLogLevel(OF_LOG_VERBOSE); break; } FrameUtils::init(); ofSetFrameRate(gdata->sys_data->fps); total2D = gdata->total2D; //Hacer que se cargue dinámico. total3D = gdata->total3D; //Hacer que se cargue dinámico. //ofSetFrameRate(gdata->sys_data->fps); if((gdata->total2D + gdata->total3D) > 0) { tData = new ThreadData[gdata->total2D + gdata->total3D]; for(int w = 0; w < (gdata->total2D + gdata->total3D); w++) { tData[w].cliId = gdata->sys_data->cliId; } } else { tData = NULL; } t_camera * camera = gdata->camera; if(gdata->total2D > 0) { t2D = new Thread2D[gdata->total2D]; } if(gdata->total3D > 0) { t3D = new Thread3D[gdata->total3D]; } int i2D = 0; int i3D = 0; while(camera != NULL) { if(camera->use3D == 1) { t3D[i3D].sys_data = gdata->sys_data; t3D[i3D].context = camera; t3D[i3D].startThread(true, false); i3D ++; } else { t2D[i2D].sys_data = gdata->sys_data; t2D[i2D].context = camera; t2D[i2D].startThread(true, true); i2D ++; } camera = camera->sig; } ofLogVerbose() << "[Grabber::setup] " << gdata->sys_data->goLive; if(gdata->sys_data->goLive == 1) { //Si desde el Calibrator se indicó que se debe trasmitir en vivo. transmitter.grabber = this; transmitter.sys_data = gdata->sys_data; transmitter.startThread(true, true); } ofVideoGrabber vid; vid.listDevices(); }