Esempio n. 1
0
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h) {
    if (w < 600) {
        ofVec2f windowPosition = ofVec2f(ofGetWindowPositionX(), ofGetWindowPositionY());
        ofSetWindowShape(600, h);
        ofSetWindowPosition(windowPosition.x, windowPosition.y);
    }
    if (h < 400) {
        ofVec2f windowPosition = ofVec2f(ofGetWindowPositionX(), ofGetWindowPositionY());
        ofSetWindowShape(w, 400);
        ofSetWindowPosition(windowPosition.x, windowPosition.y);
    }

    //hsvGui.setPosition(ofPoint(w-200, 0));
}
Esempio n. 2
0
    void update() {
        if( goFullscreen == 2 ){
            ofSetFullscreen(false);
            ofSetWindowPosition(1920, 0);
        }
        if( goFullscreen == 4 ){
            ofSetFullscreen(true);
            ofViewport(ofGetNativeViewport());
        }
        goFullscreen++;
        if(goFullscreen > 4 && ofGetWindowPositionX() < 1440) {
            goFullscreen = 0;
        }
        
        renderTimer.tick();
        while(osc.hasWaitingMessages()) {
            ofxOscMessage msg;
            osc.getNextMessage(&msg);
            if(msg.getAddress() == "/lookAngle/set") {
                targetLookAngle = msg.getArgAsFloat(0);
            }
            if(msg.getAddress() == "/lookAngle/add") {
                targetLookAngle += msg.getArgAsFloat(0);
                ofLog() << "targetLookAngle: " << targetLookAngle;
            }
            if(msg.getAddress() == "/screenshot") {
                saveScreen("button/");
            }
        }
        lookAngle = ofLerp(lookAngle, targetLookAngle, .1);
        if(screenshotTimer.tick()) {
//            saveScreen("automatic/"); // uncomment to enable automatic screenshot
        }
	}
//--------------------------------------------------------------
void testApp::update(){
	
    captureWidth = ofGetWidth();
    captureHeight = ofGetHeight();
    
	unsigned char * data = pixelsBelowWindow(ofGetWindowPositionX(), ofGetWindowPositionY(), captureWidth, captureHeight);
	
	// now, let's get the R and B data swapped, so that it's all OK:
	for (int i = 0; i < captureWidth * captureHeight; i++){
		
		unsigned char r = data[i*4]; // mem A  
		
		data[i*4]   = data[i*4+1];   
		data[i*4+1] = data[i*4+2];   
		data[i*4+2] = data[i*4+3];   
		data[i*4+3] = r; 
	}
	
	
	if (data!= NULL) {
		//tex.loadData(data, captureWidth, captureHeight, GL_RGBA);
		//tex.readToPixels(pixels);
		//image = pixels;
		image.setFromPixels(data, captureWidth, captureHeight, OF_IMAGE_COLOR_ALPHA, true);
		image.setImageType(OF_IMAGE_COLOR);
		image.update();
		finder.findHaarObjects(image.getPixelsRef());
		
	}
	//cout << imageBelowWindow()[0] << endl;
	
	

}
Esempio n. 4
0
void testApp::keyPressed(int key)
{
	pressed[key] = true;
	
	if (key == key::fullscreen)
	{
		ofToggleFullscreen();
	}
	else if (key == key::projector)
	{
		if (ofGetWindowPositionX() == 0)
		{
			ofSetWindowPosition(1440,0);
		}
		else
		{
			ofSetWindowPosition(0,0);
		}
	}
	else if (key == key::debug_camaralucida)
	{
		camluc.toggle_debug();
	}
	else if (key == key::debug_depth_texture)
	{
		debug_depth_texture = !debug_depth_texture;
	}
	else if (key == key::print_mesh)
	{
		mesh->print();
	}
}
Esempio n. 5
0
//--------------------------------------------------------------
void testApp::keyPressed(int key)
{
    if( key == 'f' )
        ofToggleFullscreen();
    
    if( key == 'v' )
        ofSetVerticalSync( ( bVSync = !bVSync ) );
    
    if( key == 'm' )
    {
        bShowCursor = !bShowCursor;
        if( bShowCursor )
            ofShowCursor();
        else
            ofHideCursor();
    }
    
    if( key == 's' )
    {
        bWindowShape = !bWindowShape;
        if( bWindowShape )
            ofSetWindowShape( 1024, 768 );
        else
            ofSetWindowShape( 800, 600 );
    }
    
    int windowMoveInc = 20;
    
    if( key == OF_KEY_LEFT )
    {
        ofSetWindowPosition( MAX( ofGetWindowPositionX() - windowMoveInc, 0 ), ofGetWindowPositionY() );
    }
    else if( key == OF_KEY_RIGHT )
    {
        ofSetWindowPosition( MIN( ofGetWindowPositionX() + windowMoveInc, ofGetScreenWidth() - ofGetWidth() ), ofGetWindowPositionY() );
    }
    else if( key == OF_KEY_UP )
    {
        ofSetWindowPosition( ofGetWindowPositionX(), MAX( ofGetWindowPositionY() - windowMoveInc, 0 ) );
    }
    else if( key == OF_KEY_DOWN )
    {
        ofSetWindowPosition( ofGetWindowPositionX(), MIN( ofGetWindowPositionY() + windowMoveInc, ofGetScreenHeight() - ofGetHeight() ) );
    }
}
Esempio n. 6
0
LRESULT ofTouch::processTouch(HWND hWnd, WPARAM wParam, LPARAM lParam) {
	//return DefWindowProc(hWnd, WM_TOUCH, wParam, lParam);
	BOOL bHandled = FALSE;
	UINT cInputs = LOWORD(wParam);
	PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
	if (pInputs){
		if (GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs, sizeof(TOUCHINPUT))){
			for (UINT i=0; i < cInputs; i++){
				TOUCHINPUT ti = pInputs[i];
				//do something with each touch input entry
				if (ti.dwFlags & TOUCHEVENTF_DOWN){
					OnTouchDown(ti.dwID, TOUCH_COORD_TO_PIXEL(ti.x)-ofGetWindowPositionX(), TOUCH_COORD_TO_PIXEL(ti.y)-ofGetWindowPositionY());
				}
				else if (ti.dwFlags & TOUCHEVENTF_MOVE){
					OnTouchMove(ti.dwID, TOUCH_COORD_TO_PIXEL(ti.x)-ofGetWindowPositionX(), TOUCH_COORD_TO_PIXEL(ti.y)-ofGetWindowPositionY());
				}
				if (ti.dwFlags & TOUCHEVENTF_UP){
					OnTouchUp(ti.dwID, TOUCH_COORD_TO_PIXEL(ti.x)-ofGetWindowPositionX(), TOUCH_COORD_TO_PIXEL(ti.y)-ofGetWindowPositionY());
				}
			}
			bHandled = TRUE;
		}else{
			/* handle the error here */
		}
		delete [] pInputs;
	}else{
		/* handle the error here, probably out of memory */
	}
	if (bHandled){
		// if you handled the message, close the touch input handle and return
		CloseTouchInputHandle((HTOUCHINPUT)lParam);
		return 0;
	}else{
		// if you didn't handle the message, let DefWindowProc handle it
		return DefWindowProc(hWnd, WM_TOUCH, wParam, lParam);
	}
}
Esempio n. 7
0
//--------------------------------------------------------------
void testApp::draw()
{
    vector<ofColor> colors;
    colors.push_back( ofColor :: red );
    colors.push_back( ofColor :: green );
    colors.push_back( ofColor :: blue );
    colors.push_back( ofColor :: magenta );
    colors.push_back( ofColor :: yellow );
    colors.push_back( ofColor :: cyan );
    
    int w   = ofGetWidth();
    int h   = ofGetHeight();
    int dy  = h / colors.size();
    int x   = 0;
    int y   = 0;
    
    for( int i=0; i<colors.size(); i++ )
    {
        float p = i / (float)( colors.size() - 1 );
        
        ofSetColor( colors[ i ] );
        ofRect( x, y, w, dy );
        
        y += dy;
    }
    
    ofSetColor( 255 );
    image.draw( imagePos.x, imagePos.y );
	
    y = 10;
    
	ofSetColor( 0 );
	ofDrawBitmapString( "press 'f' to toggle fullscreen ", 20, y+=20 );
    ofDrawBitmapString( "press 'v' to toggle vertical sync, currently " + ( bVSync ? string("on") : string("off") ), 20, y+=20 );
    ofDrawBitmapString( "press 'm' to show/hide cursor, currently " + ( bShowCursor ? string("on") : string("off") ), 20, y+=20 );
    ofDrawBitmapString( "press 's' to reshape the window", 20, y+=20 );
    ofDrawBitmapString( "press the arrow keys to nudge the window. note: works only in OF_WINDOW mode", 20, y+=20 );
    
    y+=20;
    
    ofDrawBitmapString( "fps = " + ofToString( ofGetFrameRate() ), 20, y+=20 );
    ofDrawBitmapString( "frame no. = " + ofToString( ofGetFrameNum() ), 20, y+=20 );
    ofDrawBitmapString( "window position x = " + ofToString( ofGetWindowPositionX() ), 20, y+=20 );
    ofDrawBitmapString( "window position y = " + ofToString( ofGetWindowPositionY() ), 20, y+=20 );
    ofDrawBitmapString( "window width = " + ofToString( ofGetWidth() ), 20, y+=20 );
    ofDrawBitmapString( "window height = " + ofToString( ofGetHeight() ), 20, y+=20 );
    ofDrawBitmapString( "screen width = " + ofToString( ofGetScreenWidth() ), 20, y+=20 );
    ofDrawBitmapString( "screen height = " + ofToString( ofGetScreenHeight() ), 20, y+=20 );
}
void TouchEventController::onSingleTouchMoveEvent(SingleTouchMoveEvent & event)
{
   
    ofPoint p = event.point;
    ofTouchEventArgs e;
    e.x = p.x- ofGetWindowPositionX();;
    e.y = p.y- ofGetWindowPositionY();;
    
    //cout << "TouchEventController::onSingleTouchMoveEvent _x: " << p.x << " _y: " << p.y << endl;
    
    TouchEvent *savedEvent = new TouchEvent();
    savedEvent->type = TOUCH_MOVE;
    savedEvent->args = e;
    _eventQueue.push(savedEvent);
   
}
Esempio n. 9
0
void testApp::drawGaze()
{
    if(gazeCoords[2] == -1)
        return;
    int coordX = gazeCoords[2] - ofGetWindowPositionX();
    int coordY = gazeCoords[3] - ofGetWindowPositionY();
    ofPushMatrix();
    ofNoFill();
    ofSetColor(100,255,255,100);
    ofCircle(ofPoint(coordX, coordY), 40);
    ofSetColor(100,255,255,50);
    ofCircle(ofPoint(coordX, coordY), 20);
    ofSetColor(100,255,255,20);
    ofCircle(ofPoint(coordX, coordY), 10);
    ofPopMatrix();
}
Esempio n. 10
0
void ofxBKDoubleSlider::mousePressed(ofMouseEventArgs &e)
{
	currentDraggingValue = getNearestValueIndex(getValueForPosition(getMousePosition().x));
	mouseDragOffset = getValueForPosition(getMousePosition().x) - (currentDraggingValue == 1?value:value2);
	ofHideCursor();

	#ifdef _WIN32

	LPPOINT pt = LPPOINT();
	int x = ofGetWindowPositionX()+getGlobalBounds().x + (currentDraggingValue == 1?value:value2)*width;
	int y = ofGetWindowPositionY()+getGlobalBounds().y+getMousePosition().y;
	SetCursorPos(x,y);
	mouseDragOffset = 0;
	#endif

	isDragging = true;
}
Esempio n. 11
0
void mpeClientTCP::draw(ofEventArgs& e)
{
    //no blocking
    if(useMainThread && lock()) {

		for(int i = 0; i < dataMessage.size(); i++){
			ofxMPEEventArgs e;
			e.message = dataMessage[i];
			e.frame = getFrameCount();
			//cout << "sending message in update " << e.frame << " message " << e.message << endl;

			ofNotifyEvent(ofxMPEEvents.mpeMessage, e);
		}
		dataMessage.clear();

		//TODO: ints, floats, bytes,

		if(shouldReset){
			reset();
		}

		if(triggerFrame){
			//ofLog(OF_LOG_VERBOSE, "Trigger Event :: ! with frame count " + frameCount);

			triggerFrame = false;

//            cout << "triggering frame" << endl;

			ofxMPEEventArgs e;
			e.message = "";
			e.frame = frameCount;
			ofNotifyEvent(ofxMPEEvents.mpeFrame, e);

			if(!simulationMode){
				done();
			}
		}

		unlock();
    }

    //cout << ofGetWidth() << " :: " << lWidth << "  " << ofGetHeight() << " :: " << lHeight << endl;
    if(ofGetWindowPositionX() != xOffset || ofGetWindowPositionY() != yOffset || ofGetWidth() != lWidth || ofGetHeight() != lHeight){
        setupViewport();
    }
}
void TouchEventController::onSingleTouchGestureEvent(SingleTouchGestureEvent & event)
{
    ofPoint p = event.point;
    ofTouchEventArgs e;
    e.x = p.x - ofGetWindowPositionX();
    e.y = p.y - ofGetWindowPositionY();
    
    //cout << "TouchEventController::onSingleTouchGestureEvent _x: " << p.x << " _y: " << p.y << endl;
    
    // for some reason the first event is always 0,0, ignoring it
    if(p.x == 0 && p.y == 0) 
        return;
    
    TouchEvent *savedEvent = new TouchEvent();
    savedEvent->type = TOUCH_DOWN;
    savedEvent->args = e;
    _eventQueue.push(savedEvent);
 
}
Esempio n. 13
0
//--------------------------------------------------------------
void testApp::update() {

    //update our window title with the framerate and the position of the window
    //[zach fix] ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+":fps - pos ("+ofToString((int)windowX)+","+ofToString((int)windowY)+")");


    if(bFullscreen) {
        ofHideCursor();
    } else {
        ofShowCursor();
    }


    ballPositionX += ballVelocityX;
    ballPositionY += ballVelocityY;

    int posx = ofGetWindowPositionX();
    int posy = ofGetWindowPositionY();

    if (ballPositionX < 0) {
        ballPositionX = 0;
        ballVelocityX *= -1;
        if (!bFullscreen) ofSetWindowPosition(posx-10, posy);
    } else if (ballPositionX > ofGetWidth()) {
        ballPositionX = ofGetWidth();
        ballVelocityX *= -1;
        if (!bFullscreen) ofSetWindowPosition(posx+10, posy);
    }

    if (ballPositionY < 0) {
        ballPositionY = 0;
        ballVelocityY *= -1;
        cout << posy << endl;
        if (!bFullscreen) ofSetWindowPosition(posx, posy-10);
        cout << ofGetWindowPositionY() << endl;
    } else if (ballPositionY > ofGetHeight()) {
        ballPositionY = ofGetHeight();
        ballVelocityY *= -1;
        if (!bFullscreen) ofSetWindowPosition(posx, posy+10);
    }

}
Esempio n. 14
0
//--------------------------------------------------------------
void testApp::draw(){
	ofSetupScreen();
	
	ofSetColor(0x999999);
	
	//lets show our window pos in pixels
	//macs actually start the Y pos from 40
	vagRounded.drawString("window pos ("+ofToString(ofGetWindowPositionX())+", "+ofToString( ofGetWindowPositionY())+")", 10, 25);

	if(!bFullscreen){
		vagRounded.drawString("press f to enter fullscreen", -140 + ofGetWidth()/2, ofGetHeight()/2);	
		vagRounded.drawString("window is normal", -100 + ofGetWidth()/2, ofGetHeight() - 10);
	} else {
		vagRounded.drawString("press f to exit fullscreen", -150 + ofGetWidth()/2, ofGetHeight()/2); 
		vagRounded.drawString("window is fullscreen", -140 + ofGetWidth()/2, ofGetHeight() - 10); 
	}
	

	ofSetColor(0xFFFFFF);
	ofCircle(ballPositionX, ballPositionY, 15);
}
//--------------------------------------------------------------
void testApp::update(){

	

	int w = 300;
	int h = 300;
	
	unsigned char * data = pixelsBelowWindow(ofGetWindowPositionX(),ofGetWindowPositionY(),w,h);
	
	// now, let's get the R and B data swapped, so that it's all OK:
	for (int i = 0; i < w*h; i++){
		
		unsigned char r = data[i*4];
		data[i*4] = data[i*4+2];
		data[i*4+2] = r;
	}
	
	
	if (data!= NULL) tex.loadData(data, 300, 300, GL_RGBA);
	//cout << imageBelowWindow()[0] << endl;

}
Esempio n. 16
0
//--------------------------------------------------------------
void testApp::update() {

    // very ugly code
    if (gazeTrackBtn.on)
    {
        mypropWindow.mouseFocus = false;
        mytdWindow.mouseFocus = false;
        mytxtWindow1.mouseFocus = false;
        mytxtWindow2.mouseFocus = false;
    }
    else
    {
        mypropWindow.mouseFocus = true;
        mytdWindow.mouseFocus = true;
        mytxtWindow1.mouseFocus = true;
        mytxtWindow2.mouseFocus = true;
    }
    receiveGazeCoords();
    if ( gazeTrackBtn.on && (gazeCoords[2] != prevGazeCoords[0] || gazeCoords[3] != prevGazeCoords[1]) )
    {
        // Eyes have moved
        //ofLogVerbose() << "eyes have moved";
        prevGazeCoords[0] = gazeCoords[2];
        prevGazeCoords[1] = gazeCoords[3];
        int coordX = gazeCoords[2] - ofGetWindowPositionX();
        int coordY = gazeCoords[3] - ofGetWindowPositionY();
        ofVec2f gc = ofVec2f(coordX, coordY);
        //ofLogVerbose() << gc;
        ofNotifyEvent(gazeMove, gc);
    }
    if (startBtn.on) {
        broker.update();
    }
    mypropWindow.update();
    mytdWindow.update();
    mytxtWindow1.update();
    mytxtWindow2.update();
}
Esempio n. 17
0
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    // camera lucida keys
    switch (key)
    {
            
        case 'o':
            cml->gpu( !cml->gpu() );
            break;
            
        case 'w':
            cml->wireframe( ! cml->wireframe() );
            break;
            
        case 'e':
            kinect.enableDepthNearValueWhite(!kinect.isDepthNearValueWhite());
            break;
            
        case 'f':
            ofToggleFullscreen();
            break;
            
        case 'p':
            ofSetWindowPosition( ofGetWindowPositionX() == 0 ? 1920 : 0, 0 );
            break;
            
        case 'g':
            gui->toggleVisible();
            break;
            
        case 'r':
            gobStopper.unload();
            gobStopper.load("shaders/gobstopper.vert", "shaders/gobstopper.frag");
            break;
        case 's':
            gui->saveSettings("settings/gui.xml");
            break;
    }
}
Esempio n. 18
0
	void GamingScene6::Steup()
	{
		w_ = ofGetWindowWidth();
		h_ = ofGetWindowHeight();
		x_ = ofGetWindowPositionX();
		y_ = ofGetWindowPositionY();
		
		hand_pos_.set(200,200,0);
		hand_vel_.set(0,0,0);
		hand_radius_ = 50;
		max_hand_radius_ = 70;
		hand_mass_ = 1;

		moving_time_ = 0;
		moving_ = false;
		track_moving_ = false;
		interval_ = false;
		interval_time_ = 0;

		butterfly_pos_.set(350, 350,0);
		butterfly_vel_.set(0, 0, 0);
		butterfly_radius_ = 50;
		butterfly_mass_ = 1;	

		ofEnableLighting();

		main_camera_.setPosition(0,12,51);
		main_camera_.lookAt(ofVec3f(0,0,0));
		

		ofBackground(0);
		ofSetFrameRate(60);
		ofSetVerticalSync(true);

		ofViewport(x_, y_, w_, h_, false);
	}
Esempio n. 19
0
//--------------------------------------------------------------
void testApp::setup()
{
    ofSetWindowPosition( ofGetWindowPositionX() == 0 ? 1920 : 0, 0 );
    ofToggleFullscreen();
    ofSetFrameRate(60);
    ofBackground(50);
    
    // KINECT SETUP
    kinect.setRegistration(false);
    kinect.setDepthClipping(near, far); //mm (50cm - 4mt)
    kinect.enableDepthNearValueWhite(true);
    // ir:false, rgb:false, texture:true
    kinect.init(false, false, true);
    kinect.open();
    
    // CAMARA LUCIDA SETUP
    string cfg = ofToDataPath("camara_lucida/config.xml");
    
    cml = new cml::CamaraLucida( cfg );
    
    ofAddListener( cml->render_texture, this, &testApp::render_texture );
    ofAddListener( cml->render_3d, this, &testApp::render_3d );
    ofAddListener( cml->render_2d, this, &testApp::render_2d );
    
    // center of gobstopper
    center.set(kinect.getWidth()/2.0, kinect.getHeight()/2.0, .5 );
    
    // OFX UI SETUP!
    
    gui = new ofxUICanvas(0,0,400,1000);
    gui->toggleVisible();
    gui->addSlider("Near", 0.0, 10000.0, &near);
    gui->addSlider("Far", 0.0, 10000.0, &far);
    gui->addSlider("Center.x", 0.0, ofGetHeight(), &center.x);
    gui->addSlider("Center.y", 0.0, ofGetWidth(), &center.y);
    gui->addSlider("Center.z", 0.0, 10000.0, &center.z);
    gui->addToggle("Use Camara Lucida", &bUseCL);
    gui->addSpacer();
    gui->addIntSlider("Pump 1 Value", 0, 255, &pumpOneVal);
    gui->addIntSlider("Pump 2 Value", 0, 255, &pumpTwoVal);
    gui->addSpacer();
//    gui->addSlider("rotate x", 0, 360.0, &rotateX);
//    gui->addSlider("rotate y", 0, 360.0, &rotateY);
//    gui->addSlider("rotate z", 0, 360.0, &rotateZ);
//    gui->addSlider("trans x", -1.0, 1.0, &translateX);
//    gui->addSlider("trans y", -1.0, 1.0, &translateY);
//    gui->addSlider("trans z", -1.0, 1.0, &translateZ);
//    gui->addSlider("scale", 0.0, 2.0, &scale);
//    gui->addSlider("origin", -1.0, 1.0, &origin);
    gui->addToggle("Smooth mesh?", &bSmoothMesh);
    gui->addSlider("shaderMin", -100.0, 1000.0, &shaderMin);
    gui->addSlider("shaderMax", -100.0, 1000.0, &shaderMax);
    gui->addToggle("useData", &bUseData);
    gui->addIntSlider("servoDebug", 0, 180, &servoDebug);
    gui->addToggle("bServoAuto", &bServoAuto);
    gui->addSlider("servo position", -1, 1, &servoPos);
    gui->loadSettings("settings/gui.xml");
    
    // COLOR SETUP: setup gobstopper render
    gobStopper.load("shaders/gobstopper.vert", "shaders/gobstopper.frag");
    colorMap.allocate(cml->getConfig()->tex_width, cml->getConfig()->tex_height);
    
    colorsGLSL = new float[10 * 3];
    // colors
    for ( int i=0; i<10; i++){
        colors.push_back( ofColor() );
        colors.back().setSaturation(1.0);
        colors.back().setBrightness(1.0);
        colors.back().setHue(ofRandom(0,1.0));
        colorsGLSL[i * 3] = colors.back().r;
        colorsGLSL[i * 3 + 1] = colors.back().g;
        colorsGLSL[i * 3 + 2] = colors.back().b;
    }
    colorMesh.setMode(OF_PRIMITIVE_POINTS);
    
    colorMesh.setupIndicesAuto();
    for (int x=0; x<kinect.getWidth(); x++){
        for (int y=0; y<kinect.getHeight(); y++){
            colorMesh.addVertex(ofVec3f(x,y,0));
        }
    }
    
    // ARDUINO SETUP
    // load settings from XML
    ofxXmlSettings arduinoSettings;
    bool bSettingsLoaded = arduinoSettings.load("settings/arduino.xml");
    
    if ( bSettingsLoaded ){
        arduinoName = arduinoSettings.getValue("name", arduinoName);
        engagePin1  = arduinoSettings.getValue("engagePin1", engagePin1);
        engagePin2  = arduinoSettings.getValue("engagePin2", engagePin2);
        hIn1        = arduinoSettings.getValue("hIn1", hIn1);
        hIn2        = arduinoSettings.getValue("hIn2", hIn2);
        hIn3        = arduinoSettings.getValue("hIn3", hIn3);
        hIn4        = arduinoSettings.getValue("hIn4", hIn4);
    } else {
        // need to save settings
        arduinoSettings.setValue("name", arduinoName);
        arduinoSettings.setValue("engagePin1", engagePin1);
        arduinoSettings.setValue("engagePin2", engagePin2);
        arduinoSettings.setValue("hIn1", hIn1);
        arduinoSettings.setValue("hIn2", hIn2);
        arduinoSettings.setValue("hIn3", hIn3);
        arduinoSettings.setValue("hIn4", hIn4);
        arduinoSettings.save("settings/arduino.xml");
    }
    
    // connect to arduino and stuff
    arduino.connect( arduinoName, 57600);
	ofAddListener(arduino.EInitialized, this, &testApp::setupArduino);
	bSetupArduino	= false;
    
    
    // SALT DATA SETUP
    map<int, vector<PumpPins> > pumps;
    pumps[0] = vector<PumpPins>();
    pumps[1] = vector<PumpPins>();
    
    PumpPins pumpOne;
    pumpOne.enablePin = engagePin1;
    pumpOne.dataPin1 = hIn1;
    pumpOne.dataPin2 = hIn2;
    
    pumps[0].push_back(pumpOne);
    
    PumpPins pumpTwo;
    pumpTwo.enablePin = engagePin2;
    pumpTwo.dataPin1 = hIn3;
    pumpTwo.dataPin2 = hIn4;
    
    pumps[1].push_back(pumpTwo);
    
    saltData.setup(arduino, pumps);
    
    // SETUP SPACEBREW + CONNECT TO PUMP DATA
    spacebrew.addSubscribe("gplus_api", &saltData.APIlevels[0].value );
    spacebrew.addSubscribe("yt_api", &saltData.APIlevels[1].value );
    spacebrew.addSubscribe("numPeople", &saltData.localLevels[0].value );
    spacebrew.connect(host, name);
}
Esempio n. 20
0
	void Level1::Steup()
	{
        
		Player& player = JungleApp::PlayerInstance();
        
        light_.setAmbientColor(ofFloatColor(1, 0, 0));
        light_.setDiffuseColor(ofFloatColor(1 ,1 ,1));
        light_.setSpecularColor(ofFloatColor(0,0,0));
 
        light_.setDirectional();
        light_.setPosition(1024, 768, 0);

        ofEnableLighting();
        light_.enable();
        ofBackground(255);
		
		thunder.loadSound("audio/thunder.mp3");

        lightning_count_ = 0;
        max_leaf_ = 0;
		angle_ = 180;

		// Mushroom Placement        
        title_.loadImage("UI/title-screen-3.png");
        
        index_=0;
		//
		//z axis
		//              all glowing circle
		//                      |
		//--------------(-7)----0---------------500
		//               ^						 ^
		//				 |				         |
		//			    tree			     camera pos

		//left bottom corner is X:0,     Y:0
		//right up cornor is    X: 1280, Y:720
 
        
        if(!JungleApp::SceneManagerInstance().LoadScene("SceneConfig.xml"))
            cout<<"Cannot Load Scene"<<endl;
			//throw exception("Cannot Load Scene");;
       JungleApp::SceneManagerInstance().Enable(Group::TREE,true);
       // JungleApp::SceneManagerInstance().Reset();
        //JungleApp::SceneManagerInstance().Reset();
        
        stage_color_ = JungleApp::SceneManagerInstance().GetStageColor();
        //light_color_ = stage_color[1];
//        
//        cout<<(int)light_color_[0].r<<" "<<
//        (int)light_color_[0].g<<" "<<
//        (int)light_color_[0].b<<" "<<
//        (int)light_color_[0].a<<endl;
            
       SceneType &scene = JungleApp::SceneManagerInstance().GetDynamicObj();
	   light_.setDiffuseColor(stage_color_[0][2]);
	   light_.setAmbientColor(stage_color_[0][2]);
	   current_stage_ = TREE;
       for (unsigned int i =0; i < 5; ++i)
       {
		   time_.push_back(0.0f);
       }
	   lightning_time_ = 0;
       lightning_.loadModel("Environment/Lightning.obj");
        lightning_.setPosition(800, 0, 0);
        lightning_.setScale(1.1, 1.2, 1.1);
//        lightning_.setRotation(0, 180, 1, 0, 0);
        lightning_.setRotation(0, 180, 0, 1, 0);
        white_screen_ = false;
        
		//circle_.loadImage("Environment/glowing-circle-2.png");
		w_ = ofGetWindowWidth();
		h_ = ofGetWindowHeight();
		x_ = ofGetWindowPositionX();
		y_ = ofGetWindowPositionY();
	}