//-------------------------------------------------------------- void testApp::setup(){ ofSetLogLevel(OF_LOG_VERBOSE); sender.setup(HOST, PORT); setGUI1(); serial.listDevices(); vector <ofSerialDeviceInfo> deviceList = serial.getDeviceList(); serial.setup(5, 9600); //open the 5th in list //serial.setup("COM4"); // windows example //serial.setup("/dev/tty.usbserial-A4001JEC",9600); // mac osx example Logo.loadImage("logo.png"); diagram.loadImage("diagram.png"); table.loadModel("table3.obj"); A0.loadModel("arrows/0.obj"); A45.loadModel("arrows/45.obj"); A90.loadModel("arrows/90.obj"); A135.loadModel("arrows/135.obj"); A180.loadModel("arrows/180.obj"); A225.loadModel("arrows/225.obj"); A270.loadModel("arrows/270.obj"); A225.loadModel("arrows/225.obj"); A315.loadModel("arrows/315.obj"); cam.setDistance(1200); ofSetBackgroundColor(0, 0, 0); }
//-------------------------------------------------------------- void ofApp::setup(){ ofMesh mesh; mesh.setMode(OF_PRIMITIVE_POINTS); mesh.getVertices().resize(numVertices); ofSetBackgroundColor(0); ofShader::TransformFeedbackSettings settings; settings.shaderFiles[GL_VERTEX_SHADER] = "vert.glsl"; settings.bindDefaults = false; settings.varyingsToCapture = { "v_position", "v_color" }; shader.setup(settings); buffer.allocate(sizeof(glm::vec4) * 2 * numVertices, GL_STATIC_DRAW); ofShader::TransformFeedbackBinding binding(buffer); binding.index = 0; binding.offset = 0; binding.size = numVertices * sizeof(glm::vec4) * 2; shader.beginTransformFeedback(GL_POINTS, binding); mesh.draw(); shader.endTransformFeedback(binding); vbo.setVertexBuffer(buffer, 4, sizeof(glm::vec4) * 2, 0); vbo.setColorBuffer(buffer, sizeof(glm::vec4) * 2, sizeof(glm::vec4)); ofEnablePointSprites(); glPointSize(4); cam.setDistance(2400); cam.orbit(80, 80, 2400, { 0.f, 0.f, 0.f }); }
//-------------------------------------------------------------- void ofApp::setup(){ // Load a CSV File. csv.loadFile(ofToDataPath("diseases.txt")); cout << "Print out a specific CSV value" << endl; cout << csv.getString(1,0) << endl; for (int i = 0; i < csv.data.size(); i++) { Epidemic e(csv.getString(i, 0), csv.getFloat(i, 1), csv.getFloat(i, 2), csv.getFloat(i, 3), csv.getFloat(i, 4)); epidemicList.push_back(e); } gui.setup(); gui.add(years.setup("Year: ", epidemicList.at(counter).getYearOne(), epidemicList.at(counter).getYearOne(), epidemicList.at(counter).getYearTwo())); setRadius(); startingRadius = popRadius; ofSetBackgroundColor(ofColor::black); ofSetCircleResolution(150); ofSetColor(ofColor::white); epidemicTitle.loadFont(OF_TTF_SANS, 35); popCountText.loadFont(OF_TTF_SANS, 25); deathCountText.loadFont(OF_TTF_SANS, 25); ofSetColor(ofColor::white); popTitle.loadFont(OF_TTF_SANS, 32); deathTitle.loadFont(OF_TTF_SANS, 32); yearsText.loadFont(OF_TTF_SANS, 32); }
//-------------------------------------------------------------- void ofApp::setup() { ofSetBackgroundColor(ofColor::black); videoPath = ofToDataPath("../../../videoTestFile/video1.mp4", true); ofLogWarning("setup") << videoPath; moduleManager.acceptProviderType<PlayerModuleProvider>(); moduleManager.addProvider(new GstreamerModuleProvider()); //load included Modules //moduleManager.load("bin/data/.modules/Core/MyModule"); moduleManager.getProviders(modulesProvider); std::vector<PlayerModuleProvider *>::iterator it; ofLogWarning("setup()") << "setting up myModule"; for (it = modulesProvider.begin(); it != modulesProvider.end(); it++) { myModule = (*it)->create(); } if(myModule != nullptr) { ofLogWarning("setup()") << "myModule setUp ok"; } else { ofLogError("setup()") << "myModule setUp failed"; } myModule->setPath(this->videoPath); myModule->setup(); ofSetWindowShape(1280, 720); myModule->play(); this->frameCounter = 0; }
//-------------------------------------------------------------- void ofApp::setupGui(){ parameters.setName("parameters"); parameters.add(radius.set("radius",50,1,100)); parameters.add(color.set("color",100,ofColor(0,0),255)); gui.setup(parameters); ofSetBackgroundColor(0); }
//-------------------------------------------------------------- void testApp::setup(){ ofSetBackgroundColor(255,255,255); ofSetVerticalSync(true); ofSetBackgroundAuto(true); bLoad = false; bPushLoad = false; bAnal = false; bPushAnal = false; bCreate = false; bPushCreate = false; bFileDone = false; bStartRgb = false; bImageMakePush = false; bImageMakeStart = false; pos = 0; imageCnt = 0; colorCnt = 0; folderPath = ""; chgColorNumStr = ""; imgWidth = 64; imgHeight = 48; wantColor = ofColor(255,255,255); wr = 255; wg = 255; wb = 255; }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetFrameRate(60); ofEnableAlphaBlending(); ofSetBackgroundColor(255, 240, 255); ofSetCircleResolution(10); int gridSize = 7; started = false; image.load("text.jpg"); for(float x=0;x<image.getWidth();x+=gridSize) { for(float y=0;y<image.getHeight();y+=gridSize){ ofColor color=image.getColor(x,y); if(color.getBrightness()>250 ){ Particle p; p.isActive = true; p.setup(ofVec2f(x ,y+ 200)); particles.push_back(p); } } } }
//-------------------------------------------------------------- void ofApp::setup(){ //Systemwide Settings ofEnableAlphaBlending(); ofSetVerticalSync(TRUE); ofSetBackgroundAuto(FALSE); ofSetFrameRate(60); // ofSetFullscreen(true); ofSetBackgroundColor(0, 0, 0); ofSetCircleResolution(128); isMousePressed = false; //number of birds initiation numBirds = 300; framesBetweenRecordedPosition = 3; frameCounter = 0; //create all my birds for(int i = 0; i < numBirds; i++){ Bird tempBird; //create a temp bird tempBird.setup(); //give it life myBirds.push_back(tempBird); //copy it and stick it in the vectory } //tempBird is no more //cursorAmp is the magnitude multiplier to the cursor attraction force it will approach an assymptote of cursorAmp = 1.0; ampAsymptote = 7.0; }
//-------------------------------------------------------------- void ofApp::setup(){ // 画面基本設定 ofSetFrameRate(60); //秒間60コマで描画 ofSetBackgroundColor(0); //背景色を黒に //数の上限を1000個に max_num = 1000; }
void ofApp::setup() { // lower frame rate to see console output ofSetFrameRate(1); ofSetBackgroundColor(0); // allocate memory for image mImage.allocate(600, 200, OF_IMAGE_COLOR_ALPHA); ofLog() << "image type: " << mImage.getPixels().getImageType() << " - num channels: " << mImage.getPixels().getNumChannels(); }
//-------------------------------------------------------------- void testApp::setup(){ ofSetBackgroundColor(0); bNeedsUpdate = true; // a housekeeping variable to respond to gui changes currentClipperType = OFX_CLIPPER_INTERSECTION; // the clip type currentClipperJoinType = OFX_CLIPPER_JOINTYPE_SQUARE; // for offsets, the joint type currentClipperEndType = OFX_CLIPPER_ENDTYPE_SQUARE; // for offsets, the joint type clipSubjectType = CIRCLES; // what kind of test subjects to create clipMaskType = CIRCLES; // what kind of test clip masks to create // gui setup clipTypePanel.setup("clipper","settings.xml", 10, 10); clipTypePanel.add(clipTypeSlider.setup("TYPE: INTERSECTION",0,0,3)); clipTypePanel.add(subjectTypeSlider.setup("SUBJ. POLYS: CIRCLES",0,0,2)); clipTypePanel.add(nClipSubjects.setup("# clip subjects",2,1,100)); clipTypePanel.add(maskTypeSlider.setup("CLIP POLYS: CIRCLES",0,0,2)); clipTypePanel.add(nClipMasks.setup("# clip masks ",1,1,100)); clipTypePanel.add(useMouseClipper.setup("Use Mouse Clip Mask", true)); useMouseClipper.addListener(this,&testApp::mouseClipper); clipTypeSlider.addListener(this,&testApp::clipType); maskTypeSlider.addListener(this,&testApp::maskPolyType); subjectTypeSlider.addListener(this,&testApp::subjectPolyType); // nClipMasks.addListener(this,&testApp::genMasks); // ! results in poco non viable overload, how to fix? // nClipSubjects.addListener(this,&testApp::genSubjects); // ! results in poco non viable overload, how to fix? offsetPanel.setup("offsets","settings.xml", 10, 200); offsetPanel.add(enableOffsetsToggle.setup("show offset", true)); offsetPanel.add(offsetDeltaSlider.setup("offset delta",20,-200,200)); offsetPanel.add(joinTypeSlider.setup("JOIN TYPE: SQUARE",0,0,2)); offsetPanel.add(endTypeSlider.setup("END TYPE: SQUARE",0,0,3)); offsetPanel.add(miterLimitSlider.setup("miter limit",2,0,30)); joinTypeSlider.addListener(this,&testApp::joinType); endTypeSlider.addListener(this,&testApp::endType); miterLimitSlider.addListener(this,&testApp::miterLimit); offsetDeltaSlider.addListener(this,&testApp::offsetDelta); simplifyPanel.setup("Simplify","settings.xml", ofGetWidth()-100,10); simplifyPanel.add(simplifyPath.setup("num vertices",10,3,40)); // simplifyPath.addListener(this,&testApp::genSimplifyPath); // ! results in poco non viable overload, how to fix? genSimplifyPath(simplifyPath); bSimplifyPathNeedsUpdate = true; // generate some initial data genSubjects(nClipSubjects); genMasks(nClipMasks); mclip = useMouseClipper; }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetBackgroundColor(ofColor::thistle); eX = ofGetWidth() / 2; eY = ofGetHeight() / 2; easing = 0.1; }
void Application::setup(){ if(!loadXmlSettings(PIMAPPER_USER_SURFACES_XML_FILE)){ ofLogWarning("Application::setup()") << "Failed to load user settings. Populated default one" << endl; } ofSetBackgroundColor(ofColor::black); ofEnableAntiAliasing(); ofSetFrameRate(25); ofHideCursor(); consoleListener.setup(this); _osc.setup(5250); ofAddListener(ofxOscEvent::packetIn, this, &Application::onPacketIn); }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetBackgroundColor(255); //Load the font for the graph font.load("verdana.ttf", 12, true, true); font.setLineHeight(14.0f); //Setup the plot plot1.setup( NUM_DIMENSIONS, "sine data"); plot1.setRanges( -1.0, 1.0, true ); }
ofApp::ofApp() : walker(ofPoint(ofGetWidth() / 2, ofGetHeight() / 2)) { ofSetBackgroundColor(ofColor::black); fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA); fbo.begin(); ofClear(255, 255, 255, 0); fbo.end(); std::srand(std::time(NULL)); }
//-------------------------------------------------------------- void testApp::setup(){ initData(); ofSetBackgroundColor(230, 230, 230); initUI(); //Initialize UI /* Finish with UI Kinect setting up*/ #ifndef __APPLE__ #ifndef __NO_KINECT__ initKinect(); #endif #endif ofSetFrameRate(60); }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetBackgroundColor(20); // setup the server to listen on 11999 TCP.setup(11999); receiveSize = 1024000; tcpBuffer.allocate(receiveSize); lastSent = 0; opcClient.setup("127.0.0.1", 7890); }
//-------------------------------------------------------------- void ofApp::setup() { ofSetBackgroundColor(0, 0, 0); devs = vid.listDevices(); windowS.x = ofGetWidth(); windowS.y = ofGetHeight(); wCenter = windowS / 2; }
//-------------------------------------------------------------- void testApp::draw() { ofSetBackgroundColor(255); int i = 0; for(Circle c : circles) { //ofCircle(c.pos.getPosition(), c.radius); ofSetColor(0); ofVec3f p = c.pos.getPosition(); ofTriangle(p + c.tri[0], p + c.tri[1], p + c.tri[2]); ofSetColor(255); ofDrawBitmapString(ofToString(i++), c.pos.getPosition()); } gui.draw(); }
void setup() { ofSetColor(255, 255, 255); ofSetBackgroundColor(0, 0, 0); receiver.setup(9005); receiver.addCallback("/test", [](ofxModernOscMessage &mess) { ofLogNotice("ofApp") << mess; }); receiver.addThreadCallback("/json", [](ofxModernOscMessage &mess) { return ofJson::parse(mess[0].get<std::string>()); }, [](ofJson::basic_json &&json) { ofLogNotice() << ofGetElapsedTimef() << ":" << json; }); }
//-------------------------------------------------------------- void testApp::setup(){ ofSetBackgroundColor(255); lastTimeUsed = 0; gameEndsAt = gameDuration; gameOver = 0; font.loadFont("MONACO.TTF", 32); bgImg.loadImage("george.jpg"); startGame(); ofSetCircleResolution(100); ofEnableAlphaBlending(); ofSetFrameRate(30); }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetBackgroundColor(0); ofSetFrameRate(30); // ofSetLogLevel(OF_LOG_VERBOSE); lastSecond = ofGetElapsedTimeMillis(); bDevicesInited = false; bTrackingEventsRegistered = false; bSendDepth = true; if (device.setup()) { ofLogNotice() << "device inited"; bDevicesInited = true; } else { ofLogError() << "device NOT inited"; } try { if (bDevicesInited && tracker.setup(device)) { ofLogNotice() << "tracker inited"; ofAddListener(tracker.newUser, this, &ofApp::onTrackerNewUser); ofAddListener(tracker.lostUser, this, &ofApp::onTrackerLostUser); bTrackingEventsRegistered = true; } else { ofLogError() << "tracker NOT inited"; } } catch(std::runtime_error) { ofLogError() << "tracker NOT inited"; } // try { // if(depth.setup(*device)){ // depth.setSize(320, 240); // depth.setFps(30); // depth.start(); // } // } catch (std::runtime_error err) { // ofLogError() << "depth NOT inited"; // } niStreamer.registerEvents(this); }
void nebulaEye::setup() { sender.setup(OSC_IP, OSC_PORT); receiver.setup(OSC_LISTENING_PORT); video.setup(); flow.setup(); bgSub.setup(); contour.setup(); zone.setup(); pix_share.setup("/video_server"); displayGuiGrp.setName("display"); displayGuiGrp.add(showGui.set("show this menu",true)); displayGuiGrp.add(showVideo.set("show video",true)); displayGuiGrp.add(showBgSub.set("show bgsub",true)); displayGuiGrp.add(bgSubIntensity.set("bg intensity",127,0,255)); displayGuiGrp.add(showContour.set("show contour",true)); displayGuiGrp.add(showFlow.set("show motion flow",true)); displayGuiGrp.add(showZone.set("show zone",true)); displayGuiGrp.add(showDebug.set("debug",0,0,5)); displayGuiGrp.add(mouseTest.set("mouse blob simulation",false)); gui.setup("nebula-eye","settings.xml",660,10); gui.add(displayGuiGrp); gui.add(video.guiGrp); gui.add(bgSub.guiGrp); gui.add(flow.guiGrp); gui.add(contour.guiGrp); gui.add(zone.guiGrp); parameterSync.setup((ofParameterGroup&)gui.getParameter(),6667,"localhost",6666); recordPanel.setup("record", "recordSetting.xml",10, ofGetHeight()-50); recordPanel.add(record.set("recording",false)); ofAddListener(gui.savePressedE, &bgSub, &nebulaBackground::saveAlgoParam); showGui.addListener(&bgSub, &nebulaBackground::showGui); showZone.addListener(&zone, &nebula::Zone::attach); record.addListener(this, &nebulaEye::csvRecordCb); mouseTest.addListener(this, &nebulaEye::clearTestImg); gui.loadFromFile("settings.xml"); ofSetCircleResolution(100); ofSetBackgroundColor(0,0,0,0); }
//-------------------------------------------------------------- void ofApp::setup(){ // allocate numVertices without setting them, the vertex // shader will fill the positions and colors ofMesh mesh; mesh.setMode(OF_PRIMITIVE_POINTS); mesh.getVertices().resize(numVertices); ofSetBackgroundColor(0); // We only need a vertex shader since we are only using the // shader to store the modified vertices in a buffer ofShader::TransformFeedbackSettings settings; settings.shaderFiles[GL_VERTEX_SHADER] = "vert.glsl"; settings.bindDefaults = false; settings.varyingsToCapture = { "v_position", "v_color" }; ofShader shader; shader.setup(settings); // allocate enough space for all the vertices in a gpu buffer buffer.allocate(sizeof(glm::vec4) * 2 * numVertices, GL_STATIC_DRAW); // bind the full buffer using glBindBaseBuffer to default index 0 // and draw the mesh which will end up stored in our buffer shader.beginTransformFeedback(GL_POINTS, buffer); shader.setUniform1i("numVertices", numVertices); mesh.draw(); shader.endTransformFeedback(buffer); // more fine grained control with range bindings: // ofShader::TransformFeedbackRangeBinding binding(buffer); // binding.index = 0; // binding.offset = 0; // binding.size = numVertices * sizeof(glm::vec4) * 2; // shader.beginTransformFeedback(GL_POINTS, binding); // now set the buffer as vertices and colors in the vbo // by specifying the stride and offsets // since we have position and color both as 4 coordinates: // 4 coordinates position at offset 0 vbo.setVertexBuffer(buffer, 4, sizeof(glm::vec4) * 2, 0); // color at offset sizeof(glm::vec4) vbo.setColorBuffer(buffer, sizeof(glm::vec4) * 2, sizeof(glm::vec4)); ofEnablePointSprites(); glPointSize(4); cam.setDistance(2400); }
//-------------------------------------------------------------- void ofApp::setup(){ //we run at 60 fps! ofSetVerticalSync(true); ofSetFrameRate(60); ofEnableAntiAliasing(); //create the socket and bind to port 11999 ofxUDPSettings settings; settings.receiveOn(11999); settings.blocking = false; udpConnection.Setup(settings); ofSetBackgroundAuto(false); ofSetBackgroundColor(255); }
//-------------------------------------------------------------- void ofApp::setup(){ //gamestate GameStart=true; //font Font.loadFont("Comenia Sans.otf", 18); //image target.loadImage("target.jpg"); //sound backgroundSound.loadSound("background.mp3"); backgroundSound.setLoop(true); //setup Balls; for(int i=0; i<maxPoints; i++){ Mover *c = new Mover(); player.push_back(*c); } //background ofBackground(30,30,30); ofSetBackgroundColor(255); //points points=0; //rect size rectSize=40; //set color; ofSetColor(255); ofSetVerticalSync(true); ofSetCircleResolution(200); //make the connection myArduino.connect("COM4",57600); //to see if the arduino has been setup. bSetupArduino = false; counter = 500; //target location Target=ofPoint(ofRandom(20,ofGetWidth()-20), ofRandom(20,ofGetHeight()-20)); //playsound backgroundSound.play(); }
//-------------------------------------------------------------- void ofApp::draw(){ if(startscreen){ ofSetBackgroundColor(ofColor::green); ofSetColor(ofColor::black); myfont.drawString("PRESS P TO START", 100, 300); } ofSetColor(ofColor::black); for(int i=0;i<w;i++) ofLine(i*bs,0,i*bs,ofGetHeight()); for(int i=0;i<h;i++) ofLine(0,i*bs,ofGetWidth(),i*bs); ofSetColor(ofColor::green); for(int i = 0; i < x.size(); i++) { ofRect(x.get_at(i)*bs,y.get_at(i)*bs,bs,bs); } ofSetColor(ofColor::red); ofRect(applex*bs,appley*bs,bs,bs); if(!gameover&&!startscreen) { if(ofGetFrameNum()%5==0) { x.insert_at(0, x.get_at(0) + dx[dir]); y.insert_at(0, y.get_at(0) + dy[dir]); if(x.get_at(0) < 0 || y.get_at(0) < 0 || x.get_at(0) >= w || y.get_at(0) >= h){ gameover=true; } for(int i = 1; i < x.size(); i++){ if(x.get_at(0) == x.get_at(i) && y.get_at(0) == y.get_at(i)) gameover=true; } if(x.get_at(0)==applex&&y.get_at(0)==appley){ applex=(int)ofRandom(20); appley=(int)ofRandom(20); } else{ x.delete_at(x.size()-1); y.delete_at(y.size()-1); } } } if(gameover){ ofSetColor(ofColor::black); myfont.drawString("GAMEOVER", 100, 300); myfont.drawString("PRESS SPACE TO RESTART", 25, 400); } }
Application::Application(){ playerName = "defaultPlayer"; ofSetBackgroundColor(ofColor::black); _surfaceManager.setMediaServer(&_mediaServer); _gui.setMediaServer(&_mediaServer); _gui.setCmdManager(&_cmdManager); _gui.setSurfaceManager(&_surfaceManager); setState(PresentationState::instance()); ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed); ofAddListener(ofEvents().keyReleased, this, &Application::onKeyReleased); ofAddListener(ofEvents().mousePressed, this, &Application::onMousePressed); ofAddListener(Gui::instance()->jointPressedEvent, this, &Application::onJointPressed); ofAddListener(Gui::instance()->surfacePressedEvent, this, &Application::onSurfacePressed); ofAddListener(Gui::instance()->backgroundPressedEvent, this, &Application::onBackgroundPressed); }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetBackgroundColor(230); // our send and recieve strings msgTx = ""; msgRx = ""; // connect to the server - if this fails or disconnects // we'll check every few seconds to see if the server exists tcpClient.setup("127.0.0.1", 11999); // optionally set the delimiter to something else. The delimiter in the client and the server have to be the same tcpClient.setMessageDelimiter("\n"); connectTime = 0; deltaTime = 0; }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetBackgroundColor(0); matrices.resize(3000); // upload the transformation for each box using a // texture buffer. // for that we need to upload the matrices to the buffer // and allocate the texture using it buffer.allocate(); buffer.bind(GL_TEXTURE_BUFFER); buffer.setData(matrices,GL_STREAM_DRAW); // using GL_RGBA32F allows to read each row of each matrix // as a float vec4 from the shader. // Note that we're allocating the texture as a Buffer Texture: // https://www.opengl.org/wiki/Buffer_Texture tex.allocateAsBufferTexture(buffer,GL_RGBA32F); // now we bind the texture to the shader as a uniform // so we can read the texture buffer from it shader.load("vert.glsl","frag.glsl"); shader.begin(); shader.setUniformTexture("tex",tex,0); shader.end(); // we are going to use instanced drawing so we // only need one geometry mesh = ofMesh::box(50,50,50,1,1,1); mesh.setUsage(GL_STATIC_DRAW); // we want each box to have a different color so let's add // as many colors as boxes mesh.getColors().resize(matrices.size()); for(int i=0;i<mesh.getColors().size();i++){ mesh.getColors()[i] = ofColor::fromHsb(i % 255, 255, 255); } // then we tell the vbo that colors should be used per instance by using // ofVbo::setAttributeDivisor mesh.getVbo().setAttributeDivisor(ofShader::COLOR_ATTRIBUTE,1); // lots of boxes, let's move the camera backwards camera.setDistance(ofGetWidth()*6); camera.setFarClip(ofGetWidth()*12); }