Beispiel #1
0
//--------------------------------------------------------------
void testApp::setup()
{
    //Set the background to black
    ofBackground( 0 , 0 , 0 ) ; 
    //load our image inside bin/data
    image.loadImage ( "images/text.png" ) ;
    //if the app performs slowly raise this number
    sampling = 1 ; 
    curImageIndex = 0 ; 
    
    //Retrieve the pixels from the loaded image
    unsigned char * pixels = image.getPixels() ;
    //store width and height for optimization and clarity
    int w = image.width ; 
    int h = image.height ; 
    
    //offsets to center the particle son screen
    int xOffset = (ofGetWidth() - w ) /2 ; 
    int yOffset = (ofGetHeight() - h ) /2 ;
    numParticles= 0 ; 
    
    r = ofRandom ( 45 , 255 ) ; 
    g = ofRandom ( 45 , 255 ) ; 
    b = ofRandom ( 45 , 255 ) ; 
    
    ofVec3f origin = ofVec3f( ofGetWidth() /2 , ofGetHeight() /2 , 0 ) ; 
    //Loop through all the rows
    for ( int x = 0 ; x < w ; x+=sampling ) 
    {
        //Loop through all the columns
        for ( int y = 0 ; y < h ; y+=sampling ) 
        {
            //Pixels are stored as unsigned char ( 0 <-> 255 ) as RGB
            //If our image had transparency it would be 4 for RGBA
            int index = ( y * w + x ) * 4 ; 
            ofColor color ; 
            if ( pixels[index+3] > 0 ) 
            {
                color.r = r ; //pixels[index+0] ;       //red pixel
                color.g = g ; //pixels[index+1] ;     //blue pixel
                color.b = b ; //pixels[index+2] ;     //green pixel
                ofVec3f spawnPoint = ofPoint ( x + xOffset , y + yOffset , ofRandom ( -50, 50 ) ) ;
//                spawnPoint.z =  ; //origin.distance ( spawnPoint )  * 200.0f ; 
                particles.push_back( Particle ( spawnPoint , color ) ) ; 
                numParticles++ ; 
            }
        }
    }
    
    ofSetFrameRate( 30 ) ; 
  //  numParticles = ( image.width * image.height ) / sampling ; 
    
    //Set spring and sink values
    cursorMode = 0 ; 
    forceRadius = 45 ; 
    friction = 0.85 ; 
    springFactor = 0.12 ; 
    springEnabled = true ; 
   
    //setup openGL
    ofSetFrameRate(30) ;
    ofBackground(0, 0, 0);
	//ofSetBackgroundAuto(false);
	ofSetVerticalSync(true);

    nImages = DIR.listDir("images/");
 	images = new ofImage[nImages];
    //you can now iterate through the files as you like
    for(int i = 0; i < nImages; i++)
    {
        images[i].loadImage(DIR.getPath(i));
    }
    
    fadeFbo.allocate( ofGetWidth() , ofGetHeight() ) ;
    fadeFbo.begin() ; 
    ofClear(0, 0, 0, 1);
    fadeFbo.end() ; 
    
    
    fadeAlpha = 2 ; 
}
Beispiel #2
0
//--------------------------------------------------------------
void testApp::setup(){
	ofSetFrameRate(30);

	ofBackground(0,0,0);
	TTF.loadFont("mono.ttf", 7);
}
Beispiel #3
0
//--------------------------------------------------------------
void testApp::setup() {
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	ofBackground( 10, 10, 10);
	
	camera.setPosition(ofVec3f(0, -3.f, -40.f));
	camera.lookAt(ofVec3f(0, 0, 0), ofVec3f(0, -1, 0));

	world.setup();
	world.enableGrabbing();
	world.setCamera(&camera);
	world.setGravity( ofVec3f(0, 25., 0) );
	
	ofVec3f startLoc;
	ofPoint dimens;
	boundsWidth = 30.;
	float hwidth = boundsWidth*.5;
	float depth = 2.;
	float hdepth = depth*.5;
	boundsShape = new ofxBulletCustomShape();
	boundsShape->create(world.world, ofVec3f(0, 0, 0), 10.);
	
	for(int i = 0; i < 6; i++) {
		bounds.push_back( new ofxBulletBox() );
		if(i == 0) { // ground //
			startLoc.set( 0., hwidth+hdepth, 0. );
			dimens.set(boundsWidth, depth, boundsWidth);
		} else if (i == 1) { // back wall //
			startLoc.set(0, 0, hwidth+hdepth);
			dimens.set(boundsWidth, boundsWidth, depth);
		} else if (i == 2) { // right wall //
			startLoc.set(hwidth+hdepth, 0, 0.);
			dimens.set(depth, boundsWidth, boundsWidth);
		} else if (i == 3) { // left wall //
			startLoc.set(-hwidth-hdepth, 0, 0.);
			dimens.set(depth, boundsWidth, boundsWidth);
		} else if (i == 4) { // ceiling //
			startLoc.set(0, -hwidth-hdepth, 0.);
			dimens.set(boundsWidth, depth, boundsWidth);
		} else if (i == 5) { // front wall //
			startLoc.set(0, 0, -hwidth-hdepth);
			dimens.set(boundsWidth, boundsWidth, depth);
		}
		btBoxShape* boxShape = ofBtGetBoxCollisionShape( dimens.x, dimens.y, dimens.z );
		boundsShape->addShape( boxShape, startLoc );
		
		bounds[i]->create( world.world, startLoc, 0., dimens.x, dimens.y, dimens.z );
		bounds[i]->setProperties(.25, .95);
		bounds[i]->add();
	}
	
	bDropBox	= false;
	bDrawDebug	= false;
	
	// this model is huge! scale it down 
	ofVec3f scale(.0009, .0009, .0009);
	
	// 3D logo by Lauren Licherdell | http://www.laurenlicherdell.com/ // 
	assimpModel.loadModel("OFlogo.dae", true);
	assimpModel.setScale(scale.x, scale.y, scale.z);
	assimpModel.setPosition(0, 0, 0);
	
	ofQuaternion startRot = ofQuaternion(1., 0., 0., PI);
	
	for (int i = 0; i < 3; i++) {
		logos.push_back( new ofxBulletCustomShape() );
		startLoc = ofVec3f( ofRandom(-5, 5), ofRandom(0, -hwidth+5), ofRandom(-5, 5) );
		
		if(i == 0) {
			for(int i = 0; i < assimpModel.getNumMeshes(); i++) {
				logos[i]->addMesh(assimpModel.getMesh(i), scale, true);
			}
		} else {
			logos[i]->init( (btCompoundShape*)logos[0]->getCollisionShape(), logos[0]->getCentroid() );
		}
		logos[i]->create( world.world, startLoc, startRot, 3. );
		logos[i]->add();
	}
	
	// let's make an object for the light to follow //
	shapes.push_back( new ofxBulletSphere() );
	((ofxBulletSphere*)shapes[0])->create(world.world, ofVec3f(0, -hwidth+5, -5), .15f, 2.);
	((ofxBulletSphere*)shapes[0])->setActivationState( DISABLE_DEACTIVATION );
	shapes[0]->add();
	
	logoMat.setAmbientColor(ofFloatColor(0, 0, 0));
	logoMat.setDiffuseColor(ofFloatColor(150, 0, 150));
	logoMat.setSpecularColor(ofFloatColor(220, 0, 220));
	logoMat.setShininess(40);
	
	boundsMat.setAmbientColor(ofFloatColor(10, 9, 10));
	boundsMat.setDiffuseColor(ofFloatColor(12, 10, 12));
	boundsMat.setSpecularColor(ofFloatColor(1, 1, 1));
	boundsMat.setShininess(10);
	
	shapesMat.setShininess(80);
}
Beispiel #4
0
//--------------------------------------------------------------
void testApp::setup(){
	ofSetFrameRate(24);
	ofBackground(255,255,255);
	ofSetWindowShape(640, 480);
}
Beispiel #5
0
//--------------------------------------------------------------
void testApp::setup() {
	ofSetLogLevel(OF_LOG_VERBOSE);

    ofEnableAlphaBlending();
    ofSetPolyMode(OF_POLY_WINDING_NONZERO);

    ofTrueTypeFont::setGlobalDpi(72);
    font.loadFont("GUI/dinnextroundedltprolight.ttf", 28, true, true);

    // enable depth->rgb image calibration
	kinect.setRegistration(true);

	//kinect.init();
	//kinect.init(true); // shows infrared instead of RGB video image
	kinect.init(false, false); // disable video image (faster fps)
	kinect.open();

    angle=kinect.getCurrentCameraTiltAngle();
	//kinect.setCameraTiltAngle(angle);
	//ofSleepMillis(1000);

	kinect.enableDepthNearValueWhite(true);

    ofAddListener(blob2DTracker.blobAdded, this, &testApp::blob2DAdded);
    ofAddListener(blob2DTracker.blobMoved, this, &testApp::blob2DMoved);
    ofAddListener(blob2DTracker.blobDeleted, this, &testApp::blob2DDeleted);

    blobFinder.init(&kinect, true); // standarized coordinate system: z in the direction of gravity
    blobFinder.setResolution(BF_LOW_RES);
    blobFinder.setRotation( ofVec3f( angle, 0, 0) );
    blobFinder.setTranslation(ofVec3f(0,0,0));
    blobFinder.setScale(ofVec3f(0.001, 0.001, 0.001)); // mm to meters
    // bind our kinect to the blob finder
    // in order to do this we need to declare in testApp.h: class testApp : public ofBaseApp, public ofxKinectBlobListener
    blobTracker.setListener( this );

    blobImage.allocate(kinect.width, kinect.height, OF_IMAGE_GRAYSCALE);

    background.allocate(kinect.width, kinect.height, OF_IMAGE_GRAYSCALE);
    backgroundTex.allocate(kinect.width, kinect.height);//,OF_IMAGE_GRAYSCALE);
    inPainter.setup(kinect.width, kinect.height);

    tmpMapMask = new unsigned char[kinect.width*kinect.height];
    tmpZonesMask = new unsigned char[kinect.width*kinect.height];

    nearThreshold=10000.;
    farThreshold=10000.;

    diffThreshold=100.;

    maxBlobs = 10;
    minBlobPoints=250;
    maxBlobPoints=1000000;
    // NOTE: measurement units in meters!!!
    minBlobVol = 0.02f;
    maxBlobVol = 2.0f;

    damping=10.;
    mass=1.;
    K=30.;
    /*zonesCols=3;
    zonesRows=3;
    zonesColSpacing=20;
    zonesRowSpacing=20;*/

    dilate=10;
    erode=10;

    getPitchAndRoll=false;
    pitch=0.;
    roll=0.;

    mapPoint=0;
	mapFbo.allocate(kinect.width,kinect.height);
	mapPixels.allocate(kinect.width,kinect.height,OF_IMAGE_GRAYSCALE);
    mapMask.allocate(kinect.width, kinect.height);

    zonesDistance=10.;
    zonesFbo.allocate(kinect.width,kinect.height);

    gui = new ofxUISuperCanvas("kinectMap", OFX_UI_FONT_MEDIUM);
    gui->addSpacer();
    gui->addTextArea("CONTROL", "Control de parametros de kinectMap");
    gui->addSpacer();
    gui->addSlider("angle", -30, 30, &angle);
    gui->addLabelToggle("learnBackground", &learnBackground);
    gui->addSlider("backFrames", 0.0, BACKGROUND_FRAMES, &backFrames);
    gui->addSpacer();
    gui->addSlider("maxBlobs", 0, 20, &maxBlobs);
    gui->addSlider("min blob points", 0, 2000, &minBlobPoints);
    gui->addSlider("min blob vol", 0.0, 0.2, &minBlobVol);
    gui->addSlider("max blob vol", 1., 10., &maxBlobVol);
    gui->addSpacer();
    gui->addRangeSlider("near and far threshold", 0., 5000., &nearThreshold,&farThreshold);
    gui->addSlider("diff threshold", 0., 1000., &diffThreshold);
    gui->addSpacer();
    gui->addSlider("person damping", 0., 10., &damping);
    gui->addSlider("person mass", 1., 10., &mass);
    gui->addSlider("person K", 1., 30., &K);
    gui->addSpacer();
    gui->addLabelToggle("get pitch and roll",&getPitchAndRoll);
    gui->addSlider("pitch", -180., 180., &pitch);
    gui->addSlider("roll", -180., 180., &roll);
    gui->addSpacer();
    gui->addLabelToggle("mapOpen", &mapOpen);
    gui->addSpacer();
    gui->addLabelButton("zonesNew", &zonesNew);
    gui->addLabelButton("zonesClear", &zonesClear);
    gui->addSpacer();
    gui->addSlider("dilate", 0, 20, &dilate);
    gui->addSlider("erode", 0, 20, &erode);
    gui->autoSizeToFitWidgets();
    ofAddListener(gui->newGUIEvent,this,&testApp::guiEvent);

    if(ofFile::doesFileExist("GUI/guiSettings.xml"))
        gui->loadSettings("GUI/guiSettings.xml");

    loadMap();

    loadZones();

    sender.setup(IP,PORT);

    mapOpen=false;

    zonesNew=false;
    zonesClear=false;

    rotation.makeRotationMatrix(-90-pitch,ofVec3f(1,0,0),0,ofVec3f(0,1,0),-roll,ofVec3f(0,0,1));

    learnBackground = true;
    backFrames=0.;

	ofSetFrameRate(60);

}
Beispiel #6
0
//--------------------------------------------------------------
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 testApp::setup(){
    //base setup
    ofSetFrameRate(FRAME_RATE);
    ofBackground(0);
	ofTrueTypeFont::setGlobalDpi(72);
    ofRegisterURLNotification(this);
    //height fo bar on top and bottom
    barHeight=96;
    
    //
    recentPostcards="http://www.ualphabets.com/requests/Riga/postcards.php";
    recentLetters="http://www.ualphabets.com/requests/Riga/letters.php";
    currentAlphabet="http://www.ualphabets.com/requests/Riga/alphabet.php";
    info="Info";
    
    
    //setup of the URLS that need to be loaded
    URLsToLoad[0]=info;
    URLsToLoad[1]=recentPostcards;
    URLsToLoad[2]=recentLetters;
    URLsToLoad[3]=recentPostcards;
    URLsToLoad[4]=currentAlphabet;
    URLsToLoad[5]=recentPostcards;
    
    currentURLNo=0; //first screen to be shown
    currentURL=URLsToLoad[currentURLNo];
    loading= true; //send the first request on start alphabets/postcards/...
    
    //setup for intro screens before actual
    counterDrawInfo=0;
    loadingResponseDone=false;
    blendInfo=0;
    introLength=5;
    
    //setup for alphabet screen
    counterDrawAlphabet=0;
    alphabetLength=10;
    alphabetTitle.loadImage("intro/intro_currentAlphabet.png");
    
    //setup for postcards and letters screen
    lengthPostcardsAndLetters=10;//in secs
    counterPostcardsAndLetters=0;
    lettersTitle.loadImage("intro/intro_titleLetters.png");
    postcardsTitle.loadImage("intro/intro_titlePostcards.png");
    
    //the latvian alphabet
    alphabet[0]="A";
    alphabet[1]="LatvA";
    alphabet[2]="B";
    alphabet[3]="C";
    alphabet[4]="LatvC";
    alphabet[5]="D";
    alphabet[6]="E";
    alphabet[7]="LatvE";
    alphabet[8]="F";
    alphabet[9]="G";
    alphabet[10]="LatvG";
    alphabet[11]="H";
    alphabet[12]="I";
    alphabet[13]="LatvI";
    alphabet[14]="J";
    alphabet[15]="K";
    alphabet[16]="LatvK";
    alphabet[17]="L";
    alphabet[18]="LatvL";
    alphabet[19]="M";
    alphabet[20]="N";
    alphabet[21]="LatvN";
    alphabet[22]="O";
    alphabet[23]="P";
    alphabet[24]="R";
    alphabet[25]="S";
    alphabet[26]="LatvS";
    alphabet[27]="T";
    alphabet[28]="U";
    alphabet[29]="LatvU";
    alphabet[30]="V";
    alphabet[31]="Z";
    alphabet[32]="LatvZ";
    alphabet[33]="1";
    alphabet[34]="2";
    alphabet[35]="3";
    alphabet[36]="4";
    alphabet[37]="5";
    alphabet[38]="6";
    alphabet[39]="7";
    alphabet[40]="8";
    alphabet[41]="9";
    
    //images before the actual screens
    imagesIntro[0].loadImage("intro/intro_Title.png");//logo
    imagesIntro[1].loadImage("intro/intro_recentLetters.png");//letters
    imagesIntro[2].loadImage("intro/intro_currAlphabet.png");//alphabet
    imagesIntro[3].loadImage("intro/intro_recentPostcards.png");//postcards
    
    //send the first request
    if (currentURL!="Info") {
        printf("now \n");
        int id = ofLoadURLAsync(currentURL, "async_req");
    } else {
        printf("%s", currentURL.c_str());
        loadingResponseDone=true;
    }
    
}
Beispiel #8
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    //ENVIRONMENT AND MAXIMILIAN
    ofSetFrameRate(60);
    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    ofBackground(0,0,0);
    sampleRate 	= 44100; /* Audio sampling rate */
    bufferSize	= 512; /* Audio buffer size */
    ofxMaxiSettings::setup(sampleRate, 2, bufferSize);
    
    ofColor bg(100,100,100,150);
    ofColor fg(255);
    
    //sequencing
    now = ofGetElapsedTimeMillis();
    delay = 1000;
    numSequencerSteps = 16;
    
    //UI positions and dimensions
    padBounds.x = 150;
    padBounds.y = 50;
    padBounds.width = padBounds.height = 625;
    
    sequencerX = padBounds.x+padBounds.width+25;
    sequencerY = padBounds.y;
    sequencerW = 330;
    sequencerToggleH = 100;
    sequencerStepH = 25;
    
    //parameter names
    xParamName = "x";
    yParamName = "y";
    timerParamName = "timer";
    playbackParamName = "playback";
    filterSpeedParamName = "filter speed";
    resetParamName = "reset playback gesture";
    
    //ZONE SETUP
    //parameters: name, x, y, width, background color, foreground color, sound filename, sound buffer size
    //PAD
    zonePad.setup("padZone", padBounds.x, padBounds.y, padBounds.width, bg,fg, "synth.wav", bufferSize);
    zonePad.addParameterFloat(xParamName, 0.0, 1.0, 0.5);
    zonePad.addParameterFloat(yParamName, 0.0, 1.0, 0.5);
    zonePad.addUI(new ofxAVUIXYPad("Pad", "","", xParamName,yParamName), padBounds.height);
    
    //SEQUENCER
    //kick.wav = https://www.freesound.org/people/DWSD/sounds/171104/
    zoneSequencer.setup("toggleZone", sequencerX, sequencerY, sequencerW, bg, fg, "kick.wav", bufferSize);
    //ZONE UI
    zoneSequencer.addParameterBool(playbackParamName, true);
    zoneSequencer.addUI(new ofxAVUIToggle(playbackParamName,playbackParamName), sequencerToggleH);

    sequencerTogglePrefix = "toggle #";
    for(int i = 0 ; i < numSequencerSteps; i++){
        string toggleParamName = sequencerTogglePrefix + (ofToString(i));
        zoneSequencer.addParameterBool(toggleParamName, false);
        zoneSequencer.addUI(new ofxAVUIToggle(toggleParamName,toggleParamName), sequencerStepH);
    }
    //timer control
    //params
    zoneSequencer.addParameterFloat(timerParamName, 125, 2000, delay);
    zoneSequencer.addParameterBool(resetParamName, false);
    zoneSequencer.addParameterFloat(filterSpeedParamName, 0.010, 0.100, 0.025);
    //ui
    zoneSequencer.addUI(new ofxAVUIEmpty(""), sequencerStepH);
    //slider parameters: caption, trigger (single tap) parameter name, toggle (double tap) parameter name, x parameter name
    zoneSequencer.addUI(new ofxAVUISlider(timerParamName,"","",timerParamName), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUISlider(filterSpeedParamName,"","",filterSpeedParamName), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUIEmpty(""), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUIButton(resetParamName,resetParamName),sequencerStepH);
    //sound FX
    ofxAVUISoundFxFilter *sfx = new ofxAVUISoundFxFilter();
    //sound fx parameters:
    //- filter enabled toggle name (will be linked to any toggle UI with same name), start value
    //- 1st parameter float name (will be linked to any toggle UI with same name), min value, max value, start value
    //- 2nd parameter float name (will be linked to any toggle UI with same name), min value, max value, start value
    sfx->setup("filterToggle", true, "frequency", 200, 20000, 200, "resonance", 0, 100, 10);
    zoneSequencer.addSoundFx(sfx);
    //START SOUND
    ofSoundStreamSetup(2,2,this, sampleRate, bufferSize, 4); /* this has to happen at the end of setup*/
    
}
Beispiel #9
0
//--------------------------------------------------------------
void testApp::setup(){
    //ofSetLogLevel(OF_LOG_NOTICE);
	project = NULL;

	while(!checkConfigExists()){
		askOFRoot();
	}

	setOFRoot(getOFRootFromConfig());

	setupDrawableOFPath();

	int targ = ofGetTargetPlatform();
	//plat = OF_TARGET_IPHONE;

    setupForTarget(targ);
    if(projectPath!="" || buildAllExamples){
    	for(int i = 0; i < (int)targetsToMake.size(); i++){
			setupForTarget(targetsToMake[i]);
			if(buildAllExamples){
				generateExamples();
			}else{
				project->setup(target);
				project->create(projectPath);
				vector < string > addons;
				parseAddonsDotMake(project->getPath() + "addons.make", addons);
				for (int i = 0; i < (int)addons.size(); i++){
					ofAddon addon;
					addon.fromFS(ofFilePath::join(ofFilePath::join(getOFRoot(), "addons"), addons[i]),target);
					project->addAddon(addon);
				}
				project->save(false);
			}
    	}
        std::exit(0);
    }

#ifndef COMMAND_LINE_ONLY
    panelAddons.setup();
    ofDirectory addons(ofFilePath::join(getOFRoot(),"addons"));
    addons.listDir();
    for(int i=0;i<(int)addons.size();i++){
    	string addon = addons.getName(i);
    	if(addon.find("ofx")==0){
    		ofxToggle * toggle = new ofxToggle();
    		panelAddons.add(toggle->setup(addon,false,300));
    	}
    }

    panelOptions.setup("","settings.xml",ofGetWidth()-panelAddons.getWidth()-10,120);
    panelOptions.add(createProject.setup("create project",300));
    panelOptions.add(updateProject.setup("update project",300));
    panelOptions.add(createAndOpen.setup("create and open project",300));
    panelOptions.add(changeOFRoot.setup("change OF path",300));

    createProject.addListener(this,&testApp::createProjectPressed);
    updateProject.addListener(this,&testApp::updateProjectPressed);
    createAndOpen.addListener(this,&testApp::createAndOpenPressed);
    changeOFRoot.addListener(this,&testApp::changeOFRootPressed);

	examplesPanel.setup("generate examples", "examples.xml", 400, 10);
	examplesPanel.add(generateButton.setup("<--Generate"));
	examplesPanel.add(wincbToggle.setup("win CB projects",ofGetTargetPlatform()==OF_TARGET_WINGCC));
	examplesPanel.add(winvsToggle.setup("win VS projects", ofGetTargetPlatform()==OF_TARGET_WINVS));
	examplesPanel.add(linuxcbToggle.setup("linux CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX));
	examplesPanel.add(linux64cbToggle.setup("linux64 CB projects",ofGetTargetPlatform()==OF_TARGET_LINUX64));
	examplesPanel.add(osxToggle.setup("osx projects",ofGetTargetPlatform()==OF_TARGET_OSX));
	examplesPanel.add(iosToggle.setup("ios projects",ofGetTargetPlatform()==OF_TARGET_IPHONE));

	generateButton.addListener(this,&testApp::generateExamplesCB);

    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
	ofSetFrameRate(60);
#else
	std::exit(0);
#endif
}
Beispiel #10
0
//--------------------------------------------------------------
void ofApp::setup() {

	ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetFrameRate(60);

	h = 480;
	w = 640;
	angle = 0;
	screenSectionWidth = floor(w/3);

	allowSaveMesh = false;

	kinect.setRegistration(true);
	kinect.init(false, false); // disable video image (faster fps)

	kinect.open();		// opens first available kinect

	// print the intrinsic IR sensor values
	if(kinect.isConnected()) {
		ofLogNotice() << "sensor-emitter dist: "   << kinect.getSensorEmitterDistance() << "cm";
		ofLogNotice() << "sensor-camera dist:  "   << kinect.getSensorCameraDistance() 	<< "cm";
		ofLogNotice() << "zero plane pixel size: " << kinect.getZeroPlanePixelSize() 	<< "mm";
		ofLogNotice() << "zero plane dist: " 	   << kinect.getZeroPlaneDistance() 	<< "mm";
	}

	kinectAngle.addListener(this, &ofApp::angleChange);
	saveMeshBtn.addListener(this, &ofApp::saveMesh);

	cameraUpDwn.addListener(this, &ofApp::cameraUpDwnChange);

	topLimit.addListener(this, &ofApp::topLimitChange);
	botLimit.addListener(this, &ofApp::botLimitChange);
	leftLimit.addListener(this, &ofApp::leftLimitChange);
	rightLimit.addListener(this, &ofApp::rightLimitChange);

	nearThreshold.addListener(this, &ofApp::nearThresholdChange);
	farThreshold.addListener(this, &ofApp::farThresholdChange);

	// ui
	gui.setup();

	gui.add(cameraUpDwn.setup( "Camera Up/Dwn", 0, -500, 500 ));
	gui.add(cameraInOut.setup( "Camera In/Out", 670, 0, 1000 ));

	gui.add(nearThreshold.setup( "Near Threshold", 0, 0, KINECT_MAX_THRESHOLD ));
	gui.add(farThreshold.setup( "Far Threshold", KINECT_MAX_THRESHOLD, 0, KINECT_MAX_THRESHOLD ));

	gui.add(topLimit.setup("top", 0, 0, 480));
	gui.add(botLimit.setup("bot", 480, 0, 480));
	gui.add(leftLimit.setup("left", 0, 0, 640));
	gui.add(rightLimit.setup("right", 640, 0, 640));
	gui.add(kinectAngle.setup("angle", 0, -15, 15));
	gui.add(pointStep.setup("point step", 1, 1, h/2));
	gui.add(saveMeshBtn.setup("SAVE"));

	// mesh
	mesh.setMode(OF_PRIMITIVE_POINTS);

	// camera
	cam.setPosition(ofVec3f(0,0,0));
	centreNode.setPosition(ofVec3f(0,0,0));
	cam.lookAt(centreNode);

	// serial
	AD1.listDevices();
	AD1.setup("COM6", BAUD_RATE);

	resetDetectionVariables();
}
Beispiel #11
0
//--------------------------------------------------------------
void ofApp::setup(){
	ofSetFrameRate(60);
	cam.setFarClip(100000000);
	cam.setOrientation(ofVec3f(45, 0, 0));
	//cam.setTarget(ofVec3f(100, 100, 200));

	font.loadFont("BuxtonSketch.ttf", 20);


#ifdef ONCE
#ifdef STRETCH
	// stretch
	node1 = new crossingNode(ofVec3f(20, 25, 0), 20, 25);
	node2 = new crossingNode(ofVec3f(25, 25, 0), 25, 25);
	
	link = new stretchLink(node1, node2, 0.25 * 0.25 * 3.1415 * 10000000);
	
	node2->velocity.y = 0.1;
	node2->velocity.x = 0.1;
#endif // STRETCH

#ifdef BEND
	//	bend
	node1 = new crossingNode(ofVec3f(25, 25, 0), 25, 25);
	node2 = new crossingNode(ofVec3f(20, 25, 0), 20, 25);
	node3 = new crossingNode(ofVec3f(15, 30, 0), 15, 30);

	bLink = new bendLink(node1, node2, node3, 0.01 * 3.1415 * 0.25 * 0.25);
#endif // BEND

#ifdef SHEAR
	// shear
	node0 = new crossingNode(ofVec3f(20, 25, 0), 20, 25);
	node1 = new crossingNode(ofVec3f(25, 25, 0), 25, 25);
	node3 = new crossingNode(ofVec3f(25, 30, 0), 22, 30);
	
	sLink = new shearLink(node0, node1, node3, 1);
#endif // SHEAR

	// friction
#ifdef FRICTION

#endif // FRICTION

#endif // ONCE

#ifdef TEST
	// 假定交叉点不会互相分离

	for(int i=0; i<width; i++)
	{
		for(int j=0; j<height; j++)
		{
			crossingNode* node1 = new crossingNode(ofVec3f(i*L - width * L / 2, j*L - height * L / 2 + 2000, -2000), i*L, j*L);

			if((i + j) % 2 == 0)
				node1->warpIsUp = true;
			else
				node1->warpIsUp = false;

			wovenCloth.push_back(node1);
		}
	}

	// parallel Contact
	for(int i=0; i < wovenCloth.size(); i++)
	{
		// 经纱
		if(i % width + 1 < width)
		{
			// ks = Y * PI * R * R
			parallelContactLink* link = new parallelContactLink(wovenCloth[i], wovenCloth[i+1], 1);
			link->bType = 0;
			parallelContactLinkList.push_back(link);
		}

		// 纬纱
		if(i + height < wovenCloth.size())
		{
			parallelContactLink* link = new parallelContactLink(wovenCloth[i], wovenCloth[i + width], 1);
			link->bType = 1;
			parallelContactLinkList.push_back(link);
		}
	}

	// stretch
	for(int i=0; i < wovenCloth.size(); i++)
	{
		// 经纱
		if(i % width + 1 < width)
		{
			// ks = Y * PI * R * R
			stretchLink* link = new stretchLink(wovenCloth[i], wovenCloth[i+1], 0.25 * 0.25 * 3.1415 * 10000000);
			link->bType = 0;
			stretchLinkList.push_back(link);
		}

		// 纬纱
		if(i + height < wovenCloth.size())
		{
			stretchLink* link = new stretchLink(wovenCloth[i], wovenCloth[i + width], 0.25 * 0.25 * 3.1415 * 10000000);
			link->bType = 1;
			stretchLinkList.push_back(link);
		}
	}

	// bend
	for(int i=0; i < wovenCloth.size(); i++)
	{		
		// 经纱
		if(i % width + 2 < width)
		{
			bendLink* link = new bendLink(wovenCloth[i], wovenCloth[i+1], wovenCloth[i+2], 0.01 * 3.1415 * 0.25 * 0.25);
			link->bType = 0;
			bendLinkList.push_back(link);
		}

		// 纬纱
		if(i + height * 2 < wovenCloth.size())
		{
			bendLink* link = new bendLink(wovenCloth[i], wovenCloth[i + width], wovenCloth[i + width * 2], 0.01 * 3.1415 * 0.25 * 0.25);
			link->bType = 1;
			bendLinkList.push_back(link);
		}
	}

	// shear
	for(int i=0; i < wovenCloth.size(); i++)
	{		
		// 经纱
		if(i - width >= 0 && i % width + 1 < width)
		{
			shearLink* link = new shearLink(wovenCloth[i], wovenCloth[i-width], wovenCloth[i+1], 0.01);
			shearLinkList.push_back(link);
		}
	}

	// drawLink
	// 只在渲染时才会有双层的概念
	for(int i=0; i < wovenCloth.size(); i++)
	{
		// 分上下层 相距2R
		// 经纱
		if(i % width + 1 < width)
		{
			crossingNode* node1 = wovenCloth[i], *node2 = wovenCloth[i+1];
			drawLink *link;
			if(node1->warpIsUp)
			{
				link = new drawLink(node1, node2, R);
				link->type = 0;
				link->state = 0;
				drawLinkList.push_back(link);
			}
			else
			{
				link = new drawLink(node1, node2, R);
				link->type = 0;
				link->state = 1;
				drawLinkList.push_back(link);
			}
		}

		// 纬纱
		if(i + height < wovenCloth.size())
		{
			crossingNode* node1 = wovenCloth[i], *node2 = wovenCloth[i + height];
			drawLink *link;
			if(node1->warpIsUp)
			{
				link = new drawLink(node1, node2, R);
				link->type = 1;
				link->state = 0;
				drawLinkList.push_back(link);
			}
			else
			{
				link = new drawLink(node1, node2, R);
				link->type = 1;
				link->state = 1;
				drawLinkList.push_back(link);
			}
		}
	}

	for(int i=0; i<FRAME_NUM; i++)
	{
		ofFbo *fbo = new ofFbo();
		fbo->allocate(ofGetWidth(), ofGetHeight());
		fboList.push_back(fbo);
	}

	// 自变量
	//wovenCloth[13]->position.z = 5;
#endif // TEST
}
Beispiel #12
0
//--------------------------------------------------------------
void ofApp::setup() {
    ofBackground(0, 0, 0);
    ofSetVerticalSync(true);
    ofSetFrameRate(60);
    
    cameraRotation.set(0);
    zoom = -500;
    zoomTarget = 200;
    
    billboards.getVertices().resize(NUM_BILLBOARDS);
    billboards.getColors().resize(NUM_BILLBOARDS);
    billboards.getNormals().resize(NUM_BILLBOARDS,ofVec3f(0));
    
    // ------------------------- billboard particles
    for (int i=0; i<NUM_BILLBOARDS; i++) {
        
        billboardVels[i].set(ofRandomf(), -1.0, ofRandomf());
        billboards.getVertices()[i].set(ofRandom(-500, 500),
                                        ofRandom(-500, 500),
                                        ofRandom(-500, 500));
        
        billboards.getColors()[i].set(ofColor::fromHsb(ofRandom(96, 160), 255, 255));
        billboardSizeTarget[i] = ofRandom(4, 64);
        
    }
    
    
    billboards.setUsage( GL_DYNAMIC_DRAW );
    billboards.setMode(OF_PRIMITIVE_POINTS);
    //billboardVbo.setVertexData(billboardVerts, NUM_BILLBOARDS, GL_DYNAMIC_DRAW);
    //billboardVbo.setColorData(billboardColor, NUM_BILLBOARDS, GL_DYNAMIC_DRAW);
    
    // load the billboard shader
    // this is used to change the
    // size of the particle
    if(ofGetGLProgrammableRenderer()){
        billboardShader.load("shadersGL3/Billboard");
    }else{
        billboardShader.load("shadersGL2/Billboard");
    }
    
    // we need to disable ARB textures in order to use normalized texcoords
    ofDisableArbTex();
    texture.loadImage("dot.png");
    ofEnableAlphaBlending();
    
    //initialize the video grabber
    vidGrabber.setVerbose(true);
    vidGrabber.initGrabber(320,240);
    
    //store the width and height for convenience
    int width = vidGrabber.getWidth();
    int height = vidGrabber.getHeight();
    
    //add one vertex to the mesh for each pixel
    for (int y = 0; y < height; y++){
        for (int x = 0; x<width; x++){
            mainMesh.addVertex(ofPoint(x,y,0));	// mesh index = x + y*width
												// this replicates the pixel array within the camera bitmap...
            mainMesh.addColor(ofFloatColor(0,0,0));  // placeholder for colour data, we'll get this from the camera
        }
    }
    
    for (int y = 0; y<height-1; y++){
        for (int x=0; x<width-1; x++){
            mainMesh.addIndex(x+y*width);				// 0
            mainMesh.addIndex((x+1)+y*width);			// 1
            mainMesh.addIndex(x+(y+1)*width);			// 10
            
            mainMesh.addIndex((x+1)+y*width);			// 1
            mainMesh.addIndex((x+1)+(y+1)*width);		// 11
            mainMesh.addIndex(x+(y+1)*width);			// 10
        }
    }
    
    //this is an annoying thing that is used to flip the camera
    cam.setScale(1,-1,1);
    
    
    //this determines how much we push the meshes out
    extrusionAmount = 300.0;
}
void Scene4::setup(){
    
    ofSetVerticalSync(true);
    ofSetFrameRate(24);
    
    cat.loadFont("MTLmr3m.ttf", 24);
    cat.setLineHeight(12.0f);
	cat.setLetterSpacing(1.0);
    
    float tx1 = cat.stringWidth("つめのあいだにも");
    float ty1 = cat.stringHeight("つめのあいだにも");
    i1X = ofGetWidth() / 2 - tx1 / 2;
    i1Y = ofGetHeight() / 2 +  ty1 / 2;
    
    float tx2 = cat.stringWidth("バイキンがいっぱい!");
    float ty2 = cat.stringHeight("バイキンがいっぱい!");
    i2X = ofGetWidth() / 2 - tx2 / 2;
    i2Y = ofGetHeight() / 2 +  ty2 / 2;
    
    float tx3 = cat.stringWidth("ねこのポーズで");
    float ty3 = cat.stringHeight("ねこのポーズで");
    i3X = ofGetWidth() / 2 - tx3 / 2;
    i3Y = ofGetHeight() / 2 +  ty3 / 2;
    
    float tx4 = cat.stringWidth("あらってみよう!");
    float ty4 = cat.stringHeight("あらってみよう!");
    i4X = ofGetWidth() / 2 - tx4 / 2;
    i4Y = ofGetHeight() / 2 +  ty4 / 2;
    
    
    // Initial Allocation
    //
    fluid.allocate(ofGetWidth(), ofGetHeight(), 0.5);
    
    // Seting the gravity set up & injecting the background image
    //
    fluid.dissipation = 0.99;
    fluid.velocityDissipation = 0.99;
    fluid.setGravity(ofVec2f(0.0,0.0));
    //  Set obstacle
    //
    fluid.setUseObstacles(false);
    
    // Adding constant forces
    ofSetWindowShape(ofGetWidth(), ofGetHeight());
    
    //指の座標の初期化
    for(int i=0;i<10;i++){
        fingerPosX[i] = 0;
        fingerPosY[i] = 0;
    }
    
    //使えるカメラのリスト化
    vector<ofVideoDevice> devices = vidGrabber.listDevices();
    for(int i = 0; i < devices.size(); i++){
		cout << devices[i].id << ": " << devices[i].deviceName;
        if( devices[i].bAvailable ){
            cout << endl;
        }else{
            cout << " - unavailable " << endl;
        }
	}
    
    //ビデオの設定
    camWidth 		= ofGetWidth();	// try to grab at this size.
	camHeight 		= ofGetHeight();
    
    getSharedData().vidGrabber.setDesiredFrameRate(24);
    getSharedData().vidGrabber.setVerbose(true);
    
    //
    //initialize parameters
    fogDensity = 5.0f;
    
	mouseX = 0;
	mouseY = 0;
}
Beispiel #14
0
//--------------------------------------------------------------
void ofApp::setup(){
    

    
    //base setup
    ofSetFrameRate(FRAME_RATE);
    ofBackground(100);
    ofTrueTypeFont::setGlobalDpi(72);
    ofRegisterURLNotification(this);
    
    syphonServer.setName("Syphon Output");
    
    //size of LED 2
    screenWidth=480;
    screenHeight=288;
    
    //size of LED1
    screenWidthLED1=768;
    screenHeightLED1=288;
    
    //
    recentPostcards="http://www.ualphabets.com/requests/SaoPaulo/postcards.php";
    recentLetters="http://www.ualphabets.com/requests/SaoPaulo/letters.php";
    currentAlphabet="http://www.ualphabets.com/requests/SaoPaulo/alphabet.php";
    currentQuestion="http://www.ualphabets.com/requests/Riga/connected/question.php";
    
    info="Info";
    
    //setup of the URLS that need to be loaded
    URLsToLoad[0]=info;
    URLsToLoad[1]=currentAlphabet;
    URLsToLoad[2]=recentPostcards;
    URLsToLoad[3]=recentPostcards;
    URLsToLoad[4]=recentLetters;
    URLsToLoad[5]=recentPostcards;
    URLsToLoad[6]=recentPostcards;
    
    currentURLNo=0; //first screen to be shown
    currentURL=URLsToLoad[currentURLNo];
    loading= true; //send the first request on start alphabets/postcards/...
    
    
    //setup for intro screens before actual
    loadingResponseDone=false;
    blendInfoFacade=0;
    blendInfoLED2=0;
    introLength=5;
    
    //setup for alphabet screen
    counterDrawAlphabet=0;
    alphabetLength=11.6;
    alphabetLengthLED1=alphabetLength-4.4;
    counterAlphabetsTitle=0;
    alphabetTitleFacade.loadImage("intro_facade/intro_currentAlphabet.png");
    alphabetTitleLED1.loadImage("intro_LED1/intro_currentAlphabet.png");
    alphabetTitleLED2.loadImage("intro_LED2/intro_currentAlphabet.png");
    
    //setup for postcards and letters screen
    lengthPostcards=10;//in secs
    lengthLetters=8;//in secs
    counterPostcardsAndLetters=0;
    counterPostcardsTitle=0;
    counterPostcardsQuestion=0;
    counterLettersTitle=0;
    counterNumberPostcards=0;
    lettersTitleFacade.loadImage("intro_facade/intro_titleLetters.png");
    lettersTitleLED1.loadImage("intro_LED1/intro_titleLetters.png");
    lettersTitleLED2.loadImage("intro_LED2/intro_titleLetters.png");
    currImgNo=0;
    
    //changing questions setup
    questionsFacade[0].loadImage("questions_facade/questions_english_-01.png");
    questionsFacade[1].loadImage("questions_facade/questions_english_-02.png");
    questionsFacade[2].loadImage("questions_facade/questions_english_-03.png");
    questionsFacade[3].loadImage("questions_facade/questions_english_-04.png");
    //LED questions
    questionsLED2[0].loadImage("questions_LED2/questions_english_-01.png");
    questionsLED2[1].loadImage("questions_LED2/questions_english_-02.png");
    questionsLED2[2].loadImage("questions_LED2/questions_english_-03.png");
    questionsLED2[3].loadImage("questions_LED2/questions_english_-04.png");
    currentQuestionNumber=0;
    
    postcardsTitleLED1.loadImage("intro_LED1/intro_titlePostcards.png");
    postcardsTitleLED2.loadImage("intro_LED2/intro_titlePostcards.png");
    
    
    //the latvian alphabet
    alphabet[0]="A";
    alphabet[1]="B";
    alphabet[2]="C";
    alphabet[3]="D";
    alphabet[4]="E";
    alphabet[5]="F";
    alphabet[6]="G";
    alphabet[7]="H";
    alphabet[8]="I";
    alphabet[9]="J";
    alphabet[10]="K";
    alphabet[11]="L";
    alphabet[12]="M";
    alphabet[13]="N";
    alphabet[14]="O";
    alphabet[15]="P";
    alphabet[16]="Q";
    alphabet[17]="R";
    alphabet[18]="S";
    alphabet[19]="T";
    alphabet[20]="U";
    alphabet[21]="V";
    alphabet[22]="W";
    alphabet[23]="X";
    alphabet[24]="Y";
    alphabet[25]="Z";
    alphabet[26]="+";
    alphabet[27]="$";
    alphabet[28]=",";
    alphabet[29]=".";
    alphabet[30]="!";
    alphabet[31]="?";
    alphabet[32]="0";
    alphabet[33]="1";
    alphabet[34]="2";
    alphabet[35]="3";
    alphabet[36]="4";
    alphabet[37]="5";
    alphabet[38]="6";
    alphabet[39]="7";
    alphabet[40]="8";
    alphabet[41]="9";
    
    //question
    xPosQuestion=430;
    
    //send the first request
    if (currentURL!="Info") {
        printf("now \n");
        int id = ofLoadURLAsync(currentURL, "async_req");
    } else {
        printf("%s", currentURL.c_str());
        loadingResponseDone=true;
    }
}
//--------------------------------------------------------------
void testApp::setup(){
	
	
	//ofEnableSmoothing();	
	ofEnableAlphaBlending();  
	ofSetFrameRate(30);
	
	//ofSetDataPathRoot("./data/");
	//if we need to package up program
	
	//Syphon
	mClient.setup();
    mClient.setApplicationName("Simple Server");
    mClient.setServerName("");

	backgroundServer.setName("Background");
	//foregroundServer.setName("Foreground");
	textServer.setName("Text");
	
	backgroundTex.allocate(ofGetWidth(), ofGetHeight(),GL_RGBA);  
	//foregroundTex.allocate(ofGetWidth(), ofGetHeight()/4,GL_RGBA);
	textTex.allocate(ofGetWidth(),300, GL_RGBA);
	
	//UI
	smsTriggerIP = "hello hi";
	
	smsIP = "127.0.0.1";
	drawFill = true;
	float dim = 16;
	float xInit = OFX_UI_GLOBAL_WIDGET_SPACING; 
    float length = 320-xInit; 
	
	gui = new ofxUICanvas(0,0,length+xInit*2.0,ofGetHeight());   
	gui->addWidgetDown(new ofxUILabel("JOLIETTE INTERACTIVE", OFX_UI_FONT_LARGE)); 
	gui->addSpacer(length, 2); 
	
	gui->addWidgetDown(new ofxUILabel("BOID CONTROL", OFX_UI_FONT_MEDIUM));
	gui->addMinimalSlider("STATIC FLYING PUSH", 0, 50, setSeparation, 95, dim);
	gui->addMinimalSlider("STATIC FLYING PULL", 0, 10, setCohesion, 95, dim);
	gui->addMinimalSlider("MAXSPEED", 0, 5, setMaxSpeed, 95, dim);
	gui->addMinimalSlider("MAXFORCE", 0, 1, setForce, 95, dim);
    gui->addMinimalSlider("FLAP MAGNITUDE", 0, 1, flapMagnitude, 95, dim);
	gui->addMinimalSlider("LINE FOLLOW", 0, 200, setNeighbordist, 95, dim);
    
    gui->addWidgetDown(new ofxUILabel("VIDEO SETTINGS", OFX_UI_FONT_MEDIUM));
	gui->addMinimalSlider("VIDEO SCALE", 0, 640, scale, 95, dim);
	gui->addMinimalSlider("SCALE MAGNITUDE", 0, 300, scaleMagnitude, 95, dim);
	
    gui->addWidgetDown(new ofxUILabel(" CV SETTINGS ", OFX_UI_FONT_MEDIUM));
	gui->addMinimalSlider("THRESHOLD", 0, 100, threshold, 95, dim);
    
	gui->addSpacer(length, 2);
	gui->addWidgetDown(new ofxUILabel("RECORD FLYING", OFX_UI_FONT_MEDIUM));
	gui->addMinimalSlider("UP MULTIPLIER", 0,10, downMult, 95, dim);
	gui->addMinimalSlider("DOWN MULTIPLIER", 0, 1, upMult, 95, 0);
	gui->addMinimalSlider("FLAP THRESHOLD", 0, 1, flapThresh, 95, dim);
	gui->addMinimalSlider("END RECORD SEQUENCE DELAY", 0, 100 , endRecordSequenceDelay, 95, dim);
    gui->addMinimalSlider("END SPEED", 0, 2, endSpeed, 95, dim);

    gui->addSpacer(length, 2);
	gui->addWidgetDown(new ofxUILabel("TEXT", OFX_UI_FONT_MEDIUM));
	
	gui->addWidgetDown( new ofxUITextInput("UDP_TARGET_IP", "", 95, dim)); //("UDP_TARGET_IP",smsTriggerIP, 95,dim); //smsIP
	
	gui->addMinimalSlider("TEXT SPEED", 0, 10, textSpeed, 95, dim);
		
	ofAddListener(gui->newGUIEvent,this,&testApp::guiEvent);
	gui->loadSettings("GUI/guiSettings.xml"); 

	
	//UDP Communication
	
	textMessageConnection.Create();
	textMessageConnection.Bind(7303);
	textMessageConnection.SetNonBlocking(true);
	
	triggerInConnection.Create();
	triggerInConnection.Bind(7304);
	triggerInConnection.SetNonBlocking(true);
	
	triggerOutConnection.Create();
	triggerOutConnection.Connect("127.0.0.1",7305);   //"192.168.7.254" MAC pro IP in Joliette:
	triggerOutConnection.SetNonBlocking(true);
	
	
	// Messages
	shimmer.loadFont("shimmerbold_opentype.ttf", 30);
	sendTrigger = false;
		
	
	//Video
	camWidth 	= 640; 
	camHeight 	= 360; 
	
	vidGrabber.setVerbose(true);
	vidGrabber.listDevices();
	
	vidGrabber.setDeviceID(0);
	vidGrabber.initGrabber(camWidth,camHeight,true);
    
	camWidthScale = ofGetWidth();
	camHeightScale = camWidthScale *0.562; //should give proportions of 16:9

	cout << camHeightScale;
	cout << camWidthScale;
	
	// OpenCV
	getBackground = false; // true is auto, false is manual
	
	highBlob = 9999999;
	lowBlob = 100;
	
	diffMode  = 0;
	flap	  = 0;
    mappedFlap = 0;
    
	
	cvColor.allocate(camWidth,camHeight);
	cvGray.allocate(camWidth,camHeight);
	cvBackground.allocate(camWidth,camHeight);
	cvThresh.allocate(camWidth,camHeight);
	lastGray.allocate(camWidth,camHeight);
	frameDiff.allocate(camWidth,camHeight);
	
	
	
	
	// Recording
	
	playIndex = 0;
	lastPlayIndex = 0;
	
	nrDisplaySequences = 12;
	bufferSize = 24;
   
	cutoutTex.allocate(camWidth,camHeight,GL_RGBA);
	cutoutPixels = new unsigned char[camWidth*camHeight*4];
	record = 0;
	index = 0;  
	
	videoPos = 0;
	videoVel = 0;
	videoProgressBar = 100;
	
	endRecordSequence = false;
	endRecordSequenceTime = 0;
	
	bufferFull = false;
    bufferFullDuringShow = false;
  	
	//Playback
	play = 0;
	playbackIndex = 0;
	playSequenceIndex = 0;
	sequenceIndex = 0;
	startIndex = 0;
	
	gui->toggleVisible();
	
	
	//XML Settings
	message = "loading mySettings.xml";
	
	if (XML.loadFile("mySettings.xml")) {
		message = "mySettings.xml loaded";
	}else{
		message = "unable to load mySettings.xml check data/ folder";
	}
		int numDragTags = XML.getNumTags("STROKE:PT");
		
		if(numDragTags > 0 ){
		
			XML.pushTag("STROKE", numDragTags-1);
			
			int numPtTags = XML.getNumTags("PT");
			
			if (numPtTags > 0) {
				
				int totalToRead = numPtTags;
				
				for (int i = 0; i < totalToRead; i ++) {
					
					int x = XML.getValue("PT:X", 0,i);
					int y = XML.getValue("PT:Y", 0,i);
					pth.addPoint(x, y);
					
				}
				
			}
			
			XML.popTag();
		
		}
	
	
	//Debug 
	cvImgDisp = false;

	
	// Show Management
	end = 0;
	pan = 0;
	showState = 0;
	hold = 0;
	
    
	//Flock
	
	for(int i = 0; i < bufferSize; i ++) {
		flock.addBoid(ofRandom(-100, -500),ofRandom(100,2*ofGetHeight()/3));
	}
    
	showBoidsHead = 0;
	showBoidsTail = 0;
	showBoids = false;
	removeLastBoid = false;
    
	// LOAD BACKGROUNS IMAGE
	//bgImg.loadImage("imgBg/bgParallax-1.png");
	bgImg.loadImage("imgBg/bgCabine.jpg");
	progressBar.loadImage("progressBarCandy.png");
	
    // LOAD BACKGROUND VIDEO
	//bgVideo.loadMovie("videoBg/bg_cabanRotate.mov");
	//bgVideoEndRec.loadMovie("videoBg/blue-sparks.mov");
    
    posBgImg = -960;
    
    controllerThread.start();
}
Beispiel #16
0
//--------------------------------------------------------------
void testApp::setup(){
	
	ofSetVerticalSync(true);
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetFrameRate(60);
	
	
	// XML LOAD ------------------------------------------------*
	
	XML.loadFile("app_settings.xml");
	
	// SET NUMBER OF MODULES HERE ------------------------------*
	
	XML.pushTag("all", 0);
	numMod = XML.getValue("numMod", 1, 0); // -------------------------------------------***
	filesPath = XML.getValue("filesPath", "", 0);
	bExhibitionMode = XML.getValue("bExhibitionMode", false, 0);
	XML.popTag();
	
	// SET OSC HERE --------------------------------------------*
	
	XML.pushTag("all", 0);
	oscHost = XML.getValue("oscHost", "localhost", 0); // -------------------------------***
	oscPort = XML.getValue("oscPort", 1234, 0); // ---------------------------------------***
	XML.popTag();
	
	oscSender.setup(oscHost, oscPort);
	
	// ---------------------------------------------------------*
	
	// DRAWING VARS --------------------------------------------*
	
	camWidth 		= 640;
	camHeight 		= 480;
	
	dispWidth		= 1280;
	dispHeight		= 720;
	
	drawWidth		= 640;
	drawHeight		= 360;
	drawX			= 500;
	drawY			= 115;
	
	screenWidth		= (numMod + 1) * dispWidth;
	screenHeight	= dispHeight;
	
	ofSetWindowShape(screenWidth, screenHeight);
	
	
	// ---------------------------------------------------------*
	
	// OBJECT ARRAYS -------------------------------------------*
	
	modules = new margModule[numMod];
	textures = new ofTexture[numMod];	
	
	// SETUP VARS ----------------------------------------------*
	
	curMod = -1;
	
	modes[0] = "SOURCE";
	modes[1] = "LENSCORRECTED_SOURCE";
	modes[2] = "WARPED_SOURCE";
	modes[3] = "THRESHOLD_SOURCE";
	modes[4] = "TRAIL_MAP";
	modes[5] = "FINAL_IMAGE";
	modes[6] = "BYPASS_VIDEO";
	
	interactModes[0] = "NORMAL_TRAIL";
	interactModes[1] = "NO_FADE_TRAIL";
	interactModes[2] = "BYPASS_TRAIL";
	
	quads[0] = "DISP_QUAD";
	quads[1] = "CAPT_QUAD";
	
	blobsToDraw[0] = "ORIGINAL_BLOBS";
	blobsToDraw[1] = "CORRECTED_BLOBS";
	blobsToDraw[2] = "INTERPOLATED_BLOBS";

	
	// MODULE INITIALIZATION -----------------------------------*
	
	for (int i = 0; i < numMod; i++) {
		XML.pushTag("module", i);
		
		int capt = XML.getValue("captDev", -1, 0);
		string moviePath = XML.getValue("moviePath", filesPath + "movies/", 0);
		
		XML.popTag();
		
		modules[i].init(camWidth, camHeight, dispWidth, dispHeight, capt, i, filesPath, moviePath, bExhibitionMode);
		modules[i].setSharedVarsAddresses(&minBlob, &maxBlob, &numBlob,
										  &maxDist, &maxAreaDiff, &maxUnfitness,
										  &blobDefScaleFactor, &blobCondScaleConst, &blobCondScaleMax,
										  &exposureConst, &fadeConst, &blurLevel,
										  &displayMode, &bDynInteractMode,
										  &bDrawBlobs, &whichBlobs,
										  &bAdjQuad, &whichQuad);
		textures[i].allocate(dispWidth, dispHeight, GL_RGB);
	}
	
	oscMessage.setAddress("/sound/play");
	
	if (checkEveryModNeedPlay()) {
		for (int i = 0; i < numMod; i++) {
			modules[i].playVideos();
		}
		oscSender.sendMessage(oscMessage);
	}
	
	// INTERFACE SETUP ----------------------------------------*
	
	gui.addComboBox("Display Mode", displayMode, 7, modes);
	gui.addToggle("No warp control", bDrawUndistorted);
	gui.addToggle("Dynamic Interact Mode", bDynInteractMode);
	gui.addToggle("Control Display", bControlDisplay);
	gui.addToggle("External Display", bExtDisplay);
	gui.addToggle("Run Thread", bRunThread);
	gui.addToggle("Stop Thread", bStopThread);
	gui.addToggle("Update Settings", bUpdateSettings);
	gui.addToggle("Draw White", bDrawWhite);
	
	gui.currentPage().setXMLPath(filesPath);
	
	for (int i = 0; i < numMod; i++) {
		gui.addSlider("Module " + ofToString(i) + " FPS", (float&)modules[i].moduleFPS, 0, 1);
	}
	
	for (int i = 0 ; i < numMod; i++) {
		gui.addPage("Capture " + ofToString(i));
		gui.addToggle("Video Settings", opVidSet);
		gui.addComboBox("Interaction Mode", modules[i].interactMode, 3, interactModes);
		gui.addToggle("Adj Quad", bAdjQuad);
		gui.addComboBox("Which Quad to Adj", whichQuad, 2, quads);
		gui.addToggle("Clear Quad", clearQuad);
		gui.addSlider("Threshold Min", modules[i].blobFindThreshMin, 0, 255);
		gui.addSlider("Threshold Max", modules[i].blobFindThreshMax, 0, 255);
		gui.addTitle("Lens Correction");
		gui.addSlider("RadialDistX", (float&)modules[i].correctRdX, (float)-1.000, (float)1.000);
		gui.addSlider("RadialDistY", (float&)modules[i].correctRdY, (float)-1.000, (float)1.000);
		gui.addSlider("TangentDistX", (float&)modules[i].correctTgX, (float)-1.000, (float)1.000);
		gui.addSlider("TangentDistY", (float&)modules[i].correctTgY, (float)-1.000, (float)1.000);
		gui.addSlider("FocalX", (float&)modules[i].correctFX, (float)0.000, (float)camWidth);
		gui.addSlider("FocalY", (float&)modules[i].correctFY, (float)0.000, (float)camHeight);
		gui.addSlider("CenterX", (float&)modules[i].correctCX, (float)0.000, (float)camWidth);
		gui.addSlider("CenterY", (float&)modules[i].correctCY, (float)0.000, (float)camHeight);
		gui.currentPage().setXMLPath(filesPath);
	}
	
	gui.addPage("Blob Detection");
	gui.addSlider("Blob Min Area", minBlob, 0, 307200);
	gui.addSlider("Blob Max Area", maxBlob, 0, 307200);
	gui.addSlider("Blob Max Number", numBlob, 0, 20);
	
	gui.addTitle("Blob Tracking");
	gui.addSlider("Max Area Diff", maxAreaDiff, 0, 100);
	gui.addSlider("Max Dist", maxDist, 0, 150);
	
	gui.addTitle("Blob Scaling");
	gui.addSlider("Def. Scale Factor", blobDefScaleFactor, 0.5, 4.0);
	gui.addSlider("Cond. Scale Const.", blobCondScaleConst, 0.0, 3.0);
	gui.addSlider("Cond. Scale Max.", blobCondScaleMax, 1.0, 6.0);
	
	gui.addTitle("Blob Drawing");
	gui.addToggle("Draw Blobs", bDrawBlobs);
	gui.addComboBox("Which Blobs to Draw", whichBlobs, 3, blobsToDraw);
	
	gui.addTitle("Trail");
	gui.addSlider("Exp Const", exposureConst, 0, 15);
	gui.addSlider("Fade Const", fadeConst, 0, 1.0);
	gui.addSlider("Blur Level", blurLevel, 0, 10);
	
	gui.currentPage().setXMLPath(filesPath);
	
	gui.loadFromXML();
	
	gui.show();
	gui.setAutoSave(false);
	
	// ---------------------------------------------------------*
	
	for(int i = 0; i < numMod; i++) {
		modules[i].updateSettings();
	}

}
//--------------------------------------------------------------
void ofApp::setup(){
	/********************
		ofSetVerticalSync(true); 
	の時、処理がどんなに速く終わっても、Displayの垂直同期を待ってからの描画になるので、60fpsが頭打ち。
	
	Speed checkしたい時は、
		ofSetFrameRate(0);
		ofSetVerticalSync(false); 
		
	実動作時は、ブンブンに回る結果ファンがうるさくなるので、
		ofSetFrameRate(60);
		ofSetVerticalSync(true); 
		
	あたりが良さそう。
	********************/
	/*
	ofSetFrameRate(0);
	ofSetVerticalSync(false);
	/*/
	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	// */
	
	/********************
	********************/
	b_fullScreen = false;
	b_disp_Time_and_FrameRate = false;
	
	ofEnableSmoothing();

	// ofEnableDepthTest(); // 注意!!!! 2d imageで、αが効かなくなる.
	
	ofSetWindowShape(WIDTH, HEIGHT);
	
	/********************
	********************/
	SpectrumIndicator.setup(N);
	img_Jacket.loadImage( "jacket.png" );
	
	/********************
	********************/
	video.loadMovie("GoodVibesTimeLapse Video.mov");
	video.setLoopState(OF_LOOP_NORMAL);
	video.play();
	video.setSpeed(1);
	video.setVolume(0);

	
	/********************
	********************/
	b_Particle = false;
	ParticleSet.setup();
	
	/********************
	********************/
	// sound.load( "ClubLife by Tiesto Podcast 465.wav" );	
	// sound.load( "ClubLife by Tiesto Podcast 471.wav" );
	sound.load( "ClubLife by Tiesto Podcast 485.wav" );
	// sound.load( "faithless.wav" );	
	
	sound.setLoop( true );
	sound.play();
	
	// ここでvolume cnotrolすると、fft結果に影響が出るので注意
	// 全体音量でControlする分には、影響が出ない.
	// sound.setVolume(0.0);

	//Set spectrum values to 0
	for (int i=0; i<N; i++) {
		spectrum[i] = 0.0f;
	}
	
	/********************
	********************/
	State = STATE_NONE;

	/********************
	********************/
	gui.setup();
	
	gui.add(gui_param[0].setup("smooth", 0.05, 0.01, 0.2));
	gui.add(gui_param[1].setup("NonLinear", 0.02, 0.01, 0.5));
	
	/********************
	********************/
	b_DispGui = false;
	b_showCursor = true;
}
Beispiel #18
0
void ofApp::setup(){
    ofSetFrameRate(60);
    ofBackground(200, 200, 200);
	myRobots.initialize();
    
}
Beispiel #19
0
//--------------------------------------------------------------
void AppCore::setup(const int numOutChannels, const int numInChannels,
				    const int sampleRate, const int ticksPerBuffer) {

	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	//ofSetLogLevel(OF_LOG_VERBOSE);
	
	cout << Poco::Path::current() << endl;
	
	if(!pd.init(numOutChannels, numInChannels, sampleRate, ticksPerBuffer)) {
		ofLog(OF_LOG_ERROR, "Could not init pd");
		OF_EXIT_APP(1);
	}
	
	// add recieve source names
	pd.addSource("toOF");
	pd.addSource("env");
    pd.addSource("one");
	
	// add listener
	pd.addListener(*this);
	pd.subscribe(*this);			// listen to everything
	pd.unsubscribe(*this, "env");	// don't listen to "env"
	
	//pd.subscribe(*this, "toOF");	// listen to "toOF"
	//pd.unsubscribe(*this);		// don't listen to anything
	
	// add the data/pd folder to the search path
	pd.addToSearchPath("pd");
	
	// audio processing on
	pd.dspOn();
	
	
	cout << endl << "BEGIN Patch Test" << endl;
	
	// open patch
	Patch patch = pd.openPatch("droid2.pd");
	cout << patch << endl;
/*	
	// close patch
	pd.closePatch(patch);
	cout << patch << endl;
	
	// open patch
	patch = pd.openPatch("mintest2.pd");
	cout << patch << endl;
*/	
	cout << "FINISH Patch Test" << endl;
	
	
/*	
	cout << endl << "BEGIN Message Test" << endl;
	
	// test basic atoms
	pd.sendBang("fromOF");
	pd.sendFloat("fromOF", 100);
	pd.sendSymbol("fromOF", "test string");
	
	// send a list
	pd.startList("fromOF");
		pd.addFloat(1.23);
		pd.addSymbol("a symbol");
	pd.finish();
	
	// send a message to the $0 reciever ie $0-toOF
	pd.startList(patch.dollarZeroStr()+"-fromOF");
		pd.addFloat(1.23);
		pd.addSymbol("a symbol");
	pd.finish();
	
	cout << "FINISH Message Test" << endl;
	
	
	cout << endl << "BEGIN MIDI Test" << endl;
	
	// send functions
	pd.sendNote(60);
	pd.sendCtl(100, 64);
	pd.sendPgm(100);
	pd.sendBend(2000);
	pd.sendTouch(100);
	pd.sendPolyTouch(64, 100);
	pd.sendMidiByte(239, 1);
	pd.sendSysExByte(239, 1);
	pd.sendSysRTByte(239, 1);
	
	// stream
	pd << Note(60) << Ctl(100, 64) << Bend(2000)
	   << Touch(100) << PolyTouch(64, 100)
	   << StartMidi(1) << 239 << Finish()
	   << StartSysEx(1) << 239 << Finish()
	   << StartSysRT(1) << 239 << Finish();
	
	cout << "FINISH MIDI Test" << endl;
	
	
	cout << endl << "BEGIN Array Test" << endl;
	
	// array check length
	cout << "array1 len: " << pd.getArrayLen("array1") << endl;
	
	// read array
	std::vector<float> array1;
	pd.readArray("array1", array1);	// sets array to correct size
	cout << "array1 ";
	for(int i = 0; i < array1.size(); ++i)
		cout << array1[i] << " ";
	cout << endl;
	
	// write array
	for(int i = 0; i < array1.size(); ++i)
		array1[i] = i;
	pd.writeArray("array1", array1);
	
	// ready array
	pd.readArray("array1", array1);
	cout << "array1 ";
	for(int i = 0; i < array1.size(); ++i)
		cout << array1[i] << " ";
	cout << endl;
	
	// clear array
	pd.clearArray("array1", 10);
	
	// ready array
	pd.readArray("array1", array1);
	cout << "array1 ";
	for(int i = 0; i < array1.size(); ++i)
		cout << array1[i] << " ";
	cout << endl;

	cout << "FINISH Array Test" << endl;


	
	cout << endl << "BEGIN PD Test" << endl;
	pd.sendSymbol("fromOF", "test");
	cout << "FINISH PD Test" << endl << endl;
	
	
	
	// play a tone by sending a list
	// [list tone pitch 72 (
	pd.startList("tone");
		pd.addSymbol("pitch");
		pd.addFloat(72);
	pd.finish();
	pd.sendBang("tone");
*/
}
//--------------------------------------------------------------
void testApp::setup(){
    ofSetFrameRate(60);
    ofSetVerticalSync(true);
    ofBackground(255);
    ofSetBackgroundAuto(FALSE);
    ofSetColor(0);
    ofSetCircleResolution( 100 );
    ofSetLineWidth(3);
    
    bIsDrawing = false;
    lastX = 0;
    lastY = 0;
    
    remoteX = 0;
    remoteY = 0;
    remoteLastX = 0;
    remoteLastY = 0;
    
    penColor = ofColor(0, 0, 0);
    remoteColor = ofColor(0, 0, 0);
    
    gHeart.loadImage("gHeart.png");
    lHeart.loadImage("lHeart.png");
    rHeart.loadImage("rHeart.png");
    fullHeart.loadImage("fullHeart.png");
    gHeart.setAnchorPercent(0.5, 0.5);
    lHeart.setAnchorPercent(0.5, 0.5);
    rHeart.setAnchorPercent(0.5, 0.5);
    fullHeart.setAnchorPercent(0.5, 0.5);
    
    currentFrame = ofGetFrameNum();
    lastFrame = ofGetFrameNum();
    
    // variables use to test if we receive a complete line in each frame
    tempX = 0;
    tempY = 0;
    tempLX = 0;
    tempLY = 0;
    txRecd = false;
    tyRecd = false;
    tlxRecd = false;
    tlyRecd = false;
    
    bSaveRequestSent = false;
    
    // Spacebrew stuff--------------
    // spacebrew connection stuff
    string host = Spacebrew::SPACEBREW_CLOUD;
    string name = "ofxSideOfTool";
    string description = "Drawing tool for lovers";
    
    // publishers
    spacebrew.addPublish("button", Spacebrew::TYPE_BOOLEAN);
    spacebrew.addPublish("posX", Spacebrew::TYPE_RANGE);
    spacebrew.addPublish("posY", Spacebrew::TYPE_RANGE);
    spacebrew.addPublish("lastPosX", Spacebrew::TYPE_RANGE);
    spacebrew.addPublish("lastPosY", Spacebrew::TYPE_RANGE);
    spacebrew.addPublish("color", Spacebrew::TYPE_STRING);
    // subscribers
    spacebrew.addSubscribe("button", Spacebrew::TYPE_BOOLEAN);
    spacebrew.addSubscribe("posX", Spacebrew::TYPE_RANGE);
    spacebrew.addSubscribe("posY", Spacebrew::TYPE_RANGE);
    spacebrew.addSubscribe("lastPosX", Spacebrew::TYPE_RANGE);
    spacebrew.addSubscribe("lastPosY", Spacebrew::TYPE_RANGE);
    spacebrew.addSubscribe("color", Spacebrew::TYPE_STRING);
    
    // connection and listener
    spacebrew.connect( host, name, description );
    Spacebrew::addListener(this, spacebrew);
    
}
//--------------------------------------------------------------
void testApp::setup(){
	ofSetVerticalSync(true);
	ofSetFrameRate(30);
    ofEnableAlphaBlending();
    
	camWidth = CAMWIDTH;
	camHeight = CAMHEIGHT;
	
    // ps3eye-specific settings
	ps3eye.listDevices(); // goes to console
	
	ps3eye.setDesiredFrameRate(60);
	ps3eye.initGrabber(camWidth,camHeight);
	
	ps3eye.setAutoGainAndShutter(false); // otherwise we can't set gain or shutter
	ps3eye.setGain(0.2);  // if use 640x480 image, make 0.4
	ps3eye.setShutter(1.0);
	ps3eye.setGamma(0.4);
	ps3eye.setBrightness(0.4); // if use 640x480 image, make 0.5
	ps3eye.setContrast(0.7);
    //	ps3eye.setHue(0.0); // this made things really yellow
	
	ps3eye.setFlicker(0);
    
    // images used in creating loops
    background.allocate(camWidth, camHeight, OF_IMAGE_COLOR);
    grayImageForAlpha.allocate(camWidth, camHeight, OF_IMAGE_GRAYSCALE);
    displayCutOut.allocate(camWidth, camHeight, OF_IMAGE_COLOR_ALPHA);
    
    
    // images to be displayed in loops
    displayImage.allocate(camWidth, camHeight, OF_IMAGE_COLOR);
    
    // temp (and awesome) background
    tulips.loadImage("holland_tulips.jpg");
    
    // threshold for background subtractions
    threshold = 400;
    
    // music setup; start all instruments together
    // will turn on volume only when that loop is triggered
    drums.loadSound("drums.mp3");
    conga.loadSound("conga.mp3");
    bass.loadSound("bass.mp3");
    guitar.loadSound("guitar.mp3");
    
    drums.setLoop(true);
    conga.setLoop(true);
    bass.setLoop(true);
    guitar.setLoop(true);
    
    drums.setVolume(0);
    conga.setVolume(0);
    bass.setVolume(0);
    guitar.setVolume(0);
    
    drums.play();
    conga.play();
    bass.play();
    guitar.play();

}
//--------------------------------------------------------
void captureApp::setup(){
	ofSetLogLevel(OF_LOG_NOTICE);
	serial.enumerateDevices();
	
	ofxXmlSettings serialSetup;
	serialSetup.loadFile("serialSettings.xml");
	string serialPort = serialSetup.getValue("serialPort", "");
	serial.setup(serialPort, 9600);		// < this should be set
	// to whatever com port
	// your serial device is 
	// connected to.  
	// (ie, COM4 on a pc, dev/tty.... on a mac)
	// arduino users check in arduino app....
	serial.flush();
	
	state			= CAP_STATE_WAITING;
	debugState		= CAP_NORMAL;
	camState		= CAMERA_CLOSED;
	prevCamState	= CAMERA_CLOSED;
	
	preCamMode				= 0;
	cameraFrameNum			= 0;
	sdk						= NULL;
	settings				= NULL;
	timeToEndCapture		= 0.0;
	bNeedsToLeaveFrame		= false;
	bOscSetup				= false;
	fadeInStartTime			= 0.0;
	spotLightAlpha			= 1.0;
	bDoThreadedRSync		= false;
	bDoThreadedFrameSave	= false;
	
	camera3D.disableMouseEvents();
				
	if( !ofxFileHelper::doesFileExist(CAPTURE_MAIN_FOLDER) ){
		printf("making folder %s\n", CAPTURE_MAIN_FOLDER.c_str());
		ofxFileHelper::makeDirectory(CAPTURE_MAIN_FOLDER);
	}
	
	if( !ofxFileHelper::doesFileExist(EXPORT_FOLDER) ){
		printf("making folder %s\n", EXPORT_FOLDER.c_str());	
		ofxFileHelper::makeDirectory(EXPORT_FOLDER);
		if( !ofxFileHelper::doesFileExist(DECODE_FOLDER) ){
			ofxFileHelper::makeDirectory(DECODE_FOLDER);
		}		
	}
	
	ofxXmlSettings xml;
	xml.loadFile("locationSettings.xml");
	currentCity			= xml.getValue("city_name", "NYC");
	transformSpaces(currentCity); //remove space and add underscores
	currentDecodePath		= DECODE_FOLDER;
	currentCaptureFolder    = string(CAPTURE_MAIN_FOLDER) + FRAME_CAPTURE_FOLDER;
	currentTimestamp		= (ofxTimeStamp()).getUnixTimeAsString();
	
	// setup panel
	panel.setup("control", 0, 0, 300, 768);

	panel.setBackgroundColor(simpleColor(10, 10, 10, 0));
		
	//panel.loadFont("resources/myFont.ttf", 9);
	panel.addPanel("app/capture settings", 1);
	panel.addPanel("app settings", 1);
	panel.addPanel("face trigger settings", 1);
	panel.addPanel("pattern settings", 1);
	panel.addPanel("misc settings", 1);
	
	panel.setWhichPanel("app/capture settings");

	panel.addToggle("use face trigger", "B_FACE_TRIGGER", false);
	
	vector <string> camModes;
	camModes.push_back("camera off");
	camModes.push_back("camera qt");
	camModes.push_back("camera dc1394");
	
	panel.addMultiToggle("camera mode", "camMode", 0, camModes);
	
	panel.addToggle("camera settings", "cameraSettings", false);
	
	panel.addToggle("overide light", "bOverideLight", true);
	panel.addToggle("show red clipping", "SHOW_RED", true);

	panel.addToggle("fullscreen", "fullscreen", false);
	
	panel.addToggle("spot light image", "bSpotLight", true);
	panel.addSlider("spotlight %", "spotLightBrightness", 1.0, 0.0, 1.0, false);
	
	panel.addToggle("frame by frame", "frameByFrame", false);
	panel.addToggle("large video", "largeVideo", false);

	panel.addSlider("min brightness", "minBrightness", 0, 0, 255, true);
	panel.addSlider("max brightness", "maxBrightness", 255, 0, 255, true);	
	panel.addSlider("3 phase - wavelength", "wavelength", 64, 8, 512, true);
	panel.addToggle("use projector lut", "projectorLut", false);
		
	panel.setWhichPanel("app settings");
	
	panel.addSlider("fade in time", "fadeInTime", 2.0, 0.0, 5.0, false);
	
	vector<string> postCapModes;
	postCapModes.push_back("save frames");
	postCapModes.push_back("decode and frames");
	postCapModes.push_back("decode, export and frames");
	postCapModes.push_back("all above + notify");
	panel.addMultiToggle("post capture:", "postCapture", 2, postCapModes);
	
	panel.addToggle("notify with osc", "use_osc", false);
	
	panel.addSlider("decode skip frames", "decodeSkipFrame", 2, 0, 5, true);
	
	panel.addSlider("capture time f", "CAPTURE_TIME_F", 4.0, 2.0, 15.0, false);
	
	panel.setWhichPanel("pattern settings");
	
	panel.addSlider("pattern rate", "patternRate", 1, 1, 6, true);
	panel.addSlider("camera rate", "cameraRate", 1, 1, 6, true);
	panel.addSlider("camera offset", "cameraOffset", 0, 0, 5, true);
	
	panel.addToggle("reverse", "reverse", false);
	
	vector<string> orientations;
	orientations.push_back("vertical");
	orientations.push_back("horizonal");
	panel.addMultiToggle("orientation", "orientation", 0, orientations);
	
	
	panel.setWhichPanel("face trigger settings");
	panel.addSlider("face trigger fps", "FACE_FPS", 10, 3, 30, false);
	panel.addSlider("face detected time", "FACE_DETECT_TIME", 2.0, 0.1, 10.0, false);
	panel.addSlider("face forget time", "FACE_FORGET_TIME", 2.0, 0.1, 10.0, false);
	
	guiStatVarPointer varPtr;
	varPtr.setup("num faces", &face.numFaces, GUI_VAR_INT, true);
	panel.addChartPlotter("num faces", varPtr, 240, 60, 240, -1, 3);
	panel.addChartPlotter("face confidence", guiStatVarPointer("confidence", &face.confidence, GUI_VAR_FLOAT, true, 2), 240, 70, 240, -0.2, 1.2);
	
	panel.addDrawableRect("state", &face, 240, 40);
	
	panel.addSlider("confidence add amnt", "confidence_add", 0.1, 0.05, 1.0, false);
	panel.addSlider("confidence fade amnt", "confidence_fade", 0.95, 0.8, 0.995, false);
	panel.addSlider("confidence gate start val", "confidence_gate_start", 0.65, 0.15, 1.0, false);
	panel.addSlider("confidence gate stop val", "confidence_gate_stop", 0.4, 0.0, 1.0, false);
	
	panel.setWhichPanel("misc settings");
	
	panel.addToggle("brightness setting", "brightnessSetting", false);
	panel.addSlider("check brigheness", "checkBrightness", 0, 0, 255, true);
	panel.addToggle("delete after transfer", "bDeleteAfterSend", false);
	panel.addToggle("restart at 3.00am", "bRestart", false);
	panel.addSlider("restart hour", "restartHour", 3, 1, 23, true);
	panel.addSlider("restart minute", "restartMinute", 0, 0, 59, true);
	
	panel.loadSettings("controlCapture.xml");
	
	if( panel.getValueB("use_osc") ){
		setupOsc();
	}
	
	//overides 
	//panel.setValueI("camMode", 0);
	panel.setValueI("fullscreen", 1);
	panel.setValueI("cameraSettings", 0);
	panel.setValueI("frameByFrame", 0);
	panel.setValueI("largeVideo", 0);
	panel.setValueI("brightnessSetting",0);
	panel.setValueI("bOverideLight",0);
	panel.setValueI("bSpotLight", 1);
	
	cameraWidth  = 640;
	cameraHeight = 480;
	
	int n = 3; // no patterns have more than 3 frames
	for(int i = 0; i < n; i++) {
		recent.push_back(ofImage());
		recent.back().allocate(
							   cameraWidth,
							   cameraHeight,
							   OF_IMAGE_COLOR);
		needsUpdate.push_back(false);
	}
	curGenerator = &threePhase;
	
	int captureTime = 15;
	imageSaver.setup(cameraWidth, cameraHeight, captureTime * 60);
	
	ofSetVerticalSync(true);
	ofSetFrameRate(60);
	
	ofBackground(0, 0, 0);
	
	scanningSound.loadSound("resources/scanningPlaceholder.mp3");
	scanningSound.setLoop(true);
	
	spotLightImage.loadImage("resources/captureMask.jpg");
	generateSpotlight(spotLightImage);
	spotLightImage.setAnchorPercent(0.5, 0.5);
	
	face.setup("faceHaar/haarcascade_frontalface_alt.xml", 320, 240, 2.0, 2.0);
	prevFaceCheckTimeF = ofGetElapsedTimef();
	
	threePhase.setSize(1024, 768);
	updateGenerator();
	
	light.setup(0);
}
Beispiel #23
0
/******************************************************************************
 * The setup function is run once to perform initializations in the application
 *****************************************************************************/
void testApp::setup()
{	
	

	/********************
	* Initalize Variables
	*********************/
	fuzzy.loadImage("particle.png");
	fuzzy.setUseTexture(true);

	//For screengrab
	snapCounter	= 6; 
	//Background Subtraction Learning Rate
	fLearnRate	= 0.0001f;
	//Intialize FPS variables
	frames		= 0;
	fps			= 0;
	lastFPSlog	= 0;
	//Calibration Booleans
	bCalibration= false;
	bShowTargets = true;
	bW			= false;
	bA			= false;
	bS			= false;
	bD			= false;
	
	downColor = 0xFF0000;

	bDrawVideo = true;
	bFullscreen = false;

	//bFlowing	= false;
//	ofSetBackgroundAuto(false);

	//Load Settings from config.xml file 
	loadXMLSettings();

	//Load Calibration Settings from calibration.xml file
	calibrate.setCamRes(camWidth, camHeight);
	calibrate.loadXMLSettings();

	//Setup Window Properties 
	ofSetWindowShape(winWidth,winHeight);
	ofSetFrameRate(camRate);			//This will be based on camera fps in the future		
	ofSetVerticalSync(false);	//Set vertical sync to false for better performance

	//Pick the Source - camera or video
	if(bcamera){

		activeInput = true;

		vidGrabber.listDevices();
		vidGrabber.setDeviceID(deviceID);
		vidGrabber.setVerbose(true);		
        vidGrabber.initGrabber(camWidth,camHeight);		

		printf("Camera Mode\n");
		int grabW = vidGrabber.width;
		int grabH = vidGrabber.height;
		printf("Asked for %i by %i - actual size is %i by %i \n", 
				camWidth, camHeight, grabW, grabH);
	}
	else{
		
		activeInput = true;	

        //vidPlayer.loadMovie("test_videos/FrontDI.m4v");
		//vidPlayer.loadMovie("test_videos/HCI_FTIR.mov");
		vidPlayer.loadMovie("test_videos/raw.mp4");
		//vidPlayer.loadMovie("test_videos/5point.avi");
        vidPlayer.play();	
		printf("Video Mode\n");
		camHeight = vidPlayer.height;
		camWidth = vidPlayer.width;
	}
    
	/*****************************************************************************************************
	* Allocate images (needed for drawing/processing images) ----Most of These won't be needed in the end
	******************************************************************************************************/
	processedImg.allocate(camWidth, camHeight); //main Image that'll be processed.
	processedImg.setUseTexture(false);
	sourceImg.allocate(camWidth, camHeight);    //Source Image
	sourceImg.setUseTexture(false);				//We don't need to draw this so don't create a texture

	//These images are used for drawing only
	grayImg.allocate(camWidth, camHeight);		//Gray Image
	grayBg.allocate(camWidth, camHeight);		//Background Image
	subtractBg.allocate(camWidth, camHeight);   //Background After subtraction
	grayDiff.allocate(camWidth, camHeight);		//Difference Image between Background and Source
	highpassImg.allocate(camWidth, camHeight);  //Highpass Image
	ampImg.allocate(camWidth, camHeight);		//Amplied Image	
	fiLearn.allocate(camWidth, camHeight);		//ofxFloatImage used for simple dynamic background subtracti
//	fiLearn.setUseTexture(false);
	pressureMap.allocate(camWidth, camHeight);	//Pressure Map Image
	
	//For camera warp
	giWarped.allocate(camWidth, camHeight);     //Warped Image (used for warped calibration)
	giWarped.setUseTexture(false);

   if(bFlowing){	
	//FLOW
	   opticalFlowLK.allocate(camWidth, camHeight);
	   opticalFlowBM.allocate(camWidth, camHeight);
   }
	/********************************************************************************************************/


	/**********************************************************/
	//GPU stuff initialization
	/**********************************************************/
	glGenTextures(1, &gpuSourceTex);
	glGenTextures(1, &gpuBGTex);

	//initialize texture once with glTexImage2D so we can use gltexSubImage2D afetrwards (fastser)
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, gpuSourceTex);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,  camWidth, camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
	glBindTexture(GL_TEXTURE_2D, gpuBGTex);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,  camWidth, camHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
	glBindTexture(GL_TEXTURE_2D, 0);
	glDisable(GL_TEXTURE_2D);

	grabFrameToGPU(gpuBGTex);

	//so very inefficient..but only for now..until i fix the gpu blob detection and geoemtry shader for variable length output
	gpuReadBackBuffer = new unsigned char[camWidth*camHeight*3]; 
	gpuReadBackImage.allocate(camWidth, camHeight);
	gpuReadBackImageGS.allocate(camWidth, camHeight);

	subtractFilter = new ImageFilter("filters/absSubtract.xml", camWidth, camHeight);
	subtractFilter2 = new ImageFilter("filters/subtract.xml", camWidth, camHeight);
	contrastFilter = new ImageFilter("filters/contrast.xml", camWidth, camHeight);
	gaussVFilter = new ImageFilter("filters/gaussV.xml", camWidth, camHeight);
	gaussHFilter = new ImageFilter("filters/gauss.xml", camWidth, camHeight);
	gaussVFilter2 = new ImageFilter("filters/gaussV2.xml", camWidth, camHeight);
	gaussHFilter2 = new ImageFilter("filters/gauss2.xml", camWidth, camHeight);
	threshFilter = new ImageFilter("filters/threshold.xml", camWidth, camHeight);
	/**********************************************************/




	//Fonts - Is there a way to dynamically change font size?
	verdana.loadFont("verdana.ttf", 8, true, true);	   //Font used for small images
	sidebarTXT.loadFont("verdana.ttf", 8, true, true);
	calibrationText.loadFont("verdana.ttf", 10, true, true);
	bigvideo.loadFont("verdana.ttf", 13, true, true);  //Font used for big images.
	
	//Static Images
	logo.loadImage("images/logo.jpg");
	background.loadImage("images/background.jpg"); //Main (Temp?) Background

	//Setup green warped box
	warp_box.setup( 40, 30, camWidth, camHeight, camWidth/320, camHeight/240); 

	warp_box.fHandles[0].x = handle1x;
	warp_box.fHandles[0].y = handle1y;
	warp_box.fHandles[1].x = handle2x;
	warp_box.fHandles[1].y = handle2y;
	warp_box.fHandles[2].x = handle3x;
	warp_box.fHandles[2].y = handle3y;
	warp_box.fHandles[3].x = handle4x;
	warp_box.fHandles[3].y = handle4y;

	//Warped points
	dstPts[0].x = 0.0f;
    dstPts[0].y = camHeight;   
    dstPts[1].x = camWidth;
    dstPts[1].y = camHeight;   
    dstPts[2].x = camWidth;
    dstPts[2].y = 0.0f;   
    dstPts[3].x = 0.0f;
    dstPts[3].y = 0.0f;

	//Setup testApp to listen for touch events
	tracker.setListener(this); 

	gui = ofxGui::Instance(this);
	setupGUI();

	printf("Touchlib application is setup!\n");
}
//--------------------------------------------------------------
void testApp::setup(){	
	ofSetVerticalSync(true);
	ofSetFrameRate(60);
	
	bMousePressed = false;
}
Beispiel #25
0
//--------------------------------------------------------------
void testApp::setup()
{
	
videosurce = false;	
	
	if (videosurce) {
		camWidth = 640;
		camHeight = 480;
		vidGrabber.setVerbose(true);
		vidGrabber.initGrabber(camWidth, camHeight, false);
		
		colorImg.allocate(camWidth, camHeight);
		grayImage.allocate(camWidth, camHeight);
		grayBg.allocate(camWidth,camHeight);
		grayDiff.allocate(camWidth,camHeight);
		
		bLearnBakground = true;
		Threshold = 50;
				
		
		
		bThreshWithOpenCV = false;

		
	} else {
		//shows infrared image
		kinect.init(true);
		kinect.setVerbose(true);
		kinect.open();
		
		colorImg.allocate(kinect.width, kinect.height);
		grayImage.allocate(kinect.width, kinect.height);
		grayThresh.allocate(kinect.width, kinect.height);
		grayThreshFar.allocate(kinect.width, kinect.height);
		
		nearThreshold = 50;
		farThreshold  = 200;
		bThreshWithOpenCV = true;
		
		angle = 0;
		kinect.setCameraTiltAngle(angle);
	
	}

	
		
	ofSetFrameRate(60);

	
	colorz=1;
	contour_min = 100;
	scale_x = 1.0;
	scale_y = 1.0;
	mtrx = 1.0;
	mtry = 1.0;
	interface = true;
	circle = true;
	cloud = false;
	debug = false;
	
	rectangle = false;
}
Beispiel #26
0
//--------------------------------------------------------------
void testApp::setup(){
    ofBackground(0);
    ofSetVerticalSync(true);
    ofEnableSmoothing();
    ofSetCircleResolution(180);
       
    // 0 output channels, 
	// 2 input channels
	// 44100 samples per second
	// 256 samples per buffer
	// 4 num buffers (latency)
	
	soundStream.listDevices();
	
	//if you want to set a different device id 
	soundStream.setDeviceID(3); //bear in mind the device id corresponds to all audio devices, including  input-only and output-only devices.
	
    
	int bufferSize = 256;
    
    ofxXmlSettings xml;
    xml.loadFile("settings.xml");
    xml.pushTag("settings");
    
    
    
    
    scale = xml.getValue("scale", 1.5);
    velocity = xml.getValue("velocity", -0.05);
    rot = ofVec2f(0.0,0.0)*xml.getValue("rotation", 0.0001) ;
    
    for (int i=0;i<xml.getNumTags("channel");i++) {
        xml.pushTag("channel",i);
        
        channel c;
        channels.push_back(c);
        vector<channel>::iterator iter=channels.begin()+i;
        iter->input.assign(bufferSize,0.0);
        iter->peakVec.assign(VECTOR_SIZE,0.0);
        iter->limiterVec.assign(VECTOR_SIZE,0.0);
        iter->envelopeVec.assign(VECTOR_SIZE,0.0);
        iter->peak = 0.0;
        iter->envelope = 0.0;
        
        
        
        iter->thresholds.assign(THRESHOLD_NUM, 0.01);
        for (int j=0;j<xml.getNumTags("threshold"); j++) {
            iter->thresholds[j] = xml.getValue("threshold", 0.01,j);
        }
        
        
        iter->bTriggered = false;
        
        xml.popTag();
    }
	xml.popTag();
    
    
	cout << channels.size();
    
    bufferCounter	= 0;
    drawCounter		= 0;
    float sampleRate = 44100;
    
    float attackMs= 10;
    float releaseMs = 500;
    ga = pow( 0.01, 1.0 / ( attackMs * sampleRate * 0.001 ) ); 
    gr = pow( 0.01, 1.0 / ( releaseMs * sampleRate * 0.001 ) ); 
    
	soundStream.setup(this, 0, channels.size(), sampleRate, bufferSize, 4);
    
    bDebug = true;
    //ofToggleFullscreen();
    ofSetFrameRate(30);
    ofEnableAlphaBlending();
    
    ofNoFill();
    
    curThresh = THRESHOLD_MIN;
    
    int width =ofGetWidth()/2;
    int height = ofGetHeight()/2;
    
    image.allocate(width, height, OF_IMAGE_COLOR);
    
    buffers.push_back(new int[width*height]);
    buffers.push_back(new int[width*height]);
    memset(buffers.front(), 0, width*height);
    memset(buffers.back(), 0, width*height);
    
    counter = 0;
    
    bSetThresh = false;
    
    
    stars.assign(512, star());
    for (vector<star>::iterator iter=stars.begin(); iter!=stars.end(); iter++) {
        randomStar(*iter,velocity,true);
    }
    
    quadWarp.setup();
    
    
}
Beispiel #27
0
//--------------------------------------------------------------
void ofApp::setup(){

#if OCULUS_YAH

	oculusRift.baseCamera = &cam; //attach to your camera
    //opens the device, an Oculus must be plugged in 
    //as it uses the params returned from the head set to configure 
    //the resolution settings
    oculusRift.setup();

    ofSetVerticalSync(true);
	
	// this uses depth information for occlusion
	// rather than always drawing things on top of each other
	//ofEnableDepthTest();

	//ofEnableNormalizedTexCoords();
	
	// this sets the camera's distance from the object
	cam.setDistance(5);


    ofSetFrameRate(30);

#endif

  
	
	fov = 180;
	precision = 1500;
	shiftAmountLR = 0;
	shiftAmountUD = 0;
	//radius = 5000;
	radius = 100;
	limitH = 1.75;
	
	// initial calculation of segment size
	//this->calculateFrustumSphereIntersects(fov, ratio, &latMin, &latMax, &longMin, &longMax);
	

#if STATIC_IMAGE	
    img.setUseTexture(true);
	img.loadImage("roomleft1.jpeg"); //left
	ratio = img.getHeight()/(double) img.getWidth();
	// initial calculation of segment size
	this->calculateFrustumSphereIntersects(fov, ratio, &latMin, &latMax, &longMin, &longMax);
	//this->createSegmentedMesh(ofVec3f(0,0,0), radius, precision, img.getWidth(), img.getHeight(), longMin, longMax, latMin, latMax);
	this->createSegmentedMeshTriangles(ofVec3f(0,0,0), mesh1, radius, limitH, img.getWidth(), img.getHeight());
	
	img2.setUseTexture(true);
	img2.loadImage("roomright1.jpeg"); //right
	ratio = img2.getHeight()/(double) img2.getWidth();


	this->createSegmentedMeshTriangles(ofVec3f(0,0,0), mesh2, radius, limitH, img2.getWidth(), img2.getHeight());
#endif

#if VIDEO
	//vW = 1920;
	//vH = 1080;
	vW = 1296;
	vH = 972;

	texture1.allocate(vW,vH,GL_RGB);
	texture2.allocate(vW,vH,GL_RGB);

	client1.setup(10);
	client1.addVideoChannel(5000);
	client2.setup(10);
	client2.addVideoChannel(5001);
	client1.play();
	//client2.play();
	ratio = vH/ (double) vW;
	// initial calculation of segment size
	//this->calculateFrustumSphereIntersects(fov, ratio, &latMin, &latMax, &longMin, &longMax);
	this->createSegmentedMeshTriangles(ofVec3f(0,0,0), mesh1, radius, limitH, vW, vH);
	this->createSegmentedMeshTriangles(ofVec3f(0,0,0), mesh2, radius, limitH, vW, vH);
	//this->createSegmentedMesh(ofVec3f(0,0,0), mesh2, radius, precision, vW, vH, longMin, longMax, latMin, latMax);

#endif	





	// generate segment
	//this->createSegmentedMesh(ofVec3f(0,0,0), radius, precision, width, height, longMin, longMax, latMin, latMax);
}
Beispiel #28
0
//--------------------------------------------------------------
void testApp::setup(){
    ofSetFrameRate(60);
    ofBackground(255);
}
Beispiel #29
0
//--------------------------------------------------------------
void testApp::setup(){

    ofSetLogLevel(OF_LOG_VERBOSE);

    //disable vertical Sync tooo bad with light sometimes!!!!
    ofSetVerticalSync(true);
	ofSetFrameRate(60);
	ofBackground(10, 10, 10);


    // lets make a high-res sphere //
    // default is 20 //
    ofSetSphereResolution(128);

    // radius of the sphere //
	radius		= 180.f;
	center.set(ofGetWidth()*.5, ofGetHeight()*.5, 0);

    // Point lights emit light in all directions //
    // set the diffuse color, color reflected from the light source //
    pointLight.setDiffuseColor( ofColor(0.f, 255.f, 0.f));

    // specular color, the highlight/shininess color //
	pointLight.setSpecularColor( ofColor(255.f, 255.f, 0.f));
	pointLight.setPointLight();

	 spotLight.setDiffuseColor( ofColor(255.f, 0.f, 0.f));
	spotLight.setSpecularColor( ofColor(255.f, 255.f, 255.f));

///spotlight doesn't works yet with my shader!!
/*
    // turn the light into spotLight, emit a cone of light //
    spotLight.setSpotlight();

    // size of the cone of emitted light, angle between light axis and side of cone //
    // angle range between 0 - 90 in degrees //
    spotLight.setSpotlightCutOff( 50 );

    // rate of falloff, illumitation decreases as the angle from the cone axis increases //
    // range 0 - 128, zero is even illumination, 128 is max falloff //
    spotLight.setSpotConcentration( 45 );
*/

    // Directional Lights emit light based on their orientation, regardless of their position //
	directionalLight.setDiffuseColor(ofColor(0.f, 0.f, 255.f));
	directionalLight.setSpecularColor(ofColor(255.f, 255.f, 255.f));
	directionalLight.setDirectional();

    // set the direction of the light
    // set it pointing from left to right -> //
	directionalLight.setOrientation( ofVec3f(0, 90, 0) );


	bShiny = true;
    // shininess is a value between 0 - 128, 128 being the most shiny //
	material.setShininess( 120 );
	material.setDiffuseColor(ofColor(10.0f,200.0f,0.0f,255));
    // the light highlight of the material //
    material.setSpecularColor(ofColor(255, 255, 255, 255));

	bPointLight = bSpotLight = bDirLight = true;

    shader.load("multilight");


    shader.begin();

    shader.setUniform1i("numLights",3);
    shader.end();

}
Beispiel #30
0
//--------------------------------------------------------------
void testApp::setup()
{
	ofBackground(0, 0, 0, 1);
	ofSetFrameRate(30);
	ofSetVerticalSync(false);
	ofEnableSmoothing();
	ofEnableAlphaBlending();
	//ofEnableNormalizedTexCoords();
	//ofHideCursor();
    
//    drawGUI=true;
//    setGUI();
//    gui->setDrawBack(false);
    
    
	glNewList(1, GL_COMPILE);
	glutSolidSphere(1, 40, 40);
	glEndList();
    
    glNewList(2, GL_COMPILE);
	glutSolidSphere(5, 40, 40);
	glEndList();
    
    
	
    flyBox_x = flyBox_x0, flyBox_y=flyBox_y0, flyBox_z = flyBox_z0;
    
	target = ofVec3f(0, 0, 0);
	
	for (int i = 0; i < boidNum; i++)
	{
		SteeredVehicle v(ofRandom(100)-50, ofRandom(100)-50, ofRandom(100)-50);
		v.maxForce = 0.5f;
		v.inSightDist = 60.0f;
		boids.push_back(v);
        follow.push_back(ofRandom(100)>70); //if true, boid will chase the tuio target
	}
	
    cam.setDistance(cam_z);
    adjustCamAngle();
    cam_center_distance0 = cam_center_distance;
    cam.disableMouseInput();
    cam.setNearClip(nearClip);
    cam.setFarClip(farClip);
    fbo.allocate(ofGetWidth(), ofGetHeight());
//    backdrop.loadImage("images/clouds.jpg");
    backdropWhole.loadImage("images/interstellar_top.jpg");
    backdrop.cropFrom(backdropWhole, 1024, -cam_angle*backdrop_rate, 1024, 768);
//    music[0].loadSound("Koda - Glass Veil (CoMa Remix).mp3");
    for(int i=0; i<numMusic; i++){
        music[i].loadSound(musicFiles[i]);
    }
//    music[0].play();
	
    float backdroplight = 1.0;
	GLfloat color[] = { backdroplight, backdroplight, backdroplight };
//	GLfloat color[] = { 1.0, 1.0, 1.0 };
	
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);
    glEnable(GL_DEPTH_TEST);

	glLightfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
    glLightfv(GL_LIGHT0, GL_AMBIENT, color);
    
    tuioClient.start(3333);
    kinectXMax=-100, kinectXMin=100, kinectYMax = -100, kinectYMin=100;

//  OSC
//    sender.setup(HOST_IPAD, PORT_TO_IPAD);
    receiver.setup(PORT_IN);
}