//-------------------------------------------------------------- void ofApp::setup(){ connected = false; ofxAccelerometer.setup(); // make a web socket connection that we can stream data to client.Create(); client.Connect("192.168.42.1", 3000); client.SetNonBlocking(true); switch (ofGetOrientation()) { case OF_ORIENTATION_DEFAULT: ofSetOrientation(OF_ORIENTATION_90_LEFT); break; case OF_ORIENTATION_180: ofSetOrientation(OF_ORIENTATION_90_LEFT); break; case OF_ORIENTATION_90_LEFT: ofSetOrientation(OF_ORIENTATION_90_LEFT); break; case OF_ORIENTATION_90_RIGHT: ofSetOrientation(OF_ORIENTATION_90_RIGHT); break; default: break; } int count = 0; for( float i = 0; i < 1.0; i+=0.05 ) { arcPoint p; p.position = i; if(count % 2) { p.fill.set(122, 122, 122); } else { p.fill.set(255, 255, 255); } arcPoints.push_back(p); count++; } left = 0; right = 0; carIcon.load("car2.png"); }
void ofApp::deviceOrientationChanged(int newOrientation) { ofLogNotice() << "Detected orientation change " << newOrientation; if (isPhone()) { ofLogNotice() << "Ignoring orientation change since it's a phone"; return; } if (newOrientation == OF_ORIENTATION_UNKNOWN) { return; } if (isTablet() && appState != APP) { if (newOrientation == OF_ORIENTATION_DEFAULT || newOrientation == OF_ORIENTATION_180) { ofLogNotice() << "!!!Ignoring orientation change in tablet in app "; return; } } // upside down is no good for anything if (isPhone() && newOrientation == OF_ORIENTATION_180) ofSetOrientation(OF_ORIENTATION_DEFAULT); else { ofLogNotice() << "Changing orientation change"; ofSetOrientation(ofOrientation(newOrientation)); } // it transitioning to landscape, activate back all modules if (newOrientation == OF_ORIENTATION_90_LEFT || newOrientation == OF_ORIENTATION_90_RIGHT) { //imgAbout.rotate90(3); for (unsigned int i = 0; i < modules.size(); i++) modules[i]->activate(); } // it transitioning to portrait, deactivate all modules, except the one with which last interacted else { //imgAbout.rotate90(1); for (unsigned int i = 0; i < modules.size(); i++) { if (i == moduleActive) { ofLogNotice() << "Activating module " << i; modules[i]->activate(); } else { ofLogNotice() << "Deactivating module " << i; modules[i]->deactivate(); } } } setupModules(); }
void ofApp::setup(){ ofSetFrameRate(target_fps); ofSetVerticalSync(true); //ofSetWindowShape(1920, 1080); ofSetWindowPosition(0, 0); ofEnableAlphaBlending(); ofDisableAntiAliasing(); ofDisableSmoothing(); ofSetOrientation( OF_ORIENTATION_DEFAULT ); bStart = true; bLog = true; // sound int nCh = 1; int sampleRate = 48000; int bufferSizeTry = bufferSize = 2048; currentSamplePos = 0; prevSamplePos = 0; sound_stream.setup(this, 0, nCh, sampleRate, bufferSizeTry, 4); // visual int w = ofGetWindowWidth(); int h = ofGetWindowHeight(); bHandy = w<h; float longside = bHandy ? h:w; float shortside = bHandy ? w:h; canvas.set(0, 0, longside, shortside); track_len = longside * 0.9f; track_offset = longside * 0.05; start_point.x = track_offset; start_point.y = shortside/2; indicator.set(0, 0); bNeedSaveImg = false; ofSetLogLevel(OF_LOG_VERBOSE); #ifdef USE_GRABBER // video grbW = 360; grbH = 240; grabber.listDevices(); grabber.setDeviceID(1); grabber.setUseTexture(false); grabber.setPixelFormat( OF_PIXELS_RGB ); grabber.setDesiredFrameRate( target_fps ); grabber.setPixelFormat(OF_PIXELS_MONO); grabber.setup( grbW, grbH ); colorImg.allocate( grbW, grbH ); grayImg.allocate( grbW, grbH ); #endif }
//-------------------------------------------------------------- void testApp::setup(){ ofBackground(255,255,255); ofSetLogLevel(OF_LOG_NOTICE); ofSetOrientation(OF_ORIENTATION_90_LEFT); grabber.initGrabber(320,240); one_second_time = ofGetElapsedTimeMillis(); camera_fps = 0; frames_one_sec = 0; }
//-------------------------------------------------------------- void testApp::setup(){ ofSetLogLevel(OF_LOG_WARNING); //NOTICE ofSetOrientation(OF_ORIENTATION_90_LEFT); //zoom in effect zoom = -500; zoomTarget = 350; zoomSpeed = 0.4; grabber.initGrabber(800, 600); // we need GL_TEXTURE_2D for our models coords. ofDisableArbTex(); if (model.loadModel("astroBoy_walk.dae", true)) { model.setAnimation(0); model.setPosition(ofGetWidth()/2, (float)ofGetHeight() * 0.75 , 0); //model.createLightsFromAiModel(); model.disableTextures(); model.disableMaterials(); /* mesh = model.getMesh(0); position = model.getPosition(); normScale = model.getNormalizedScale(); scale = model.getScale(); sceneCenter = model.getSceneCenter(); material = model.getMaterialForMesh(0); tex = model.getTextureForMesh(0); */ } ofEnableBlendMode(OF_BLENDMODE_ALPHA); glEnable(GL_DEPTH_TEST); //some model / light stuff glShadeModel(GL_SMOOTH); light.setup(); ofEnableSeparateSpecularLight(); bAnimate = false; animationTime = 0.0; tcpConnected = tcp.setup(HOST_IP, PORT, false); //nonblocking if (tcpConnected) tcp.sendRaw("Phew!\n"); drawCamera = false; debugMessage = "Bupkes..."; }
//-------------------------------------------------------------- void ofApp::setup(){ ofSetOrientation(OF_ORIENTATION_90_LEFT); synth.loadSound("sounds/synth.wav"); beats.loadSound("sounds/1085.mp3"); vocals.loadSound("sounds/Violet.mp3"); synth.setVolume(0.75f); beats.setVolume(0.75f); vocals.setVolume(0.5f); font.loadFont("Sudbury_Basin_3D.ttf", 32); beats.setMultiPlay(false); vocals.setMultiPlay(true); }
//---------------------------------------- void ofCamera::begin(ofRectangle viewport) { if(!isActive) ofPushView(); isActive = true; ofViewport(viewport.x,viewport.y,viewport.width,viewport.height); ofSetOrientation(ofGetOrientation(),vFlip); ofSetMatrixMode(OF_MATRIX_PROJECTION); ofLoadMatrix( getProjectionMatrix(viewport) ); ofSetMatrixMode(OF_MATRIX_MODELVIEW); ofLoadViewMatrix( getModelViewMatrix() ); }
void Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv* env, jclass thiz ){ ofLog(OF_LOG_NOTICE,"onSurfaceCreated"); if(!surfaceDestroyed){ ofUnloadAllFontTextures(); ofPauseVideoGrabbers(); } reloadTextures(); if(androidApp){ androidApp->reloadTextures(); } ofSetStyle(ofGetStyle()); ofSetOrientation(ofGetOrientation()); surfaceDestroyed = false; }
//-------------------------------------------------------------- void ofApp::setup(){ ofDisableArbTex(); ofxAccelerometer.setup(); ofSetVerticalSync(false); ofBackground(0,0,0); ofSetLogLevel(OF_LOG_NOTICE); ofSetOrientation(OF_ORIENTATION_DEFAULT); preCameraID = cameraID = 0; camWidth = 640; camHeight = 480; grabber.setDeviceID(cameraID); grabber.setup(camWidth, camHeight); ofx::HTTP::SimpleIPVideoServerSettings settings; // Many other settings are available. settings.setPort(7890); // The default maximum number of client connections is 5. settings.ipVideoRouteSettings.setMaxClientConnections(2); // Apply the settings. server.setup(settings); // Start the server. server.start(); pix = new ofPixels(); pix->allocate(camWidth, camHeight, 3); image = new ofImage(); image->allocate(camWidth, camHeight, OF_IMAGE_COLOR); sender.setup("REMOTEVIEWER.WV.CC.CMU.EDU", 7777); // sender.setup("10.0.0.5", 7777); // receiver.setup(7776); drawConnections = false; bPtouch = false; bTouch = false; fader.setLength(0.5, 0.5); faderDelay.setLength(1.55, 0); }
//-------------------------------------------------------------- void ofApp::setup() { ofBackground(255,255,255); ofSetLogLevel(OF_LOG_NOTICE); ofSetOrientation(OF_ORIENTATION_90_LEFT); int grabberWidth = 320; int grabberHeight = 240; grabber.setup(grabberWidth,grabberHeight); colorCv.allocate(grabberWidth, grabberHeight); colorCvSmall.allocate(grabberWidth/4, grabberHeight/4); grayCv.allocate(grabberWidth/4, grabberHeight/4); faceFinder.setup("haarcascade_frontalface_default.xml"); faceFinder.setNeighbors(1); faceFinder.setScaleHaar(1.5); one_second_time = ofGetSystemTime(); camera_fps = 0; frames_one_sec = 0; }
//-------------------------------------------------------------- void ofApp::setup() { ofSetOrientation(OF_ORIENTATION_90_LEFT); ofSetLogLevel(OF_LOG_VERBOSE); ofBackground(0, 0, 0); ofSetVerticalSync(true); ofSetFrameRate(60); planet.setUseVbo(false); planet.set(1500, 50); planet.setPosition(0, 0, 0); easycam.setDistance(20); cam.setPosition(0, 0, 0); ofxAccelerometer.setup(); ofxRegisterAccelEvents(this); tracking.reset(); invert = ofNode(); node = ofNode(); view = ofMatrix4x4(); }
//-------------------------------------------------------------- void ArtvertiserApp::setup(){ //ofSleepMillis(5000); ofSetVerticalSync(true); // ofSetFrameRate( 30.0f ); //ofSetLogLevel(OF_LOG_VERBOSE); ofBackground(66,51,51); ofEnableAlphaBlending(); doTakeAPhoto = true; doComms = true; vector<Artvert> artverts = Artvert::listAll(); ofLogVerbose("ArtvertiserApp","checking artverts integrity"); for(int i=0; i<(int)artverts.size(); i++){ if(!artverts[i].checkIntegrity()){ ofLogVerbose("ArtvertiserApp") << "found corrupt or incomplete advert " << artverts[i].getUID() << " deleting"; string generated = artverts[i].generateMD5(); string stored = artverts[i].getStoredMD5(); ofLogVerbose("ArtvertiserApp") << "generated md5 " << artverts[i].generateMD5(); ofLogVerbose("ArtvertiserApp") << "stored md5 " << artverts[i].getStoredMD5(); artverts[i].removeAnalisys(); ofFile md5(artverts[i].getMD5File().path(),ofFile::WriteOnly); md5 << artverts[i].generateMD5(); md5.close(); } } refreshArtvert = false; #ifdef TARGET_ANDROID ofSetOrientation(OF_ORIENTATION_90_LEFT); #endif grabber.setDeviceID(0); grabber.setDesiredFrameRate(60); grabber.setUseTexture(false); //grabber.setPixelFormat(OF_PIXELS_MONO); grabber.initGrabber(camW, camH); if ( CommandlineParser::get()->isRunningOnBinoculars() ) { Binocular::get()->setup( grabber, /*bDebug*/ true ); ofHideCursor(); } counter = 0; allocated = true; iconCache = ofPtr<gui::IconCache>(new gui::IconCache); geo = ofPtr<ofxGeoLocation>(new ofxGeoLocation); comm = ofPtr<Comm>(new Comm); menu.setIconCache(iconCache); menu.setup( doTakeAPhoto, doComms ); menu.enableEvents(); artvertInfo.setIconCache(iconCache); artvertInfo.setGeo(geo); if ( doTakeAPhoto ) { takeAPhoto.setGeo(geo); takeAPhoto.setup(grabber); } #ifdef TARGET_ANDROID ofxAndroidVideoGrabber * androidGraber = dynamic_cast<ofxAndroidVideoGrabber*>(grabber.getGrabber().get()); ofAddListener(androidGraber->newFrameE,&takeAPhoto,&TakeAPhoto::newFrame); #elif defined (TARGET_LINUX) ofGstVideoGrabber * linuxGrabber = dynamic_cast<ofGstVideoGrabber*>(grabber.getGrabber().get()); ofGstVideoUtils * videoUtils = linuxGrabber->getGstVideoUtils(); ofAddListener(videoUtils->bufferEvent,&takeAPhoto,&TakeAPhoto::newFrame); #endif if ( doComms ) { onlineArtverts.setURL(SERVER_URL); onlineArtverts.setIconCache(iconCache); onlineArtverts.setComm(comm); onlineArtverts.setup(); comm->setURL(SERVER_URL); comm->start(); } if ( CommandlineParser::get()->isRunningOnBinoculars() ) { state = Tracking; } else { state = Menu; } circularPB.setRadius(30); circularPB.setColor(ofColor(190,190,190)); circularPB.setPosition(ofPoint(grabber.getWidth()*0.5,ofGetHeight()*0.5)); ofAddListener(takeAPhoto.exitE,this,&ArtvertiserApp::appFinished); ofAddListener(takeAPhoto.newPhotoE,this,&ArtvertiserApp::newPhoto); ofAddListener(comm->gotAnalysisE,this,&ArtvertiserApp::gotAnalysis); ofAddListener(menu.cameraPressedE,this,&ArtvertiserApp::cameraPressed); ofAddListener(menu.downloadPressedE,this,&ArtvertiserApp::downloadPressed); ofAddListener(menu.artvertSelectedE,this,&ArtvertiserApp::advertSelected); ofAddListener(artvertInfo.artvertSelectedE,this,&ArtvertiserApp::artvertSelected); ofAddListener(onlineArtverts.downloadedE,this,&ArtvertiserApp::gotAnalysis); if ( CommandlineParser::get()->isRunningOnBinoculars() ) { ofAddListener( Binocular::get()->artvertSelectedEvent, this, &ArtvertiserApp::artvertSelectedBinoculars ); } ofSetLogLevel(OF_LOG_SILENT); }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(255,255,255); ofSetLogLevel(OF_LOG_NOTICE); ofSetOrientation(OF_ORIENTATION_90_LEFT); noconnectionImg.loadImage("noconnection-error.png"); noboardfoundImg.loadImage("nosurface-warning.png"); if(!grabber.isInitialized()) { grabber.initGrabber(640, 480); } // calculate draw size to avoid scaling video content to strange ratios // (video will be drawn at maximum size fitting in the screen with bars usually left and right) // scale height to resolution-height and check if videowidth is smaller that resolution width // if not, do the same for width, that should work then float fact = ofGetHeight() / (float)grabber.getHeight(); drawSize.x = grabber.getWidth() * fact; drawSize.y = grabber.getHeight() * fact; if(drawSize.x > ofGetWidth()) { float fact = ofGetWidth() / (float)grabber.getWidth(); drawSize.y = ofGetHeight() * fact; drawSize.x = ofGetWidth() * fact; } drawOffset.x = (ofGetWidth() - drawSize.x) / 2.f; drawOffset.y = (ofGetHeight() - drawSize.y) / 2.f; // connect time for tcp connection connectTime = ofGetElapsedTimeMillis(); lastAutofocus = 0.f; debugMsgStr = " "; // oscSender.setup("10.0.1.3", 12332); //aruco.setThreaded(false); aruco.setup("intrinsics.int", grabber.getWidth(), grabber.getHeight(), ""); // set planes, size must fit actual planes, should put that somewhere else... ProjectionSurface psurf0(691, "boardConfigurationF0.yml", ofVec2f(4.3, 1.7)); projectionSurfaces.push_back(psurf0); ProjectionSurface psurf1(268, "boardConfigurationF1.yml", ofVec2f(4.3, 1.7)); projectionSurfaces.push_back(psurf1); ProjectionSurface psurf2(581, "boardConfigurationF2.yml", ofVec2f(4.3, 3.95)); projectionSurfaces.push_back(psurf2); ProjectionSurface psurf3(761, "boardConfigurationF3.yml", ofVec2f(3.0, 1.7)); projectionSurfaces.push_back(psurf3); ProjectionSurface psurf4(528, "boardConfigurationF4.yml", ofVec2f(3.0, 1.7)); projectionSurfaces.push_back(psurf4); ProjectionSurface psurf5(286, "boardConfigurationF5.yml", ofVec2f(4.3, 1.7)); projectionSurfaces.push_back(psurf5); ProjectionSurface psurf6(484, "boardConfigurationF6.yml", ofVec2f(4.3, 1.7)); projectionSurfaces.push_back(psurf6); ProjectionSurface psurf7(99, "boardConfigurationF7.yml", ofVec2f(4.3, 3.95)); projectionSurfaces.push_back(psurf7); ProjectionSurface psurf8(222, "boardConfigurationF8.yml", ofVec2f(3.0, 1.7)); projectionSurfaces.push_back(psurf8); ProjectionSurface psurf9(903, "boardConfigurationF9.yml", ofVec2f(3.0, 1.7)); projectionSurfaces.push_back(psurf9); for (int i = 0; i < projectionSurfaces.size(); i++) { ProjectionSurface surfc = projectionSurfaces[i]; aruco.addBoardConf(surfc.boardConfigurationFile); projectionSurfaces[i].setBoard(aruco.getBoards()[i]); } showMarkers = true; showBoard = true; showBoardImage = false; setupDrawStuff(); // android!! ofxAndroidLockScreenSleep(); }
//-------------------------------------------------------------- void ofApp::setup(){ //ofSetOrientation(OF_ORIENTATION_90_RIGHT); ofBackground(0,0,0); //ofSetBackgroundAuto(true); ofSetOrientation(OF_ORIENTATION_90_LEFT); ofSetFrameRate(60); ofEnableSmoothing(); ofSetCircleResolution(48); center.set((ofGetWidth()/2),410); //OSC // open an outgoing connection to HOST:PORT M8sender.setup(M8HOST, M8PORT); liveSender.setup(LIVEHOST, LIVEPORT); //timing elapsedTime = ofGetElapsedTimeMillis(); last = ofGetElapsedTimeMillis(); activeStep = 33; //paging page = 1; currentPage = 1; font.loadFont("fonts/Inconsolata.otf", 15, true,false,false,0.3,90); rightBover = false; leftBover = false; fadeUp = false; fadeDown = false; cc = 80; pausa = false; //stepping counter = 5; nextStep = false; //step state inizialization for(int i=0; i<8; i++){ stepOver[i] = false; } //load interface images banner.loadImage("images/banner.jpg"); colsx.loadImage("images/colsx.jpg"); coldx.loadImage("images/coldx.jpg"); fondocentral.loadImage("images/fondocentral.jpg"); letra.loadImage("images/letra.jpg"); // crear las slices for(int i=0; i<32; i++){ slice[i].lineTo(center); slice[i].arc(center,315,310,(i*11.25),(i*11.25)+11.25, 100); } //color FX slice for(int i=0; i<4; i++){ if(i == 0){ fxColor[i].r=255; fxColor[i].g=0; fxColor[i].b=103; } if(i == 1){ fxColor[i].r=0; fxColor[i].g=177; fxColor[i].b=177; } if(i == 2){ fxColor[i].r=176; fxColor[i].g=241; fxColor[i].b=0; } if(i == 3){ fxColor[i].r=243; fxColor[i].g=46; fxColor[i].b=35; } } //FX state inizialization for(int i=0; i<32; i++){ fxState[i] = false; } //inizialize steps myStep = new ofStep*[8]; for(int j = 0; j < 8; j++){ myStep[j] = new ofStep(j, center); } //inizialize buttons myButton = new ofButton*[3]; //reset //ofPoint myPos(965, (ofGetHeight()-((ofGetHeight()/100)*35))); ofPoint myPos(0, (ofGetHeight()-((ofGetHeight()/100)*23))); myButton[0] = new ofButton(0,myPos, "RESET", false ); //random myPos.y += myButton[0]->form.height+10; myButton[1] = new ofButton(1,myPos, "RANDOM", false ); //masterplay ofPoint myPos2(0, (ofGetHeight()-((ofGetHeight()/100)*35))); myButton[2] = new ofButton(2,myPos2, "PLAY/STOP", false ); /* myButton[1] = new ofButton(1,myPos, "RANDOM" ); */ //convertir steps en ofPath para que se puedan llenar for(int j = 0; j < 32; j++){ for( int i = 0; i < slice[j].getVertices().size(); i++) { if(i == 0) { path[j].newSubPath(); path[j].moveTo(slice[j].getVertices()[i] ); } else { path[j].lineTo( slice[j].getVertices()[i] ); } } path[j].close(); path[j].simplify(); } //inizialize patterns pattern = new myPattern*[32]; for(int j = 0; j < 32; j++){ pattern[j] = new myPattern(j+1); } }
void ofApp::setup() { ofSetLogLevel(OF_LOG_NOTICE); ofLogNotice() << "setup()"; if (ofApp::isSemibreve()) ofLogNotice() << "Going to run Semibreve version"; if (ofApp::isOsx()) ofLogNotice() << "OSX detected"; if (ofApp::isIos()) ofLogNotice() << "iOS detected"; if (ofApp::isAndroid()) ofLogNotice() << "Android detected"; if (ofApp::isPhone()) ofLogNotice() << "Phone detected"; if (ofApp::isTablet()) ofLogNotice() << "Tablet detected"; // if (ofApp::isIphone()) ofLogNotice() << "iPhone detected"; // if (ofApp::isIpad()) ofLogNotice() << "iPad detected"; // if (ofApp::isAndroidPhone()) ofLogNotice() << "Android phone detected"; // if (ofApp::isAndroidTablet()) ofLogNotice() << "Android tablet detected"; #if defined TARGET_OSX ofLogNotice() << "Running OSX version"; ofSetDataPathRoot("../Resources/data/"); #endif #if defined TARGET_SEMIBREVE ofLogNotice() << "Running SEMIBREVE version"; oscReceiver.setup(RECEIVE_PORT); oscSender.setup(HOST, SEND_PORT); #endif #if defined TARGET_OF_IOS if (ofApp::isTablet()) { ofSetOrientation(OF_ORIENTATION_90_LEFT); swiper.setup(); ofAddListener(swiper.swipeRecognized, this, &ofApp::onSwipe); swiping = false; } else { swiper.setup(); ofAddListener(swiper.swipeRecognized, this, &ofApp::onSwipe); swiping = false; } #endif #ifndef TARGET_OSX if (isAndroid() || isIos()) { ofxAccelerometer.setup(); accelCount = 0; crop = 0; } #endif if (!ofApp::isIos()) { ofLogNotice() << "Registering for touch events if not ios"; ofRegisterTouchEvents(this); } ofSetFrameRate(FRAME_RATE); ofSetCircleResolution(CIRCLE_RESOLUTION); if (multitouch) ofHideCursor(); ofApp::language = ofApp::getSystemLanguage(); ofLogNotice() << "Language is " << ofApp::language; initTranslations(); initModules(); setupModules(); loadModuleSounds(); initImages(); appState = ABOUT; inactivityState = ACTIVE; // init global vars aboutY = 0; splashAlpha = 255; arrowDownY = ofGetHeight()/3*2; arrowDownYBase = arrowDownY; arrowDownDir = 1; showSwipeInfo = true; ofApp::maxParticleY = round(ofGetHeight() * (1-LIMIT_PARTICLE)); uint swipeFontSize; if (isTablet()) swipeFontSize = 26; else swipeFontSize = 20; swipeFont.load(UI_FONT_FACE, swipeFontSize); }