コード例 #1
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    ofBackground(0, 0, 0);
    ofSetFrameRate(60);
    ofEnableDepthTest();

    
    cam.setNearClip(0.0001f);
    cam.setFarClip(10000.0f);
    cam.toggleControl();
    cam.setPosition(0, 0, 700);

    
    mainOffSetXPos = (ofGetWidth() - (baseArch.fassadeCorner[0].x + baseArch.fassadeCorner[1].x)) * 0.5;
    mainOffSetYPos = (ofGetHeight() - (baseArch.fassadeCorner[0].y + baseArch.fassadeCorner[3].y)) * 0.5;
    baseArch.mainOffSetXPos = mainOffSetXPos;
    baseArch.mainOffSetYPos = mainOffSetYPos;

    
    
    FeatureNode* _rootNode_33975_22294;
    
    JsonLoader _jsonLoader_33975_22294 = JsonLoader("OSMJSON.json");
    _rootNode_33975_22294 = _jsonLoader_33975_22294.loadNodeGraph();
    
    ofxJSONElement _jsonMain;
    _jsonMain = _jsonLoader_33975_22294.jsonRoot;
    
    ofxJSONElement _jsonBuildings;
    _jsonBuildings = _jsonMain["features"];
    
    
    
    
    for (int i=0; i<_jsonBuildings.size(); i++) {
        
        string _way = _jsonBuildings[i]["id"].asString();
        
        if (_way.at(0) == 'w') {
            ofxJSONElement _jsonBuilding;
            _jsonBuilding = _jsonBuildings[i]["geometry"]["coordinates"][0];
            
            ofMesh _m;
            _m.setMode(OF_PRIMITIVE_LINE_LOOP);
            
            ofPolyline _pl;
            _pl.setClosed(false);
            _pl.begin();
            
            string _polygon = _jsonBuildings[i]["geometry"]["type"].asString();
            
            if (_polygon == "Polygon") {
                
                for (int j=0; j<_jsonBuilding.size(); j++) {
                    
                    ofxJSONElement _coordinateBuilding;
                    _coordinateBuilding = _jsonBuilding[j];
                    
                    
                    ofVec2f _v;
                    _v.x = _jsonLoader_33975_22294.lon2x(_coordinateBuilding[0].asFloat()) - 740603;
                    _v.y = _jsonLoader_33975_22294.lat2y(_coordinateBuilding[1].asFloat()) - 6.40447e+06;
                    
                    
                    _m.addVertex(_v);
                    _m.addColor( ofColor(255) );
                    
                    _pl.addVertex( _v );
                    
                }
                
                
                buildings_33975_22294.push_back( _m );
                
                _pl.end();
                buildingsPolyline_33975_22294.push_back(_pl);
            }
            
        }
        
        
    }
    
    
    
    ofxJSONElement _jsonRoads;
    _jsonRoads = _jsonMain["features"];
    
    for (int i=0; i<_jsonRoads.size(); i++) {
        ofxJSONElement _jsonRoad;
        
        
        string _way = _jsonRoads[i]["id"].asString();
        
        if (_way.at(0) == 'w') {
            
            ofMesh _m;
            _m.setMode(OF_PRIMITIVE_LINE_STRIP);
            
            ofPolyline _pl;
            
            string _LineString = _jsonRoads[i]["geometry"]["type"].asString();
            
            if (_LineString == "LineString") {
                
                _jsonRoad = _jsonRoads[i]["geometry"]["coordinates"];
                
                for (int j=0; j<_jsonRoad.size(); j++) {
                    
                    ofxJSONElement _coordinateRoad;
                    _coordinateRoad = _jsonRoad[j];
                    
                    ofVec2f _v;
                    _v.x = _jsonLoader_33975_22294.lon2x(_jsonRoad[j][0].asFloat()) - 740603;
                    _v.y = _jsonLoader_33975_22294.lat2y(_jsonRoad[j][1].asFloat()) - 6.40447e+06;
                    
                    _m.addVertex(_v);
                    _m.addColor( ofColor(255) );
                    
                    _pl.addVertex(_v);
                    
                    
                }
                
                roads_33975_22294.push_back( _m );
                roadsPolyline_33975_22294.push_back( _pl );
                
                
            } else {
                
                //                _jsonRoad = _jsonRoads[i]["geometry"]["coordinates"][0];
                //
                //                for (int j=0; j<_jsonRoad.size(); j++) {
                //
                //                    ofxJSONElement _coordinateRoad;
                //                    _coordinateRoad = _jsonRoad[j];
                //
                //                    ofVec2f _v;
                //                    _v.x = _jsonLoader_33975_22294.lon2x(_jsonRoad[j][0].asFloat()) - 740603;
                //                    _v.y = _jsonLoader_33975_22294.lat2y(_jsonRoad[j][1].asFloat()) - 6.40447e+06;
                //
                //                    _m.addVertex(_v);
                //                    _m.addColor( ofColor(255) );
                //
                //                    _pl.addVertex(_v);
                //
                //                }
                //
                //                roads_33975_22294.push_back( _m );
                //                roadsPolyline_33975_22294.push_back( _pl );
                
            }
            
        }
        
    }
    
    
    
    _rootNode_33975_22294->setPosition(0, 0, 0);
    _rootNode_33975_22294->printPosition("");
    
    
    camera = ofEasyCam();
    camera.setPosition(_rootNode_33975_22294->getGlobalPosition());
    camera.move(0, 0, 300);
    camera.setTarget(_rootNode_33975_22294->getGlobalPosition());
    
    mainLight = ofLight();
    mainLight.setPointLight();
    mainLight.setGlobalPosition(-100, 0, 500);
    mainLight.setDiffuseColor(ofColor(35, 35, 35));
    mainLight.setSpecularColor(ofColor(170, 170, 170));
    
}
コード例 #2
0
//--------------------------------------------------------------
void testApp::setup() {

    ofBackground(21, 234, 245);

    ard.connect("/dev/tty.usbmodemfd121", 57600);
    ofAddListener(ard.EInitialized, this, &testApp::setupArduino);


    bSetupArduino	= false;
    mouse_pressed = false;
    gravity = 0.1;
    friction = 0.999;


    for(int i = 0; i < NUM; i++) {
        loc_x[i] = ofGetWidth() / 2;
        loc_y[i] = ofGetHeight() / 2;
        speed_x[i] = ofRandom(-10, 10);
        speed_y[i] = ofRandom(-10, 10);
        radius[i] = ofRandom(1, 10);
        red[i] = ofRandom(0, 255);
        green[i] = ofRandom(0, 255);
        blue[i] = ofRandom(0, 255);
    }

    ardButtonPressed = false;





    myVideo.initGrabber( 1324,968,true);

    ofSetFrameRate(24);
    ofEnableAlphaBlending();
    ofSetCircleResolution(50);
    ofEnableSmoothing();

    ofSoundStreamSetup(0, 2, this, 44100, 256, 4);
    left = new float[256];
    right = new float[256];

    AAleft.setup();
    AAright.setup();

    //
    inputBufferCopy = new float [512 *2];
    //




    lines[0].min_y = 0;
    lines[0].max_y = 50;
    lines[0].id = 1;

    lines[1].min_y = 50;
    lines[1].max_y = 100;

    lines[1].id = 2;

    lines[2].min_y = 70;
    lines[2].max_y =110;
    lines[2].id = 3;

    lines[3].min_y = 100;
    lines[3].max_y = 140;
    lines[3].id = 4;

    lines[4].min_y = 110;
    lines[4].max_y =160;
    lines[4].color = ofColor(255, 255, 255, 0);
    lines[4].id = 5;


}
コード例 #3
0
void ofxHighlightRects::draw(ofEventArgs &e) {
	unsigned long long currentTime = ofGetElapsedTimeMillis();

	//ofLogVerbose("ofxHighlightRects") << "drawing " << highlights.size() << " highlights." ;

	std::vector<HighlightRectData>::iterator it = highlights.begin();

	ofPushStyle();
	ofColor fg = ofColor(90,200,90);
	ofColor bg = ofColor(0,0,0);
	ofNoFill();

	while(it != highlights.end()) {
		int alpha;
		if(currentTime < it->timestamp + it->stayTime) {
			alpha = 255;
		} else {
			alpha = 255*(1-((currentTime - (it->timestamp + it->stayTime))/((float) it->fadeTime)));
		}
		if(alpha > 1) {
        	ofSetColor(fg,alpha);

            	ofPushMatrix();

        	ofPath path;

            	path.setPolyWindingMode(OF_POLY_WINDING_ODD);
            	path.setColor(ofColor(fg,alpha));
            	path.setFilled(true);

		path.rectRounded(it->rect, it->lineWidth);
		path.close();

		path.rectangle( it->rect.x + it->lineWidth,
				it->rect.y + it->lineWidth,
				it->rect.width - 2*it->lineWidth,
				it->rect.height - 2* it->lineWidth
				);
		path.close();

            	path.draw();

            	ofPopMatrix();


            	ofDrawBitmapStringHighlight( it->name,
                                         it->rect.x+it->lineWidth + 4,
                                         it->rect.y+it->lineWidth + 14,
					 ofColor(fg,alpha),
					 ofColor(0,alpha)
					 );
		}

		if(it->timestamp + it->stayTime + it->fadeTime < currentTime) {
			it = highlights.erase(it);
		} else {
			++it;
		}
	}

	ofPopStyle();
}
コード例 #4
0
void ofxFenster::setBackgroundColor(int r, int g, int b, int a) {
	setBackgroundColor(ofColor(r, g, b, a));
}
コード例 #5
0
void ofxDuration::parseTrackMessage(const ofxOscMessage& m){
	for(int i = 0; i < trackNames.size(); i++){
		if(trackNames[i] == m.getAddress()){
			ofxDurationTrack& track = tracks[trackNames[i]];
			bool updated = false;
			
			if(track.type == "Bangs"){
				updated = true;
			}
			else if(track.type == "Curves" || track.type == "LFO"){
				if(m.getNumArgs() == 1 && m.getArgType(0) == OFXOSC_TYPE_FLOAT){
					track.value = m.getArgAsFloat(0);
					updated = true;
				}
				else {
					ofLogError("ofxDuration::parseTrackMessage") << "Incorrect arguments sent to Curves track " << track.name;
				}
			}
			else if(track.type == "Colors"){
				if(m.getNumArgs() == 3 &&
				   m.getArgType(0) == OFXOSC_TYPE_INT32 &&
				   m.getArgType(1) == OFXOSC_TYPE_INT32 &&
				   m.getArgType(2) == OFXOSC_TYPE_INT32)
				{
					track.color = ofColor(m.getArgAsInt32(0),
										  m.getArgAsInt32(1),
										  m.getArgAsInt32(2));
					updated = true;
				}
				else {
					ofLogError("ofxDuration::parseTrackMessage") << "Incorrect arguments sent to Colors track " << track.name;
				}
			}
			else if(track.type == "Switches"){
				if(m.getNumArgs() == 1 && m.getArgType(0) == OFXOSC_TYPE_INT32){
					track.on = m.getArgAsInt32(0) != 0;
					updated = true;
				}
				else{
					ofLogError("ofxDuration::parseTrackMessage") << "Incorrect arguments sent to Switches track " << track.name;
				}
			}
			else if(track.type == "Flags"){
				if(m.getNumArgs() == 1 && m.getArgType(0) == OFXOSC_TYPE_STRING){
					track.flag = m.getArgAsString(0);
					updated = true;
				}
				else{
					ofLogError("ofxDuration::parseTrackMessage") << "Incorrect arguments sent to Flags track " << track.name;
				}
			}
			else if(track.type == "Audio"){
				track.fft.clear();
				for(int i = 0; i < m.getNumArgs(); i++){
					if(m.getArgType(i) == OFXOSC_TYPE_FLOAT){
						float fftdata = m.getArgAsFloat(i);
						track.fft.push_back(m.getArgAsFloat(i));
						track.maxBinReceived = MAX(fftdata, track.maxBinReceived);
					}
				}
			}
			
			if(updated){
				track.lastUpdatedTime = ofGetElapsedTimef();
				ofxDurationEventArgs trackEventArgs;
				trackEventArgs.duration = this;
				trackEventArgs.track = &track;
				ofNotifyEvent(events.trackUpdated, trackEventArgs, this);
			}
			
			return;
		}
	}	
}
コード例 #6
0
//--------------------------------------------------------------
void testApp::setup() {
	ofSetLogLevel(OF_LOG_VERBOSE);
    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
    
    // enable depth->rgb image calibration
	kinect.setRegistration(true);
	kinect.init();
	kinect.open();
    
    
    // setup mesh
    mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
	for (int y = 0; y < NUMROWS; y++){
        for (int x = 0; x < NUMCOLS; x ++){
            int index = x + y * NUMROWS;
            mesh.addColor(ofColor(0));
			mesh.addVertex(ofPoint(x * SPACING, y * SPACING , 0));
		}
	}
    
//    // setup mesh indices
//	for (int y = 0; y < NUMROWS - 1; y++){
//        for (int x = 0; x < NUMCOLS; x++){
//            int index = x + y * NUMCOLS;
//            mesh.addIndex(index);
//            index = x + (y+1) * NUMCOLS;
//            mesh.addIndex(index);
//		}
//	}
    
    
    // http://dan.lecocq.us/wordpress/2009/12/25/triangle-strip-for-grids-a-construction/
    
    int counter = 0;
    int colSteps = NUMCOLS * 2;  
    int rowSteps = NUMROWS - 1;      
    
    for (int y = 0; y < rowSteps; y++) {
        for (int x = 0; x < colSteps; x++) {
            int index = x + y * colSteps;
            
            mesh.addIndex(counter);
            
            if(x == colSteps - 1){  // last col
                break;              // don't change counter (we double this one)
            }
            else{
                if(index % 2 == 0){ // even indices
                    counter += NUMCOLS; // move counter to next row
                }
                else{
                    if(y % 2 == 0){ // uneven indices, even rows
                        counter -= NUMCOLS - 1; // move back to previous row, and move one to the left
                    }
                    else{           // uneven indices, uneven rows
                        counter -= NUMCOLS + 1; // move back to previous row and move one to the right
                    }
                }
            }
        }
    }

}
コード例 #7
0
void ofApp::setup() {
    ofSetFrameRate(30);
    
    nearThreshold = 255;//212;
    farThreshold = 146;
    minArea = 1000;
    maxArea = 70000;
    threshold = 15;
    persistence = 15;
    maxDistance = 32;
    
    ofSetVerticalSync(true);
    
    blobColors[0] = ofColor(255, 0, 0);
    blobColors[1] = ofColor(0, 255, 0);
    blobColors[2] = ofColor(0, 0, 255);
    blobColors[3] = ofColor(255, 255, 0);
    blobColors[4] = ofColor(255, 0, 255);
    blobColors[5] = ofColor(0, 255, 255);
    blobColors[6] = ofColor(255, 127, 0);
    blobColors[7] = ofColor(127, 0, 255);
    blobColors[8] = ofColor(0, 255, 127);
    blobColors[9] = ofColor(127, 255, 0);
    blobColors[10]= ofColor(255, 0, 127);
    blobColors[11]= ofColor(0, 127, 255);
    
    // set up kinect
    kinect.setRegistration(true);
    kinect.init();
    kinect.open();

        
    kpt.loadCalibration("/Users/Fehrj1/Desktop/calibration.xml");
    
    
    // setup gui
    gui = new ofxUICanvas();
    gui->setHeight(800);
    gui->setName("parameters");
    gui->addLabel("kinect");
    gui->addSpacer();
    gui->addSlider("nearThresh", 0, 255, &nearThreshold);
    gui->addSlider("farThresh", 0, 255, &farThreshold);
    gui->addLabel("contours");
    gui->addSpacer();
    gui->addIntSlider("imgIndx", 1, 6, &imgIndx);

    
    detectHands.setup(640, 480);
    
    senderToFlock.setup(HOST, PORT_toFlock);
    senderToMax.setup(HOST, PORT_toMax);
    
    longWindow.name = "Long";
    midWindow.name = "Mid";
    shortWindow.name = "Short";
    
    longWindow.setup(30);
    midWindow.setup(20);
    shortWindow.setup(10);

    isTracking = isTrackingOld = false;
}
コード例 #8
0
//--------------------------------------------------------------
void testApp::draw(){
    

    if(narrativeState == 0){
        
        
    } else if(narrativeState == 1){
    

        
        //draw particles
        for( vector<Particle>::iterator it = pList.begin(); it!=pList.end(); it++){
            if(it -> dead == false){
                it -> draw();
            }
        }
        
        //Draw Attractor
//        ofSetColor(255, 230, 165, 255*0.09);
        ofColor out = ofColor(255, 240, 200, 80);
        ofColor in = ofColor(255, 212, 100, 80);
        int numBlobs = 100;
        
        for(int i = 0; i < numBlobs; i++){
        
//            ofSetColor(255, 255 - 255 * i/numBlobs, 225 - 225 * i/numBlobs, 255 * 0.08);
            ofColor thisCol = out.lerp(in, 0.01);
            
            ofSetColor(thisCol);
            
            float blobWobble = ofMap(i, 0, numBlobs, 0.6, 0.1);
            perlinBlob(attractorSize - attractorSize * i/numBlobs, blobWobble, 0 + i*2000, 36*i);
      
        
        }
        

        
    
    } else if(narrativeState == 2){
        
        
        //draw particles
        for( vector<Particle>::iterator it = pList.begin(); it!=pList.end(); it++){
            if(it -> dead == false){
                it -> draw();
            }
        }
        
        //Draw Attractor
        
        ofColor out = ofColor(255, 255, 255, 100);
        ofColor in = ofColor(255, 0, 0, 100);
        int numBlobs = 100;
        
        for(int i = 0; i < numBlobs; i++){
            ofSetColor(255, 255 - 255 * i/numBlobs, 225 - 225 * i/numBlobs, 255 * 0.08);
//            ofSetColor(in.lerp(out, i/numBlobs));
            
            float blobWobble = ofMap(i, 0, numBlobs, 0.6, 0.1);
            perlinBlob(attractorSize - attractorSize * i/numBlobs, blobWobble, 0 + i*2000, 36*i);
        }
        
        //adds a little shading outside the central circle
        for(int i = 0; i < 5; i++){
            ofSetColor(0, 255 * 0.03);
            perlinBlob(attractorSize - attractorSize * 0.8, 0.6, 0 + i*2000, 36*i);
        }
        
        //draw central red circle
        ofSetColor(255, 0, 0);
        ofCircle(ofGetWindowSize()/2, attractorSize*0.1);
        
        
        
    }
        

    
        
    //draw UI
    drawUI();
    
    
    //Show all the debugging visuals 
    if(debugVisuals){
        debugVis();
    }
    
    
    
    
    


    
    
    
    
    
    //----------after everything else is done----------
    //lets take note of the old mouse position
    oldMousePos.set(mouseX, mouseY);
    
    
    //Also, keep track of old blob positions and directions
    
    //start by clearing out the vectors
    oldBlobPos.clear();
    
    //if there are blobs then lets allocate the same number of slots as there are blobs
    if(contourFinder.blobs.size() > 0){
        oldBlobPos.resize(contourFinder.blobs.size());
    }
    
    //then lets fill it with the positions of all the blobs
    for(int i = 0; i < oldBlobPos.size(); i++){
        oldBlobPos[i].set(contourFinder.blobs[i].centroid);
    }
    
    
}
コード例 #9
0
ファイル: ofApp.cpp プロジェクト: chewyishere/DanceFlows
void testApp::setupGui() {
	
	gui.setup("settings");
	gui.setDefaultBackgroundColor(ofColor(0, 0, 0, 127));
	gui.setDefaultFillColor(ofColor(160, 160, 160, 160));
	gui.add(guiFPS.set("FPS", 0, 0, 60));
	gui.add(doFullScreen.set("fullscreen (F)", false));
	doFullScreen.addListener(this, &testApp::setFullScreen);
	gui.add(toggleGuiDraw.set("show gui (G)", false));
	gui.add(doFlipCamera.set("flip camera (C)", true));
	numVisualisationModes = 10;
	gui.add(visualisationMode.set("visualisation mode", 0, 0, numVisualisationModes - 1));
	gui.add(visualisationName.set("MODE", "draw name"));
	
	visualisationModeTitles = new string[numVisualisationModes];
    visualisationModeTitles[0] = "Source         (0)";
    visualisationModeTitles[1] = "Fld Composite  (1)";
	visualisationModeTitles[2] = "Fluid Color    (2)";
	visualisationModeTitles[3] = "Flow Mask      (3)";
    visualisationModeTitles[4] = "Point Cloud    (4)";
    visualisationModeTitles[5] = "Lines          (5)";
    visualisationModeTitles[6] = "Nothing yet    (6)";
    
	int guiColorSwitch = 0;
	ofColor guiHeaderColor[2];
	guiHeaderColor[0].set(160, 160, 80, 200);
	guiHeaderColor[1].set(80, 160, 160, 200);
	ofColor guiFillColor[2];
	guiFillColor[0].set(160, 160, 80, 200);
	guiFillColor[1].set(80, 160, 160, 200);
	
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(opticalFlow.parameters);
	
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(velocityMask.parameters);
	
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(fluid.parameters);
    
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(particleFlow.parameters);
	
	visualisationParameters.setName("visualisation");
	visualisationParameters.add(showScalar.set("show scalar", true));
	visualisationParameters.add(showField.set("show field", true));
	visualisationParameters.add(displayScalarScale.set("display scalar scale", 0.25, 0.05, 0.5));
	displayScalarScale.addListener(this, &testApp::setDisplayScalarScale);
	visualisationParameters.add(velocityFieldArrowScale.set("arrow scale", 0.6, 0.2, 1));
	velocityFieldArrowScale.addListener(this, &testApp::setVelocityFieldArrowScale);
	visualisationParameters.add(temperatureFieldBarScale.set("temperature scale", 0.25, 0.05, 0.5));
	temperatureFieldBarScale.addListener(this, &testApp::setTemperatureFieldBarScale);
	visualisationParameters.add(visualisationLineSmooth.set("line smooth", false));
	visualisationLineSmooth.addListener(this, &testApp::setVisualisationLineSmooth);
    
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(visualisationParameters);
	
	leftButtonParameters.setName("mouse left button");
	for (int i=0; i<3; i++) {
		leftButtonParameters.add(flexDrawForces[i].parameters);
	}
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(leftButtonParameters);
	
	rightButtonParameters.setName("mouse right button");
	for (int i=3; i<6; i++) {
		rightButtonParameters.add(flexDrawForces[i].parameters);
	}
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(rightButtonParameters);
	
	gui.setDefaultHeaderBackgroundColor(guiHeaderColor[guiColorSwitch]);
	gui.setDefaultFillColor(guiFillColor[guiColorSwitch]);
	guiColorSwitch = 1 - guiColorSwitch;
	gui.add(doResetDrawForces.set("reset draw forces (D)", false));
	doResetDrawForces.addListener(this,  &testApp::resetDrawForces);
    
	gui.loadFromFile("settings.xml");
	gui.minimizeAll();
	
	toggleGuiDraw = true;
    
    
}
コード例 #10
0
void ofxLayerMask::drawOverlay() {
    if(overlayOn) {
        overlayHeight = thumbSize * (layers.size() + 1) + (overlayPadding * layers.size());

        //Draw overlay panel
        x = ofGetWidth() - tripleThumbWidth - textAreaWidth - quadruplePadding - overlayMargin;
        y = ofGetHeight() - overlayHeight - doublePadding - overlayMargin;
        drawDebugBox(x, y, tripleThumbWidth + textAreaWidth + quadruplePadding, overlayHeight + doublePadding);
        
        //Draw layers
        x += overlayPadding;
        y += overlayPadding;
        for(int i = 0; i < layers.size(); i++) {
            ofDrawBitmapString("Layer " + ofToString(i + 1), x, y + halfThumbHeight + 4);
            drawDebugBox(x - 1 + textAreaWidth, y - 1, thumbWidth + 2, thumbHeight + 2, ofColor(255, 255, 255, 150));
            drawLayer(i, x + textAreaWidth, y, thumbWidth, thumbHeight, false);
            drawDebugBox(x - 1 + textAreaWidth + thumbWidth + overlayPadding, y - 1, thumbWidth + 2, thumbHeight + 2, ofColor(255, 255, 255, 150));
            drawMask(i, x + textAreaWidth + thumbWidth + overlayPadding, y, thumbWidth, thumbHeight);
            drawDebugBox(x - 1 + textAreaWidth + doubleThumbWidth + doublePadding, y - 1, thumbWidth + 2, thumbHeight + 2, ofColor(255, 255, 255, 150));
            drawLayer(i, x + textAreaWidth + doubleThumbWidth + doublePadding, y, thumbWidth, thumbHeight);
            y += thumbHeight + overlayPadding;
        }

        //Draw composite thumbnail
        ofDrawBitmapString("Composite", x, y + halfThumbHeight + 4);
        drawDebugBox(x - 1 + textAreaWidth + doubleThumbWidth + doublePadding, y - 1, thumbWidth + 2, thumbHeight + 2, ofColor(255, 255, 255, 150));
        draw(x + textAreaWidth + doubleThumbWidth + doublePadding, y, thumbWidth, thumbHeight);
    }
}
コード例 #11
0
//--------------------------------------------------------------
void testApp::setup(){
    ofSetVerticalSync(true);
    ofBackground(0);
    ofSetFrameRate(60);
    ofEnableAlphaBlending();

    
    //Kinect stuff
//    kinect.setRegistration();
//    kinect.init();
//    kinect.open();
    
//    grayScale.allocate(kinect.width, kinect.height);
    nearThreshold = 193;
    farThreshold = 183;
    
    //These are the values of the bounding box of the ROI
    //within the kinect's field of view.
    kinectXmin = 100;
    kinectXmax = 278;
    kinectYmin = 50;
    kinectYmax = 230;
    
    disturbRad = 200;
    
    
    //Narrative control
    narrativeState = 1;
        //0 = intro video
        //1 = molecular cloud
        //2 = cloud fragment
        //3 = protostar
        //4 = star
    
    
    //view controls
    transitionTo2 = false;
    transitionTo2Timer = 0;

    transitionTo3 = false;
    transitionTo3Timer = 0;
    
    zooming = false;
    
    //Attractor stuff
    attractorBase = 30;
    attractorSize = 0;
    attractorPos.set(ofGetWindowWidth()/2, ofGetWindowHeight()/2);
    attractionRad = 30;
    attractStrength = 0.6;
    
    mouseRad = 150;
    
    
    //CREATE PARTICLE FIELD
    fieldRes = 6;
    newParticleField(fieldRes);

    pImg.loadImage("sprite8sm3.png");
    
    
    //UI Stuff
    instructions.loadFont("avenir.ttc", 100, true, true);
    instructions.setLetterSpacing(0.95);
    instructionA = "Help the body acrete mass by";
    instructionB = "pushing the gas cloud to the center";
    instructCol = ofColor(0, 150, 255);

    
    status.loadFont("avenir.ttc", 100, true, true);
    statusBigger.loadFont("avenir.ttc", 15, true, true);
    status.setLetterSpacing(0.95);
    statusCol = ofColor(255);
    statusA = "Status: Cloud";
    statusB = "Fragment";
    
    zoomSquareWidth = 1080;
    zoomSquareThick = 10;
    zoomSquareCol = ofColor(255, 0, 0);
    
 
    //Sound Effects
    zoom.loadSound("zoom.mp3");
    zoom.setVolume(1.0f);
    zoom.setSpeed(0.5f);
    zoom.setMultiPlay(false);
    
    pWhoosh.loadSound("whoosh.mp3");
    pWhoosh.setVolume(0.1f);
    pWhoosh.setSpeed(1.0f);
    pWhoosh.setMultiPlay(true);

    narrate1.loadSound("pops.mp3");
    narrate1.setVolume(0.1f);
    narrate1.setSpeed(1.0f);
    narrate1.setMultiPlay(false);
    
    debugVisuals = true;
    
}
コード例 #12
0
void ofxLayerMask::initFbo(ofFbo &fbo) {
    fbo.allocate(width, height, GL_RGBA, 1);
    fbo.begin();
    ofBackground(ofColor(ofColor::black, 0));
    fbo.end();
}
コード例 #13
0
//--------------------------------------------------------------
void testApp::setup(){
	//cairo.setup("3d.pdf",ofCairoRenderer::PDF);
	renderer.renderers.push_back(&gl);
	//renderer.renderers.push_back(&cairo);
	ofSetDefaultRenderer(&renderer);
	//ofSetFrameRate( 12 ); //each frame generates a page
	
	nCurveVertexes = 7;
	
	curveVertices[0].x = 326;
	curveVertices[0].y = 209;
	curveVertices[1].x = 306;
	curveVertices[1].y = 279;
	curveVertices[2].x = 265;
	curveVertices[2].y = 331;
	curveVertices[3].x = 304;
	curveVertices[3].y = 383;
	curveVertices[4].x = 374;
	curveVertices[4].y = 383;
	curveVertices[5].x = 418;
	curveVertices[5].y = 309;
	curveVertices[6].x = 345;
	curveVertices[6].y = 279;
	
	for (int i = 0; i < nCurveVertexes; i++){
		curveVertices[i].bOver 			= false;
		curveVertices[i].bBeingDragged 	= false;
		curveVertices[i].radius = 4;
	}
	
	
	
	
	//------(a)--------------------------------------
	// 
	// 		draw a star
	//
	// 		use poly winding odd, the default rule
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	shapeA.setHexColor(0xe0be21);
	shapeA.setFilled(true);
	shapeA.setPolyWindingMode(OF_POLY_WINDING_ODD);	// this is the normal mode
	shapeA.moveTo(200,135);
	shapeA.lineTo(15,135);
	shapeA.lineTo(165,25);
	shapeA.lineTo(105,200);
	shapeA.lineTo(50,25);
	
	

	//------(b)--------------------------------------
	// 
	// 		draw a star
	//
	// 		use poly winding nonzero
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	shapeB.setHexColor(0xb5de10);
	shapeB.setFilled(true);
	shapeB.setPolyWindingMode(OF_POLY_WINDING_NONZERO);
	shapeB.moveTo(400,135);
	shapeB.lineTo(215,135);
	shapeB.lineTo(365,25);
	shapeB.lineTo(305,200);
	shapeB.lineTo(250,25);
	shapeB.close();
	//-------------------------------------
	
	
	
	//------(c)--------------------------------------
	// 
	// 		draw a star dynamically
	//
	// 		use the mouse position as a pct
	//		to calc nPoints and internal point radius
	//
	float xPct = (float)(200) / (float)(ofGetWidth());
	float yPct = (float)(400) / (float)(ofGetHeight());
	int nTips = 5 + xPct * 60;
	int nStarPts = nTips * 2;
	float angleChangePerPt = TWO_PI / (float)nStarPts;
	float innerRadius = 0 + yPct*80;
	float outerRadius = 80;
	float origx = 525;
	float origy = 100;
	float angle = 0;
	
	shapeC.setHexColor(0xa16bca);
	shapeC.setFilled(true);
	for (int i = 0; i < nStarPts; i++){
		if (i % 2 == 0) {
			// inside point:
			float x = origx + innerRadius * cos(angle);
			float y = origy + innerRadius * sin(angle);
			shapeC.lineTo(x,y);
		} else {
			// outside point
			float x = origx + outerRadius * cos(angle);
			float y = origy + outerRadius * sin(angle);
			shapeC.lineTo(x,y);
		}
		angle += angleChangePerPt;
	}
	//-------------------------------------
	
	//------(d)--------------------------------------
	// 
	// 		poylgon of random points
	//
	// 		lots of self intersection, 500 pts is a good stress test
	// 
	// 
	shapeD.setHexColor(0x0cb0b6);
	shapeD.setFilled(true);
	shapeD.setPolyWindingMode(OF_POLY_WINDING_ODD);
	for (int i = 0; i < 10; i++){
		shapeD.lineTo(ofRandom(650,850), ofRandom(20,200));
	}
	//-------------------------------------
	
	
	//------(e)--------------------------------------
	// 
	// 		use sin cos and time to make some spirally shape
	//
	shapeE.setHexColor(0xff2220);
	shapeE.setFilled( true );
	shapeE.setPolyWindingMode(OF_POLY_WINDING_ODD);
	float angleStep 	= TWO_PI/(100.0f + sin(35/5.0f) * 60);
	float radiusAdder 	= 0.5f;
	float radius 		= 0;
	for (int i = 0; i < 200; i++){
		float anglef = (i) * angleStep;
		float x = radius * cos(anglef) + 100;
		float y = radius * sin(anglef) + 300;
		shapeE.lineTo(x,y);
		radius 	+= radiusAdder; 
	}
	shapeE.close();
	//-------------------------------------
	
	//------(f)--------------------------------------
	// 
	// 		addCurveVertex
	// 
	// 		because it uses catmul rom splines, we need to repeat the first and last 
	// 		items so the curve actually goes through those points
	//
	
	shapeF.setHexColor(0x2bdbe6);
	shapeF.setFilled(true);
	
	for (int i = 0; i < nCurveVertexes; i++){
		
		
		// sorry about all the if/states here, but to do catmull rom curves
		// we need to duplicate the start and end points so the curve acutally 
		// goes through them.
		
		// for i == 0, we just call the vertex twice
		// for i == nCurveVertexes-1 (last point) we call vertex 0 twice
		// otherwise just normal ofCurveVertex call
		
		if (i == 0){
			shapeF.curveTo(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
			shapeF.curveTo(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
		} else if (i == nCurveVertexes-1){
			shapeF.curveTo(curveVertices[i].x, curveVertices[i].y);
			shapeF.curveTo(curveVertices[0].x, curveVertices[0].y);	// to draw a curve from pt 6 to pt 0
			shapeF.curveTo(curveVertices[0].x, curveVertices[0].y);	// we duplicate the first point twice
		} else {
			shapeF.curveTo(curveVertices[i].x, curveVertices[i].y);
		}
	}
	shapeF.close();
	
	// show a faint the non-curve version of the same polygon:
	shapeFNonCurve.setFilled( false );
	shapeFNonCurve.setColor( ofColor(0,0,0,40) );
	for (int i = 0; i < nCurveVertexes; i++){
		shapeFNonCurve.lineTo(curveVertices[i].x, curveVertices[i].y);
	}
	shapeFNonCurve.close();
	//-------------------------------------
	
	
	//------(g)--------------------------------------
	// 
	// 		addBezierVertex
	// 
	// 		with addBezierVertex we can draw a curve from the current vertex
	//		through the the next three vertexes we pass in.
	//		(two control points and the final bezier point)
	//		
	
	float x0 = 500;
	float y0 = 300;
	float x1 = 550+50*cos(5.8*1.0f);
	float y1 = 300+100*sin(5.8/3.5f);
	float x2 = 600+30*cos(5.8*2.0f);
	float y2 = 300+100*sin(5.8);
	float x3 = 650;
	float y3 = 300;
		
	
	shapeG.setFilled(true);
	shapeG.setHexColor(0xFF9933);
	shapeG.lineTo(x0,y0);
	shapeG.bezierTo(x1,y1,x2,y2,x3,y3);

	
	//------(h)--------------------------------------
	// 
	// 		holes / nextContour
	// 
	// 		with nextContour we can create multi-contour shapes
	// 		this allows us to draw holes, for example... 
	//
	shapeH.setFilled(true);
	shapeH.setHexColor( 0xff00ff );
	shapeH.lineTo(100,500);
	shapeH.lineTo(180,550);
	shapeH.lineTo(100,600);
	shapeH.close();
	shapeH.lineTo(120,520);
	shapeH.lineTo(160,550);
	shapeH.lineTo(120,580);
	shapeH.close();

	//-------------------------------------

	
	//------(i)--------------------------------------
	// 
	// 		CSG / nextContour
	// 
	// 		with different winding rules, you can even use nextContour to 
	// 		perform constructive solid geometry 
	// 		
	// 		be careful, the clockwiseness or counter clockwisenss of your multiple
	// 		contours matters with these winding rules.
	//
	// 		for csg ideas, see : http://glprogramming.com/red/chapter11.html
	// 
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	shapeIa.setFilled(false);
	shapeIa.setPolyWindingMode(OF_POLY_WINDING_ODD);
	shapeIa.setHexColor(0xff00ff);
	shapeIa.lineTo(300,500);
	shapeIa.lineTo(380,550);
	shapeIa.lineTo(300,600);
	shapeIa.close();
	shapeIa.arc(340,550,30,30,0,360);


	shapeIb.setPolyWindingMode(OF_POLY_WINDING_NONZERO);
	shapeIb.setHexColor(0xff00ff);
	shapeIb.setFilled(false);
	shapeIb.lineTo(400,500);
	shapeIb.lineTo(480,550);
	shapeIb.lineTo(400,600);
	shapeIb.close();
	shapeIb.arc(440,550,30,60,0,360);

	shapeIc.setPolyWindingMode(OF_POLY_WINDING_ABS_GEQ_TWO);
	shapeIc.setHexColor(0xff00ff);
	shapeIc.setFilled(false);
	shapeIc.lineTo(500,500);
	shapeIc.lineTo(580,550);
	shapeIc.lineTo(500,600);
	shapeIc.close();
	shapeIc.arc(540,550,30,20,0,360);
	
	selectedDraggableVertex.arc(0,0,4,4,0,360);
	selectedDraggableVertex.setFilled(true);
	selectedDraggableVertex.setColor(ofColor(0,0,0,80));

	unselectedDraggableVertex.arc(0,0,4,4,0,360);
	unselectedDraggableVertex.setFilled(false);
	unselectedDraggableVertex.setColor(ofColor(0,0,0,80));
	
}
コード例 #14
0
ファイル: ofApp.cpp プロジェクト: 6uclz1/openFrameworks
//--------------------------------------------------------------
void ofApp::draw(){
	ofBackgroundGradient( ofColor(255), ofColor(180), OF_GRADIENT_CIRCULAR);
	renderSignedNoiseDemo();
	renderNoisyRobotArmDemo();
}
コード例 #15
0
void of3dLevelScene::setup()
{
    if(level.loadModel(getName() + ".dae")) {
        level.setRotation(0, 180, 1, 0, 0);
    }
    
    setupCollision();
    
    // fog
    GLfloat fogCol[4] = {0,0,0.5,1.f};
    glFogi(GL_FOG_MODE, 1); // exp2
    glFogfv(GL_FOG_COLOR, fogCol);
    glFogf(GL_FOG_DENSITY, 0.02f);
    glFogf(GL_FOG_START, 10.f);
    glFogf(GL_FOG_END, 300.f);
    
    cam.setup();
    cam.setNearClip(1.0f);
    cam.setPosition(0,6.f,-10.f);
    cam.lookAt(ofVec3f(0,0,100),ofVec3f(0,1,0));
    cam.setFov(38.f);
    cam.usemouse = false;
//    cam.enableOrtho();
    
    ofEnableAlphaBlending();
    ofEnableLighting();
    ofEnableDepthTest();
    
    // lighting
    light.setPosition(0, 400, 20);
    light.setDiffuseColor(ofFloatColor(0.95,1.0,1.0));
    light.enable();
    light.setParent(cam);
    
    // gui
    gui = new ofxUICanvas();
    gui->setFont("GUI/DejaVuSans.ttf");
    gui->setColorBack(ofColor(0,0,0,0));
    
    float guiWidth = 512.f;
    gameOverLose = new ofImage("GUI/game-over-lose.png");
    gameOverWin = new ofImage("GUI/game-over-win.png");
    gameOverImage = gui->addImage("game_over", gameOverLose, 512,128);
    okButton = gui->addImageButton("OK", "GUI/ok-btn.png", true, 256, 64);
    // center horizontally
    okButton->getRect()->setX(gameOverImage->getRect()->getHalfWidth() - okButton->getRect()->getHalfWidth());
    gui->autoSizeToFitWidgets();
    // center horizontally
    gui->setPosition(ofGetWidth()/2 - gui->getRect()->getHalfWidth(),
                     ofGetHeight()/2 - gui->getRect()->getHalfHeight());
    ofAddListener(gui->newGUIEvent, this, &of3dLevelScene::guiEvent);
    
    gui->setVisible(false);
    gui->setAutoDraw(false);
    
    // effects
    post.init(ofGetWidth(),ofGetHeight());
    post.createPass<BloomPass>()->setEnabled(true);
    convolutionPass = post.createPass<ConvolutionPass>();
    convolutionPass->setEnabled(false);

    // player
    player = new ofPlayer();
    
    backgroundMusic.loadSound("ludumdare29.mp3");
    backgroundMusic.setVolume(0.7);
    backgroundMusic.setLoop(true);
    backgroundMusic.play();
    
    // load level
    load();
}
コード例 #16
0
ファイル: ofApp.cpp プロジェクト: chewyishere/DanceFlows
//--------------------------------------------------------------
void testApp::draw(){

    ofClear(0);
    
    opticalFlow.setSource(cameraFbo.getTextureReference());
    opticalFlow.update(deltaTime);
    
    velocityMask.setDensity(cameraFbo.getTextureReference());
    velocityMask.setVelocity(opticalFlow.getOpticalFlow());
    velocityMask.update();
    
    
    fluid.addVelocity(opticalFlow.getOpticalFlowDecay());
    fluid.addDensity(velocityMask.getColorMask());
    fluid.addTemperature(velocityMask.getLuminanceMask());
    
    
	for (int i=0; i<numDrawForces; i++) {
		flexDrawForces[i].update();
		if (flexDrawForces[i].didChange()) {
			// if a force is constant multiply by deltaTime
			float strength = flexDrawForces[i].getStrength();
			if (!flexDrawForces[i].getIsTemporary())
				strength *=deltaTime;
			switch (flexDrawForces[i].getType()) {
				case flowTools::FT_DENSITY:
					fluid.addDensity(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_VELOCITY:
					fluid.addVelocity(flexDrawForces[i].getTextureReference(), strength);
					particleFlow.addFlowVelocity(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_TEMPERATURE:
					fluid.addTemperature(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_PRESSURE:
					fluid.addPressure(flexDrawForces[i].getTextureReference(), strength);
					break;
				case flowTools::FT_OBSTACLE:
					fluid.addTempObstacle(flexDrawForces[i].getTextureReference());
				default:
					break;
			}
		}
	}
	
    fluid.update();
    
	if (particleFlow.isActive()) {
		particleFlow.setSpeed(fluid.getSpeed());
		particleFlow.setCellSize(fluid.getCellSize());
		particleFlow.addFlowVelocity(opticalFlow.getOpticalFlow());
		particleFlow.addFluidVelocity(fluid.getVelocity());
		particleFlow.setObstacle(fluid.getObstacle());
	}
	particleFlow.update();
	
	int windowWidth = ofGetWindowWidth();
	int windowHeight = ofGetWindowHeight();
	
    ofClear(0,0);
    
    switch(visualisationMode.get()) {
            
        case 0: // Source
			cameraFbo.draw(0,0, windowWidth, windowHeight);
			break;
            
        case 1: // Fluid Composite

            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            
            cameraFbo.end();
            cameraFbo.draw(0,0, windowWidth, windowHeight);
            
            ofEnableBlendMode(blendMode);
			fluid.draw(0, 0,windowWidth, windowHeight);
			if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);
            if (showLogo) {
				theImage.draw(0, 0,windowWidth, windowHeight);
			}
            ofPopStyle();
			break;
            
        case 2: // Fluid Color
            
            //----------------------
            
            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            cameraFbo.end();
            
            //----------------------
            ofEnableBlendMode(blendMode);
			fluid.draw(0, 0, windowWidth, windowHeight);

			if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);
            
            ofPopStyle();
			break;
            
        case 3: // velocityMask
            
            //----------------------
            
            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            cameraFbo.end();
            ofBackground(255);
            ofEnableBlendMode(blendMode);
            velocityMask.draw(0, 0, windowWidth, windowHeight);
			fluid.draw(0, 0, windowWidth, windowHeight);
            if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);
            if (showLogo) {
				ofEnableBlendMode(OF_BLENDMODE_ADD);
				theImage.draw(0,0,windowWidth, windowHeight);
			}


            ofPopStyle();
            break;
            
        case 4: // CLOUD
            
            ofPushStyle();
            
            ofEnableBlendMode(blendMode);
            
            
            easyCam.begin();
            drawPointCloud();
            easyCam.end();
            cameraFbo.begin();
            particleFlow.draw(0, 0, windowWidth, windowHeight);
     
            cameraFbo.end();
            ofPopStyle();
            break;
            
            
        case 5: // LINES
            
            fluid.draw(0, 0, windowWidth, windowHeight);
            
			ofPushStyle();
			ofEnableBlendMode(blendMode);
            
            easyCam.begin();
            drawLines();
            easyCam.end();
            
            ofPopStyle();
            break;
            
        case 6: // FACES
            
            fluid.draw(0, 0, windowWidth, windowHeight);
            
			ofPushStyle();
			ofEnableBlendMode(blendMode);
            
            easyCam.begin();
            drawFaces();
            easyCam.end();
            
            ofPopStyle();
            break;

        case 7: //
            
            ofPushStyle();
            ofEnableBlendMode(OF_BLENDMODE_DISABLED);
            cameraFbo.begin();
            
            if (doFlipCamera)
                kinect.draw(cameraFbo.getWidth(), 0, -ofGetWindowWidth(), ofGetWindowHeight());
            else
                kinect.draw(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
            
            cameraFbo.end();
            ofBackground(220,200,100,60);
                        ofColor(188,10,10);
            ofEnableBlendMode(blendMode);
            
            fluid.draw(0, 0, windowWidth, windowHeight);
            
			if (particleFlow.isActive())
				particleFlow.draw(0, 0, windowWidth, windowHeight);

            if (showLogo) {
				ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
				ofSetColor(255,255,255,200);
				theImage.draw(0,0,windowWidth, windowHeight);
			}
           
            ofPopStyle();
            break;
  }

    if (toggleGuiDraw) {
		guiFPS = ofGetFrameRate();
		if (visualisationMode.get() >= numVisualisationModes)
			visualisationMode.set(numVisualisationModes-1);
		visualisationName.set(visualisationModeTitles[visualisationMode.get()]);
		gui.draw();
	}
    
    drawtheMidi();
    
}
コード例 #17
0
//--------------------------------------------------------------
void testApp::draw(){
    ofBackgroundGradient(ofColor(40, 60, 70), ofColor(10,10,10));
    p.draw();
}
コード例 #18
0
void MyKeeponControlPanel::guiListener(ofxUIEventArgs &args){
	string name = args.widget->getName();
	// Serial list bureaucracy
	if(name.compare("Serial List") == 0) {
		ofxUIDropDownList *ddlist = (ofxUIDropDownList *) args.widget;
		if(ddlist->getSelected().size()) {
			string selection = ddlist->getSelected()[0]->getName();
			if(selection.compare("Refresh List") == 0){
				// refresh static list, but only update dropdown on next call to update()
				updateSerialList();
				bUpdateSerialList = true;
				ddlist->clearSelected();
			}
			// else, if clicked on an item, try to setup a serial connection
			// TODO: add some feedback as to whether we're connected and to what
			else if(!ddlist->isOpen()) {
				mSerial.close();
				bSerialInited = mSerial.setup(selection, 115200);
			}
		}
	}
	// immediate-mode stuff
	else if(name.compare("Pan/Tilt") == 0) {
		mGazeValues.pan = ((ofxUI2DPad *)args.widget)->getScaledValue().x;
		mGazeValues.tilt = ((ofxUI2DPad *)args.widget)->getScaledValue().y;
		// keep dance values up-to-date
		mDanceValues.panCenter = mGazeValues.pan;
		mDanceValues.tiltCenter = mGazeValues.tilt;

		if(!bIsGazeSync) {
			sendPanAndTilt();
		}
		else {
			syncGazeValues = mGazeValues;
			sendSyncPanAndTilt();
		}
	}
	else if(name.compare("Pan Speed") == 0) {
		mGazeValues.panSpeed = ((ofxUISlider *)args.widget)->getScaledValue();
		if(!bIsGazeSync) {
			sendPanSpeed();
		}
		else {
			syncGazeValues = mGazeValues;
			sendSyncPanSpeed();
		}
	}
	else if(name.compare("Tilt Speed") == 0) {
		mGazeValues.tiltSpeed = ((ofxUISlider *)args.widget)->getScaledValue();
		if(!bIsGazeSync) {
			sendTiltSpeed();
		}
		else {
			syncGazeValues = mGazeValues;
			sendSyncTiltSpeed();
		}
	}
	else if(name.compare("PonSide Speed") == 0) {
		mGazeValues.sideSpeed = ((ofxUISlider *)args.widget)->getScaledValue();
		if(!bIsGazeSync) {
			sendSideSpeed();
		}
		else {
			syncGazeValues = mGazeValues;
			sendSyncSideSpeed();
		}
	}

	else if(name.compare("Synchronize Gaze") == 0){
		bIsGazeSync = ((ofxUIButton*)args.widget)->getValue();
		if(bIsGazeSync) {
			// if first item, copy to syncValue
			if(theSyncGazePanels.size() < 1){
				syncGazeValues = mGazeValues;
			}
			else{
				mGazeValues = syncGazeValues;
				// keep dance values up-to-date
				mDanceValues.panCenter = mGazeValues.pan;
				mDanceValues.tiltCenter = mGazeValues.tilt;
				bUpdateGazeGuiFromValues = true;
			}
			// add to set of sync panels
			theSyncGazePanels.insert(this);
		}
		else {
			// remove from vector of sync panels
			theSyncGazePanels.erase(this);
		}
	}

	//////// Dance
	else if(name.compare("Pan Dance(0,0)") == 0) {
		mDanceValues.pan.enabled = !mDanceValues.pan.enabled;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}
	else if(name.compare("Pan Dance(0,1)") == 0) {
		mDanceValues.pan.doubled = !mDanceValues.pan.doubled;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}
	else if(name.compare("Pan Dance(0,2)") == 0) {
		mDanceValues.pan.reversed = !mDanceValues.pan.reversed;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}

	else if(name.compare("Tilt Dance(0,0)") == 0) {
		mDanceValues.tilt.enabled = !mDanceValues.tilt.enabled;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}
	else if(name.compare("Tilt Dance(0,1)") == 0) {
		mDanceValues.tilt.doubled = !mDanceValues.tilt.doubled;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}
	else if(name.compare("Tilt Dance(0,2)") == 0) {
		mDanceValues.tilt.reversed = !mDanceValues.tilt.reversed;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}

	else if(name.compare("PonSide Dance(0,0)") == 0) {
		mDanceValues.side.enabled = !mDanceValues.side.enabled;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}
	else if(name.compare("PonSide Dance(0,1)") == 0) {
		mDanceValues.side.doubled = !mDanceValues.side.doubled;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}
	else if(name.compare("PonSide Dance(0,2)") == 0) {
		mDanceValues.side.reversed = !mDanceValues.side.reversed;
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}
	
	else if(name.compare("Tempo") == 0) {
		mDanceValues.tempo = ((ofxUISlider *)args.widget)->getScaledValue();
		if(bIsDanceSync) {
			syncDanceValues = mDanceValues;
			syncDance();
		}
	}

	else if(name.compare("Synchronize Dance") == 0){
		bIsDanceSync = ((ofxUIButton*)args.widget)->getValue();
		if(bIsDanceSync) {
			// if first item, copy to syncValue
			if(theSyncDancePanels.size() < 1){
				syncDanceValues = mDanceValues;
			}
			else{
				mDanceValues = syncDanceValues;
				bUpdateDanceGuiFromValues = true;
			}
			// add to set of sync panels
			theSyncDancePanels.insert(this);
		}
		else {
			// remove from vector of sync panels
			theSyncDancePanels.erase(this);
		}
	}

	//////// Script
	else if((name.compare("Load") == 0) && (((ofxUIButton*)args.widget)->getValue())) {
		// just in case
		isScriptLoaded = false;
		mLoad->setColorBack(OFX_UI_COLOR_BACK);
		// open XML file
		ofFileDialogResult mFDR = ofSystemLoadDialog("Pick an xml script file", false, ofToDataPath("",true));
		if(mFDR.bSuccess) {
			mScript.loadScript(mFDR.getName());
			isScriptLoaded = true;
			mLoad->setColorBack(ofColor(0,100,0));
			isScriptPlaying = false;
		}
	}
	else if((name.compare("Play") == 0) && (((ofxUIButton*)args.widget)->getValue())) {
		isScriptPlaying = !isScriptPlaying;
		if(isScriptLoaded && isScriptPlaying) {
			lastScriptCommand = ofGetElapsedTimeMillis();
			((ofxUIButton*)args.widget)->setColorBack(ofColor(0,100,0));
		}
		else if(isScriptLoaded && !isScriptPlaying) {
			((ofxUIButton*)args.widget)->setColorBack(ofColor(100,0,0));
		}
	}
	else if((name.compare("Reset") == 0) && (((ofxUIButton*)args.widget)->getValue())) {
		mScript.reset();
		isScriptPlaying = false;
		mPlay->setColorBack(OFX_UI_COLOR_BACK);
	}

	//////// 
	else if((name.compare("Remove") == 0) && (((ofxUIButton*)args.widget)->getValue())){
		bDelete = true;
	}
}
コード例 #19
0
ファイル: ofApp.cpp プロジェクト: markkorput/ARtoolkitTest
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackgroundGradient(ofColor(120), ofColor(170));
    arTest.drawRestoring();
}
コード例 #20
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofSetVerticalSync(true);
    ofEnableAntiAliasing();
    glEnable(GL_POINT_SMOOTH); // use circular points instead of square points
    glPointSize(3);
    
//    // --- Loading files
    ofFileDialogResult openFileResult = ofSystemLoadDialog("Get the txt data", true);
    ofLogNotice()  << "Folder: " << openFileResult.getPath();
    ofDirectory     dirFiles;
    dirFiles.listDir( openFileResult.getPath() );
    ofDrawBitmapString("Loading files", ofGetWidth()/2 - 20, ofGetHeight() / 2 );
    
    for ( int indexOfFile = 0; indexOfFile < dirFiles.size(); ++indexOfFile )
    {
//        ofLogNotice() << "file: " << dirFiles.getPath( indexOfFile );
        ofBuffer buffer = ofBufferFromFile( dirFiles.getPath( indexOfFile ) );
        std::vector< weatherData >     currentWeatherData;
        
        if(buffer.size()) {
            buffer.getNextLine();
            while(buffer.isLastLine() == false) {
                string              line = buffer.getNextLine();
                std::stringstream   lineStream( line );
                string              cell;
                std::getline( lineStream, cell, ';' );
                weatherData data;
                
                std::getline( lineStream, cell, ';' );
                data.lon = ofToDouble( cell );
                std::getline( lineStream, cell, ';' );
                data.lat = ofToDouble( cell );
                std::getline( lineStream, cell, ';' );
                data.temp = ofToDouble( cell );
                std::getline( lineStream, cell, ';' );
                data.velWind = ofToDouble( cell );
                
                currentWeatherData.push_back( data );
//                std::cout << data.lon << "\t" << data.lat << "\t" << data.temp << "\n";
            }
        }
        weatherTimed.weatherDataVector.push_back( currentWeatherData );
        
        // --- transform into pixel vec
        ofMesh  currentMeshTemp, currentMeshWind;
        currentMeshTemp.setMode(OF_PRIMITIVE_POINTS);
        currentMeshWind.setMode(OF_PRIMITIVE_POINTS);
        
        for ( auto &data : weatherTimed.weatherDataVector[ indexOfFile ] )
        {
            data.point = ofVec3f( ofMap( data.lon, 0, 357, 0, 300 ),
                                  ofMap( data.lat, 32, 77, 0, 100),
                                  ofMap( data.temp, 273, 320, 0, 100 ) );
            currentMeshTemp.addColor( ofColor(ofMap( data.temp, 273, 320, 0, 255, true ), 0, 0 ) );
            currentMeshTemp.addVertex( data.point );
            
            currentMeshWind.addColor( ofColor( 0, 0, ofMap( std::abs( data.velWind ), 0, 45, 0, 255, true ) ) );
            currentMeshWind.addVertex( ofVec3f( ofMap( data.lon, 0, 357, 0, 300 ),
                                               ofMap( data.lat, 32, 77, 0, 100),
                                               ofMap( data.velWind, -55, 55, -100, 100 ) ) );
        }
        weatherTimed.meshVecTemp.push_back( currentMeshTemp );
        weatherTimed.meshVecWind.push_back( currentMeshWind );
    }
    
    ofLogNotice() << "Loaded file amount: " << weatherTimed.meshVecTemp.size();

    tempButton.addListener( this, &ofApp::tempPlotActivation );
    windButton.addListener( this, &ofApp::windPlotActivation );
    
    gui.setup();
    gui.add( tempButton.setup( "Temperature Plot", true ) );
    gui.add( windButton.setup("Wind Velocity Plot", false ) );
	gui.add( timeSlider.setup("time", 0, 0, weatherTimed.meshVecTemp.size() - 1 ) );
    gui.add( playButton.setup("play time", false ) );
    gui.add( rotation.setup( "rotation", 0, 0, 360 ) );
    gui.add( autoRotate.setup("Auto Rotate", true ) );
    
    cam.disableMouseInput();
    rotation = 0.0;
    tempPlotActivation();
    
    picturePlot.loadImage("Plot1.png");
}
コード例 #21
0
ofxRemoteUIServer::ofxRemoteUIServer(){

	//cout << "serving at: " << getMyIP() << endl;
	readyToSend = false;
	saveToXmlOnExit = true;
	broadcastTime = OFXREMOTEUI_BORADCAST_INTERVAL + 0.05;
	timeSinceLastReply = avgTimeSinceLastReply = 0;
	waitingForReply = false;
	colorSet = false;
	computerName = binaryName = "";
	callBack = NULL;
	upcomingGroup = OFXREMOTEUI_DEFAULT_PARAM_GROUP;
	verbose_ = false;
	threadedUpdate = false;
	drawNotifications = true;
	showValuesOnScreen = false;
	loadedFromXML = false;
	//add random colors to table
	colorTableIndex = 0;
	selectedItem = 0;
	int a = 80;
#ifdef OF_AVAILABLE
	ofSeedRandom(1979);
	ofColor prevColor = ofColor::fromHsb(0, 255, 255, 40);
	for(int i = 0; i < 30; i++){
		ofColor c = prevColor;
		c.setHue(  ((int) (prevColor.getHue() + 25) ) % 255 );
		//c.setSaturation(prevColor.getSaturation() + ofRandom(-0.1,0.1) );
		colorTables.push_back( c );
		prevColor = c;
	}
	//shuffle
	//std::random_shuffle ( colorTables.begin(), colorTables.end() );
	ofSeedRandom();
#else
	colorTables.push_back(ofColor(194,144,221,a) );
	colorTables.push_back(ofColor(202,246,70,a)  );
	colorTables.push_back(ofColor(74,236,173,a)  );
	colorTables.push_back(ofColor(253,144,150,a) );
	colorTables.push_back(ofColor(41,176,238,a)  );
	colorTables.push_back(ofColor(180,155,45,a)  );
	colorTables.push_back(ofColor(63,216,92,a)   );
	colorTables.push_back(ofColor(226,246,139,a) );
	colorTables.push_back(ofColor(239,209,46,a)  );
	colorTables.push_back(ofColor(234,127,169,a) );
	colorTables.push_back(ofColor(227,184,233,a) );
	colorTables.push_back(ofColor(165,154,206,a) );
#endif

#ifdef OF_AVAILABLE
	ofDirectory d;
	d.open(OFXREMOTEUI_PRESET_DIR);
	d.create(true);
#else
#if defined(_WIN32)
	_mkdir(OFXREMOTEUI_PRESET_DIR);
#else
	mkdir(OFXREMOTEUI_PRESET_DIR, 0777);
#endif
#endif

	computerIP = getMyIP();
	if (computerIP != "NOT FOUND"){
		doBroadcast = true;
		vector<string>comps;
		split(comps, computerIP, '.');
		string multicastIP = comps[0] + "." + comps[1] + "." + comps[2] + "." + "255";
		broadcastSender.setup( multicastIP, OFXREMOTEUI_BROADCAST_PORT ); //multicast @
		cout << "ofxRemoteUIServer: letting everyone know that I am at " << multicastIP << ":" << OFXREMOTEUI_BROADCAST_PORT << endl;
	}else{
		doBroadcast = false;
	}
}
コード例 #22
0
void ContourSillhouetteApp::onAppSwitch() {
    ofColor bg = ofColor(ofRandom(0, 255), ofRandom(0, 255), ofRandom(0, 255));
    bg.setSaturation(255);
    _colorManager.setBackground(bg);
}
コード例 #23
0
void LightsEditor::draw(float x, float y, float w, float h)
{
    ofPushMatrix();
    ofTranslate(x,y,0);
    ofPushStyle();
    if(data->bShowBgImage) {
        treeimg[data->currentTree].draw(0,0,editorWidth,editorHeight);
    }

    ofSetRectMode(OF_RECTMODE_CENTER);
    unsigned int numLights = data->trees[data->currentTree]->lights.size();
    for(int j=0; j < numLights;j++)
    {
        /* Draw circle */
        ofVec2f pos = data->trees[data->currentTree]->lights.at(j)->getPosition();
        ofNoFill();
        ofSetLineWidth(3);
        if(data->currentLight == j) {
            ofSetColor(0,0,255);
            if(data->bEditMode) {
                data->trees[data->currentTree]->lights.at(j)->setColour(ofColor(255,255,255));
                data->trees[data->currentTree]->lights[j]->setBrightness(data->brightness);
            }
        }
        else {
            ofSetColor(100,100,100);
            if(data->bEditMode) {
                data->trees[data->currentTree]->lights.at(j)->setColour(ofColor(0,0,0));
                data->trees[data->currentTree]->lights[j]->setBrightness(data->brightness);
            }
        }
        ofDrawCircle(pos,circleRadius);

        /* draw lighth number */
        ofSetHexColor(0xff3355);
        float w = 10.0f + lightNum.stringWidth(ofToString(j+1));
        lightNum.drawString(ofToString(j+1),pos.x - w,pos.y + circleRadius);

        /* draw connecting grey lines */
        ofSetColor(100,100,100);
        ofSetLineWidth(1);
        if(j+1 < numLights-1) {
            ofVec2f pos2 = data->trees[data->currentTree]->lights.at(j+1)->getPosition();
            ofDrawLine(pos.x,pos.y,pos2.x,pos2.y);
        }

        /* Draw LEDs */
        for(int k=0; k < data->trees[data->currentTree]->lights.at(j)->pixels.size(); k++)
        {
            ofVec2f pixpos = data->trees[data->currentTree]->lights.at(j)->pixels[k]->getPosition();
            ofColor c = data->trees[data->currentTree]->lights.at(j)->pixels[k]->getColour();
            float b = data->trees[data->currentTree]->lights.at(j)->pixels[k]->getBrightness();
            ofSetColor(c.r * b, c.g * b, c.b * b);
            ofFill();
            ofDrawRectangle(pixpos,data->pixelWidth,data->pixelWidth);
        }
    }

    ofSetColor(255);
    ofDrawBitmapString("Name = " + data->trees[data->currentTree]->getName()+" Tree = "+ofToString(data->currentTree)+"  Light Id= "+ofToString(data->currentLight) ,20,ofGetHeight()-20);

    ofPopStyle();
    ofPopMatrix();

}
コード例 #24
0
//--------------------------------------------------------------
void testApp::draw(){

	//-----
	// draw image
	if (!this->recorder.getIsRecording()) {
		if (this->selectionView.isAllocated()) {
			this->selectionView.draw(ofGetCurrentViewport());
		} else {
			this->grabber.draw(0,0, ofGetWidth(), ofGetHeight());
		}
	}
	//-----

	timeStart = this->recorder.getFirstTimestamp();
	timeWindow = MAX(this->recorder.getDuration(), 1);

	//----
	//draw frame ticks
	ofPushStyle();
	ofEnableAlphaBlending();
	ofSetColor(ofColor(255, 100));
	for (auto &it : recorder) {
		float position = it.first;
		position -= timeStart;
		position /= timeWindow;
		position *= ofGetWidth();
		ofLine(position, ofGetHeight() - 150, position, ofGetHeight() - 50);
	}	
	ofPopStyle();
	//-----


	//-----
	//draw selection
	ofPushStyle();
	{
		float x = selectionTimestamp;
		x -= timeStart;
		x /= timeWindow;
		x *= ofGetWidth();
		
		float width = selectionDuration;
		width *= ofGetWidth() / (float) timeWindow;

		ofSetColor(ofColor(255, 100));
		ofSetLineWidth(0);
		ofRect(x, ofGetHeight() - 150, width, 200);

		ofSetLineWidth(1.0f);
		ofSetColor(ofColor(255, 200));
		ofLine(x, ofGetHeight() - 150, x, ofGetHeight());
	}
	ofPopStyle();
	//-----


	//-----
	//draw time ticks

	//find scale of time
	int timeScale = floor(log((float) timeWindow) / log(10.0f) + 0.5f);
	double timeScaleMinor = pow(10, timeScale - 2);

	double firstTick = floor(timeStart / timeScaleMinor) * timeScaleMinor;
	double time = firstTick;
	int i = 0;
	while (time < timeStart + timeWindow) {
		//convert to screen space
		float x = (time - timeStart) / timeWindow;
		x *= ofGetWidth();

		float height;
		float y2;
		if (i % 10 == 0) {
			height = 10.0f;
			string label;
			if (timeScale >= 6) {
				label = ofToString((time - timeStart) / 1e6, 2) + "s";
			} else if (timeScale >= 3) {
				label = ofToString((time - timeStart) / 1e3, 2) + "ms";
			} else {
				label = ofToString((time - timeStart) , 2) + "us";
			}
			ofDrawBitmapString(label, x, ofGetHeight() - 3);
			y2 = ofGetHeight() - 3.0f;
		} else if (i % 5 == 0) {
			height = 5.0f;
			y2 = ofGetHeight() - 15.0f;
		} else {
			height = 2.0f;
			y2 = ofGetHeight() - 18.0f;
		}
		ofLine(x, ofGetHeight() - 20.0f, x, y2);

		time += timeScaleMinor;
		i++;
	}
	//
	//-----


	//-----
	// draw pipet selections
	ofPushStyle();
	for (auto pipet : pipets) {
		auto drawLocation = pipet * ofVec2f(ofGetWidth(), ofGetHeight());

		//background
		ofSetColor(0, 100);
		ofRect(drawLocation.x, drawLocation.y, 24, 20);

		//number
		ofSetColor(255);
		if (recorder.count(this->selectionTimestamp) > 0) {
			auto value = this->getValue(this->selectionTimestamp, pipet);
			ofDrawBitmapString(ofToString((int) value), drawLocation.x + 2, drawLocation.y + 18);
		}

		//line
		ofLine(drawLocation.x, drawLocation.y, drawLocation.x, drawLocation.y + 20);

		//other lines
		ofLine(drawLocation.x, drawLocation.y - 3, drawLocation.x, drawLocation.y - 10);
		ofLine(drawLocation.x - 3, drawLocation.y, drawLocation.x - 10, drawLocation.y);
		ofLine(drawLocation.x + 3, drawLocation.y, drawLocation.x + 10, drawLocation.y);

	}
	ofPopStyle();
	//-----

}
コード例 #25
0
ofxDuration::ofxDuration(){
	isSetup = false;
	redColor = ofColor(250, 200, 80);
	blueColor = redColor.getInverted();	
}
コード例 #26
0
ファイル: testApp.cpp プロジェクト: MrMDeluxe/generative
//--------------------------------------------------------------
void testApp::update(){

    if (!recording && !needsRedraw)
        return;
    
    //recording a sequence, add some points, rebuild
    if (recording) {
        
        int cursize = voronoi.getPoints().size();
        if (cursize >= endpoints) {
            cout << "done! drew " << voronoi.cells.size() << " cells" << endl;
            recording = false;
            needsRedraw = false;
            savelast = true;
        } else  {
            int newpoints = max((double)1.0, round(cursize * scalerate));

            if (cursize + newpoints > endpoints)
                newpoints = endpoints - cursize;
            
            cout << "adding " << newpoints << " points" << endl;
            addVoronoiPoints(newpoints);
            buildVoronoi();
        }
        
    } else { //single image, add/remove points and rebuild if necessary
        

        int pointdiff = npoints - voronoi.getPoints().size();
        if (pointdiff > 0) {

            cout << "adding " << pointdiff << " points" << endl;
            addVoronoiPoints(pointdiff);
            buildVoronoi();

        } else if (pointdiff < 0) {

            cout << "removing " << abs(pointdiff) << " points" << endl;
            vector<ofPoint>& vpts = voronoi.getPoints();
            vpts.erase(vpts.begin()+npoints, vpts.begin() + vpts.size());
            buildVoronoi();
            
        }
    }

    //draw the picture
    fbo.begin();
    for (int i = 0; i < voronoi.cells.size(); i++) {
        ofxVoronoiCell cell = voronoi.cells.at(i);
        ofRectangle bound(ofGetWidth()+1, ofGetHeight()+1, -1, -1);
        
        ofPath path;
        int nverts = cell.pts.size();
        float *vertx = new float[cell.pts.size()];
        float *verty = new float[cell.pts.size()];
        
        for (int j = 0; j < cell.pts.size(); j++) {
            ofPoint p = cell.pts[j];
            if (p.x < 0)
                p.x = 0;
            
            vertx[j] = p.x;
            verty[j] = p.y;
            
            if (p.x < bound.x)
                bound.x = p.x;
            if (p.x > bound.width)
                bound.width = p.x;
            if (p.y < bound.y)
                bound.y = p.y;
            if (p.y > bound.height)
                bound.height = p.y;
            
            path.lineTo(cell.pts[j]);
        }
        
        path.setFilled(true);
        ofColor c = getAverageColor(img, bound, nverts, vertx, verty);
        path.setFillColor(c);
        path.setStrokeColor(ofColor(0, 0, 0));
        path.draw();
        
        if (c.r == 0 && c.b == 0 && c.g == 0) {
            cout << "dead spot" << endl;
            cout << bound.x << " -> " << bound.width << ", ";
            cout << bound.y << " -> " << bound.height << endl;
            
            for (int j = 0; j < cell.pts.size(); j++) {
                ofPoint p = cell.pts[j];
                cout << p << endl;
            }
        }
        
        delete [] vertx;
        delete [] verty;
    }
    fbo.end();
    if (!recording)
        needsRedraw = false;
}
コード例 #27
0
//--------------------------------------------------------------
void ofApp::draw(){

    ofSetColor(255);
    kinect.drawDepth(0, 0, ofGetWidth(), ofGetHeight());
    ofSetColor(255, 255, 0);
    ofPushMatrix();
    ofScale(ofGetWidth() / float(kinect.width), ofGetHeight() / float(kinect.height));
    contourFinder.draw();
    ofPopMatrix();
    // GUI
    gui.draw();
    
    //TRACKER -------------------------------------
     tracker = contourFinder.getTracker();
    for(int i = 0; i < contourFinder.size(); i++) {
        ofPoint center = ofxCv::toOf(contourFinder.getCenter(i)); //center of blobs?
        ofPushMatrix();
        ofTranslate(center.x, center.y);
        int label = contourFinder.getLabel(i);
        string msg = ofToString(label); //label is the id i guess
        ofDrawBitmapStringHighlight(msg, 0, 0);
        ofVec2f velocity = ofxCv::toOf(contourFinder.getVelocity(i));
        ofScale(5, 5);
        ofDrawLine(0, 0, velocity.x, velocity.y);
        ofPopMatrix();
    }

    
    ofSetColor(0,0,255);
    for(int i = 0; i < tracker.getCurrentLabels().size(); i++) {
        int label = tracker.getLabelFromIndex(i);
        
        ofLog()<<i<<" label "<<label<<" age "<<tracker.getAge(label);
        positions[label].draw();
    }
    
    ofSetColor(255,0,0);
    vector<unsigned int> dead = tracker.getDeadLabels();
    for(int i = 0; i < dead.size(); i++) {
        int label = dead[i];
        positions[label].draw();
        ofPoint lastPoint = positions[label].getPointAtPercent(100);
        string msg = ofToString(label) + ":" + ofToString(tracker.getAge(label));
        ofDrawBitmapStringHighlight(msg, lastPoint,ofColor(255,0,0),ofColor(255,255,255));
        
    }
    
    
    for(int i = 0; i < contourFinder.size(); i++) {
        int label = tracker.getLabelFromIndex(i);
        ofLog()<<i<<" n ."<<label<<" , "<<tracker.getLastSeen(label)<<" , "<<tracker.getAge(label);
    }
    ofLog()<<"------------";
    for(int i = 0; i < dead.size(); i++) {
        int label = dead[i];
        ofLog()<<i<<" o ."<<label<<" , "<<tracker.getLastSeen(label)<<" , "<<tracker.getAge(label);
        
    }
    //}
    
    // this chunk of code visualizes the creation and destruction of labels
    const vector<unsigned int>& currentLabels = tracker.getCurrentLabels();
    const vector<unsigned int>& previousLabels = tracker.getPreviousLabels();
    const vector<unsigned int>& newLabels = tracker.getNewLabels();
    const vector<unsigned int>& deadLabels = tracker.getDeadLabels();
    ofSetColor(ofxCv::cyanPrint);
    for(int i = 0; i < currentLabels.size(); i++) {
        int j = currentLabels[i];
        ofDrawLine(j, 0, j, 4);
    }
    ofSetColor(ofxCv::magentaPrint);
    for(int i = 0; i < previousLabels.size(); i++) {
        int j = previousLabels[i];
        ofDrawLine(j, 4, j, 8);
    }
    ofSetColor(ofxCv::yellowPrint);
    for(int i = 0; i < newLabels.size(); i++) {
        int j = newLabels[i];
        ofDrawLine(j, 8, j, 12);
    }
    ofSetColor(ofColor::white);
    for(int i = 0; i < deadLabels.size(); i++) {
        int j = deadLabels[i];
        ofDrawLine(j, 12, j, 16);
    }
    
    //thresholded.draw(0, ofGetHeight()-320,320,320*9/16.0);
    ofPushMatrix();
    ofTranslate(0, ofGetHeight()-320);
    ofScale(0.3, 0.3);
    ofxCv::drawMat(thresholded_mat, 0, 0);
    ofPopMatrix();

}
コード例 #28
0
void OSCLineObject::cmd_color(int r, int g, int b, int a){
    line->setColor(ofColor(r, g, b, a));
}
コード例 #29
0
//----------------------------------------------------------
ofColor ofGetBackground(){
	return ofColor(ofGetCurrentRenderer()->getBgColor());
}
コード例 #30
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    //    ofEnableLighting();
    
    cam.begin();
    
    
    
    //    mainLight.enable();
    
    
    //    for (int i=0; i<buildingsPolyline_33975_22294.size(); i++) {
    //        buildingsPolyline_33975_22294[i].draw();
    //    }
    
    //    ofPushStyle();
    //    ofSetColor(255, 160);
    //
    //    for (int i=0; i<buildings_33975_22294.size(); i++) {
    //        vector<ofVec3f> & _v = buildings_33975_22294[i].getVertices();
    //        for (int j=0; j<_v.size(); j++) {
    //            ofDrawLine( _v[j] - ofVec3f(0, 0, 0), _v[j] + ofVec3f(0, 0, 100) );
    //        }
    //    }
    //    ofPopStyle();
    
    
    for (int i=0; i<roadsPolyline_33975_22294.size(); i++) {
        roadsPolyline_33975_22294[i].draw();
    }
    
    
    for (int i=0; i<roadsPolyline_33975_22294.size(); i++) {
        ofDrawCircle(roadsPolyline_33975_22294[i].getPointAtPercent( roadMoving_33975_22294 ) , 2);
    }
    
    
    
    ofPushStyle();
    ofSetColor(255, 180);
    for (int i=0; i<buildingsPolyline_33975_22294.size(); i++) {
        
        buildingsPolyline_33975_22294[i].draw();
        
//                ofBeginShape();
//                vector<ofVec3f>& vertices = buildingsPolyline_33975_22294[i].getVertices();
//                for(int j = 0; j < vertices.size(); j++) {
//                    ofVertex(vertices[j]);
//                }
//                ofEndShape();
//        
//                ofBeginShape();
//                vector<ofVec3f>& verticesUp = buildingsPolyline_33975_22294[i].getVertices();
//                for(int j = 0; j < verticesUp.size(); j++) {
//                    ofVec3f _v = verticesUp[j] + ofVec3f(0, 0, 100);
//                    ofVertex(_v);
//                }
//                ofEndShape();
        
    }
    ofPopStyle();
    
    
    
    //    mainLight.disable();
    
    cam.end();
    
    //    ofDisableLighting();
    
    

    ofPushMatrix();
    
    ofTranslate( mainOffSetXPos, mainOffSetYPos );
    
    baseArch.guideFrames();
    baseArch.drawEdgeCover( ofColor(0) );
    baseArch.guideLines();
    baseArch.guidePoints();
    
    ofPopMatrix();

    
    ofDrawBitmapString("control : w, s, a, d, r, q, e, c, mouse", 10, 20);
    
    
}