Exemple #1
0
void screen0::draw(int x, int y){
	// BEGIN DRAW IN FBO
	votesManager::getInstance()->drawFBOBegin();
	ofBackground(0,0,0);
	ofSetColor(0,0,0);
	ofRect(0,0,(ofGetWidth()-666),ofGetHeight());
	float radius = 360;
	int totalScreens = screensManager::getInstance()->getCurrentTotalScreens();
	float partionForScreen = ofDegToRad((360.0f/((float)totalScreens)));
	ofVec2f centerPos = ofVec2f((ofGetWidth()-666)/2,ofGetHeight()/2);
	int partCount = 0;

	// draw part show already
	if(screensManager::getInstance()->getScreenArId()>0){
		ofSetColor(50,50,50);
		ofBeginShape();
		for(int i=0; i<screensManager::getInstance()->getScreenArId()+1; i++){
			float degrees = partionForScreen * (float)i;
			ofVec2f pos = ofVec2f( radius*cos(degrees) , radius*sin(degrees) );
			float radius3 = radius-65;
			ofVec2f point1 = ofVec2f( centerPos.x+(radius3*cos(degrees)) , centerPos.y+(radius3*sin(degrees)) );
			ofVertex(point1.x,point1.y);
		}
		for(int i=screensManager::getInstance()->getScreenArId(); i>=0; i--){
			float degrees = partionForScreen * (float)i;
			ofVec2f pos = ofVec2f( radius*cos(degrees) , radius*sin(degrees) );
			float radius4 = radius+50;
			ofVec2f point2 = ofVec2f( centerPos.x+(radius4*cos(degrees)) , centerPos.y+(radius4*sin(degrees)) ); 
			ofVertex(point2.x,point2.y);
		}
		ofEndShape();
	}
	
	for(int i=0;i<totalScreens;i++){
		// position in circle
		float degrees = partionForScreen * (float)i;
		ofVec2f pos = ofVec2f( radius*cos(degrees) , radius*sin(degrees) );
		
		// Part
		int secondPart = screensManager::getInstance()->getTotalScreensPart1();
		int thirdPart = (screensManager::getInstance()->getTotalScreensPart1()+screensManager::getInstance()->getTotalScreensPart2());
		
		if( i==0 || secondPart==i || thirdPart==i ){
			if( secondPart==i || thirdPart==i ){ ofSetColor(190,190,190); }else{ofSetColor(255,255,255);}
			float radius3 = radius-65;
			float radius4 = radius+50;
			ofVec2f point1 = ofVec2f( centerPos.x+(radius3*cos(degrees)) , centerPos.y+(radius3*sin(degrees)) );
			ofVec2f point2 = ofVec2f( centerPos.x+(radius4*cos(degrees)) , centerPos.y+(radius4*sin(degrees)) ); 
			ofLine( point1.x, point1.y, point2.x, point2.y);
			double angleText = ofRadToDeg(atan2(point2.y-point1.y, point2.x-point1.x));
			// get total screens per part
			int totalScreensThisPart = 0;
			
			ofSetColor(190,190,190);
			if(i==0){
				totalScreensThisPart = screensManager::getInstance()->getTotalScreensPart1();
				partCount = 1;
			}else if(i==secondPart){
				totalScreensThisPart = screensManager::getInstance()->getTotalScreensPart2();
				partCount = 2;
			}else if(i==thirdPart){
				totalScreensThisPart = screensManager::getInstance()->getTotalScreensPart3();
				partCount = 3;
			}
			
			string partText = translateManager::getInstance()->t("Part");
			partText[0] = toupper(partText[0]);
			string textThisPart = partText+" "+ofToString(partCount)+"["+ofToString(totalScreensThisPart)+"]";
			int withTextThisPart = fontManager::getInstance()->getPixelFont()->stringWidth(textThisPart);
			// draw text of the part
			ofPushMatrix();
			ofTranslate(point1.x,point1.y);	
			ofRotate(angleText);
			ofTranslate(-5-withTextThisPart,0);
			fontManager::getInstance()->getPixelFont()->drawString(textThisPart,0,0);
			ofPopMatrix();
			
		}
		
		// type by colors
		string typeScreen = screensManager::getInstance()->getIdScreenType(i);
		if(typeScreen=="question"){
			ofSetColor(5,143,249);
		}else if(typeScreen=="debate"){
			ofSetColor(255,255,0);
		}else if(typeScreen=="statement"){
			ofSetColor(255,0,240);
		}else{
			ofSetColor(255,0,0);
		}
		
		// represent
		ofEllipse(centerPos.x+pos.x,centerPos.y+pos.y,2,2);
		
		float radius2 = radius+10;
		ofVec2f pos2 = ofVec2f( radius2*cos(degrees) , radius2*sin(degrees) );
		ofLine(centerPos.x+pos.x,centerPos.y+pos.y,centerPos.x+pos2.x,centerPos.y+pos2.y);
		
		// error Link
		if( screensManager::getInstance()->getScreenHasBrokenLinks(i) ){
			ofSetColor(255,0,0);
			float radius3 = radius-5;
			float radius4 = radius-150;
			ofVec2f pos3 = ofVec2f( radius3*cos(degrees) , radius3*sin(degrees) );
			ofVec2f pos4 = ofVec2f( radius4*cos(degrees) , radius4*sin(degrees) );
			ofVec2f point1 = ofVec2f(centerPos.x+pos3.x,centerPos.y+pos3.y);
			ofVec2f point2 = ofVec2f(centerPos.x+pos4.x,centerPos.y+pos4.y);
			ofLine(point1.x,point1.y,point2.x,point2.y);

			string idScreen = ofToString(screensManager::getInstance()->getIdScreen(i));
		
			double angleText = ofRadToDeg(atan2(point2.y-point1.y, point2.x-point1.x))+180.0f;
			//int stringSize = fontManager::getInstance()->getPixelFont()->stringWidth(idScreen);
			ofVec2f posText = ofVec2f(centerPos.x+pos4.x,centerPos.y+pos4.y);
			ofPushMatrix();
			ofTranslate(posText.x,posText.y);	
			ofRotate(angleText);
			ofTranslate(0,-2);
			fontManager::getInstance()->getPixelFont()->drawString(idScreen,0,0);
			ofPopMatrix();
		}
		// show current screen
		if(screensManager::getInstance()->getScreenArId()==i){
			ofSetColor(255,255,255);
			float radius3 = radius-65;
			float radius4 = radius+50;
			ofVec2f pos3 = ofVec2f( radius3*cos(degrees) , radius3*sin(degrees) );
			ofVec2f pos4 = ofVec2f( radius4*cos(degrees) , radius4*sin(degrees) );
			ofVec2f point1 = ofVec2f(centerPos.x+pos3.x,centerPos.y+pos3.y);
			ofVec2f point2 = ofVec2f(centerPos.x+pos4.x,centerPos.y+pos4.y);
			ofLine(point1.x,point1.y,point2.x,point2.y);

			string idScreen = ofToString(screensManager::getInstance()->getIdScreen(i));
			double angleText = ofRadToDeg(atan2(point2.y-point1.y, point2.x-point1.x));
			int stringSize = fontManager::getInstance()->getPixelFont()->stringWidth(idScreen);
			ofVec2f posText = ofVec2f(centerPos.x+pos3.x,centerPos.y+pos3.y);
			ofPushMatrix();
			ofTranslate(posText.x,posText.y);	
			ofRotate(angleText);
			ofTranslate(60-stringSize,-5);
			fontManager::getInstance()->getPixelFont()->drawString(idScreen,0,0);
			ofPopMatrix();
		}

	}
	// Title
	ofSetColor(255,255,255);
	string textTitle = "Screens PdV";
	int stringHalfSize = fontManager::getInstance()->getPixelFont()->stringWidth(textTitle)/2;
	fontManager::getInstance()->getPixelFont()->drawString(textTitle,(ofGetWidth()-666)/2-stringHalfSize,ofGetHeight()/2);
	
	// Total screens
	ofSetColor(90,90,90);
	string totalScreensStr = "total screens:"+ofToString(totalScreens);
	totalScreensStr[0] = toupper(totalScreensStr[0]);
	stringHalfSize = fontManager::getInstance()->getPixelFont()->stringWidth(totalScreensStr)/2;
	fontManager::getInstance()->getPixelFont()->drawString(totalScreensStr,(ofGetWidth()-666)/2-stringHalfSize,(ofGetHeight()/2)+15);

	// Total errors
	if( settingsManager::getInstance()->getDebugMode() ){
		int totalErrors = screensManager::getInstance()->getTotalXMLErrors();
		if(totalErrors>0){
			ofSetColor(255,0,0);
			stringHalfSize = fontManager::getInstance()->getPixelFont()->stringWidth("Total XML errors:"+ofToString(totalErrors))/2;
			fontManager::getInstance()->getPixelFont()->drawString("Total XML errors:"+ofToString(totalErrors),(ofGetWidth()-666)/2-stringHalfSize,(ofGetHeight()/2)+30);
		}else{
			ofSetColor(0,255,0);
			stringHalfSize = fontManager::getInstance()->getPixelFont()->stringWidth("There is no XML errors")/2;
			fontManager::getInstance()->getPixelFont()->drawString("There is no XML errors",(ofGetWidth()-666)/2-stringHalfSize,(ofGetHeight()/2)+30);
		}
	}

	ofPushMatrix();
	ofTranslate(20,-20);
	string typeScreen = "";
	// 
	ofSetColor(5,143,249);
	ofRect(15,ofGetHeight()-65,10,10);
	typeScreen = "question";
	fontManager::getInstance()->getPixelFont()->drawString(typeScreen,30,ofGetHeight()-55);
	
	ofSetColor(255,255,0);
	ofRect(15,ofGetHeight()-50,10,10);
	typeScreen = "debate";
	fontManager::getInstance()->getPixelFont()->drawString(typeScreen,30,ofGetHeight()-40);
	
	ofSetColor(255,0,240);
	ofRect(15,ofGetHeight()-35,10,10);
	typeScreen = "statement or text";
	fontManager::getInstance()->getPixelFont()->drawString(typeScreen,30,ofGetHeight()-25);
	
	if( settingsManager::getInstance()->getDebugMode() ){
		ofSetColor(255,0,0);
		ofRect(15,ofGetHeight()-20,10,10);
		typeScreen = "errors";
		fontManager::getInstance()->getPixelFont()->drawString(typeScreen,30,ofGetHeight()-10);
	}
	ofPopMatrix();

	
	// END DRAW IN FBO
	votesManager::getInstance()->drawFBOEnd();

	// Draw FBO
	ofSetColor(255,255,255);
	votesManager::getInstance()->drawFBO(x,y);
}
//--------------------------------------------------------------
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();

}
Exemple #3
0
//--------------------------------------------------------------
void ofApp::draw(){
    //BG------white paper with light blue gridded lines--------------------
    ofBackground(255);
    ofSetColor( ofColor::lightBlue);
    ofSetLineWidth(1);
    for (int i = 0; i < ofGetWidth(); i = i + 20){
        ofLine(i,0,i, ofGetHeight());
        
    }
    
    for (int i = 0; i < ofGetHeight(); i = i + 20){
        ofLine(0, i, ofGetWidth(), i);
    }
    
    ofFill();
    ofSetColor(MedAqua);
    if (ofGetElapsedTimef() <= 10){
        ofTriangle(10*ofGetElapsedTimef(),100,10*ofGetElapsedTimef()+50,150,10*ofGetElapsedTimef(),200);
    }
    
  
    //-----------mesh------square--------slowly---------dropping-----------------------------------------------------
    ofPushMatrix();
    //  ofRotate(2*ofGetElapsedTimef());
    ofTranslate(-200, -600+2*ofGetElapsedTimef());
    ofScale(7,7);
    
    ofMesh tempMesh;
    tempMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    
    tempMesh.addVertex( ofPoint(100,100));
    tempMesh.addColor(Gold);
    
    tempMesh.addVertex( ofPoint(200,100));
    tempMesh.addColor(Gold);
    
    tempMesh.addVertex( ofPoint(100,200));
    tempMesh.addColor(Aqua);
    
    tempMesh.addVertex( ofPoint(200,200));
    tempMesh.addColor(Aqua);
    
    tempMesh.draw();
    ofPopMatrix();

    //-----------------------bg ball drops----------------------------------------------------------------------
    ofSetColor(col);
    if(ofGetElapsedTimeMillis() - last > 50)
        col.setHue(counter % 256); // what does the division sign do?
    counter ++;
    last = ofGetElapsedTimeMillis();
    ofFill();
    float rando = ofRandom(0, 100); // random number from 0 to 100
    
    for (int l = 0; l<30; l++) {
        for (int m = 0; m<10; m++) {
            ofCircle(500*m,-1000+20*ofGetElapsedTimef()+(l*500),Myradius*2);
        }
    }
    
    for (int n = 0; n<30; n++) {
        for (int nb = 0; nb<10; nb++) {
            ofCircle(250+500*nb,-250+20*ofGetElapsedTimef()+(n*500),Myradius);
        }
    }

    ofPushMatrix();
    ofTranslate(400, 200);
    drawaPolkaDotO(750, 50, 0.5);
    drawHI(270, 00, 1);
    
    ofPopMatrix();

    ofSetColor(ofRandom(0,100),ofRandom(0,140), ofRandom(0,190));
    Consider.draw(100,100,200,78);
    Everything.draw(200, 300, 205,90);
    tobe.draw(400,500,140,70);
    an.draw(600,600,70,40);
    Experiment.draw(800,700,210,80);
         
    
    
}
Exemple #4
0
//--------------------------------------------------------------
void testApp::draw(){
	DWORD threadid = GetCurrentThreadId();
	cout <<"draw " << threadid << endl;

	ofSetColor(0, 255, 0);
	ofNoFill();

	ofDrawBitmapString("AUDIO FILE INPUT", 32, 32);
	if (deviceID == -1)
		ofDrawBitmapString("Using default audio output. Press ,/. to switch", 32, 64);
	else
	{
		string did_string = "Using device " + ofToString(deviceID) + ". Press ,/. to switch";
		ofDrawBitmapString(did_string, 32,64);
	}

	string play_audio_text ;
	if (playAudio)
		play_audio_text = "Audio enabled: press 'p' to toggle";
	else
		play_audio_text = "Audio disabled: press 'p' to toggle";
	ofDrawBitmapString(play_audio_text,32, 86);

	ofPushStyle();
	ofPushMatrix();
	ofTranslate(32, 100);

	ofSetLineWidth(1);
	ofDrawBitmapString("RAW", 0, 0);
	ofRect(0,20,50,400);
	ofFill();
	float drawScaledVol = scaledVol * 400;
	ofRect(0, 420 - drawScaledVol, 50, drawScaledVol);

	ofPopMatrix();
	ofPopStyle();


	ofPushStyle();
	ofPushMatrix();
	ofTranslate(150, 100);

	ofSetLineWidth(1);
	ofDrawBitmapString("SMOOTH", 0, 0);
	ofRect(0,20,50,400);
	ofFill();
	float drawSmoothScaledVol = smoothScaledVol * 400;
	ofRect(0, 420 - drawSmoothScaledVol, 50, drawSmoothScaledVol);

	ofPopMatrix();
	ofPopStyle();

	// draw left buffer
	ofPushStyle();
	ofPushMatrix();
	ofTranslate(300, 100);

	ofDrawBitmapString("LEFT",4,20);

	ofRect(0,0,bufferSize*2, 200);
	ofBeginShape();
	for (int i = 0; i < bufferSize; i++)
	{
		ofVertex(i*2, 100 - leftChannel[i] * 100.0f);
	}
	ofEndShape(false);

	ofPopMatrix();
	ofPopStyle();

	// draw rigt buffer
	ofPushStyle();
	ofPushMatrix();
	ofTranslate(300, 310);

	ofDrawBitmapString("RIGHT",4,20);

	ofRect(0,0,bufferSize*2, 200);
	ofBeginShape();
	for (int i = 0; i < bufferSize; i++)
	{
		ofVertex(i*2, 100 - rightChannel[i] * 100.0f);
	}
	ofEndShape(false);

	ofPopMatrix();
	ofPopStyle();
}
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();

}
Exemple #6
0
void Torso::drawFaces()
{
    ofPushMatrix();
    ofTranslate(*originPoint);
    // rotate in direction of target
    ofRotate(qangle, qaxis.x, qaxis.y, qaxis.z);
    
    float ambientArray[4];
    ambientArray[0] = ambient.r;
    ambientArray[1] = ambient.g;
    ambientArray[2] = ambient.b;
    ambientArray[3] = ambient.a;
    float diffuseArray[4];
    diffuseArray[0] = diffuse.r;
    diffuseArray[1] = diffuse.g;
    diffuseArray[2] = diffuse.b;
    diffuseArray[3] = diffuse.a;
    float specularArray[4];
    specularArray[0] = specular.r;
    specularArray[1] = specular.g;
    specularArray[2] = specular.b;
    specularArray[3] = specular.a;
    
	if (isShadingActive)
	{
		shader->begin();
		shader->setUniformTexture("tex0", *texture, texture->getTextureData().textureID);
		shader->setUniformTexture("texDepthMap", *bumpMap, bumpMap->getTextureData().textureID);
		shader->setUniform4fv("ambient", ambientArray);
		shader->setUniform4fv("diffuse", diffuseArray);
		shader->setUniform4fv("specular", specularArray);
		shader->setUniform1f("shinyness", shinyness);
		shader->setUniform1f("shadowIntensity", shadowIntensity);
		shader->setUniform1i("isBumpMapActive", (isBumpMapActive) ? 1 : 0);
		shader->setUniform1f("bumpMapStrength", bumpMapStrength);
	}

    if (isUseOfMesh)
	{
		ofPushMatrix();
		ofScale(scaleW, scaleH, scaleD);
		ofRotate(rotX, 1, 0, 0);
		ofRotate(rotY, 0, 1, 0);
		ofRotate(rotZ, 0, 0, 1);

		if (isVisible)
		{
			for (int i = 0; i < meshes.size(); i++)
				meshes[i].drawFaces();
		}

		ofPopMatrix();
	}
	else
	{
		if (isVisible)
		    model.drawFaces();
	}
    
    if (isShadingActive) shader->end();

    ofPopMatrix();

	formatConnections();
}
void Pong::drawNumber( float _x, int n ) {
    ofPushMatrix();
    ofPushStyle();
    ofTranslate(_x, space.y+space.height*0.05+pixel);
    ofSetLineWidth(5);
    int pixel = 30;
    ofNoFill();
    switch( n ) {
    case 0 :
        ofRect(0, 0, pixel/2, pixel);
        break;
    case 1 :
        ofLine(pixel/2, 0, pixel/2, pixel);
        break;
    case 2 :
        ofLine(0, 0, pixel/2, 0);
        ofLine(pixel/2, 0, pixel/2, pixel/2);
        ofLine(pixel/2, pixel/2, 0, pixel/2);
        ofLine(0, pixel/2, 0, pixel);
        ofLine(0, pixel, pixel/2, pixel);
        break;
    case 3:
        ofLine(0, 0, pixel/2, 0);
        ofLine(pixel/2, 0, pixel/2, pixel);
        ofLine(pixel/2, pixel, 0, pixel);
        ofLine(pixel/2, pixel/2, 0, pixel/2);
        break;
    case 4:
        ofLine(0, 0, 0, pixel/2);
        ofLine(0, pixel/2, pixel/2, pixel/2);
        ofLine(pixel/2, pixel/2, pixel/2, pixel);
        break;
    case 5:
        ofLine(0, 0, pixel/2, 0);
        ofLine(0, 0, 0, pixel/2);
        ofLine(0, pixel/2, pixel/2, pixel/2);
        ofLine(pixel/2, pixel/2, pixel/2, pixel);
        ofLine(0, pixel, pixel/2, pixel);
        break;
    case 6:
        ofLine(0, 0, 0, pixel);
        ofLine(0, pixel/2, pixel/2, pixel/2);
        ofLine(pixel/2, pixel/2, pixel/2, pixel);
        ofLine(0, pixel, pixel/2, pixel);
        break;
    case 7:
        ofLine(0, 0, pixel/2, 0);
        ofLine(pixel/2, 0, pixel/2, pixel);
        break;
    case 8:
        ofLine(0, 0, pixel/2, 0);
        ofLine(0, pixel/2, pixel/2, pixel/2);
        ofLine(0, pixel, pixel/2, pixel);
        ofLine(0, 0, 0, pixel);
        ofLine(pixel/2, 0, pixel/2, pixel);
        break;
    case 9:
        ofLine(0, 0, pixel/2, 0);
        ofLine(0, pixel/2, pixel/2, pixel/2);
        ofLine(0, 0, 0, pixel/2);
        ofLine(pixel/2, 0, pixel/2, pixel);
        break;
    case 10:
        reset();
        break;
    }
    ofPopStyle();
    ofPopMatrix();
}
void ofxTLCurves::drawModalContent(){

	//****** DRAW EASING CONTROLS
	if(!drawingEasingWindow){
    	return;
    }

    ofxTLTweenKeyframe* tweenFrame = (ofxTLTweenKeyframe*) selectedKeyframe;
	if(tweenFrame == NULL){
		if(selectedKeyframes.size() == 0){
			return;
		}
		tweenFrame = (ofxTLTweenKeyframe*)selectedKeyframes[0];
	}

	for(int i = 0; i < easingTypes.size(); i++){
        //TODO turn into something like selectionContainsEaseType();
        //so that we can show the multi-selected easies
        if(easingTypes[i] ==  ((ofxTLTweenKeyframe*)selectedKeyframes[0])->easeType){
            ofSetColor(150, 100, 10);
        }
        else{
            ofSetColor(80, 80, 80);
        }
        ofFill();
        ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x, easingWindowPosition.y + easingTypes[i]->bounds.y,
               easingTypes[i]->bounds.width, easingTypes[i]->bounds.height);
        ofSetColor(200, 200, 200);
        timeline->getFont().drawString(easingTypes[i]->name,
									   easingWindowPosition.x + easingTypes[i]->bounds.x+11,
									   easingWindowPosition.y + easingTypes[i]->bounds.y+10);
        ofNoFill();
        ofSetColor(40, 40, 40);
        ofRect(easingWindowPosition.x + easingTypes[i]->bounds.x,
               easingWindowPosition.y + easingTypes[i]->bounds.y,
               easingTypes[i]->bounds.width, easingTypes[i]->bounds.height);
    }

    for(int i = 0; i < easingFunctions.size(); i++){
        //TODO: turn into something like selectionContainsEaseFunc();
        if(easingFunctions[i] == tweenFrame->easeFunc){
            ofSetColor(150, 100, 10);
        }
        else{
            ofSetColor(80, 80, 80);
        }
        ofFill();
        ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y,
               easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height);
        ofSetColor(200, 200, 200);
//        timeline->getFont().drawString(easingFunctions[i]->name,
//                           easingWindowPosition.x + easingFunctions[i]->bounds.x+10,
//                           easingWindowPosition.y + easingFunctions[i]->bounds.y+15);
		ofPushMatrix();
		ofTranslate(easingWindowPosition.x + easingFunctions[i]->bounds.x,
					easingWindowPosition.y + easingFunctions[i]->bounds.y);
		if(tweenFrame->easeType->type == ofxTween::easeIn){
			easingFunctions[i]->easeInPreview.draw();
		}
		else if(tweenFrame->easeType->type == ofxTween::easeOut){
			easingFunctions[i]->easeOutPreview.draw();
		}
		else {
			easingFunctions[i]->easeInOutPreview.draw();
		}

		ofPopMatrix();
        ofNoFill();
        ofSetColor(40, 40, 40);
        ofRect(easingWindowPosition.x + easingFunctions[i]->bounds.x, easingWindowPosition.y +easingFunctions[i]->bounds.y,
               easingFunctions[i]->bounds.width, easingFunctions[i]->bounds.height);
    }

}
void ofApp::draw()
{
    ofBackground(0);

    cam.begin();

    ofPushMatrix();
    ofTranslate(- ofGetWidth() / 2, - ofGetHeight() / 2, 0);

    ofNoFill();
    ofSetColor(255);

    // Draw all of the points.
    mesh.draw();

    ofFill();
    ofSetColor(255, 255, 0, 80);

    for (std::size_t i = 0; i < searchResults.size(); ++i)
    {
        std::size_t resultIndex = searchResults[i].first;
        float resultDistance = searchResults[i].second;

        DataType& result = points[resultIndex];

        glm::vec3 resultAsPoint(result[0], result[1], result[2]);

        float normalizedDistance = ofMap(resultDistance, radius * radius, 0, 0, 1, true);

        ofSetColor(255, 255, 0, normalizedDistance * 127);

        ofDrawSphere(resultAsPoint, 5);

        if (MODE_NEAREST_N == mode)
        {
            ofSetColor(255, 127);
            ofDrawBitmapString(ofToString(i), resultAsPoint);
        }
    }

    if (MODE_RADIUS == mode)
    {
        ofNoFill();
        ofSetColor(255, 0, 0, 50);

        glm::vec3 fireflyAsPoint(firefly[0], firefly[1], firefly[2]);

        ofDrawSphere(fireflyAsPoint, radius);
    }

    ofPopMatrix();

    cam.end();

    std::stringstream ss;


    if (MODE_RADIUS == mode)
    {
        ss << "SEARCH MODE (space): RADIUS" << std::endl;
        ss << "       RADIUS (-/=): " << radius;
    }
    else
    {
        ss << "SEARCH MODE (space): NEAREST N" << std::endl;
        ss << "    NEAREST N (-/=): " << nearestN;
    }

    ofDrawBitmapStringHighlight(ss.str(), glm::vec2(30, 30));
}
void RecordScene::draw()
{
    ofPushStyle();
    ofBackground(ofColor::white);
    
    /*
    //Draw background rect for spectrum
    ofSetColor( 230, 230, 230 );
    ofFill();
    ofRect( 0, recordRect.getMaxY(), N * 6, -100 );
    
    //Draw spectrum
    ofSetColor( 0, 0, 0 );
    for (int i=0; i<N; i++) {
        //Draw bandRad and bandVel by black color,
        //and other by gray color
        if ( i == bandRad || i == bandVel ) {
            ofSetColor( 0, 0, 0 ); //Black color
        }
        else {
            ofSetColor( 128, 128, 128 ); //Gray color
        }
        ofRect( 10 + i * 5, recordRect.getMaxY(), 3, -spectrum[i] * 100 );
    }
    */
    
    //Draw cloud
    
    //Move center of coordinate system to the screen center
    ofPushMatrix();
    ofTranslate( ofGetWidth() / 2, ofGetHeight() / 2 );
    
    //Draw points
    ofSetColor( 0, 0, 0 );
    ofFill();
    for (int i=0; i<n; i++) {
        ofCircle( p[i], 2 );
    }
    
    //    ofSetColor(ofColor::yellow);
    //Draw lines between near points
    float dist = 40;	//Threshold parameter of distance
    for (int j=0; j<n; j++) {
        for (int k=j+1; k<n; k++) {
            if ( ofDist( p[j].x, p[j].y, p[k].x, p[k].y )
                < dist ) {
                ofLine( p[j], p[k] );
            }
        }
    }
    
    //Restore coordinate system
    ofPopMatrix();
    
    ofSetColor(ofColor::white);
    ofPoint _p = recordRect.getCenter();
    if(isRecording)
        angleArc.draw(_p.x, _p.y);
    recordbtn.draw(recordRect);

    ofSetColor(ofColor::black);
    
//    path.moveTo(300, 300);
//    path.arc( 0, 0, 200, 200, 0, 271);
////    path.arc(recordRect.getCenter(), recordRect.width+20, recordRect.height+20, 0, endAngle);
    
    if(!isRecording)
        ofDrawBitmapStringHighlight("Press to record your voice expression", 5, 140);
    
    ofPopStyle();
    
    shareData->recordingEnabled = isRecording;
}
void demoAdvanced::draw( ) {

    int tx = 0;
    int ty = 0;
    
    ofBackground( 0, 0, 0 );
    
    // quaternion
    ofPushMatrix();

        ofTranslate( ofGetWidth() * 0.5f, ofGetHeight() * 0.5f, -200 );
        
        ofNoFill();
        ofSetColor( 255,255,255 );
        float rotationAmount;
        ofVec3f rotationAngle;
        quaternion.getRotate(rotationAmount, rotationAngle);
        ofRotate(rotationAmount, rotationAngle.x, rotationAngle.y, rotationAngle.z);
        ofBox( 0,0,0, 100, 100, 100 );
        
        ofSetColor( 255,0,0 );
        ofLine( 0,0,0, 100,0,0 );
        ofSetColor( 0,255,0 );
        ofLine( 0,0,0, 0,100,0 );
        ofSetColor( 0,0,255 );
        ofLine( 0,0,0, 0,0,100 );
    
    ofPopMatrix();
    
    // matrix 4x4
    ofPushMatrix();

        ofTranslate( ofGetWidth() * 0.5f, ofGetHeight() * 0.5f, -200 );
        
        ofNoFill();
        ofSetColor( 255,255,255 );
        
        ofMultMatrix( mat );
        ofBox( 0,0,0, 200, 200, 200 );
        
        ofSetColor( 255,0,0 );
        ofLine( 0,0,0, 100,0,0 );
        ofSetColor( 0,255,0 );
        ofLine( 0,0,0, 0,100,0 );
        ofSetColor( 0,0,255 );
        ofLine( 0,0,0, 0,0,100 );
    
    ofPopMatrix();
    
    
    
    ofSetColor( 255,255,255 );
    ty = 25;
    ofDrawBitmapString( "tweener fps: " + ofToString( _tweener->fps() ), 10, ty ); ty += 15;
    ofDrawBitmapString( "tweener time speed: " + ofToString( _tweener->timespeed() ), 10, ty ); ty += 15;
    ofDrawBitmapString( "tweener inner time: " + ofToString( _tweener->innertime() ), 10, ty ); ty += 15;
    if ( _tweener->running() ) {
        ofDrawBitmapString( "tweener is playing", 10, ty ); ty += 15;
    } else {
        ofDrawBitmapString( "tweener is paused", 10, ty ); ty += 15;
    }
    ofDrawBitmapString( "millis: " + ofToString( ofGetElapsedTimeMillis() ), 10, ty ); ty += 15;
    ofDrawBitmapString( "of fps: " + ofToString( ofGetFrameRate() ), 10, ty ); ty += 15;
    
    ofSetColor( 255,255,100 );
    stringstream ss;
    for ( int i = 1; i < lognum; ++i ) {
        ss << logs[ i ] << endl;
    }
    ofDrawBitmapString( ss.str(), 300, 25 );
    
}
void TownDashboardRenderer::draw()
{
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    //type
    _typeLayerFbo.begin();
    
    ofClear(0, 0, 0, 0);
    ofBackground(0, 0, 0, 0);
    
    searchingStringImage.draw(0, 0);
    ofPushMatrix();

    ofSetColor(0,255,255);
    int maxVisibleCharacters = 14;
    string subString = _townName.length() > maxVisibleCharacters ? _townName.substr(0, maxVisibleCharacters) : _townName;
    if (_townName.length() <= (maxVisibleCharacters))
    {
        int insertWs = maxVisibleCharacters - _townName.length() - 1;
        for(int i = 0; i<insertWs; i++)
        {
            subString.push_back('p');
        }
    }
    else{
        subString += "...";
        _townName = subString;// + "...";
    }
    ofRectangle fullRect = font.getStringBoundingBox(subString, 0, 0);
    int p = 0;//running count
    ofRectangle runningStringDimensions;
    
    float debugXPos = 2600.0f;
    
    for(char &c : _townName)
    {
        int nVal = min(p + 1, (int)subString.length());
        
        string runningString = subString.substr(0, nVal);
        runningStringDimensions = font.getStringBoundingBox(runningString, 0, 0);
        string thisCharString = ofToString(c);
        ofRectangle thisCharDimensions = font.getStringBoundingBox(thisCharString, 0, 0);
        
        float diff = runningStringDimensions.width - thisCharDimensions.width;
        float debugWidth = fullRect.width;
        float dPos = diff / fullRect.width;
        ofVec2f positionOnCurve = spline2D.sampleAt(dPos);
        ofVec2f tangent = getTangent(dPos, spline2D);
        float rot = atan2(tangent.y, tangent.x) * RAD_TO_DEG;
        
        ofPushMatrix();
        
        ofTranslate(positionOnCurve.x, positionOnCurve.y);
        ofRotate(rot, 0, 0, 1);
        font.drawString(thisCharString, 0, 0);
        
        ofPopMatrix();
        
        if(_debugMode)
        {
            //debug stuff off screen
            ofSetColor(255, 0, 255);
            ofDrawRectangle(debugXPos, p * 100, runningStringDimensions.width, runningStringDimensions.height);
            ofSetColor(0, 255, 0);
            ofDrawRectangle(debugXPos + diff, runningStringDimensions.height + (p * 100), thisCharDimensions.width, 3000);
            ofSetColor(0, 0, 0);
            font.drawString(runningString, debugXPos, 50 + (p * 100));
        }
        
        ofPopMatrix();
        ++p;
        
    }
    ofSetColor(255);
    searchingStringImage.draw(0, 0);
    _typeLayerFbo.end();
    
    //drawn the type
    //black pass
    _blackPassFbo.begin();
    ofClear(0, 0, 0, 255);
    ofBackground(0, 0, 0, 255);
    
    _typeLayerFbo.draw(0, 0);
    
    _blackPassFbo.end();
    
    //glow
    glow.clear();
    glow << _blackPassFbo;
    
    
    
    _glowPassFbo.begin();
    ofClear(0, 0, 0);
    ofBackground(0, 0, 0);
    ofRectangle r = ofRectangle(0, 0, PRINT_DIMENSIONS_WIDTH, PRINT_DIMENSIONS_HEIGHT);
    glow.ofxFXObject::draw(r);
    _glowPassFbo.end();
    
    //final render
    _exportFbo.begin();
    
    ofClear(0, 0, 0);
    ofBackground(0, 0, 0);
//    backgroundImage.draw(0, 0);
    blendImage.draw(0, 0);
    _typeLayerFbo.draw(0, 0);

    ofEnableBlendMode(OF_BLENDMODE_ADD);

    _glowPassFbo.draw(0, 0);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    
    _exportFbo.end();
    
}
Exemple #13
0
//--------------------------------------------------------------
void testApp::draw(){
	ofSetColor(255, 255, 255);
    
    ofPushMatrix();
    // draw debug (ie., image, depth, skeleton)
    openNIDevice.drawDebug();
    ofPopMatrix();
    
    ofPushMatrix();
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    
    
    
    // iterate through users
    for (int i = 0; i < openNIDevice.getNumTrackedHands(); i++){
        
        // get a reference to this user
        ofxOpenNIHand & hand = openNIDevice.getTrackedHand(i);
        
        // get hand position
        ofPoint & handPosition = hand.getPosition();
        
        // draw a rect at the position
        ofSetColor(255,0,0);
        ofRect(handPosition.x, handPosition.y, 2, 2);
        
        // set depthThresholds based on handPosition
        ofxOpenNIDepthThreshold & depthThreshold = openNIDevice.getDepthThreshold(i); // we just use hand index for the depth threshold index
        
        // draw ROI over the depth image
        ofSetColor(255,255,255);
        depthThreshold.drawROI();
        
        // draw depth and mask textures below the depth image at 0.5 scale
        // you could instead just do pixel maths here for finger tracking etc
        // by using depthThreshold.getDepthPixels() and/or depthThreshold.getMaskPixels()
        // and turn off the textures in the initial setup/addDepthTexture calls
        
        ofPushMatrix();
        ofTranslate(320 * i, 480);
        ofScale(0.5, 0.5);
        depthThreshold.drawDepth();
        depthThreshold.drawMask();
        ofPopMatrix();
        
    }
    
    ofDisableBlendMode();
    ofPopMatrix();
    
    // draw some info regarding frame counts etc
	ofSetColor(0, 255, 0);
	string msg = " MILLIS: " + ofToString(ofGetElapsedTimeMillis()) + " FPS: " + ofToString(ofGetFrameRate()) + " Device FPS: " + ofToString(openNIDevice.getFrameRate());
    
	verdana.drawString(msg, 20, 480 - 20);
    
    
    //--osc
    // display instructions
    ofSetColor(0);
	string buf;
	buf = "sending osc messages to" + string(HOST) + ofToString(PORT);
	ofDrawBitmapString(buf, 10, 20);
	ofDrawBitmapString("move the mouse to send osc message [/mouse/position <x> <y>]", 640, 500);

}
void ofApp::rotateScreen(float degrees) {
    ofTranslate(halfWidth, halfHeight, 0);
    ofRotate(degrees);
    ofTranslate(-halfWidth, -halfHeight, 0);
}
void defense::MixingImages(int MMode){
    ofRectangle RectOut;
    RectOut = OneBigRect();
    float TheWi;
    ofSetColor(0, 0, 0 );
    
    ofRectangle RectLimits;
//    RectLimits.x =(RectOut.getCenter()).x - 1.5*RectOut.width/4.0;
//    RectLimits.y=(RectOut.getCenter()).y - 1.3*RectOut.height/4.0;
//    RectLimits.width=1.5*RectOut.width/2.0;
//    RectLimits.height=1.5*RectOut.height/2.0;

    RectLimits.x =0.0;
    RectLimits.y=0.0;
    RectLimits.width=.98*ScreenX;
    RectLimits.height=.98*ScreenY;
    switch (MMode) {
            
        case 0: // size
        {
      
            
            float tempoval;
            ofSetColor(255,255,255);
            glPushMatrix();
            
            ofTranslate(RectLimits.x, RectLimits.y);
            ofScale(RectLimits.width/Nx,RectLimits.height/Ny);
            
            for (int i=0; i <Destino->height; i++) {
                for (int j=0; j<Destino->width; j++) {
                    
                    tempoval = (float)((uchar *)(Destino->imageData + i*Destino->widthStep))[j*Destino->nChannels + 0];
                    float ScalValue = (.2)*(1-tempoval/255.0);
                    glPushMatrix();  
                    ofTranslate(j*Nx/NumOfSquares.x+(Nx/NumOfSquares.x)/2.0, 
                                i*Ny/NumOfSquares.y+(Ny/NumOfSquares.y)/2.0);
//                    ofRect(-.5*Nx/NumOfSquares.x*ScalValue, -.5*Ny/NumOfSquares.y*ScalValue,
//                           ScalValue*Nx/NumOfSquares.x, ScalValue*Ny/NumOfSquares.y); 
                    ofScale(.2*ScalValue, .2*ScalValue);
                     colorImg.draw(0,0);
                    //          ofSetColor(tempoval,tempoval,tempoval);
                    //            ofRect(j*Nx/NumOfSquares.x, i*Ny/NumOfSquares.y, Nx/NumOfSquares.x, Ny/NumOfSquares.y);
                    glPopMatrix(); 
                    
                }
            }
            
            glPopMatrix();
        }
            
            break;         
         
        case 1: // angle
        {
            Fuentes[3].drawString("Mixing images: Angle",
                                  RectOut.x,RectOut.y + RectOut.height*.1);
            
            float tempoval;
            ofSetColor(255,255,255);
            glPushMatrix();
            
            ofTranslate(RectLimits.x, RectLimits.y);
            ofScale(RectLimits.width/Nx,RectLimits.height/Ny);
            
            for (int i=0; i <Destino->height; i++) {
                for (int j=0; j<Destino->width; j++) {
                    
                    tempoval = (float)((uchar *)(Destino->imageData + i*Destino->widthStep))[j*Destino->nChannels + 0];


                    glPushMatrix();  
                    ofTranslate(j*Nx/NumOfSquares.x+(Nx/NumOfSquares.x)/2.0, 
                                i*Ny/NumOfSquares.y+(Ny/NumOfSquares.y)/2.0);
                    //                    ofRect(-.5*Nx/NumOfSquares.x*ScalValue, -.5*Ny/NumOfSquares.y*ScalValue,
                    //                           ScalValue*Nx/NumOfSquares.x, ScalValue*Ny/NumOfSquares.y); 
                    ofRotate(tempoval/255.0*90, 0, 0, 1);
                    ofScale(NumOfSquares.x/Nx, NumOfSquares.y/Ny);
                   
                    colorImg.draw(-colorImg.width/2.0,-colorImg.height/2.0);
                    //          ofSetColor(tempoval,tempoval,tempoval);
                    //            ofRect(j*Nx/NumOfSquares.x, i*Ny/NumOfSquares.y, Nx/NumOfSquares.x, Ny/NumOfSquares.y);
                    glPopMatrix(); 
                    
                }
            }
            
            glPopMatrix();
            
        }   
            break;             
            
            
        default:
            break;
    }
    
}
Exemple #16
0
	//---------
	void Handles::Rotate::doTransform() const {
		ofTranslate(parent->getNode().getPosition());
		glMultMatrixf(ofMatrix4x4(parent->getNode().getOrientationQuat()).getPtr());
		ofTranslate(parent->getOrigin());
		ofScale(scale, scale, scale);
	}
//--------------------------------------------------------------
void ofApp::draw(){
	ofBackground( 0, 0, 0 );	//Set up the background
	stars.draw(0, 0);

	ofEnableAlphaBlending();
	ofSetColor(0, 0, 0, bg_transparent);
	ofRect(0, 0, 1000, 700);
	ofDisableAlphaBlending();

	ofSetHexColor(0x606060);
	ofDrawBitmapString("Music by: volfworks", 800,610);


	//Draw background rect for spectrum
	ofSetColor( 20, 20, 20 );
	ofFill();
	ofRect( 0, 600, N * 6, -100 );

	//Draw spectrum
	ofSetColor( 0, 0, 0 );
	for (int i=0; i<N; i++) {
		//Draw bandRad and bandVel by black color,
		//and other by gray color
		if ( i == bandRad || i == bandVel ) {
			ofSetColor( 250, 250, 250 ); //
		}
		else {
			ofSetColor( 128, 128, 128 ); //Gray color
		}
		ofRect( 10 + i * 5, 600, 3, -spectrum[i] * 100 );
	}

	//Draw cloud

	//Move center of coordinate system to the screen center
	ofPushMatrix();
	ofTranslate( ofGetWidth() / 2, ofGetHeight() / 2 );

	//Draw points
	ofEnableAlphaBlending();
	ofSetColor( 160, 160, 160, fabs(130 - bg_transparent) );
	ofFill();
	for (int i=0; i<n; i++) {
		ofCircle( p[i], 2 );
	}

	//Draw lines between near points
	float dist = 40;	//Threshold parameter of distance
	for (int j=0; j<n; j++) {
		for (int k=j+1; k<n; k++) {
			if ( ofDist( p[j].x, p[j].y, p[k].x, p[k].y )
				< dist ) {
					ofLine( p[j], p[k] );
			}
		}
	}
	ofDisableAlphaBlending();

	//Restore coordinate system
	ofPopMatrix();

	//  test for saving
  //  string fileName = "screen1.png";
  //  ofSaveScreen(fileName);
}
void of3dLevelScene::draw()
{
    post.begin(cam);
    ofEnableLighting();
//    cam.begin();
    light.enable();
    glEnable(GL_FOG);
    ofBackground(0,0,127);
    
    // level
    if(level.getNumMeshes()) {
        level.drawFaces();
    }
    
    // player
    player->draw();
    
    float drawDistSqrd = 100.f;
    // chests
    for(int i = 0; i < chests.size(); i++) {
        // prevent crash? too many objects??
        if(chests.at(i)->position.distanceSquared(player->position) < drawDistSqrd) {
            chests.at(i)->draw();
        }
    }
    
    // enemies
    for(int i = 0; i < enemies.size(); i++) {
        // prevent crash? too many objects??
        if(enemies.at(i)->position.distanceSquared(player->position) < drawDistSqrd) {
            enemies.at(i)->draw();
        }
    }
    
    glDisable(GL_FOG);
//    ofDrawAxis(20);
//    light.draw();
    //    if(collision.getNumMeshes()) {
    //        collision.drawFaces();
    //    }

    
    if(editMode) {
        ofPushMatrix();
        ofTranslate(cam.getGlobalPosition().x, cam.getGlobalPosition().y, 0.f);
        ofDrawAxis(1);
        ofPopMatrix();
    }
    
    cam.end();
    post.end();
    light.disable();
    ofDisableLighting();
    
    ofSetColor(255,255,255);
    if(gui->isVisible()) {
        gui->draw();
    }
    
    if(editMode) {
        ofSetColor(255,255,255);
        ofDrawBitmapString("edit mode active", 20, 20);
        ofSetColor(200,200,255);
        ofDrawBitmapString("object: " + currentObject, 20, 40);
        ofSetColor(255,255,255);
    }
}
//--------------------------------------------------------------
void testApp::update()
{
	ofBackground(ofColor::black);

	// grab new frame and update colorImg with it.
    bool bNewFrame = false;

	#ifdef _USE_LIVE_VIDEO
       vidGrabber.update();
	   bNewFrame = vidGrabber.isFrameNew();
    #else
        vidPlayer.update();
        bNewFrame = vidPlayer.isFrameNew();
	#endif

	if (bNewFrame)
	{
		
		#ifdef _USE_LIVE_VIDEO
            colorImg.setFromPixels(vidGrabber.getPixels(), 320,240);
	    #else
            colorImg.setFromPixels(vidPlayer.getPixels(), 320,240);
        #endif

        grayImage = colorImg; // converts from color to greyscale

		float time = ofGetElapsedTimef();

		// Update mesh from grayImage's pixels
		updateMesh();
		
		// update a few variables based on time
		float timeToChangePalettes = 10.0f;
		int paletteIndex = (int) ((ofWrap( time, 0.0f, timeToChangePalettes ) / timeToChangePalettes ) * palettes.size());
		if( palettes.size() > 0 && paletteIndex < palettes.size())  currPalette = &palettes.at(paletteIndex);
			
		linesHeight = 80.0f;
		
		lineSkip = 4; //ofMap( cos(time * 1.1f), -1.0f, 1.0f, 2, 25 );
		
		// if we click, wait a bit until we auto orbit the camera
		if( (time - lastClickTime) > 4.0 )
		{
			float orbitLong = ofMap( ofNoise(time*0.2f), 0.0f, 1.0f, -50.0f, 50.0f ) ;
			float orbitLat = ofMap( ofNoise( (time+111.0f)*0.3f), 0.0f, 1.0f, 0.0f, -100.0f ) ;
			float orbitRadius = ofMap( ofNoise( (time-123.0f)*0.45f), 0.0f, 1.0f, 100.0f, 250.0f ) ;
			camera.orbit(orbitLong, orbitLat, orbitRadius );
		}
		
		fbo.begin();
			ofClear(0, 0, 0, 0); //clear our Fbo memory
			ofEnableDepthTest(); //enable 3d
				camera.begin(); //start our camera viewpoint
					ofTranslate( 
								(grayImage.getWidth() * -0.5f) * imageToSpaceScaling.x, //move x
								0.0f,													//move y
								(grayImage.getHeight() * -0.5f) * imageToSpaceScaling.z //move z
								);
			
					ofSetColor( ofColor::white );	//start with a white mesh
					colorFromHeightShader.begin();	//begin our shader
						if( currPalette != NULL )	//make sure we have a palette
						{
							//we pass our palette to the shader
							colorFromHeightShader.setUniformTexture( "u_paletteSampler", currPalette->getTextureReference(), 1 ); 
						}
						//we pass our linesHeight to the shader
						colorFromHeightShader.setUniform1f("u_maxHeight", linesHeight );
		
						//we draw our mesh (currently in OF_PRIMITIVE_LINES mode)
						mesh.draw();
					colorFromHeightShader.end();	//stop our shader operation
				camera.end();						//end our camera view
			ofDisableDepthTest();					//ending 3d
		fbo.end();									//stop drawing inside the fbo
	}
}
void Landscape::draw( )
{
    ofPushStyle() ;
    ofPushMatrix() ;
    
   
        ofTranslate( 0 , ofGetHeight() / 2 ) ;
        ofTranslate( offset.x , offset.y , offset.z ) ;
    
        ofVec2f prevPoint = ofVec2f( 0 , 0 ) ;
    
        float segmentsSpacing = ( ofGetWidth() / ( float ) segments ) ;
    
        float landscapeFactor = 1.0f / (float) (segments/2.0f) ;
        float midPoint = segments / 2 ;
    
        ofVec2f p1 = ofVec2f ( 0  , 0 ) ;
        ofVec2f p2 = ofVec2f ( ofGetWidth() , 0 ) ;
        ofVec2f p3 = ofVec2f ( ofGetWidth() , ofGetHeight( )) ;
        ofVec2f p4 = ofVec2f ( 0 , ofGetHeight() ) ;
    
        ofEnableAlphaBlending() ;
        for ( int c = 0 ; c < copies ; c++ )
        {
            float lastZOffset = 0.0f  ;
            float lastHeightFactor = 0.0f ;
            float lastNormalZ = 0.0f ;
            
            float zOffset = zSpacing * c ;
            float normalZ = (float) c / (float) copies ;
            
            ofColor _lerp = startColor ;
            _lerp.lerp( endColor,  (float)c / copies ) ;
            
            _lerp.a = ( 1.0f - normalZ ) * 255.0f ;
            ofSetColor( _lerp ) ;
            ofTranslate( 0 , 0, zOffset ) ;

            ofSetLineWidth( 4 ) ; 
            ofLine( p1 , p2 ) ;
            ofLine( p2 , p3 ) ;
            ofLine( p3 , p4 ) ;
            ofLine( p4 , p1 ) ;
            
            ofLine ( p1.x , p1.y , 0 , p1.x , p1.y , zSpacing * 4.0f ) ;
            ofLine ( p2.x , p2.y , 0 , p2.x , p2.y , zSpacing * 4.0f ) ;
            ofLine ( p3.x , p3.y , 0 , p3.x , p3.y , zSpacing * 4.0f ) ;
            ofLine ( p4.x , p4.y , 0 , p4.x , p4.y , zSpacing * 4.0f ) ;
            
            lastZOffset = zOffset ;
            /*
            for ( int r = 0 ; r < segments ; r++ )
            {
                ofColor _lerp = startColor ;
                _lerp.lerp( endColor,  (float)c / copies ) ;
                
                
                float diff = midPoint - r ;
                diff = midPoint - abs(diff) ;
                if ( diff < 0 )
                    diff *= -1 ;
                float heightFactor = diff  * landscapeFactor ; // * landscapeFactor ;
                ofPushMatrix() ;
                    
                float zOffset = zSpacing * c ;
                float normalZ = (float) c / (float) copies ;
                
                _lerp.a = ( 1.0f - normalZ ) * 255.0f ;
                ofSetColor( _lerp ) ;
                ofTranslate( 0 , 0, zOffset ) ;
                    
                    ofVec2f point = ofVec2f ( (float)r * segmentsSpacing , ( ofNoise( ofGetElapsedTimef() * landscapeTimeFactor + r ) + 0.1 )  ) ;
                     // ofNoise( ofGetElapsedTimef() + r ) * ( landscapeHeight ) ;
                    if ( r != 0 )
                    {
                        
                        
                        float _diff = midPoint - (r-1) ;
                        _diff = midPoint - abs(_diff) ;
                        if ( _diff < 0 )
                            _diff *= -1 ;
                        float _heightFactor = _diff  * landscapeFactor ; // * landscapeFactor ;
                        
                        ofVec2f pointAhead = point ;
                        point.y *= ( heightFactor ) * landscapeHeight * (normalZ)  ;
                        pointAhead.y *= ( _heightFactor )  * landscapeHeight * (lastNormalZ)  ;
                        ofPushMatrix() ;
                        ofLine( prevPoint , point ) ;
                        ofLine( point.x , point.y , 0 , pointAhead.x , pointAhead.y , -zSpacing ) ;
                        
                        ofPopMatrix() ;
                    }
                    
                lastNormalZ = normalZ ; 
                    
                ofPopMatrix() ; 
                
                
                
                
                prevPoint = point ;
                lastHeightFactor = heightFactor ;
                lastZOffset = zOffset ; 
            }*/
        }
        
    
    ofPopMatrix() ;
    ofPopStyle() ; 
}
//-------------------------------------------
void ofxAssimpModelLoader::draw(ofPolyRenderMode renderType)
{
    if(scene){

        ofPushStyle();

#ifndef TARGET_OPENGLES
        glPushAttrib(GL_ALL_ATTRIB_BITS);
        glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
        glPolygonMode(GL_FRONT_AND_BACK, ofGetGLPolyMode(renderType));
#endif
        glEnable(GL_NORMALIZE);

        ofPushMatrix();

        ofTranslate(pos);

        ofRotate(180, 0, 0, 1);
        ofTranslate(-scene_center.x, -scene_center.y, scene_center.z);

        if(normalizeScale)
        {
            ofScale(normalizedScale , normalizedScale, normalizedScale);
        }

        for(int i = 0; i < (int)rotAngle.size(); i++){
            ofRotate(rotAngle[i], rotAxis[i].x, rotAxis[i].y, rotAxis[i].z);
        }

        ofScale(scale.x, scale.y, scale.z);


        if(getAnimationCount())
        {
            updateGLResources();
        }

		for(int i = 0; i < (int)modelMeshes.size(); i++){
			ofxAssimpMeshHelper & meshHelper = modelMeshes.at(i);

			// Texture Binding
			if(bUsingTextures && meshHelper.texture.isAllocated()){
				meshHelper.texture.bind();
			}

			if(bUsingMaterials){
				meshHelper.material.begin();
			}


			// Culling
			if(meshHelper.twoSided)
				glEnable(GL_CULL_FACE);
			else
				glDisable(GL_CULL_FACE);

			ofEnableBlendMode(meshHelper.blendMode);
#ifndef TARGET_OPENGLES
		    meshHelper.vbo.drawElements(GL_TRIANGLES,meshHelper.indices.size());
#else
		    switch(renderType){
		    case OF_MESH_FILL:
		    	meshHelper.vbo.drawElements(GL_TRIANGLES,meshHelper.indices.size());
		    	break;
		    case OF_MESH_WIREFRAME:
		    	meshHelper.vbo.drawElements(GL_LINES,meshHelper.indices.size());
		    	break;
		    case OF_MESH_POINTS:
		    	meshHelper.vbo.drawElements(GL_POINTS,meshHelper.indices.size());
		    	break;
		    }
#endif

			// Texture Binding
			if(bUsingTextures && meshHelper.texture.bAllocated()){
				meshHelper.texture.unbind();
			}

			if(bUsingMaterials){
				meshHelper.material.end();
			}
		}

        ofPopMatrix();

#ifndef TARGET_OPENGLES
        glPopClientAttrib();
        glPopAttrib();
#endif
        ofPopStyle();
    }
}
float ofxFontStash2::drawLines(const vector<StyledLine> &lines, float x, float y, bool debug){

	// if possible get rid of this translate:
	#ifndef GL_VERSION_3
	ofPushMatrix();
	ofTranslate(x, y);
	#endif

	ofVec2f offset;
	#ifdef GL_VERSION_3
	offset.x = x * pixelDensity;
	offset.y = y * pixelDensity;
	#endif

//	TS_START("count words");
//	int nDrawnWords;
//	for(int i = 0; i < lines.size(); i++){
//		for(int j = 0; j < lines[i].elements.size(); j++){
//			nDrawnWords ++;
//		}
//	}
//	TS_STOP("count words");

	//debug line heights!
	if(debug){
		TS_START("draw line Heights");
		ofSetColor(0,255,0,32);
		float yy = 0;
		for( const StyledLine &line : lines ){
			ofDrawLine(offset.x + 0.5f, offset.y + yy + 0.5f, offset.x + line.lineW + 0.5f, offset.y + yy + 0.5f);
			yy += line.lineH;
		}
		TS_STOP("draw line Heights");
	}

	ofxFontStashStyle drawStyle;
	drawStyle.fontSize = -1;

	float offY = 0.0f; // only track for return value
	TS_START("draw all lines");

	FONT_STASH_PRE_DRAW;

	#ifndef GL_VERSION_3
	if (pixelDensity != 1.0f){ //hmmmm
		ofScale(1.0f/pixelDensity, 1.0f/pixelDensity);
	}
	#endif


	for(int i = 0; i < lines.size(); i++){
		y += lines[i].lineH;
		
		for(int j = 0; j < lines[i].elements.size(); j++){

			if(lines[i].elements[j].content.type != SEPARATOR_INVISIBLE ){ //no need to draw the invisible chars

				const StyledLine &l = lines[i];
				const LineElement &el = l.elements[j];
				const string & texttt = el.content.styledText.text;

				if (el.content.styledText.style.valid &&
					drawStyle != el.content.styledText.style ){

					drawStyle = el.content.styledText.style;
					TS_START_ACC("applyStyle");
					applyStyle(drawStyle);
					TS_STOP_ACC("applyStyle");
				}
				//lines[i].elements[j].area.y += lines[i].lineH -lines[0].lineH;

				//TS_START_ACC("fonsDrawText");
				fonsDrawText(fs,
							 el.x * pixelDensity + offset.x,
							 (el.baseLineY + l.lineH - lines[0].lineH) * pixelDensity + offset.y,
							 texttt.c_str(),
							 NULL);
				//TS_STOP_ACC("fonsDrawText");

				//debug rects
				if(debug){
					//TS_START_ACC("debug rects");
					if(el.content.type == BLOCK_WORD) ofSetColor(70 * i, 255 - 70 * i, 0, 200);
					else ofSetColor(50 * i,255 - 50 * i, 0, 100);
					const ofRectangle &r = el.area;
					ofDrawRectangle(pixelDensity * r.x, pixelDensity * r.y, pixelDensity * r.width, pixelDensity * r.height);
					ofFill();
				}
			}
		}
	}
	TS_STOP("draw all lines");

	#ifndef GL_VERSION_3
	ofPopMatrix();
	#endif
	FONT_STASH_POST_DRAW;

	if(debug){
		ofSetColor(255);
	}
	return offY;
}
Exemple #23
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    // draw the bug holes
    for(unsigned int i=0; i<holes.size(); i++) {
        ofSetColor(100);
		ofDrawCircle(holes[i], 10);
        ofSetColor(40);
		ofDrawCircle(holes[i], 7);
    }
    
    for(unsigned int i=0; i<bugs.size(); i++) {
        bugs[i].draw();
    }
    
    // draw the bullets
    for(unsigned int i=0; i<bullets.size(); i++) {
        bullets[i].draw();
    }
    
    
    
    // game stats
    ofSetColor(10);
    ofDrawBitmapString("Bullets "+ofToString(bullets.size())+"\nBugs Killed: "+ofToString(bugsKilled), 20, 20);
    
    
    // gun
    ofVec2f gunPos(ofGetWidth()/2, ofGetHeight()-20);
    ofVec2f mousePos(ofGetMouseX(), ofGetMouseY());
    
    // get the vector from the mouse to gun
    ofVec2f vec = mousePos - gunPos;
    vec.normalize();
    vec *= 100;
    
    // get the angle of the vector for rotating the rect
    float angle = ofRadToDeg(atan2(vec.y, vec.x)) - 90;
    
    ofPushMatrix();
    ofTranslate(gunPos.x, gunPos.y);    
    ofRotateZ(angle);
    
    ofFill();
    ofSetColor(10);
    ofDrawRectangle(-10, 0, 20, 100);
    
    float bulletPct = ofMap(bullets.size(), 0, maxBullets, 0.0, 100.0);
    ofSetColor(100);
    ofDrawRectangle(-10, 0, 20, bulletPct);
    
    ofSetColor(100);
    ofDrawRectangle(-10, 90, 20, 10);
    
    if(bFire) {
        ofSetColor(220, 0, 0);
        ofDrawRectangle(-10, 97, 20, 3);
    }
    ofPopMatrix();
    
    ofSetColor(255);
	ofDrawCircle(gunPos.x, gunPos.y, 2);
    
}
Exemple #24
0
//--------------------------------------------------------------
void testApp::draw(){
	if( oneShot ){
		ofBeginSaveScreenAsPDF("screenshot-"+ofGetTimestampString()+".pdf", false);
	}
	
	ofSetColor(54);
	ofDrawBitmapString("PDF OUTPUT EXAMPLE", 32, 32);
	if( pdfRendering ){
		ofDrawBitmapString("press r to stop pdf multipage rendering", 32, 92);
	}else{	
		ofDrawBitmapString("press r to start pdf multipage rendering\npress s to save a single screenshot as pdf to disk", 32, 92);
	}
		
		
	ofFill();		
	ofSetColor(54,54,54);
	ofDrawBitmapString("TTF Font embdedded into pdf as vector shapes", 32, 460);
	
	if( oneShot || pdfRendering ){
		font.drawStringAsShapes("Current Frame: ",  32, 500);
		ofSetColor(245, 58, 135);
		font.drawStringAsShapes( ofToString(ofGetFrameNum()), 32 + font.getStringBoundingBox("Current Frame: ", 0, 0).width + 9, 500);
	}else{
		font.drawString("Current Frame: ",  32, 500);	
		ofSetColor(245, 58, 135);		
		font.drawString( ofToString(ofGetFrameNum()), 32 + font.getStringBoundingBox("Current Frame: ", 0, 0).width + 9, 500);		
	}
	
	
	ofSetColor(54,54,54);
	ofDrawBitmapString("Images can also be embedded into pdf", 32, dropZoneRects[0].y - 18);
	
	ofSetRectMode(OF_RECTMODE_CORNER);
	ofNoFill();
	for(int k = 0; k < dropZoneRects.size(); k++){
		ofSetColor(54,54,54);
		ofRect(dropZoneRects[k]);
		ofSetColor(245, 58, 135);		
		ofDrawBitmapString("drop images here", dropZoneRects[k].getCenter().x - 70, dropZoneRects[k].getCenter().y);
	}

	ofSetColor(255);
	for(int j = 0; j < images.size(); j ++){
		if( images[j].width > 0 ){
			
			float tw = 300;
			float th = 200;
			
			if( images[j].getWidth() / images[j].getHeight() < tw / th ){
				tw = th * ( images[j].getWidth() / images[j].getHeight() );
			}else{
				th = tw * ( images[j].getHeight() / images[j].getWidth() );			
			}
			
			images[j].draw(dropZoneRects[j].x, dropZoneRects[j].y, tw, th);
			
		}
	}
	
	//lets draw a box with a trail
	ofSetColor(245, 58, 135);
	
	ofRectangle boxBounds(32, 500, ofGetWidth()-32, 250);
	
	//lets get a noise value based on the current frame
	float noiseX = ofNoise(float(ofGetFrameNum())/600.f, 200.0f);
	float noiseY = ofNoise(float(ofGetFrameNum())/800.f, -900.0f);

	ofNoFill();
	ofBeginShape();
	ofVertices(boxTrail);
	ofEndShape(false);
	
	ofFill();
	ofSetRectMode(OF_RECTMODE_CENTER);

	ofPushMatrix();
		float x = ofMap( noiseX, 0, 1, boxBounds.x, boxBounds.x + boxBounds.width, true);
		float y = ofMap( noiseY, 0, 1, boxBounds.y, boxBounds.y + boxBounds.height, true);

		ofTranslate(x, y, 0);
		ofRotate(angle);
		ofRect(0, 0, 30, 30);
	ofPopMatrix();	
	
	if( boxTrail.size() == 0 || ( boxTrail.back() - ofPoint(x, y) ).length() > 1.5 ){
		boxTrail.push_back(ofPoint(x, y));
	}
	
	if(boxTrail.size() > 800 ){
		boxTrail.erase(boxTrail.begin(), boxTrail.begin()+1);
	}
	
	if( oneShot ){
		ofEndSaveScreenAsPDF();
		oneShot = false;
	}	
}
/**
 デバッグ表示
 */
void testApp::debugDraw()
{
    if (!bDrawing) {
        ofPushStyle();
        ofEnableAlphaBlending();
        stringstream str;
        
        ofSetLineWidth(1);
        ofSetColor(0, 255, 0, 255);
        ofNoFill();
        
        ofSetColor(255, 255, 0, 255);
        ofNoFill();
        
        //波形を描画
        ofSetColor(127, 127, 255);
        ofSetLineWidth(1);
        ofPushMatrix();
        ofTranslate(ofGetWidth()-266-110-210, 10);
        ofPoint tPos = ofPoint(0, 100/2);
        for (int i=0; i < mEdgeBits.size(); i++){
            float j = ofMap(i, 0, mEdgeBits.size()-1, 0, 200);
            ofPoint pos = ofPoint(j, mEdgeBits[i] * 50 + (100/2));
            ofLine(tPos, pos);
            tPos.set(pos);
            if (i == mEdgeBits.size()-1) {
                ofLine(tPos.x, tPos.y, 200, 100/2);
            }
        }
        ofSetColor(255);
        ofRect(0, 0, 200, 100);
        ofPopMatrix();
        
        str << "display width   : " << ofGetWidth() << endl
        << "display height  : " << ofGetHeight() << endl
        << "Points Interval : " << mInterval << endl
        << "Seq num : " << mSeqCurrentNum << endl
        ;
        if (bCircleMode) str << "Circle Mode ON" << endl;
        ofSetColor(255);
        ofDrawBitmapString(str.str(), 10, 15);
        
        ofDisableAlphaBlending();
        ofPopStyle();
        
        //---------
        // 入力音の波形を描画
        //----------
        //draw wave
        ofPushStyle();
        ofNoFill();
        ofPushMatrix();
        ofTranslate(ofGetWidth()-266, 10, 0);
        
        ofSetColor(225);
        ofDrawBitmapString("Audio Input", 4, 18);
        
        ofSetLineWidth(1);
        ofRect(0, 0, 256, 100);
        
        ofSetColor(180);
        ofSetLineWidth(2);
        
        ofBeginShape();
        for (int i = 0; i < mLefts.size(); i++){
            ofVertex(i, 50 -mLefts[i]*180.0f);
        }
        ofEndShape(false);
        
        ofPopMatrix();
        ofPopStyle();
        ofNoFill();
        
        // draw the average volume:
        ofPushStyle();
        ofPushMatrix();
        ofTranslate(ofGetWidth()-266-110, 10, 0);
        
        ofSetColor(225);
        ofDrawBitmapString("Peak: " + ofToString(mScaledVol * 100.0, 0), 4, 18);
        ofRect(0, 0, 100, 100);
        
        ofSetColor(180);
        ofFill();
        ofCircle(50, 50, mScaledVol * 100.0f);
        
        ofPopMatrix();
        ofPopStyle();
        
    }
}
Exemple #26
0
void UI2DGrid::draw(){

    bool bFlip = true;
    
    if (bEnable){
        ofPushMatrix();
        ofTranslate(ofGetWidth()*0.5,ofGetHeight()*0.5);
        ofPushStyle();
        ofDisableLighting();
        cross.draw();

        ofTranslate(0, 0, 0.1);
        subLines.draw();

        ofTranslate(0, 0, 0.1);
        Grid::draw();

        if (bFlip){
            ofTranslate(0, 0, 0.1);
            ofSetColor(fontColor);
            for(int i = 0; i <= cols-1; i++){
                int value = i+(int)(cols*refNumOffset);
                string number = ofToString( (value<0)?value+1:value );
                ofRectangle box = font.getStringBoundingBox( number ,0,0);
                ofPoint pos = offset + ofPoint(x+i*resolution+resolution*0.5,y+(rows*refCol)*resolution) - box.getCenter()*ofPoint(1,-1);
                pos *= ofPoint(1,-1);
                font.drawStringAsShapes(number,pos.x,pos.y);
            }
            
            int A = char('A');
            for(int i = 0; i <= rows-1; i++){
                string letter = ofToString(char(A+(rows-1-i)));
                ofRectangle box = font.getStringBoundingBox( letter , 0,0);
                ofPoint pos = offset + ofPoint(x+(cols*refRow)*resolution,y+i*resolution+resolution*0.5) - box.getCenter()*ofPoint(1,-1);
                pos *= ofPoint(1,-1);
                font.drawStringAsShapes(letter,pos.x, pos.y);
            }
        } else {
            ofTranslate(0, 0, 0.1);
            ofSetColor(fontColor);
            for(int i = 0; i <= cols-1; i++){
                int value = i+(int)(cols*refNumOffset);
                string number = ofToString(  (value<0)?value+1:value );
                ofRectangle box = font.getStringBoundingBox( number ,0,0);
                ofPoint pos = offset + ofPoint(x+i*resolution+resolution*0.5,y+(rows*refCol)*resolution) - box.getCenter();
                pos *= ofPoint(1,-1);
                font.drawStringAsShapes(number,pos.x,pos.y);
            }
            
            int A = char('A');
            for(int i = 0; i <= rows-1; i++){
                string letter = ofToString(char(A+i));
                ofRectangle box = font.getStringBoundingBox( letter , 0,0);
                ofPoint pos = offset + ofPoint(x+(cols*refRow)*resolution,y+i*resolution+resolution*0.5) - box.getCenter();
                pos *= ofPoint(1,-1);
                font.drawStringAsShapes(letter,pos.x, pos.y);
            }
        }

        ofTranslate(0, 0, 0.1);
        boxes.draw();
        ofEnableLighting();
        ofPopStyle();
        ofPopMatrix();
    }
}
void ofxControlPanel::draw(){
    if( hidden ) return;
	
    ofPushStyle();
    ofEnableAlphaBlending();
	
	float panelH = boundingBox.height;
	if( minimize ){
		panelH = 20;
	}
	
	glPushMatrix();
	glTranslatef(boundingBox.x, boundingBox.y, 0);
	//draw the background
	ofFill();
	glColor4fv(bgColor.getColorF());
	ofRect(0, 0, boundingBox.width, panelH);
	
	//draw the outline
	if( bDrawOutline )
	{
		ofNoFill();
		glColor4fv(outlineColor.getColorF());
		ofRect(0, 0, boundingBox.width, panelH);
		ofLine(0, 20, boundingBox.width, 20);
	}
	glPopMatrix();
	
	
	if(bDrawHeader)
	{	
		
		
		
		ofPushStyle();
		ofFill();
		
		if( saveDown )glColor4fv(fgColor.getSelectedColorF());
		else glColor4fv(fgColor.getColorF());
		
		ofRect(saveButton.x, saveButton.y, saveButton.width,saveButton.height);
		ofSetColor(255, 255, 255);
		ofDrawBitmapString("save", saveButton.x + 3, saveButton.y + saveButton.height -3);
        ofPopStyle();
		
		
        ofPushStyle();
		ofFill();
		
		if( restoreDown )glColor4fv(fgColor.getSelectedColorF());
		else glColor4fv(fgColor.getColorF());
		
		ofRect(restoreButton.x, restoreButton.y, restoreButton.width,restoreButton.height);
		ofSetColor(255, 255, 255);
		ofDrawBitmapString("restore", restoreButton.x + 3, restoreButton.y + restoreButton.height -3);
        ofPopStyle();
		
		
        ofPushMatrix();
		ofTranslate(2,0,0);
		glColor4fv(textColor.getColorF());
		guiBaseObject::renderText();
        ofPopMatrix();
		
	}
	
	if( !minimize ){
		
		//don't let gui elements go out of their panels
		glEnable(GL_SCISSOR_TEST);
		glScissor(boundingBox.x, ofGetHeight() - ( boundingBox.y + boundingBox.height - (-2 + topSpacing) ), boundingBox.width - borderWidth , boundingBox.height);
		
		if(bShowTabs)
		{
			for(int i = 0; i < panelTabs.size(); i++)
			{
				if( i == selectedPanel){
					ofPushStyle();
					ofFill();
					glColor4fv(fgColor.getSelectedColorF());
					ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height);
					glColor4fv(outlineColor.getColorF());
					ofPopStyle();
				}
				glColor4fv(outlineColor.getColorF());
				ofNoFill();
				ofRect(panelTabs[i].x, panelTabs[i].y, panelTabs[i].width, panelTabs[i].height);
			}
		}
		glPushMatrix();
		glTranslatef(hitArea.x, hitArea.y, 0);
		for(int i = 0; i < panels.size(); i++){
			if( i == selectedPanel )panels[i]->render();
		}
		glPopMatrix();
		
		glDisable(GL_SCISSOR_TEST);
	}
	
	//--- header with save,restore, title, minimize etc.
	ofNoFill();
	glColor4fv(outlineColor.getColorF());
	ofRect(minimizeButton.x, minimizeButton.y, minimizeButton.width, minimizeButton.height);
	
    ofPopStyle();
}
Exemple #28
0
//--------------------------------------------------------------
void ofApp::drawHandOverlay(){

	// contourFinder.draw();

	for (int i = 0; i < contourFinder.size(); ++i)
	{
		ofRectangle bounds = ofxCv::toOf(contourFinder.getBoundingRect(i));

		ofPushStyle();
		ofSetColor(0,0,0);
		ofBeginShape();
			for (int j = 0; j < contourFinder.getPolyline(i).size(); ++j)
			{
				ofVertex(contourFinder.getPolyline(i)[j]);
			}
		ofEndShape();

		// ofPushStyle();
		// 	ofSetColor(255,255,255);
		// 	if(contourFinder.ends[i].size() == 2) {
		// 		ofFill();
		// 		ofCircle(contourFinder.ends[i][0], 3);
		// 		ofCircle(contourFinder.ends[i][1], 3);
		// 	}
		// 	if(true) {
		// 		ofCircle(contourFinder.tips[i], 3);
		// 		ofNoFill();
		// 		ofCircle(contourFinder.tips[i], contourFinder.MAX_HAND_SIZE);
		// 		ofCircle(contourFinder.tips[i], contourFinder.MIN_HAND_SIZE);
		// 	}
		// 	if(contourFinder.wrists[i].size() == 2) {
		// 		ofCircle(contourFinder.wrists[i][0], contourFinder.MAX_WRIST_WIDTH);
		// 		ofFill();
		// 		ofCircle(contourFinder.wrists[i][0], 3);
		// 		ofCircle(contourFinder.wrists[i][1], 3);
		// 	}
		// ofPopStyle();

		if(contourFinder.handFound[i]) {

			ofPolyline hand = contourFinder.hands[i].getSmoothed(lineSmoothing);
			ofPoint center = contourFinder.oldCentroids[i];
			ofPoint tip = contourFinder.oldTips[i];

			ofPushMatrix();

				ofTranslate(center.x*(1-handScaleUp), center.y * (1 - handScaleUp ));
				ofScale(handScaleUp, handScaleUp);

				ofSetColor(0,0,0);
				ofBeginShape();
					for (int j = 0; j < hand.size(); ++j)
					{
						ofVertex(hand[j].x, hand[j].y);
					}
				ofEndShape();

			ofPopStyle();
			ofPopMatrix();

			ofPushMatrix();
			ofPushStyle();
				ofSetColor(0,0,0);

				string palmText;
				for (int j = 0; j < riverRegions.size(); ++j)
				{
					if( riverRegions[j].inside(center) ) {
						palmText = riverNames[j];
					}
				}
				palmText = ofToString(palmText);
				ofTranslate(center.x, center.y);

				float hypotenuse = sqrt( pow(center.x - tip.x, 2) + pow(center.y - tip.y, 2) );
				float angle =  ofRadToDeg( asin( (tip.y - center.y) / hypotenuse ));
				if(tip.x < center.x) angle *= -1;
				ofPoint exit = contourFinder.ends[i][0];
				if (exit.y <= contourFinder.bounds[1] + 5) angle += 180;
				if ( (exit.x <= contourFinder.bounds[0] + 5 or exit.x >= contourFinder.bounds[2] - 5 ) and tip.y < center.y ) 
					angle += 180;
				ofRotateZ(angle);

				ofPoint textCenter = myfont.getStringBoundingBox(palmText, 0, 0).getCenter();
				ofTranslate(-textCenter.x, -textCenter.y);

				ofSetColor(255,255,255);
				myfont.drawString(palmText, 0, 0);

			ofPopStyle();
			ofPopMatrix();

		}
	}

}
//--------------------------------------------------------------
void ofApp::draw(){

    ofBackground(0,0,0);
    ofSetColor(255,255,255);

    if(resolPantalla == 1 ){
        pantallaFBOKaleidoscopeA.begin();
    } else if (resolPantalla == 2 ){
        pantallaFBOKaleidoscopeB.begin();
    }else if (resolPantalla == 4 ){
        pantallaFBOKaleidoscopeC.begin();
    }
    ofClear(0,0,0,0);
    ofBackground(0,0,0);
    ofSetColor(255,255,255);
        ofEnableAlphaBlending();
        pingPong.dst->draw(0,0);

    if(resolPantalla == 1 ){
        pantallaFBOKaleidoscopeA.end();
    } else if (resolPantalla == 2 ){
        pantallaFBOKaleidoscopeB.end();
    }else if (resolPantalla == 4 ){
        pantallaFBOKaleidoscopeC.end();
    }

    if (bKaleidoscope == false){
        if(resolPantalla == 1 ){
            pantallaFBOKaleidoscopeA.draw(0,ofGetWindowHeight(),ofGetWindowWidth(),-ofGetWindowHeight());
        } else if (resolPantalla == 2 ){
            pantallaFBOKaleidoscopeB.draw(0,ofGetWindowHeight(),ofGetWindowWidth(),-ofGetWindowHeight());
        }else if (resolPantalla == 4 ){
            pantallaFBOKaleidoscopeC.draw(0,ofGetWindowHeight(),ofGetWindowWidth(),-ofGetWindowHeight());
        }

    } else {
        float distCentro = ofGetWindowHeight()/2;
        float nSlices = KaleidoscopeSlices*2;
        float angleTemp = 360/nSlices;
        float catOpuesto = tan(angleTemp*(PI/180))*distCentro;
        if(resolPantalla == 1 ){
            pantallaFBOKaleidoscopeA.getTextureReference().bind();
        } else if (resolPantalla == 2 ){
            pantallaFBOKaleidoscopeB.getTextureReference().bind();
        }else if (resolPantalla == 4 ){
            pantallaFBOKaleidoscopeC.getTextureReference().bind();
        }
            ofPushMatrix();
                ofTranslate((ofGetWindowWidth())/2,(ofGetWindowHeight())/2);
                for (int slice = 0; slice  < nSlices/2; slice++){
                    ofPushMatrix();
                    ofRotateZ(slice*angleTemp*2);
                        glBegin( GL_TRIANGLES );
                            glTexCoord2d( ((resolVert/resolPantalla)/2),                 ((resolVert/resolPantalla)/2)            ); glVertex2d(           0,           0);
                            glTexCoord2d( ((resolVert/resolPantalla)/2)+catOpuesto/resolPantalla+80/(float)resolPantalla , ((resolVert/resolPantalla)/2)+((float)distCentro/(float)resolPantalla) ); glVertex2d(  catOpuesto, -distCentro);
                            glTexCoord2d( ((resolVert/resolPantalla)/2)-catOpuesto/resolPantalla+80/(float)resolPantalla , ((resolVert/resolPantalla)/2)+((float)distCentro/(float)resolPantalla) ); glVertex2d( -catOpuesto, -distCentro);
                        glEnd();
                    ofPopMatrix();
                }
            ofPopMatrix();
        if(resolPantalla == 1 ){
            pantallaFBOKaleidoscopeA.getTextureReference().unbind();
        } else if (resolPantalla == 2 ){
            pantallaFBOKaleidoscopeB.getTextureReference().unbind();
        }else if (resolPantalla == 4 ){
            pantallaFBOKaleidoscopeC.getTextureReference().unbind();
        }
        ofSetColor(255,255,255);
        ofPushMatrix();
            ofTranslate(ofGetWindowWidth()/2,ofGetWindowHeight()/2);
            for (int slice = 0; slice  < nSlices/2; slice++){
                ofPushMatrix();
                ofRotateZ(slice*angleTemp*2);
                ofLine(  catOpuesto, -distCentro, -catOpuesto, -distCentro);
                ofPopMatrix();
            }
        ofPopMatrix();
    }

    
    if (show_fps == true){
        ofFill();
        ofSetColor(0,0,10,200);
        ofRect(0,0,300,190);
        ofSetColor(180,180,180);
        ofNoFill();
        ofRect(0,0,300,190);
        ofSetColor(255,255,255);
        ofDrawBitmapString("FPS: "+ofToString(ofGetFrameRate(), 2), 10, 1*15);
        ofDrawBitmapString("Some shader use your mouse movement!", 10, 2*15);
        ofDrawBitmapString("'f' Toggle Fullscreen.", 10, 3*15);
        ofDrawBitmapString("'s' Toggle Show INFO.", 10, 4*15);
        ofDrawBitmapString("'r' Change Resolution Divider: " +ofToString(resolPantalla), 10, 5*15);
        if( bKaleidoscope == true){
            ofDrawBitmapString("'k' Toggle Kaleidoscope: ON!", 10, 6*15);
            ofDrawBitmapString("'1' y '2' Kaleidoscope Slices: " +ofToString(KaleidoscopeSlices), 10, 7*15);
        } else {
            ofDrawBitmapString("'k' Toggle Kaleidoscope: OFF", 10, 6*15);
            ofSetColor(100,100,100);
            ofDrawBitmapString("'1' y '2' Kaleidoscope Slices: " +ofToString(KaleidoscopeSlices), 10, 7*15);
        }
        ofSetColor(255,255,255);
        ofDrawBitmapString("'Up' y 'Down' Cambia Shader", 10, 8*15);
        ofDrawBitmapString("Shader "+ofToString(nFrag+1)+ " de " +ofToString(frags.size()), 10, 9*15);
        if( bFine == true){
            ofSetColor(0,120,255);
            ofDrawBitmapString(ofToString(fragNames[nFrag]), 10,10*15);
            ofDrawBitmapString("Shader Loaded Correctly!", 10, 11*15);
        } else {
            ofSetColor(255,0,0);
            ofDrawBitmapString(ofToString(fragNames[nFrag]), 10,10*15);
            ofDrawBitmapString("Shader Loaded Incorrectly!", 10,11*15);
        }
        ofSetColor(255,255,255);
        ofDrawBitmapString("'h' Toggle hide Cursor.", 10, 12*15);
    }
    

}
Exemple #30
0
//--------------------------------------------------------------
void ofApp::drawHelper(){
    
    easyCam.begin();
    
    if (depthTestToggle == true) {
        ofEnableDepthTest();
    }

    
    // Center sphere
    if (boolCenterSphere == true) {
        ofSetColor(0, 0, 0, 255);
        ofMesh sphere = ofMesh::sphere(20, 16, OF_PRIMITIVE_TRIANGLE_STRIP);
//        ofSetColor(255, 255, 255, 255);
        
        sphere.draw();
    }
    
    ofEnableBlendMode(OF_BLENDMODE_ADD);

    
    for (int i = 0; i < nSpheres.size(); i++) {
        
        //        long eyeX = (ofGetWindowWidth() / 3) * cos(ofGetFrameNum() * 0.0008);
        //        long eyeZ = (ofGetWindowWidth() / 2) * sin(ofGetFrameNum() * 0.0008);
        
        //        long eyeX = 0;
        //        long eyeZ = 0;
        //        long eyeY = 0;
        //        centerX = ofGetWindowWidth() / 2 + 1500;
        //        centerY = ofGetWindowHeight() / 2;
        //        centerZ = (ofGetWindowWidth() / 3) * sin(ofGetFrameNum() * 0.00008);
        //        float upX = 0;
        //        float upY = 1;
        //        float upZ = 0;
        //
        //        ofVec3f camPos;
        //        ofVec3f lookAtPos;
        //
        //        camPos = ofVec3f(centerX, centerY, centerZ);
        //        lookAtPos = ofVec3f(eyeX, eyeY, eyeZ);
        //
        //        ofVec3f upVector;
        //        upVector.set(0, 1, 0);
        //
        //        cam.setPosition(camPos);
        //        cam.lookAt(lookAtPos, upVector);
        
        //        cam.begin();
        
        
        ofPushMatrix();
        
        ofTranslate(nSpheres[i].position.x, nSpheres[i].position.y, nSpheres[i].position.z);
        
        // Rotation
//        ofRotateX(ofGetFrameNum() * nSpheres[i].velocity.x * velocityMultiplier);
//        ofRotateY(ofGetFrameNum() * nSpheres[i].velocity.y * velocityMultiplier);
//        ofRotateZ(ofGetFrameNum() * nSpheres[i].velocity.z * velocityMultiplier);
        
        
        nSpheres[i].draw();
        
        
        ofPopMatrix();

        
        //        cam.end();
    }
    
    if (depthTestToggle == true) {
        ofDisableDepthTest();
    }
    
    easyCam.end();
}