void TaskKey::update()
{
	unsigned int pressed = 0;
	if(ofGetKeyPressed()) {
		for(int index = 0; table[index] != 0; index += 2) {
			if(ofGetKeyPressed(table[index+1])) {
				pressed |= table[index];
			}
		}
	}
	release_ = hold_&~pressed;
	trigger_ = pressed&~hold_;
	hold_ = pressed;
	repeat_ = 0;
	for(int i = 0; i < KEY_MAX; ++i) {
		if(hold_ & (1<<i)) {
			if(repeat_frame_count_[i]-- == 0) {
				repeat_ |= (1<<i);
				repeat_frame_count_[i] = repeat_second_;
			}
		}
		else if(release_ & (1<<i)) {
			repeat_frame_count_[i] = repeat_first_;
		}
	}
}
void ofApp::update() {
    if(ofGetKeyPressed('1')) {
        ofSeedRandom(0);
        for(int i = 0; i < mesh.getNumVertices(); i++) {
            ofVec3f point = mesh.getVertex(i);
            point*=1.001;
            point+=ofVec3f(ofRandomf(), ofRandomf(), ofRandomf());
            mesh.setVertex(i, point);
        }
    }
    if(ofGetKeyPressed('2')) {
        for(int i = 0; i< referenceMesh.getNumVertices(); i++) {
            ofVec3f refpoint = referenceMesh.getVertex(i);
            ofVec3f point = mesh.getVertex(i);
            float increment=1-.3;
            float lerpX = ofLerp(refpoint.x, point.x, increment);
            float lerpY = ofLerp(refpoint.y, point.y, increment);
            float lerpZ = ofLerp(refpoint.z, point.z, increment);
            ofVec3f move(lerpX, lerpY, lerpZ);
            ofColor cur = referenceMesh.getColor(i).lerp(mesh.getColor(i), increment);
            mesh.setColor(i, cur);
            mesh.setVertex(i, move);
        }
    }

}
Example #3
0
// returns true if intercepted (stops event bubbling), false otherwise
bool basicShape::interceptMouseClick(ofMouseEventArgs &e){
	if( isInEditMode() ){
		// toggle GUI ?
		if( guiToggle.inside(e.x, e.y) ){
			drawShapeGui = !drawShapeGui;
			shapeGui.setPosition( guiToggle.getTopRight()+ofVec2f(5,20));
			return true;
		}
		
		// over shapeGui ?
		else if(drawShapeGui && shapeGui.getShape().inside(e.x,e.y)){
			// if click on name, then ask for new name... #hacky
			ofxBaseGui* nameLabel = basicShapeGui.getControl(GUIinfo_ShapeName);
			if(nameLabel && nameLabel->getShape().inside(e.x, e.y) ){
				shapeName = ofSystemTextBoxDialog("Enter the shape name...", shapeName);
				ofLogNotice("basicShape::interceptMouseClick") << "New shape name: " << shapeName;
			}
			
			return true;
		}
		
		// on position handler ?
		else if( position.interceptMouseClick(e) ){
			
			// erase whole shape ?
			if( ofGetKeyPressed('r') || ofGetKeyPressed('R') ){
				pleaseDeleteMe = true;
			}
			
			return true;
		}
	}
	
	return false;
}
Example #4
0
bool Director::mousePressed(ofPoint _mouse){
    if (inside(_mouse)){
        
        //  Is over one dot?
        //
        bool overDot = false;
        for(int i=1;i<points.size()-1;i++){
            ofPoint pos = toScreen(points[i]);
            if(pos.distance(_mouse)<20){
                overDot = true;
                break;
            }
        }
        
        if (!overDot){
            lastCLick = _mouse;
        }
        
        if(!ofGetKeyPressed() && !overDot){
            
            float lenghtToClosest = 1000;
            int closest = -1;
            
            for (int i=0;i<points.size()-1;i++){
                int next=i+1;
                
                ofVec2f AtoM = _mouse - toScreen(points[i]);
                ofVec2f AtoB = toScreen(points[next]) - toScreen(points[i]);
                
                float a = atan2f(AtoM.x, AtoM.y);
                float b = atan2f(AtoB.x, AtoB.y);
                
                if (abs(a - b) <= 0.05 &&               //  1. Is over the line
                    AtoM.length() < lenghtToClosest &&  //  2. Is the closest one
                    AtoM.length() < AtoB.length() ){    //  3. Is between those two points
                    lenghtToClosest = AtoM.length();
                    closest = next;
                }
            }
            
            if(closest!=-1){
                points.insert(points.begin()+closest, fromScreen(_mouse));
            }
            
        } else if (ofGetKeyPressed('a') && !overDot){
            points.insert(points.end()-1, fromScreen(_mouse));
        } else if( ( ofGetKeyPressed('d') || ofGetKeyPressed(OF_KEY_BACKSPACE) || ofGetKeyPressed(OF_KEY_DEL) )&& overDot){
            for(int i=1;i<points.size()-1;i++){
                ofPoint pos = toScreen(points[i]);
                if(pos.distance(_mouse)<10){
                    points.erase(points.begin()+i);
                    break;
                }
            }
        }
    }
}
Example #5
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofEnableLighting();
    ofBackgroundGradient(ofColor(65,62,50),ofColor(25,22,10) );
    
    // disable normals if a key is pressed
    if(ofGetKeyPressed() || ofGetMousePressed()){
        mesh.disableNormals();
    }else{
        mesh.enableNormals();
    }
    
    cam.begin();
    mesh.enableColors();
    mesh.drawWireframe();
    mesh.disableColors();
    ofSetColor(137,137,140);
    ofFill();

    #ifndef TARGET_OPENGLES
    glEnable(GL_POLYGON_OFFSET_LINE);
    glPolygonOffset(-1,-1);
    #endif

    mesh.drawFaces();
    ofSetColor(255,255,255);
    light.draw();
    
    
    // draw our normals, and show that they are perpendicular to the vector from the center to the vertex
    vector<ofVec3f> n = mesh.getNormals();
    vector<ofVec3f> v = mesh.getVertices();
    float normalLength = 50.;
    
    if(!ofGetKeyPressed()){
        ofDisableLighting();
        ofSetColor(255,255,255,70);         
        for(unsigned int i=0; i < n.size() ;i++){
            ofDrawLine(v[i].x,v[i].y,v[i].z,
                   v[i].x+n[i].x*normalLength,v[i].y+n[i].y*normalLength,v[i].z+n[i].z*normalLength);

            ofDrawLine(.98*v[i].x,.98*v[i].y,.98*v[i].z,
                   .98*v[i].x+n[i].x*normalLength*.2,.98*v[i].y+n[i].y*normalLength*.2,.98*v[i].z+n[i].z*normalLength*.2);
            ofDrawLine(.98*v[i].x+n[i].x*normalLength*.2,.98*v[i].y+n[i].y*normalLength*.2,.98*v[i].z+n[i].z*normalLength*.2,
                   v[i].x+n[i].x*normalLength*.2,v[i].y+n[i].y*normalLength*.2,v[i].z+n[i].z*normalLength*.2);
        }
    }
               

    cam.end();

    ofSetColor(255,255,255);
    ofDrawBitmapString("press any key or mouse button to disable mesh normals", 20,20);
    ofDrawBitmapString("light", cam.worldToScreen(light.getGlobalPosition()) + ofPoint(10,0));
}
Example #6
0
//------------------------------------------------------------
void ofxFensterManager::mouse_cb(GLFWwindow* windowP_, int button, int state, int mods) {
	ofLogVerbose("ofxFenster") << "mouse button: " << button;

#ifdef TARGET_OSX
	//we do this as unlike glut, glfw doesn't report right click for ctrl click or middle click for alt click
	if( ofGetKeyPressed(OF_KEY_CONTROL) && button == GLFW_MOUSE_BUTTON_LEFT) {
		button = GLFW_MOUSE_BUTTON_RIGHT;
	}
	if( ofGetKeyPressed(OF_KEY_ALT) && button == GLFW_MOUSE_BUTTON_LEFT) {
		button = GLFW_MOUSE_BUTTON_MIDDLE;
	}
#endif

	switch(button) {
	case GLFW_MOUSE_BUTTON_LEFT:
		button = OF_MOUSE_BUTTON_LEFT;
		break;
	case GLFW_MOUSE_BUTTON_RIGHT:
		button = OF_MOUSE_BUTTON_RIGHT;
		break;
	case GLFW_MOUSE_BUTTON_MIDDLE:
		button = OF_MOUSE_BUTTON_MIDDLE;
		break;
	}

	ofxFensterPtr fenster = get()->getFensterByGlfwHandle(windowP_);

	if (state == GLFW_PRESS) {
		if(fenster == get()->mainWindow)
			ofNotifyMousePressed(ofGetMouseX(), ofGetMouseY(), button);

		fenster->buttonPressed=true;

		ofMouseEventArgs args;
		args.x = fenster->curMouseX;
		args.y = fenster->curMouseY;
		args.type = ofMouseEventArgs::Pressed;
		ofNotifyEvent(fenster->onMousePressed, args);
	} else if (state == GLFW_RELEASE) {
		if(fenster == get()->mainWindow)
			ofNotifyMouseReleased(ofGetMouseX(), ofGetMouseY(), button);

		fenster->buttonPressed=false;

		ofMouseEventArgs args;
		args.x = fenster->curMouseX;
		args.y = fenster->curMouseY;
		args.type = ofMouseEventArgs::Released;
		ofNotifyEvent(fenster->onMouseReleased, args);
	}
	fenster->buttonInUse = button;

}
void ofMeshP::update(string hill, int max) {

    ////////////////////////////////////////////////  //JUSTIN
    path = hill;
    l = max;
    now = currentFrame;
    //if space bar is pressed, increment playback number

    if(ofGetKeyPressed('p')) {
        skip++;
    }
    if(ofGetKeyPressed('o') && skip >= 1) {
        skip--;
    }


    if(currentFrame < l) {
        currentFrame++;

        cout<<"PLAYING"<<endl;
    } else {
        currentFrame = 1;
    }

    ostringstream fileNameToSave;
    fileNameToSave << currentFrame << ".png";
    frameResult = fileNameToSave.str();


    img.loadImage(path+ frameResult);


    mesh.clear();
    for(int y = 0; y < img.getHeight(); y++) {
        for(int x = 0; x < img.getWidth(); x++) {
            ofColor cur = img.getColor(x, y);
            if(cur.a > 0) {
                // the alpha value encodes depth, let's remap it to a good depth range
                float z = ofMap(cur.a, 0, 255, -480, 480);
                cur.a = 255;
                mesh.addColor(cur);
                ofVec3f pos(x - img.getWidth() / 2, y - img.getHeight() / 2, z);
                mesh.addVertex(pos);

            }
        }
    }




}
//--------------------------------------------------------------
void testApp::draw(){
//    ofBackgroundGradient(ofColor::gray, ofColor::black);
//    ofBackground(0);
    
	ofSetColor(255);
    
    depthOfField.begin();
    cam.begin(depthOfField.getDimensions());
    ofEnableLighting();
    coldLight.enable();
    warmLight.enable();
    
    glEnable(GL_DEPTH_TEST);
    ofPushMatrix();
    ofRotateY((ofGetElapsedTimef()*0.1)*180);
    ofRotateX(sin(ofGetElapsedTimef()*0.1)*90);
    
//    ofRotateZ((ofGetElapsedTimef()*0.1)*180);
    
    ofTranslate(0,offSet.x*0.7);
    ofRotate(-90, 0, 0, 1);
    ofSetColor(255,250,240);
    if(ofGetKeyPressed( 'm' )){
        mesh.drawWireframe();
    } else {
        mesh.drawFaces();
    }
    ofPopMatrix();
    glDisable(GL_DEPTH_TEST);
    
    coldLight.disable();
    warmLight.disable();
    ofDisableLighting();
    ofPopMatrix();
    cam.end();
    depthOfField.end();
    
    
    ofPushMatrix();
	if(ofGetKeyPressed( 'a' )){
		depthOfField.drawFocusAssist(0, 0);
        
    } else{
		depthOfField.getFbo().draw(0, 0);
	}
    ofPopMatrix();
    
    
    sServer.publishScreen();
}
void testApp::mousePressed(int x, int y,int button ){
//	cout << "mouse pressed!" << endl;
	
	ofVec2f camvec(x,y);
	ofVec2f offset = depthImage1Rect.getTopLeft();
	if(ofGetKeyPressed('1') && depthImage1Rect.inside(camvec)){
		cam1Calib[0] = camvec - offset;
	}
	if(ofGetKeyPressed('2') && depthImage1Rect.inside(camvec)){
		cam1Calib[1] = camvec - offset;
	}
	if(ofGetKeyPressed('3') && depthImage1Rect.inside(camvec)){
		cam1Calib[2] = camvec - offset;
	}
	if(ofGetKeyPressed('4') && depthImage1Rect.inside(camvec)){
		cam1Calib[3] = camvec - offset;
	}
	
	offset = depthImage2Rect.getTopLeft();
	if(ofGetKeyPressed('5') && depthImage2Rect.inside(camvec)){
		cam2Calib[0] = camvec - offset;
	}
	if(ofGetKeyPressed('6') && depthImage2Rect.inside(camvec)){
		cam2Calib[1] = camvec - offset;
	}
	if(ofGetKeyPressed('7') && depthImage2Rect.inside(camvec)){
		cam2Calib[2] = camvec - offset;
	}
	if(ofGetKeyPressed('8') && depthImage2Rect.inside(camvec)){
		cam2Calib[3] = camvec - offset;
	}

}
    void Calibrator::keyPressed(int key){
        
        ofVec3f keyVec(0,0,0);
        
        if(key == OF_KEY_LEFT){
            keyVec.x = -1;
        }
        if(key == OF_KEY_RIGHT){
            keyVec.x = 1;
        }
        if(key == OF_KEY_UP){
            keyVec.y = -1;
        }
        if(key == OF_KEY_DOWN){
            keyVec.y = 1;
        }
        
        if(ofGetKeyPressed(OF_KEY_SHIFT)){
            keyVec *= 0.01;
        } else {
            keyVec *= 0.00025;
        }
        
        for(auto point : points){
            point->set(keyVec + point->get());
        }

    }
Example #11
0
void ofEasyCam::mousePressed(ofMouseEventArgs & mouse){
	if(viewport.inside(mouse.x, mouse.y)){
		lastMouse = mouse;
		prevMouse = mouse;
		prevAxisX = getXAxis();
		prevAxisY = getYAxis();
		prevAxisZ = getZAxis();
		prevPosition = ofCamera::getGlobalPosition();
		prevOrientation = ofCamera::getGlobalOrientation();

		if ((bEnableMouseMiddleButton && mouse.button == OF_MOUSE_BUTTON_MIDDLE) || ofGetKeyPressed(doTranslationKey)  || mouse.button == OF_MOUSE_BUTTON_RIGHT){
			bDoTranslate = true;
			bDoRotate = false;
		}else if (mouse.button == OF_MOUSE_BUTTON_LEFT) {
			bDoTranslate = false;
			bDoRotate = true;
			if(ofVec2f(mouse.x - viewport.x - (viewport.width/2), mouse.y - viewport.y - (viewport.height/2)).length() < min(viewport.width/2, viewport.height/2)){
				bInsideArcball = true;
			}else {
				bInsideArcball = false;
			}
		}
		bApplyInertia = false;
	}
}
Example #12
0
void ofApp::update() {

    if (zoom_in && (ofGetKeyPressed(OF_KEY_CONTROL) ||
                    ofGetKeyPressed(OF_KEY_COMMAND))) {
        c.zoomIn();
        zoom_in = false;
        setGrid();
    }

    if (zoom_out && (ofGetKeyPressed(OF_KEY_CONTROL) ||
                     ofGetKeyPressed(OF_KEY_COMMAND))) {
        c.zoomOut();
        zoom_out = false;
        setGrid();
    }
}
Example #13
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key) {
	
	// note: when using CTRL as the modifier key, CTRL + key might be an ascii
	// control char so check for both the char 'f' and 6, the ascii value for
	// CTRL + f, see also: http://ascii-table.com/control-chars.php
	bool modifier = ofGetKeyPressed(ofxEditor::getSuperAsModifier() ? OF_KEY_SUPER : OF_KEY_CONTROL);
	if(modifier) {
		switch(key) {
			case 'f': case 6:
				ofToggleFullscreen();
				return;
			case 'l': case 12:
				editor.setLineWrapping(!editor.getLineWrapping());
				return;
			case 'n': case 14:
				editor.setLineNumbers(!editor.getLineNumbers());
				return;
			case 'k': case 26:
				editor.setAutoFocus(!editor.getAutoFocus());
				return;
		}
	}
	
	// see ofxGLEditor.h for key commands
	editor.keyPressed(key);
}
 void resetDrawSettings()
 {
     m_inSetup = false;
     fill(m_defaultFillColor.getHex());
     stroke(m_defaultStrokeColor.getHex());
     strokeWeight(m_defaultStrokeWeight);
     m_hasFill = m_defaultHasFill;
     m_hasStroke = m_defaultHasStroke;
     ofEnableBlendMode(OF_BLENDMODE_ALPHA);
     smooth(2);
     width = ofGetWidth();
     height = ofGetHeight();
     pmouseX = ofGetPreviousMouseX();
     pmouseY = ofGetPreviousMouseY();
     keyPressed = ofGetKeyPressed();
     mousePressed = ofGetMousePressed();
     mouseButton = NONE;
     if( ofGetMousePressed(0) )
         mouseButton = LEFT;
     else if(ofGetMousePressed(1))
         mouseButton = RIGHT;
     
     
     ofSetCircleResolution(100);
     ofSetCurveResolution(100);
 }
Example #15
0
	//----------
	void Scene::mousePressed(ofMouseEventArgs & args) {
		this->updateCursor();
		this->cursor.start(args.button);
		this->cursor.captured = args.button == 0 && !ofGetKeyPressed();
		this->cursor.dragged = false;
		
		this->getElementUnderCursor().cursorDown(cursor);
		
//		if (this->inspector.getShape().inside(this->cursor.screen.x, this->cursor.screen.y)) {
//			
//			//we're inside the gui
//			cursor.captured = true;
//			
//			//horrible hack to stop mouse clicks in gui affecting node selection
//			cursor.dragged = true;
//		}
		
		isSettingOrigin = ofGetModifierPressed(OF_KEY_ALT);
		cursor.captured |= isSettingOrigin;
		
		if (cursor.captured) {
			this->camera->setMouseActions(false);
		}
			
		this->lockIndex = true;
	}
Example #16
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
	if (key == 'r') {
		cam.beginRecording();
	}
	if (key == 'R') {
		cam.endRecording();
	}
	if (key == ' ') {
		if (!ofGetKeyPressed(OF_KEY_SHIFT)) {
			cam.play();
		}
		else {
			cam.pause();
		}
	}
	if (key == 'l') {
		ofFileDialogResult result = ofSystemLoadDialog("Choose a folder of recorded data", true, ofToDataPath(""));
		if (result.getPath() != "") {
			cam.setPlaybackPath(result.getPath());
		}
	}
	if (key == 'L') {
		cam.setLive();
	}
}
Example #17
0
// - - - - - - -
// GUI STUFF
// - - - - - - -
void basicShape::keyPressed(ofKeyEventArgs& e){
	if(!bEditMode) return;
	
	// select another handle ?
	if( e.key ==  91 ){ // 91 = [
		selectPrevHandle();
		return;
	}
	else if( e.key == 93){ // 93 = ]
		selectNextHandle();
	}
	else if( e.key == OF_KEY_RETURN ){
		selectHandle(NULL);
	}
	
	// editActiveHandleWithArrows
	else if( bEditMode && handleExists(activeHandle) ){
		basicPoint translation(0,0);
		int amplifier = 1 + ofGetKeyPressed(OF_KEY_SHIFT)*10;
		
		if( e.key == OF_KEY_DOWN ) translation += basicPoint(0,1);
		else if( e.key == OF_KEY_UP ) translation += basicPoint(0,-1);
		else if( e.key == OF_KEY_LEFT ) translation += basicPoint(-1,0);
		else if( e.key == OF_KEY_RIGHT ) translation += basicPoint(1,0);
		
		if(translation.x!=0 || translation.y!=0)translateActiveHandle( translation*amplifier );
	}
	
	//else ofLogNotice("basicShape::keyPressed()","Unrecognised key: "+ofToString(e.key));
}
Example #18
0
void QuadWarp::onMouseDragged(ofMouseEventArgs& mouseArgs) {
    if(bShow){
        if(selectedCornerIndex < 0 || selectedCornerIndex > 3) {
            return;
        }
        ofPoint mousePoint(mouseArgs.x, mouseArgs.y);
        
        if (ofGetKeyPressed(cKey)) {
            dstPoints[selectedCornerIndex].set( dstPoints[selectedCornerIndex]- (lastMouse - mousePoint) * value);

            if (selectedCornerIndex == 0) {
                dstPoints[1].set( dstPoints[1]- (lastMouse - mousePoint) * value *-1);
            }
            else if (selectedCornerIndex == 1) {
                dstPoints[0].set( dstPoints[0]- (lastMouse - mousePoint) * value *-1);
            }
            else if (selectedCornerIndex == 2) {
                dstPoints[3].set( dstPoints[3]- (lastMouse - mousePoint) * value *-1);
            }
            else if (selectedCornerIndex == 3) {
                dstPoints[2].set( dstPoints[2]- (lastMouse - mousePoint) * value *-1);
            }
        }
        

        else
            dstPoints[selectedCornerIndex].set( dstPoints[selectedCornerIndex]- (lastMouse - mousePoint) * value);
        
        lastMouse = mousePoint;
    }
}
Example #19
0
//--------------------------------------------------------------
void testApp::update(){

    bool press = ofGetKeyPressed();
    voro::container con(-containerSize,containerSize,
                  -containerSize,containerSize,
                  -containerSize,containerSize,
                  1, 1, 1, press, press, press, 8);
    
    for(int i = 0; i < boids.size();i++){
        boids[i]->update( boids );
        if ( insideContainer( con, *boids[i])){
            addCellSeed( con, boids[i], i);
            boids[i]->color.set(50, 200,200);
        } else {
            boids[i]->color.set(255,0,0);
        }
    }
    
    cellMeshes.clear();
    cellMeshes = getCellsFromContainer(con,0);
	cellMeshWireframes.clear();
	cellMeshWireframes = getCellsFromContainer(con,0,true);
    
    ofSetWindowTitle(ofToString(ofGetFrameRate()));
}
Example #20
0
//-----------------------------------------------------------------------------------------
//
void ofApp::update()
{
	// Update time, this let's us hit space and slow down time, even reverse it.
	if( ofGetKeyPressed(' ') ) { timeStep = ofLerp( timeStep, ofMap( ofGetMouseX(), 0, ofGetWidth(), -(1.0f/60.0f), (1.0f/60.0f) ), 0.1f );}
	else { timeStep = ofLerp( timeStep, 1.0f / 60.0f, 0.1f ); }
	time += timeStep;
	
}
Example #21
0
void ofApp::update() {
	if(ofGetKeyPressed()) {
		float minRadius = mouseX / (float) ofGetWidth();
		float maxRadius = (mouseY) / (float) ofGetHeight();
		iso.setRadius(minRadius, minRadius + maxRadius);
		iso.update();
	}
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
    ofPoint mouse = ofPoint(x,y);
    
    if ( graphView.inside(mouse)){
        
    } else if (ofGetKeyPressed()){
        map.mouseReleased(x,y,button);
    }
}
//--------------------------------------------------------------
void testApp::update(){
	
    // when press spacebar, capture the background
    if(ofGetKeyPressed(' ')){
        if(ps3eye.isFrameNew()){
            background.setFromPixels(ps3eye.getPixelsRef());
            backgroundPixels = background.getPixels();          // pixels from bg image
            
            // fill array of bgPixel vectors with the RGB values of each background pixel
            for(int i=0; i < camWidth; i++){
                for(int j=0; j < camHeight; j++){
                    bgPixels[j*camWidth + i].set(backgroundPixels[(j*camWidth + i)*3], backgroundPixels[(j*camWidth + i)*3 + 1], backgroundPixels[(j*camWidth + i)*3 + 2]);
                }
            }
        }
    }
    
    // when press a, record from camera (each frame adds an image to vector)
    if(ofGetKeyPressed('a')){
            makeLoop(images);
            drums.setVolume(1.0);
    }
    
    // when press b, record a different loop from the camera (each frame adds an image to a different vector)
    if(ofGetKeyPressed('b')){
        makeLoop(images2);
        conga.setVolume(1.0);
    }
    
    // when press c, record a different loop from the camera (each frame adds an image to a different vector)
    if(ofGetKeyPressed('c')){
        makeLoop(images3);
        bass.setVolume(1.0);
    }
    
    // when press d, record a different loop from the camera (each frame adds an image to a different vector)
    if(ofGetKeyPressed('d')){
        makeLoop(images4);
        guitar.setVolume(1.0);
    }
    
	ps3eye.update();
}
Example #24
0
 void update() {
     
     ofSetWindowTitle(ofToString(ofGetFrameRate()));
     cam.update();
     if(cam.isFrameNew()) {
         if(ofGetKeyPressed()) {
             results = ccv.classifyFace(cam);
         }
     }
 }
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
	// TODO: check if we're over the map
    ofPoint mouse = ofPoint(x,y);
    
    if ( graphView.inside(mouse)){
        
    } else if (ofGetKeyPressed()){
        map.mouseDragged(x,y,button);
    }
}
//----------------------------------------
void ofxViewportCam::begin(ofRectangle viewport)
{
    ofPushStyle();
    if(drawWireFrame)
    {
        ofNoFill();
    }
    else
    {
        ofFill();
    }
    
    ofVec3f pos = getPosition();
    ofVec2f mousePosScreen = ofVec3f(ofGetMouseX() - viewport.width / 2 - viewport.x, viewport.height / 2 - (ofGetMouseY() - viewport.y), 0);
    
#ifdef TARGET_LINUX
    if(ofGetKeyPressed(OF_KEY_SHIFT))
#else
    if(ofGetKeyPressed(OF_KEY_ALT))
#endif
    {
        ofVec2f trans(mousePosScreenPrev - mousePosScreen);
        if(ofGetMousePressed(0))
        {
            tumble(trans.x, -trans.y);
        }
        else if(ofGetMousePressed(1))
        {
            track(trans.x, trans.y);
        }
        else if(ofGetMousePressed(2))
        {
            float zoomAmount = trans.y;
            zoom(zoomAmount);
        }
    }
    
    mousePosScreenPrev = mousePosScreen;
    ofCamera::begin(viewport);
    
    ofPopStyle();
}
Example #27
0
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button)
{
    if(!ofGetKeyPressed(OF_KEY_ALT))
    {
        this->scene->pickObject(x, y);
//#define DEBUG_PICKING 1
#ifdef DEBUG_PICKING
      this->window->getWxGLCanvas()->setAutoRedraw(!this->window->getWxGLCanvas()->getAutoRedraw());
      this->window->getWxGLCanvas()->SwapBuffers();
#endif
    }
}
Example #28
0
void ofApp::draw() {
	ofBackground(0);
	ofSetColor(255);
	ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);
	ofRotateY(ofGetFrameNum());
	ofTranslate(-ofGetWidth() / 2, -ofGetHeight() / 2);
	if(ofGetKeyPressed()) {
		mesh.drawWireframe();
	} else {
		mesh.draw();
	}
}
//--------------------------------------------------------------
void ofApp::draw(){


	cam.begin();
	ofPushStyle();
	ofPushMatrix();
	//units are in meters which makes the models super small in OF
	ofScale(1000,1000,1000);

	
	if(ofGetKeyPressed('c')){
		mesh.disableColors();
	}
	else{
		mesh.enableColors();
	}
	if(ofGetKeyPressed('w')){
		ofEnableDepthTest();
		mesh.drawWireframe();
		ofDisableDepthTest();
	}
	else if(ofGetKeyPressed('p')){
		ofEnableBlendMode(OF_BLENDMODE_SCREEN); //make it glow
		mesh.drawVertices();
	}
	else {
		ofEnableDepthTest();
		mesh.draw();
		copyMesh.draw();
		ofDisableDepthTest();
	}

	//copyMesh.draw();

	ofPopMatrix();
	ofPopStyle();
	cam.end();

}
void ofApp::update() {

    kinect.update();
    if(ofGetKeyPressed('3')) {
        recordingOn =! recordingOn;
    }

    else {
        if (recordingOn==true && ofGetKeyPressed(' '))

            recordingOn =false;


    }




    if(kinect.isFrameNew()) {
        if (recordingOn == true && frameNumber <= 200) {
            ofPixels& depthPixels = kinect.getDepthPixelsRef();
            ofPixels& colorPixels = kinect.getPixelsRef();
            for(int y = 0; y < 480; y++) {
                for(int x = 0; x < 640; x++) {
                    ofColor color = colorPixels.getColor(x, y);
                    ofColor depth = depthPixels.getColor(x, y);
                    img.setColor(x, y, ofColor(color, depth.getBrightness()));

                }
            }
            frameNumber = frameNumber + 1;
            ostringstream Name;
            Name << frameNumber << ".png";
            string result = Name.str();
            img.saveImage(result);
            cout<<"recording"<<endl;
        }
    }
}