//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(255); ofEnableAntiAliasing(); ofEnableSmoothing(); ofSetFrameRate(60); ofEnableDepthTest(); // enable depth test for correctly drawing 3D shapes bResample = true; resampleSpacing = 5.0; letterThickness = 50.0; ofTrueTypeFont ttf; // to extract points, loadFont must be called with makeContours set to true ttf.loadFont(OF_TTF_SANS, 300, true, false, true); string s = "TYPE"; // Center string code from: // https://github.com/armadillu/ofxCenteredTrueTypeFont/blob/master/src/ofxCenteredTrueTypeFont.h ofRectangle r = ttf.getStringBoundingBox(s, 0, 0); center = ofVec2f(floor(-r.x - r.width * 0.5f), floor(-r.y - r.height * 0.5f)); vector <ofTTFCharacter> letters = ttf.getStringAsPoints(s); for(int i = 0; i < letters.size(); i++){ ofPath resampledPath = bResample ? resamplePath(letters[i], resampleSpacing) : letters[i]; ofMesh meshLetter = createMeshFromPath(resampledPath, letterThickness); mesh.append(meshLetter); } colorFaces(mesh); // adhere easycam view to openFrameworks coordinate system cam.setVFlip(true); }
//////////////////////////////////////// // setup //////////////////////////////////////// void ofApp::setup() { //---------------------------------------- ofxTokyo2020 fontSize = 60.0; // set font size ofxTokyo2020::setFontSize( fontSize ); // set letter spacing ofxTokyo2020::setLetterSpacing( fontSize / 3 ); // set line height ofxTokyo2020::setLineHeight( ( fontSize / 3 ) * 4 ); str = "ofxtokyo2020"; bCell = true; bWaitPrevious = false; font.setString( str, fontSize, ofGetHeight() * 0.5, ( bCell ) ? ANIMATION_TYPE_CELL: ANIMATION_TYPE_EASING, bWaitPrevious ); //---------------------------------------- application settings ofSetVerticalSync( true ); ofEnableAntiAliasing(); ofSetCircleResolution( 48 ); ofBackground( 255 ); }
//-------------------------------------------------------------- void ofApp::setup(){ saveOneFrame = false; // variable used to save a single frame as a PDF page bg_color = ofColor(255); fbo_color = ofColor(0); ofBackground(bg_color); ofEnableAntiAliasing(); ofEnableSmoothing(); ofSetFrameRate(60); ofTrueTypeFont ttf; ttf.loadFont(OF_TTF_SANS, 350); string s = "TYPE"; ofFbo fbo; fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA); pix.allocate(ofGetWidth(), ofGetHeight(), OF_PIXELS_RGBA); fbo.begin(); ofClear(0, 0, 0, 0); // Center string code from: // https://github.com/armadillu/ofxCenteredTrueTypeFont/blob/master/src/ofxCenteredTrueTypeFont.h ofRectangle r = ttf.getStringBoundingBox(s, 0, 0); ofVec2f offset = ofVec2f(floor(-r.x - r.width * 0.5f), floor(-r.y - r.height * 0.5f)); ofSetColor(fbo_color); ttf.drawString(s, fbo.getWidth() / 2 + offset.x, fbo.getHeight() / 2 + offset.y); fbo.end(); fbo.readToPixels(pix); // the ofPixels class has a convenient getColor() method }
//-------------------------------------------------------------- void testApp::setup(){ ofEnableAntiAliasing(); ofSetVerticalSync( true ); ofSetFrameRate( 30 ); #ifdef DISABLE_STREAMING cout << "Disabled streaming: compile with 'Release' to enable" << endl; #else cout << "Enabled streaming: compile with 'Release NoStream' to disable" << endl; #endif videoFeedController.init(); overlay.init(); #ifndef DISABLE_STREAMING // MULTI STREAMER // -------------------------------------------------- int fps = 15; if(!streamer.setup("streamer.xml", ofGetWidth(), ofGetHeight(), fps)) { printf("error: cannot setup the streamer.\n"); ::exit(EXIT_FAILURE); } if(!streamer.start()) { printf("error: cannot start the streamer.\n"); ::exit(EXIT_FAILURE); } sound_stream.listDevices(); sound_stream.setup(this, 0, 2, 44100, 1024, 4); #endif }
/// \brief The standard setup function. void setup() { // Set the background to zero / black. ofBackground(0); // Enable alpha blending. ofEnableAlphaBlending(); // Enable anti-aliasing. ofEnableAntiAliasing(); // Set the size of the window. ofSetWindowShape(1000, 1000); // Enable depth tests to ensure that correct 3D rendering. ofEnableDepthTest(); // The size of the box in the x, y and z dimension. boxSize = ofPoint(600, 600, 300); // Create particles. for (int i = 0; i < 100; i++) { // Create a half-sized box for calculations. ofPoint halfBoxSize = boxSize / 2; // Instantiate our base particle. std::shared_ptr<BaseParticle> aParticle = std::shared_ptr<BaseParticle>(new BaseParticle()); // Set the initial position to a random point inside our bounding box. aParticle->position = ofPoint(ofRandom(-halfBoxSize.x, halfBoxSize.x), ofRandom(-halfBoxSize.y, halfBoxSize.y), ofRandom(-halfBoxSize.z, halfBoxSize.z)); // Set a random velocity. aParticle->velocity = ofPoint(ofRandom(-10, 10), ofRandom(-10, 10), ofRandom(-10, 10)); // Set a random drag. float drag = ofRandom(0.9, 0.99); // Our drag is the same in the x, y and z directions. aParticle->drag = ofPoint(drag, drag, drag); // Create a random size for our particle. float size = 3; // Our particle size is the same in the x, y and z directions. aParticle->size = ofPoint(size, size, size); // Assign a random color to the particle. aParticle->color = ofColor(255, 127); // Add the particle to our collection. particles.push_back(aParticle); } }
void ofApp::setupVisual(){ cout << "setting up Visual" << endl; ofSetFrameRate(60); ofSetVerticalSync(true); ofSetCircleResolution(10); ofDisableAlphaBlending(); ofEnableAntiAliasing(); ofDisableSmoothing(); }
//-------------------------------------------------------------- void ofApp::keyPressed (int key){ if (key == 's'){ bSmooth = !bSmooth; if (bSmooth){ ofEnableAntiAliasing(); }else{ ofDisableAntiAliasing(); } } }
//-------------------------------------------------------------- void ofApp::keyPressed (int key){ // the key of s toggles antialiasing if (key == 's'){ bSmooth = !bSmooth; if (bSmooth){ ofEnableAntiAliasing(); }else{ ofDisableAntiAliasing(); } } }
void testApp::draw() { ofEnableAlphaBlending(); ofEnableDepthTest(); ofEnableAntiAliasing(); cam.begin(); ofPushMatrix(); double amp = rms() * 450; if (amp > 50) { float spectral_centroid = mfft.spectralCentroid(); int resolution = (int) floor(spectral_centroid / 20000.f * 64); mesh = createGeoSphere(resolution, resolution); ofVec3f center = mesh.getCentroid(); ofDrawBox(center.x, center.y, 0, 1, amp * 8, 1); ofDrawBox(center.x, center.y, 0, amp * 8, 1, 1); ofDrawBox(center.x, center.y, 0, 1, 1, amp * 8); ofNoFill(); ofCircle(center.x, center.y, amp); ofCircle(center.x, center.y, amp * 2); ofCircle(center.x, center.y, amp * 3); ofScale(amp, amp, amp); if (spectral_centroid > 0.4) { position = (int) ofRandom(mesh.getNumVertices()); } for (int i = 0; i < moct.nAverages; i++) { if (moct.averages[i] < 20) { continue; } position += (int) floor(mfft.spectralFlatness() * 20) + 1; position %= mesh.getNumVertices(); int vertex = position; float offsetDistance = moct.averages[i] * 0.02; ofVec3f p0 = mesh.getVertex(vertex); ofVec3f normal = center - p0; normal.normalize(); p0 -= (normal * (offsetDistance * 0.5)); mesh.setVertex(vertex, p0); } mesh.drawWireframe(); } ofPopMatrix(); cam.end(); ofDrawBitmapString(ofToString((int) ofGetFrameRate()) + " fps", 32, 32); }
//------------------------------------------------------------------------------ void ofApp::setup() { ofEnableAntiAliasing(); ofEnableSmoothing(); ofSetFrameRate(60); glEnable(GL_DEPTH_TEST); particleEmitter = new MeshParticleEmitter(10, 100.0f, 2.0f); light.setPointLight(); light.setPosition(0,0,0); }
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(){ // // // string hostname = ofxNet::NetworkUtils::getNodeName(); #ifdef _DEBUG printf("hostname: %s\n", hostname.c_str()); #endif // // // ofSetBackgroundAuto(false); ofEnableAntiAliasing(); ofSetCircleResolution( 24 ); //m_default_font.loadFont("fonts/verdana.ttf",false,0.3, 144.0); m_default_font.setup("fonts/verdana.ttf"); m_buttons[0].loadImage("ui/PhotoCollection.png"); m_buttons[1].loadImage("ui/BusinessModel.png"); m_buttons[2].loadImage("ui/Save.png"); m_buttons[3].loadImage("ui/Close.png"); ofDisableArbTex(); m_background_tile.loadImage("ui/background_tile.png"); m_background_tile.getTextureReference().setTextureWrap(GL_REPEAT, GL_REPEAT); ofEnableArbTex(); layout(); // // // m_db.setup(); vector< openTableDocument* > sessions = m_db.getDocumentsOfType("session"); if (sessions.size() > 0 ) { m_current_session = ( openTableSession* ) sessions[ 0 ]; } else { m_current_session = ( openTableSession* ) m_db.add("session"); m_db.save(); } // // start server // m_server.setup(); // // // m_show_keyboard = false; if ( !m_multitouch.setup() ) { ofShowCursor(); } }
//-------------------------------------------------------------- void ofApp::draw(){ if(drawGui || mouseMode) ofShowCursor(); else ofHideCursor(); ofEnableAntiAliasing(); ofBackground(0); ofEnableBlendMode(OF_BLENDMODE_ADD); // draw rays for(auto& ray: rays){ if(!ray.isDead()){ ray.draw(); } } // draw prism prism->draw(); // draw the fingers for (auto& f : finger){ f.draw(); } // draw spread display ofPushStyle(); ofPushMatrix(); ofTranslate(0, 500); ofSetLineWidth(2); spreadCircle.draw(ofGetWidth()/2 - spreadCircle.getWidth()/2, 50); ofVec2f v(-1, 0); v.rotate(spread/2.0 * 180); v.normalize(); ofPoint c(ofGetWidth()/2, 89.25); ofSetColor(255); ofDrawLine(c + 10 * v, c + v * 45); ofRectangle bounds = tstar.getStringBoundingBox(ofToString(spread.get(), 1), 0, 0); tstar.drawString(ofToString(spread.get(), 1), (c + v * 60).x - (bounds.getWidth()/2.0), (c + v * 60).y + (bounds.getHeight()/2.0)); ofPopMatrix(); ofPopStyle(); syphonMainOut.publishScreen(); // draw debug stuff if(drawGui){ gui.draw(); ofSetColor(255); ofDrawBitmapString(ofGetFrameRate(), 5, ofGetHeight() - 25); ofDrawBitmapString(rays.size(), 5, ofGetHeight()-10); } }
//-------------------------------------------------------------- void testApp::setup(){ ofEnableAntiAliasing(); ofSetFrameRate(15); for (int i=0; i<NUMOFBOIDS; i++) { boids.push_back(Boid()); } sender.setup("127.0.0.1", 6666); //old OF default is 96 - but this results in fonts looking larger than in other programs. ofTrueTypeFont::setGlobalDpi(72); verdana14.loadFont("verdana.ttf", 14, true, true); verdana14.setLineHeight(18.0f); verdana14.setLetterSpacing(1.037); }
//-------------------------------------------------------------- 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 testApp::setup() { // [P] println("hello ITP"); cout << "hello ITP" << endl; // [P] smooth(); ofEnableAntiAliasing(); ofSetCircleResolution(50); rad = 50; // center of your window posX = ofGetWidth()/2; posY = ofGetHeight()/2; speedX = 5; speedY = 5; }
void Button::draw() { ofColor backgroundColor; ofColor textColor; switch (state) { case BUTTON_STATE_DISABLED: backgroundColor = disabledColor; textColor = ofColor(100); break; case BUTTON_STATE_IDLE: backgroundColor = idleColor; textColor = ofColor(255); break; case BUTTON_STATE_HOVER: backgroundColor = hoverColor; textColor = ofColor(255); break; case BUTTON_STATE_PRESSED: case BUTTON_STATE_CLICKED: backgroundColor = pressedColor; textColor = ofColor(255); break; } ofDisableAntiAliasing(); // Background ofSetColor(backgroundColor); ofRect(displayX + colorBorder + 1, displayY + colorBorder, displayWidth - (colorBorder + 4), displayHeight - (colorBorder + 3)); // Borders ofSetColor(borderColor); ofLine(displayX, displayY, displayX + displayWidth, displayY); // Top ofLine(displayX, displayY + displayHeight, displayX + displayWidth, displayY + displayHeight); // Bottom ofLine(displayX + 1, displayY, displayX + 1, displayY + displayHeight); // Left ofLine(displayX + displayWidth, displayY, displayX + displayWidth, displayY + displayHeight); // Right // Text ofEnableAntiAliasing(); ofSetColor(textColor); font.drawString(text, textX, textY); }
//-------------------------------------------------------------- void ofApp::setup(){ ofEnableAntiAliasing(); ofEnableSmoothing(); ofEnableDepthTest(); bResample = true; resampleSpacing = 5.0; letterThickness = 145.0; ofTrueTypeFont ttf; // to extract points, loadFont must be called with makeContours set to true ttf.loadFont(OF_TTF_SANS, 300, true, false, true); string s = "TYPE"; // Center string code from: // https://github.com/armadillu/ofxCenteredTrueTypeFont/blob/master/src/ofxCenteredTrueTypeFont.h ofRectangle r = ttf.getStringBoundingBox(s, 0, 0); center = ofVec2f(floor(-r.x - r.width * 0.5f), floor(-r.y - r.height * 0.5f)); vector <ofTTFCharacter> letters = ttf.getStringAsPoints(s); for(int i = 0; i < letters.size(); i++){ ofPath resampledPath = bResample ? resamplePath(letters[i], resampleSpacing) : letters[i]; ofMesh meshLetter = createMeshFromPath(resampledPath, letterThickness); mesh.append(meshLetter); } getBoundaries(mesh); numSpheres = 7000; // the maximum number of Spheres addSpeed = 25; // the number of Spheres that is added per update() loop ofEnableLighting(); ofSetGlobalAmbientColor(ofColor(128)); directionalLight.setDiffuseColor(ofColor(128)); directionalLight.setPosition(boundsMax); directionalLight.enable(); cam.setVFlip(true); }
//-------------------------------------------------------------- void ofApp::setup() { fg_color = ofColor(0); bg_color = ofColor(255); fbo_color = ofColor(0); ofBackground(bg_color); ofSetBackgroundAuto(false); ofEnableAntiAliasing(); ofSetFrameRate(60); ofTrueTypeFont ttf; ttf.loadFont(OF_TTF_SANS, 350); string s = "TYPE"; ofFbo fbo; ofPixels pix; fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA); pix.allocate(ofGetWidth(), ofGetHeight(), OF_PIXELS_RGBA); fbo.begin(); ofClear(0, 0, 0, 0); // Center string code from: // https://github.com/armadillu/ofxCenteredTrueTypeFont/blob/master/src/ofxCenteredTrueTypeFont.h ofRectangle r = ttf.getStringBoundingBox(s, 0, 0); ofVec2f offset = ofVec2f(floor(-r.x - r.width * 0.5f), floor(-r.y - r.height * 0.5f)); ofSetColor(fbo_color); ttf.drawString(s, fbo.getWidth() / 2 + offset.x, fbo.getHeight() / 2 + offset.y); fbo.end(); fbo.readToPixels(pix); // get the fbo's ofPixels object (to set the division rates in the RD class) int w = 320; int h = 180; // setup the reaction-diffusion simulation rd.setup(w, h); // setup the simulation with the specified width and height rd.setFeedRates(0.0374, 0.0585); // set the in & out feed rates (in this sketch also dynamically changed in the update() loop) rd.setKillRates(0.0695, 0.0610); // set the in & out kill rates rd.kickstart(150); // randomly set N substance values to kickstart the simulation rd.setImage(pix); // use the ofPixels object of the offscreen fbo to set the division rates // setup the result image with the same dimensions as the simulation result.allocate(w, h, OF_IMAGE_COLOR); }
void Patch::draw() { if (isMouseOver()) { hover = true; } else { hover = false; } ofPushStyle(); ofSetColor(150.0f); ofEnableSmoothing(); ofEnableAntiAliasing(); ofSetLineWidth(2.0f); if (port_connect) { ofLine(line_start, ofPoint(ofGetMouseX(), ofGetMouseY())); } // also draw all connections for (int i = 0; i < connections.size(); i++) { ofLine(connections[i]->from->cp, connections[i]->to->cp); } ofPopStyle(); switch (type) { case PATCH: drawPatch(); break; case UI_BUTTON: drawButton(); break; case UI_FIXED_BUTTON: drawFixedButton(); break; }; }
void lineScene::draw(float x, float y, float scale){ // if ( oni->isSkeleton() ) { ofEnableAntiAliasing(); // ofEnableAlphaBlending(); // ofBackground(bgColor); ofSetColor(lineColor); ofPushMatrix(); ofTranslate(x, y); ofTranslate(160, 120); ofScale(scale, scale); ofTranslate(-160, -120); ofScale(0.5, 0.5); if ( bDrawMoire) drawMoire(); if ( bDrawBody ) drawBodyLines(); ofPopMatrix(); // ofDisableAlphaBlending(); ofDisableAntiAliasing(); // } }
//-------------------------------------------------------------- void ofApp::setup(){ ofEnableSmoothing(); ofEnableAlphaBlending(); ofEnableAntiAliasing(); ofSetFrameRate(30); string imgPath = "Serviette.png"; string exportPath = "export2.tiff"; int maGamme[]={0xcccccc,0xc950e3,0xefff1a,0x36af1c,0x0000ff,0xff0000}; carton.setColorRange(6,maGamme); carton.analyseImg(); carton.setup(imgPath); carton.addWeaveToColor(0, myWeave.fondGris); carton.addWeaveToColor(1, myWeave.fondJaune); carton.addWeaveToColor(2, myWeave.dessinSurGris); carton.addWeaveToColor(3, myWeave.dessinSurJaune); carton.addWeaveToColor(4, myWeave.empty); carton.addWeaveToColor(5, myWeave.full); carton.showColorRange(true); carton.setCardScale(2, 3); carton.makeCard(); carton.exportcard(exportPath); }
//-------------------------------------------------------------- void ofApp::setup() { #ifdef DEBUG #else ofSetDataPathRoot("../Resources/data"); #endif ofBackground(0,0); ofSetFrameRate(60); ofEnableAntiAliasing(); ofEnableDepthTest(); ofEnableAlphaBlending(); ofEnableBlendMode(OF_BLENDMODE_ADD); // glPointSize(1); // glLineWidth(4); cam.setAutoDistance(false); cam.setDistance(700); posSize.x = 4000; posSize.y = 4000; fbo.allocate(posSize.x, posSize.y, GL_RGBA); ofDisableArbTex(); texture.load("pluto.jpg"); texture.getTexture().setTextureWrap( GL_REPEAT, GL_REPEAT ); sphere.setMode( OF_PRIMITIVE_TRIANGLES ); baseColor = ofColor(255, 180); mesh.setMode(OF_PRIMITIVE_LINES); darkMesh.setMode(OF_PRIMITIVE_TRIANGLES); baseLunar.setMode(OF_PRIMITIVE_TRIANGLES); allMesh.setMode(OF_PRIMITIVE_LINES); creatorNum = 1500; lineAlpha = 80; baseColor = ofColor(255, lineAlpha); ofAddListener(ofEvents().mouseReleased, this, &ofApp::guiMouseReleased, OF_EVENT_ORDER_BEFORE_APP); gui.setup(); gui.add(hideGui.setup("h key GUI Menu OnOff", "")); gui.add(fullScreenOnOff.setup("f key Full Screen", "")); gui.add(numCreators.setup("Num Creators", creatorNum, 0, 4500)); gui.add(randomHeight.setup("Random Height", 0.025, 0, 0.05)); gui.add(lineAlpha.setup("Line Alpha", 80, 0, 255)); gui.add(meshOnOff.setup("Default Draw", true)); gui.add(lineOnOff.setup("Normal Line", true)); gui.add(creatorOnOff.setup("Creator", true)); gui.add(darkPlane.setup("Dark Plane", false)); gui.add(arcOnOff.setup("Arc Draw", false)); gui.add(innerCircle.setup("Base Sphere", true)); gui.add(textureOnOff.setup("Texture", false)); gui.add(innerCircleSize.setup("Inner Size", 0.95, 0.9, 1.1)); gui.add(frameRate.setup("FPS", "")); gui.add(screenCapture.setup("Screen Capture")); // setPoint3D(creatorNum); polarPositionProb(); creatorSetting(); fullScreen = false; bHide = true; innerCircle = false; // light.setAttenuation(); // light.setPosition(-100, 100, 100); inLineAlpha = false; inNumCreators = false; inRandomHeight = false; }
//-------------------------------------------------------------- void cyrilApp::setup(){ doResetTimers = true; ofSoundStreamSetup(0, 1, this, 44100, beat.getBufferSize(), 4); // Switch back to external data folder ofSetDataPathRoot("../../../data/"); ofBackground(0); pauseProg = false; //lightsOn = true; lightsOn = true; isOrtho = false; fxOn = true; runningProg = false; running[0] = false; running[1] = false; running[2] = false; running[3] = false; running[4] = false; running[5] = false; running[6] = false; running[7] = false; running[8] = false; running[9] = false; error[0] = false; error[1] = false; error[2] = false; error[3] = false; error[4] = false; error[5] = false; error[6] = false; error[7] = false; error[8] = false; error[9] = false; #ifdef FULL_DEBUG ofSetLogLevel("ofxGLEditor", OF_LOG_VERBOSE); #endif editor.addCommand('z', this, &cyrilApp::toggleFx); editor.addCommand('f', this, &cyrilApp::toggleFullscreen); editor.addCommand('a', this, &cyrilApp::toggleEditor); editor.addCommand('d', this, &cyrilApp::toggleBackground); editor.addCommand('k', this, &cyrilApp::toggleLights); editor.addCommand('l', this, &cyrilApp::loadFile); editor.addCommand('s', this, &cyrilApp::saveFile); editor.addCommand('e', this, &cyrilApp::resetTimers); editor.addCommand('p', this, &cyrilApp::pauseProgram); editor.addCommand('r', this, &cyrilApp::runScript); editor.addCommand('o', this, &cyrilApp::toggleOrtho); editorVisible = true; lastSignalReport = -1; // Init evaluation stack to empty _state.stk = new stack<float>; // Initialise our own matrix stack // TODO: replace with call to get from current renderer? _state.ms = new ofMatrixStack(*ofGetWindowPtr()); // Initialise empty paticle system _state.ps = new vector<Particle*>; // Initialise empty variable/register map _state.sym = new map<int, float>; // Initialise palettes _state.cs = new map<int, Palette *>; // Initialise sprites _state.img = new map<int, ofImage *>; _state.parent = NULL; _state.light = new ofLight(); //_state.light = NULL; // Directory watcher for data folder codeWatcher.registerAllEvents(this); spriteWatcher.registerAllEvents(this); codeWatcher.addPath(ofToDataPath("code", true), true, &fileFilter); spriteWatcher.addPath(ofToDataPath("sprites", true), true, &fileFilter); (*_state.sym)[REG_X_MAX] = 640; (*_state.sym)[REG_Y_MAX] = 480; (*_state.sym)[REG_X_MID] = (*_state.sym)[REG_X_MAX] / 2.0; (*_state.sym)[REG_Y_MID] = (*_state.sym)[REG_Y_MAX] / 2.0; (*_state.sym)[REG_X_SCALE] = 100; (*_state.sym)[REG_Y_SCALE] = 100; (*_state.sym)[REG_Z_SCALE] = 100; (*_state.sym)[REG_PI] = PI; (*_state.sym)[REG_TWO_PI] = TWO_PI; (*_state.sym)[REG_PARTICLE_HEALTH] = 1; (*_state.sym)[REG_PARTICLE_DECAY] = 0.1; // Reserve some space for Particle System _state.ps->reserve(2000); // Global settings ofEnableDepthTest(); ofSetVerticalSync(true); if (lightsOn) { ofEnableLighting(); _state.light->setAmbientColor(ofColor(0,0,0)); _state.light->setDiffuseColor(ofColor(255,255,255)); _state.light->setSpecularColor(ofColor(255,255,255)); _state.light->setPointLight(); _state.light->setAttenuation(1.f,0.f,0.f); } autoClearBg = true; ofSetBackgroundAuto(true); // changed this... cursorVisible = true; //ofHideCursor(); #ifdef __APPLE__ //CGDisplayHideCursor(NULL); // <- OK #endif (*_state.sym)[REG_FRAME] = 0; edBuf.allocate(); edBuf.begin(); ofClear(0,0,0,0); edBuf.end(); ofEnableAlphaBlending(); ofEnableAntiAliasing(); ofEnableSmoothing(); isFullScreen = false; //ofSetFullscreen(true); //mainOutputSyphonServer.setName("Cyril Main Output"); //mClient.setup(); //mClient.set("","Cyril Server"); // listen on the given port //cout << "listening for osc messages on port " << PORT << endl; //receiver.setup(PORT); // Configure the ofxPostProcessing effects _state.post = ofxPostProcessing(); _state.post.init(ofGetWidth(), ofGetHeight()); _state.post.setFlip(false); _state.kaleido = _state.post.createPass<KaleidoscopePass>(); _state.noisewarp = _state.post.createPass<NoiseWarpPass>(); _state.pixelate = _state.post.createPass<PixelatePass>(); _state.bloom = _state.post.createPass<BloomPass>(); }
void ofApp::setup() { ofEnableSmoothing(); ofEnableAlphaBlending(); ofSetFrameRate(60); ofSetVerticalSync(true); ofEnableDepthTest(); ofEnableAntiAliasing(); memset( dmxData_, 0, DMX_DATA_LENGTH ); //open the device dmxInterface_ = ofxGenericDmx::createDevice(DmxDevice::DMX_DEVICE_RAW); bool opened = dmxInterface_->open(); if ( dmxInterface_ == 0 || !opened ) { printf( "No FTDI Device Found\n" ); } else { printf( "isOpen: %i\n", dmxInterface_->isOpen() ); } printf("ofxGenericDmx addon version: %s.%s\n", ofxGenericDmx::VERSION_MAJOR, ofxGenericDmx::VERSION_MINOR); std::string file = "Lightweave_loops2.json"; std::string columnsFile = "Lightweave_columns2.json"; std::string facesFile = "Lightweave_faces2.json"; bool parsingSuccessful = result.open(file); bool parsingSuccessfulColumn = columnGeometry.open(columnsFile); bool parsingSuccessfulFaces = faceGeometry.open(facesFile); for (int region = 0; region < 6; region++) { string blah = "region" + ofToString(region); for (int rings = 0; rings < result[blah].size(); rings++) { string ring = "ring" + ofToString(rings); for (int pointPos = 0; pointPos < 3; pointPos++) { string point = "point" + ofToString(pointPos); } } } //setupUDP(); camWidth = 320; camHeight = 240; vector<ofVideoDevice> devices = vidGrabber.listDevices(); for (int i = 0; i < devices.size(); i++) { if (devices[i].bAvailable) { ofLogNotice() << devices[i].id << ": " << devices[i].deviceName; } else { ofLogNotice() << devices[i].id << ": " << devices[i].deviceName << " - unavailable "; } } for (int i = 0; i < devices.size(); i++) { if (!devices[i].deviceName.find("USB")) { cout << devices[i].id << endl; pcCams.push_back(devices[i].id); } } vidGrabber.setDeviceID(pcCams[0]); // vidGrabber.setDeviceID(0); vidGrabber.initGrabber(320,240); vidGrabber1.setDeviceID(pcCams[1]); // vidGrabber1.setDeviceID(0); vidGrabber1.initGrabber(320,240); colorImg1.allocate(320,240); grayImage1.allocate(320,240); grayBg1.allocate(320,240); grayDiff1.allocate(320,240); colorImg.allocate(320,240); grayImage.allocate(320,240); grayBg.allocate(320,240); grayDiff.allocate(320,240); bLearnBackground = true; bLearnBackground1 = true; threshold = 80; drawOne = false; bottomSwarm.a = 1.1f; bottomSwarm.b = (curWidth/4.0); bottomSwarm.c = 100.0; bottomSwarm.bVel = 1.0; xPos = 0; yPos = 0; zPos = 0; cam.setPosition(result["region0"]["ring0"]["point0"][0].asFloat(),result["region0"]["ring0"]["point0"][1].asFloat(),result["region0"]["ring0"]["point0"][2].asFloat()); cam.lookAt(ofVec3f(result["region0"]["ring1"]["point0"][0].asFloat(),result["region0"]["ring1"]["point0"][1].asFloat(),result["region0"]["ring1"]["point0"][2].asFloat())); cam.rotate(ofRadToDeg(PI/2), 1.0, 0.0, 0.0); cam.setFov(32.0); sphereZPos = 25.9297; sphereXPos = 364.928; for (int i = 0; i < 20; i++) { spheresXPos[i] = ofRandom(result["region0"]["ring0"]["point0"][0].asFloat()-500, result["region0"]["ring0"]["point0"][0].asFloat()+500.0); spheresZPos[i] = ofRandom(result["region0"]["ring0"]["point0"][2].asFloat()-100.0, result["region0"]["ring0"]["point0"][2].asFloat()+100.0); } /* LIGHTING */ ofSetSmoothLighting(true); pointLight.setDiffuseColor( ofColor(0.f, 255.f, 0.f)); pointLight.setSpecularColor( ofColor(255.f, 255.f, 255.f)); pointLight.setPosition(result["region0"]["ring0"]["point0"][0].asFloat(),result["region0"]["ring0"]["point0"][1].asFloat(),result["region0"]["ring0"]["point0"][2].asFloat()); material.setShininess( 64 ); colorHue = ofRandom(0, 250); colorHue2 = ofRandom(0, 250); lightColor.setBrightness( 180.f ); lightColor.set(250,250,210); materialColor.setBrightness(250.f); materialColor.set(100,100,100); lightColor.setHue(colorHue); pointLight.setDiffuseColor(lightColor); materialColor.setHue(colorHue); material.setSpecularColor(materialColor); materialColor.set(255.0,0.0,0.0); columnMaterial.setSpecularColor(materialColor); materialColor.set(55.0,55.0,55.0); peopleMaterial.setSpecularColor(materialColor); cameraColor1.set(0.0, 0.0, 255.0); cameraColor2.set(0.0, 0.0, 255.0); columnColor.set(255, 0, 0); activeColor.set(0.0,0.0,255.0); }
//-------------------------------------------------------------- void ofApp::setup(){ // This is enabled by default in recent version of openFrameworks ofEnableAntiAliasing(); ofSetCircleResolution(50); // For smoother looking circles + ellipses }
//-------------------------------------------------------------- void testApp::keyReleased(int key){ switch (key) { case 'f': ofToggleFullscreen(); break; case '0': ofEnableBlendMode(OF_BLENDMODE_DISABLED); break; case '1': ofEnableBlendMode(OF_BLENDMODE_ALPHA); break; case '2': ofEnableBlendMode(OF_BLENDMODE_ADD); break; case '3': ofEnableBlendMode(OF_BLENDMODE_SUBTRACT); break; case '4': ofEnableBlendMode(OF_BLENDMODE_MULTIPLY); break; case '5': ofEnableBlendMode(OF_BLENDMODE_SCREEN); break; case 'a': ofEnableAntiAliasing(); break; case 'b': ofBackground(0, 0, 0, 255); break; case 'd': ofDisableAlphaBlending(); break; case 'e': ofEnableAlphaBlending(); break; case 'r': //read file importFileForStruct(); break; case 's': ofDisableAntiAliasing(); break; case 'w': ofBackground(255, 255, 255, 255); break; case ' ': { saveToFile = true; ofLog(OF_LOG_NOTICE, "calculating..."); //ペアのデータを作成 --> vector<pointPair> pointPairVectorForWriting; for (int k=0; k<image1.getWidth()*image1.getHeight(); k++) { if (k <= image1.getWidth()*image1.getHeight()) { // 左の画像を右の画像に入れ替える ofPoint referencePoint; if (enableRandomExchange) { //ランダムで交換 referencePoint = ofPoint(exchangeOrderVector[k]%(int)image1.getWidth(), exchangeOrderVector[k]/(int)image1.getWidth()); }else{ //上から順に交換 referencePoint = ofPoint(k%(int)image1.getWidth(), k/(int)image1.getWidth()); } ofColor referenceColor = image1.getColor(referencePoint.x, referencePoint.y); double minimumDistance = image1.getWidth()+image2.getHeight(); ofPoint minimumDistancePoint; unsigned char * checkImagePixels = image2.getPixels(); // 最小の距離の色を調べる for (int i=0; i<image1.getHeight(); i++) { for (int j=0; j<image1.getWidth(); j++) { if (!enableDuplicate) { // 重複を許さない if (!usedOrNotVector[i*(int)image2.getWidth()+j]) { ofColor checkColor = ofColor(checkImagePixels[(i*(int)image2.getWidth()+j)*3], checkImagePixels[(i*(int)image2.getWidth()+j)*3+1], checkImagePixels[(i*(int)image2.getWidth()+j)*3+2]); double checkDistance = getColorDistance(referenceColor, checkColor); if (checkDistance < minimumDistance) { if (!usedOrNotVector[i*(int)image2.getWidth()+j]) { minimumDistance = checkDistance; minimumDistancePoint = ofPoint(j, i); } // 同じ色の重複を許す minimumDistance = checkDistance; minimumDistancePoint = ofPoint(j, i); } } } else{ ofColor checkColor = ofColor(checkImagePixels[(i*(int)image2.getWidth()+j)*3], checkImagePixels[(i*(int)image2.getWidth()+j)*3+1], checkImagePixels[(i*(int)image2.getWidth()+j)*3+2]); double checkDistance = getColorDistance(referenceColor, checkColor); if (checkDistance < minimumDistance) { if (!usedOrNotVector[i*(int)image2.getWidth()+j]) { minimumDistance = checkDistance; minimumDistancePoint = ofPoint(j, i); } // 同じ色の重複を許す minimumDistance = checkDistance; minimumDistancePoint = ofPoint(j, i); } } } } //最も近い距離の色の組み合わせをベクターに保存 pointPair tempPointPair; tempPointPair.point1 = referencePoint; tempPointPair.point2 = minimumDistancePoint; // 重複を許さない if (!enableDuplicate) { //再利用しないために、使用したPointを保存 usedOrNotVector[minimumDistancePoint.y*(int)image2.getWidth()+minimumDistancePoint.x] = true; } pointPairVectorForWriting.push_back(tempPointPair); } } ofLog(OF_LOG_NOTICE, "pointPairVectorForWriting done!"); //<-- ペアのデータを作成 ofLog(OF_LOG_NOTICE, "X1:"+ofToString(pointPairVectorForWriting[0].point1.x)+" Y1:"+ofToString(pointPairVectorForWriting[0].point1.y)); ofLog(OF_LOG_NOTICE, "X2:"+ofToString(pointPairVectorForWriting[0].point2.x)+" Y2:"+ofToString(pointPairVectorForWriting[0].point2.y)); exportFileForStruct(pointPairVectorForWriting); ofLog(OF_LOG_NOTICE, ofToString("writing file...")); saveToFile = false; ofLog(OF_LOG_NOTICE, "done"); } break; default: break; } }
//-------------------------------------------------------------- void testApp::setup() { ofEnableAntiAliasing(); // set Video Size vidSize = ofVec2f(640, 480); ofSetFrameRate(30); // initialize mouse point mouse_point = ofPoint(0,0); // intialize video ID vidID = 0; // initialize next Bot ID potential_bot_id = 0; // initialized bot color number botColorNum = 0; // set up message queue thread cout << "setting up ZMQ thread" << endl; zmqThread.start(); // initialize control booleans shouldBeginSendingBotInfo = shouldCaptureNewBot = shouldSetNewBackGround = false; shouldSetNewBackGround = true; #ifdef _USE_LIVE_VIDEO vidGrabber.setVerbose(true); vidGrabber.initGrabber(vidSize.x,vidSize.y); colorImg.allocate(vidSize.x,vidSize.y); grayImage.allocate(vidSize.x,vidSize.y); grayBg.allocate(vidSize.x,vidSize.y); grayDiff.allocate(vidSize.x,vidSize.y); ofSetWindowShape(vidSize.x,vidSize.y); #else vidPlayer.loadMovie("../GridDetectionNoText.mov"); vidPlayer.play(); colorImg.allocate(vidPlayer.width,vidPlayer.height); grayImage.allocate(vidPlayer.width,vidPlayer.height); grayBg.allocate(vidPlayer.width,vidPlayer.height); grayDiff.allocate(vidPlayer.width,vidPlayer.height); ofSetWindowShape(vidPlayer.width,vidPlayer.height); #endif // add many colors to vector for random assignment later colors[0] = ofColor::green; colors[1] =ofColor::aqua; colors[2] =ofColor::maroon; colors[3] =ofColor::lightCoral; colors[4] =ofColor::cyan; colors[5] =ofColor::red; colors[6] =ofColor::lightBlue; colors[7] =ofColor::salmon; colors[8] =ofColor::blueViolet; colors[9] =ofColor::hotPink; colors[10] =ofColor::honeyDew; colors[11] =ofColor::yellow; colors[12] =ofColor::limeGreen; colors[13] =ofColor::orange; colors[14] =ofColor::indigo; colors[15] =ofColor::fuchsia; colors[16] =ofColor::crimson; colors[17] =ofColor::purple; // GUI setup gui.setup(); gui.add(alterationsLabel.setup("Alternations\n", "")); gui.add(thresholdSlider.setup("Threshold", 45, 0, 255)); gui.add(dilateSlider.setup("Dilation", 4, 0, 20)); gui.add(autoFindBots.setup("Auto Find", false)); gui.add(infoLabel.setup("Displayed Information\n", "")); gui.add(drawReportStringToggle.setup("Info Table", true)); gui.add(drawBotRectToggle.setup("Rectangles", false)); gui.add(drawBotIDToggle.setup("ID", false)); gui.add(drawBotPathToggle.setup("Path", false)); gui.add(drawAssociationToggle.setup("Association", true)); gui.add(imageLabel.setup("Image\n", "")); gui.add(showColorImage.setup("Show Color")); gui.add(showGrayImage.setup("Show Gray")); gui.add(showSubtractedImage.setup("Show Subtracted Image")); gui.add(showBackgroundImage.setup("Show Background")); showColorImage.addListener(this, &testApp::showColorPressed); showGrayImage.addListener(this, &testApp::showGrayPressed); showBackgroundImage.addListener(this, &testApp::showBGPressed); showSubtractedImage.addListener(this, &testApp::showSubtractedPressed); showGUI = false; }
//-------------------------------------------------------------- void ofApp::setup() { #ifdef DEBUG #else ofSetDataPathRoot("../Resources/data/"); #endif ofBackground(0); ofEnableAntiAliasing(); gui.setup(); gui.add(onOffInternet.setup("Connect Internet", false)); sunName.load("NewMedia Fett.ttf", 20, true); sunName.setGlobalDpi(72); for (int i = 0; i < 512; i++) { amp[i] = 0; hertzScale[i] = 0; phases[i] = 0; sineBuffer[i] = sines[i]; sineBufferLeft[i] = sines[i]; sineBufferRight[i] = sines[i]; } // soundStream.printDeviceList(); ofSoundStreamSettings settings; auto devices = soundStream.getMatchingDevices("default"); if (!devices.empty()) { settings.setOutDevice(devices[1]); } settings.setOutListener(this); settings.bufferSize = INITIAL_BUFFER_SIZE; settings.sampleRate = SAMPLE_RATE; settings.numInputChannels = 0; settings.numOutputChannels = 2; soundStream.setup(settings); bPlaying = false; line = 0.1; maxHertz = 8000; minHertz = 150; astroidFBO.allocate(30, BIT, GL_RGB); // http://www.asterank.com/api string url = "http://asterank.com/api/asterank?query={\"e\":{\"$lt\":0.9},\"i\":{\"$lt\":2},\"a\":{\"$lt\":1.5}}&limit=1"; // Now parse the JSON // bool parsingInternetSuccessful = json(url); // parsingInternetSuccessful = false; // if (!parsingInternetSuccessful) { // json.open("asteroid_500.json"); // } else { // json.open(url); // } threshold = 0.9; cam.setAutoDistance(false); cam.setDistance(400); // if (parsingSuccessful) { // ofLogNotice("ofApp::setup") << json.getRawString(true); // } else { // ofLogNotice("ofApp::setup") << "Failed to parse JSON."; // } sun.set(2, 10); earthOrbit = setupEarthOrbit(); orbits = setupOrbits("asteroid_500.json"); drawTrackingLine.resize(orbits.size()); }
//-------------------------------------------------------------- void testApp::setup() { ofSetVerticalSync(true); ofBackgroundHex(0x000000); ofSetLogLevel(OF_LOG_NOTICE); ofEnableAntiAliasing(); box2d.init(); box2d.setGravity(0, 0); box2d.setFPS(30.0); isKeyPressed = false; isMousePressed = false; // add objects for (int i=0; i<200; i++) { // circulos addCircle(ofPoint(ofGetWidth()/2+ofRandom(100), ofGetHeight()/2+ofRandom(100))); // rectangulos addBox(ofPoint(ofGetWidth()/2+ofRandom(100), ofGetHeight()/2+ofRandom(100))); } bAddCircle = false; bAddBox = false; ptoMed_circles = ptoMedio(circles); ptoMed_boxes = ptoMedio(boxes); bola.loadImage("images/dot.png"); ladoPart1 = 5; ladoPart2 = 10; coloresBN.push_back(ofColor(0)); coloresBN.push_back(ofColor(150)); coloresBN.push_back(ofColor(255)); bDraw4Forces = true; fRed = true; borde.clear(); ofColor ctmp = ofColor::black; borde.setFillColor(ctmp); //http://www.openframeworks.cc/documentation/graphics/ofPath.html#show_setPolyWindingMode borde.setPolyWindingMode(OF_POLY_WINDING_ODD); // rectangulo borde.rectangle(0,0,ofGetWidth(),ofGetHeight()); borde.setCircleResolution(60); borde.circle(ofGetWidth()/2,ofGetHeight()/2,ofGetHeight()/2*0.95); // fbos fbo1.allocate(ofGetHeight()/2,ofGetHeight()/2); fbo2.allocate(ofGetHeight()/2,ofGetHeight()/2); fbo3.allocate(ofGetHeight()/2,ofGetHeight()/2); fbo4.allocate(ofGetHeight()/2,ofGetHeight()/2); fbo1.begin(); ofClear(255,255,255,0); fbo1.end(); fbo2.begin(); ofClear(255,255,255,0); fbo2.end(); fbo3.begin(); ofClear(255,255,255,0); fbo3.end(); fbo4.begin(); ofClear(255,255,255,0); fbo4.end(); bDrawFbos = false; }