Exemplo n.º 1
0
void Uitprobeersel::draw() {

    float revealParam = 0.0;
    float winParam = -1.0;

    float flowStartTime = .1;
    float assimilateStartTime = .4;
    float burstStartTime = .8;

    if(mTimeParameter < flowStartTime) {
        revealParam = 0.0;
        winParam = -1;
    }
    else if(mTimeParameter < assimilateStartTime) {
        float t = (mTimeParameter - flowStartTime) / (assimilateStartTime - flowStartTime);
        revealParam = .5 - .5 * cos(t * M_PI);
        winParam = - 1;
    }
    else if(mTimeParameter < burstStartTime) {
        float t = (mTimeParameter - assimilateStartTime) / (burstStartTime - assimilateStartTime);
        revealParam = 1.0;
        winParam = -1 + t;
    }
    else {
        float t = (mTimeParameter - burstStartTime) / (1. - burstStartTime);
        revealParam = 1.0;
        winParam = t;
    }

    // revealParam = mTimeParameter;
    // winParam = -1;

    int maxSamples = 30;

    ofMesh quad;
    quad.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    for(int x=0; x<maxSamples; ++x) {
        for(int y=0; y<2; ++y) {
            quad.addVertex(ofVec2f(x, 0));
            quad.addTexCoord(ofVec2f(x, y));
            quad.addNormal(ofVec3f(0,1,0));
        }
    }

    float offset = 20.0 + 20.0 * revealParam + 40.0 * (1. + winParam);

    ofPushMatrix();
    ofTranslate(400,200);
    ofScale(500 / maxSamples, 1, 1);
    mShader.begin();
    mShader.setUniformTexture("uTexImage", mTexImage.getTextureReference(), 0);
    mShader.setUniform1f("uTexDimension", texDimension);

    mShader.setUniform1f("uBoundOffset", offset);
    mShader.setUniform1f("uMaxDepth", maxSamples);
    mShader.setUniform1f("uRevealParameter", revealParam);
    mShader.setUniform1f("uWinAnimParameter", winParam);

    quad.draw();
    mShader.end();
    ofPopMatrix();

    // mTexImage.draw(0,0);
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void testApp::draw(){
    jonnysMovies.draw(0, 0, ofGetWidth(), ofGetHeight());
    
    
    if (oneOn == true) {
        
        ofSetColor(255, 255, 255);
        string user = "******" + twitter[1]["user"]["screen_name"].asString() + ":";
        font.drawString(user, 10, ofGetHeight()/5 - 50);
        
        ofSetColor(0,255,255);
        string message = twitter[1]["text"].asString();
        
        float messageWidth = font.stringWidth(message);
        if (messageWidth > ofGetWidth()-10) {
            string line1 = message.substr(0, 70);
            string line2 = message.substr(71, 70);
            
            font.drawString(line1, 10, ofGetHeight()/5);
            font.drawString(line2, 10, ofGetHeight()/5+50);
        }else {
            font.drawString(message, 10, ofGetHeight()/5);
        }
        
        
        ofSetColor(255, 255, 255);
    }else if (twoOn == true) {
        
        ofSetColor(255, 255, 255);
        string user = "******" + twitter[2]["user"]["screen_name"].asString() + ":";
        font.drawString(user, 10, 2*ofGetHeight()/5 - 50);
        
        ofSetColor(255,0,255);
        string message = twitter[2]["text"].asString();
        float messageWidth = font.stringWidth(message);
        if (messageWidth > ofGetWidth()-10) {
            string line1 = message.substr(0, 70);
            string line2 = message.substr(71, 70);
            
            font.drawString(line1, 10, 2*ofGetHeight()/5);
            font.drawString(line2, 10, 2*ofGetHeight()/5+50);
        }else {
            font.drawString(message, 10, 2*ofGetHeight()/5);
        } 
        
        ofSetColor(255, 255, 255);
    }else if (threeOn == true) {
        
        ofSetColor(255, 255, 255);
        string user = "******" + twitter[3]["user"]["screen_name"].asString() + ":";
        font.drawString(user, 10, 3*ofGetHeight()/5 - 50);
        
        ofSetColor(255,255,0);
        string message = twitter[3]["text"].asString();
        float messageWidth = font.stringWidth(message);
        if (messageWidth > ofGetWidth()-10) {
            string line1 = message.substr(0, 70);
            string line2 = message.substr(71, 70);
            
            font.drawString(line1, 10, 3*ofGetHeight()/5);
            font.drawString(line2, 10, 3*ofGetHeight()/5+50);
        }else {
            font.drawString(message, 10, 3*ofGetHeight()/5);
        }
        
        ofSetColor(255, 255, 255);
    }else if (fourOn == true) {
        
        ofSetColor(255, 255, 255);
        string user = "******" + twitter[4]["user"]["screen_name"].asString() + ":";
        font.drawString(user, 10, 4*ofGetHeight()/5 - 50);
        
        ofSetColor(200,200,200);
        string message = twitter[4]["text"].asString();
        float messageWidth = font.stringWidth(message);
        if (messageWidth > ofGetWidth()-10) {
            string line1 = message.substr(0, 70);
            string line2 = message.substr(71, 70);
            
            font.drawString(line1, 10, 4*ofGetHeight()/5);
            font.drawString(line2, 10, 4*ofGetHeight()/5+50);
        }else {
            font.drawString(message, 10, 4*ofGetHeight()/5);
        } 
        
        ofSetColor(255, 255, 255);
    }else if (sliderOn == true){
        ofSetColor(0, 0, 0);
        string feed = "#FEEDmixer";
        float mappedSize = ofMap(stringSize, 0, 127, 1, 5);
        
        float feedWidth = font.stringWidth(feed)/2;
        float feedHeight = font.stringHeight(feed)/2;
        
        float screenWidth = ofGetWidth()/2;
        float screenHeight = ofGetHeight()/2;
        
        float x = screenWidth-feedWidth;
        float y = screenHeight-feedHeight;
        
        ofSetRectMode(OF_RECTMODE_CENTER);
        ofPushMatrix();
            
            
            ofTranslate(screenWidth,screenHeight);
            ofScale(mappedSize, mappedSize);
            font.drawString(feed, 0-feedWidth, 0);
        
        ofPopMatrix();
        ofSetRectMode(OF_RECTMODE_CORNER);
        
        
        ofSetColor(255, 255, 255);
    }



}
Exemplo n.º 3
0
//--------------------------------------------------------------
void testApp::drawGeometry(){
	
    float pointAlpha = timeline.getValue("Point Alpha");
	float pointSize = timeline.getValue("Point Size");
    float wireAlpha = timeline.getValue("Wireframe Alpha");
	float thickness = timeline.getValue("Wireframe Thickness");
	
	float particleAlpha = timeline.getValue("particle fade");
//	float particleSize = timeline.getValue("particle size");

	
	glEnable(GL_LINE_SMOOTH);
	glEnable(GL_POINT_SMOOTH);
	
	player.getVideoPlayer()->getTextureReference().bind();
	
	ofPushMatrix();
	ofPushStyle();
	ofScale(1,-1,1);
	
	ofPushMatrix();
	ofTranslate(timeline.getValue("x offset"), 0, timeline.getValue("z offset"));
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);

	if(drawWireframe && wireAlpha > 0){

		glPushAttrib(GL_ALL_ATTRIB_BITS);
		glEnable(GL_CULL_FACE);

		glCullFace(GL_FRONT);

		ofTranslate(0,0,-.5);
		ofSetColor(255*wireAlpha);
		thickness *= thickness;
		ofSetLineWidth(thickness);
		meshBuilder.getMesh().drawWireframe();
		
		glPopAttrib();
	}
	
	if(drawPointcloud && pointAlpha > 0){

		ofTranslate(0,0,-.5);
		ofSetColor(255*pointAlpha);
		meshBuilder.getMesh().disableColors();
		
		meshBuilder.getMesh().setMode(OF_PRIMITIVE_POINTS);
		glPointSize(pointSize*pointSize);
		meshBuilder.getMesh().draw();
		meshBuilder.getMesh().setMode(OF_PRIMITIVE_TRIANGLES);
	
		meshBuilder.getMesh().enableColors();
	}
	
	ofPopMatrix();
	
	if(drawParticles){
		
		cloudShader.begin();
		particleRenderer.mesh.drawVertices();
		cloudShader.end();
	}
	
	player.getVideoPlayer()->getTextureReference().unbind();
	
	if(justLoadedNewScene){
		cout << "RENDERED FIRST FRAME OF " << player.getVideoPlayer()->getCurrentFrame() << endl;
		justLoadedNewScene = false;
	}
	
	ofPopStyle();
	ofPopMatrix();
}
Exemplo n.º 4
0
//--------------------------------------------------------------
void ofApp::draw(){
    // DISPLAY STATUS
    ofDrawBitmapString("Recording Status: " + status, 0, 20);
    ofDrawBitmapString("Recognition Status: " + statusWord, 0, 40);
    
    // AUDIO INPUT
    
    ofNoFill();
    
    // draw the average volume:
    ofPushStyle();
    ofPushMatrix();
    ofTranslate(300, 150, 0);
    
    ofSetColor(225);
    ofDrawBitmapString("Scaled average vol: " + ofToString(scaledVol * 100.0, 0), 4, 18);
    ofRect(0, 0, 400, 400);
    
    ofSetColor(245, 58, 135);
    ofFill();
    //ofCircle(200, 200, scaledVol * 180.0f);
    
    //lets draw the volume history as a graph
    if (isRecording) {
        ofBeginShape();
        for (unsigned int i = 0; i < volHistory.size(); i++){
            if( i == 0 ) ofVertex(i, 400);
            
            ofVertex(i, 400 - volHistory[i] * 70);
            
            if( i == volHistory.size() -1 ) ofVertex(i, 400);
        }
        ofEndShape(false);
    }
    
    ofPopMatrix();
    ofPopStyle();
    
    // DRAW FONT
    if (!isRecording && volHistory.size() != 0
        && hasRecognized) {
        //cout << "Mesh Size: " << meshesFront.size() << endl;
        
        // WAVE
        if(ofGetElapsedTimef() > addCountAt){
            tempHistory = (tempHistory + 1)%volHistory.size();
            
            addCountAt = ofGetElapsedTimef() + volHistory.size() * 0.001;
        }
        
        for (unsigned int i = 0; i < meshesFront.size(); i++) {
            float scale = meshesFront.size()/400.0;
            
            // DRAW MESH
            ofPushStyle();
            ofPushMatrix();
            
            ofTranslate(300, 350, 0);
            ofScale(1, volHistory[countHistory] * 2.0);
            
            meshesFront[i].draw();
            
            ofPopMatrix();
            ofPopStyle();
            countHistory = (countHistory + 1)%volHistory.size();
        }
        countHistory = tempHistory;
    }
    
}
Exemplo n.º 5
0
void ofxTLAudioTrack::draw(){
	
	if(!soundLoaded || player.getBuffer().size() == 0){
		ofPushStyle();
		ofSetColor(timeline->getColors().disabledColor);
		ofRectangle(bounds);
		ofPopStyle();
		return;
	}
		
	if(shouldRecomputePreview || viewIsDirty){
		recomputePreview();
	}

	//cout << "ofxTLAudioTrack::draw" << endl;

    ofSetColor(255, 255, 255, 205);
    ofFill();
    ofRect(bounds);
    ofPushStyle();
    //ofSetColor(timeline->getColors().keyColor);
    ofSetColor(0, 0 , 0, 255);
    ofNoFill();
    
    for(int i = 0; i < previews.size(); i++){
        ofPushMatrix();
        ofTranslate( normalizedXtoScreenX(computedZoomBounds.min, zoomBounds)  - normalizedXtoScreenX(zoomBounds.min, zoomBounds), 0, 0);
        ofScale(computedZoomBounds.span()/zoomBounds.span(), 1, 1);
        previews[i].draw();
        ofPopMatrix();
    }
    ofPopStyle();
	
	if(getIsPlaying() || timeline->getIsPlaying()){
		ofPushStyle();
		
		//will refresh fft bins for other calls too
		vector<float>& bins = getFFTSpectrum(defaultFFTBins);
		float binWidth = bounds.width / bins.size();
		//find max
		float averagebin = 0 ;
		for(int i = 0; i < bins.size(); i++){
			maxBinReceived = MAX(maxBinReceived, bins[i]);
			averagebin += bins[i];
		}
		averagebin /= bins.size();
		
		ofFill();
		ofSetColor(timeline->getColors().disabledColor, 120);
		for(int i = 0; i < bins.size(); i++){
			float height = bounds.height * bins[i]/maxBinReceived;
			float y = bounds.y + bounds.height - height;
			ofRect(bounds.x + i*binWidth, y, binWidth, height);
		}
		
		ofPopStyle();
	}

	// playhead 
	ofPushStyle();
	ofSetColor(0, 0, 0, 255);
	float x = normalizedXtoScreenX( oldpos, zoomBounds);
	ofLine(x, bounds.y, x, bounds.y + bounds.height);
	ofSetLineWidth(3);
	ofPopStyle();

	/*
	float pos = player.getPosition();
	if (pos) {
		ofxTLZoomer2D *zoom = (ofxTLZoomer2D*)timeline->getZoomer();
		ofRange z = zoom->getViewRange();
		ofRange oldz = z;
		float c = z.center(); 
		float d = pos - c;

		z.min = ofClamp(z.min + d, 0, 1); z.max = ofClamp(z.max + d, 0, 1);
		if (z.min == .0 && z.span() < oldz.span())
			z.max = oldz.max - oldz.min;
		if (z.max == 1. && z.span() < oldz.span())
			z.min = z.max - oldz.max + oldz.min;
	}*/




	// draw markers:
	for (vector<AlignMarker>::iterator m = markers.begin(); m != markers.end(); m++) {
		float xn = screenXtoNormalizedX(millisToScreenX(m->ms));
		if (zoomBounds.contains(xn)) {
			float x = timeline->normalizedXtoScreenX(xn, zoomBounds);
			if (m->selected)
				ofSetColor(255, 0, 0, 255);
			else 
				ofSetColor(0, 0, 0, 255);
			ofLine(x, bounds.y, x, bounds.y+bounds.height);
			m->rect = ofRectangle(x - 5, bounds.y + bounds.height - 12, 10, 10);
			ofSetColor(10, 0, 200, 100);
			ofFill();
			ofRect(m->rect);

			//cout << "m:" << m->ms << endl;
			ofSetColor(0, 0, 0, 255);
			timeline->getFont().drawString(ofToString(m->ms), x+1, bounds.y + 30);
		}
	}
	
}
Exemplo n.º 6
0
//--------------------------------------------------------------
void testApp::draw(){
    if(player.isLoaded()){
        
        //draw video player...
        player.getVideoPlayer().draw(videoRect);
        
        //...with feature overlay
        ofPushMatrix();
        ofTranslate(videoRect.x, videoRect.y);
        ofScale(videoRect.width / player.getVideoPlayer().getWidth(), 
                videoRect.height / player.getVideoPlayer().getHeight());
        
        ofPushStyle();
        ofNoFill();
        ofSetColor(255, 0, 0);
        triangulate.triangleMesh.drawWireframe();
        ofPopStyle();
        ofPopMatrix();
        
        //draw standard generated mesh
        previewFBO.begin();
        ofClear(0,0,0,0);
        cam.begin();
        glEnable(GL_DEPTH_TEST);
        meshBuilder.draw(player.getVideoPlayer());
        glDisable(GL_DEPTH_TEST);
        cam.end();
        previewFBO.end();
        previewFBO.getTextureReference().draw(meshRect);
        
        renderFBO.begin();
        ofClear(0,0,0,0);
        
        //draw triangulated mesh
        cam.begin();
        ofPushMatrix();
        ofPushStyle();
        ofScale(1,-1, 1);
        glEnable(GL_DEPTH_TEST);
        player.getVideoPlayer().getTextureReference().bind();
        ofEnableAlphaBlending();
        /*
        ofSetColor(255, 255, 255, 255);
        glShadeModel(GL_FLAT);
        ofEnableLighting();
        ofLight l;
        l.setPosition(lightX,lightY,lightZ);
        l.setAttenuation(0,.01,0);
        l.enable();
         */

//        triangulatedMesh.draw();
//        triangulatedMesh.drawWireframe();
//        ofDisableLighting();
        
        ofSetLineWidth(1);
//s        ofBlendMode(OF_BLENDMODE_ADD);
//        triangulatedMesh.drawWireframe();
        player.getVideoPlayer().getTextureReference().unbind();

        latticeMesh.drawWireframe();
//        glBegin(GL_POINTS);
//        glColor3f(1.0,0,0);
//        for(int i = 0; i < innerPoints.size(); i++) glVertex3f(innerPoints[i].x, innerPoints[i].y, innerPoints[i].z);
//        glEnd();
        
//        //draw face normals
//        ofSetLineWidth(1);
//        for(int i = 0; i < faceNormals.size(); i++){
//            ofSetColor( (faceNormals[i].x*.5+.5) * 255,
//                        (faceNormals[i].y*.5+.5) * 255,
//                        (faceNormals[i].z*.5+.5) * 255);
//                       
//            ofLine(faceCenters[i], faceCenters[i] + faceNormals[i]*6);
//        }

        glDisable(GL_DEPTH_TEST);

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

        renderFBO.end();
        
        renderFBO.getTextureReference().draw(triangulatedRect);
//        cam.setPosition(cam.getPosition() + cam.getSideDir().normalized() * .5);

        if(renderMode){
            ofImage saveImage;
            renderFBO.getTextureReference().readToPixels(saveImage.getPixelsRef());
            char filename[1024];
            sprintf(filename, "videframe_%05d.png", player.getVideoPlayer().getCurrentFrame());
            saveImage.saveImage(filename);
        }
    }
    
    gui.draw();
}
Exemplo n.º 7
0
//--------------------------------------------------------------
void ofApp::draw() {
    
    float spinX = sin(ofGetElapsedTimef()*.35f);
    float spinY = cos(ofGetElapsedTimef()*.075f);
    
    if(bMousePressed) {
        spinX = spinY = 0.0f;
    }
    
    ofEnableDepthTest();
    
    ofEnableLighting();
    pointLight.enable();
    pointLight2.enable();
    pointLight3.enable();
    
	material.begin();
    
    
    ofSetColor(180);
    ofNoFill();
    ofDrawSphere(ofGetWidth()/2, ofGetHeight()/2, ofGetWidth());
    
    if(mode == 1 || mode == 3) texture.getTexture().bind();
    if(mode == 2) vidGrabber.getTexture().bind();
    
    
    // Plane //
    plane.setPosition(ofGetWidth()*.2, ofGetHeight()*.25, 0);
    plane.rotate(spinX, 1.0, 0.0, 0.0);
    plane.rotate(spinY, 0, 1.0, 0.0);
    
    
    if(mode == 3) {
        deformPlane = plane.getMesh();
        // x = columns, y = rows //
        ofVec3f planeDims = plane.getResolution();
        float planeAngleX = ofGetElapsedTimef()*3.6;
        float planeAngleInc = 3.f/(float)planeDims.x;
        ofVec3f vert;
        for(size_t i = 0; i < deformPlane.getNumIndices(); i++ ) {
            planeAngleX += planeAngleInc;
            int ii = deformPlane.getIndex( i );
            vert = deformPlane.getVertex( ii );
            vert.z += cos(planeAngleX) * 50;
            deformPlane.setVertex( ii, vert );
        }
    }
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            plane.transformGL();
            deformPlane.draw();
            plane.restoreTransformGL();
        } else {
            plane.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        plane.setPosition(plane.getPosition().x, plane.getPosition().y, plane.getPosition().z+1);
        //if(bFill) {
        if( mode == 3 ) {
            ofSetColor(255);
        }
        plane.drawWireframe();
        //}
        plane.setPosition(plane.getPosition().x, plane.getPosition().y, plane.getPosition().z-2);
        
    }
    
    
    // Box //
    box.setPosition(ofGetWidth()*.5, ofGetHeight()*.25, 0);
    box.rotate(spinX, 1.0, 0.0, 0.0);
    box.rotate(spinY, 0, 1.0, 0.0);
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            box.transformGL();
            for(int i = 0; i < ofBoxPrimitive::SIDES_TOTAL; i++ ) {
                ofPushMatrix();
                ofTranslate( boxSides[i].getNormal(0) * sin(ofGetElapsedTimef()) * 50  );
                boxSides[i].draw();
                ofPopMatrix();
            }
            box.restoreTransformGL();
        } else {
            box.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        box.setScale(1.01f);
        if(mode == 3) {
            ofSetColor(255);
        }
        box.drawWireframe();
        box.setScale(1.f);
    }
    
    
    // Sphere //
    sphere.setPosition(ofGetWidth()*.8f, ofGetHeight()*.25, 0);
    sphere.rotate(spinX, 1.0, 0.0, 0.0);
    sphere.rotate(spinY, 0, 1.0, 0.0);
    
    if(mode == 3) {
        sphere.setMode( OF_PRIMITIVE_TRIANGLES );
        triangles = sphere.getMesh().getUniqueFaces();
    }
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            float angle = ofGetElapsedTimef()*3.2;
            float strength = (sin( angle+.25 )) * .5f * 5.f;
            ofVec3f faceNormal;
            for(size_t i = 0; i < triangles.size(); i++ ) {
                // store the face normal here.
                // we change the vertices, which makes the face normal change
                // every time that we call getFaceNormal //
                faceNormal = triangles[i].getFaceNormal();
                for(int j = 0; j < 3; j++ ) {
                    triangles[i].setVertex( j, triangles[i].getVertex(j) + faceNormal * strength);
                }
            }
            sphere.getMesh().setFromTriangles( triangles );
        }
        sphere.draw();
        
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        sphere.setScale(1.01f);
        sphere.drawWireframe();
        sphere.setScale(1.f);
    }
    
    
    // ICO Sphere //
    icoSphere.setPosition(ofGetWidth()*.2, ofGetHeight()*.75, 0);
    icoSphere.rotate(spinX, 1.0, 0.0, 0.0);
    icoSphere.rotate(spinY, 0, 1.0, 0.0);
    
    if(mode == 3) {
        triangles = icoSphere.getMesh().getUniqueFaces();
    }
    
    if(bFill) {
        ofFill();
        ofSetColor(255);
        
        if(mode == 3) {
            float angle = (ofGetElapsedTimef() * 1.4);
            ofVec3f faceNormal;
            for(size_t i = 0; i < triangles.size(); i++ ) {
                float frc = ofSignedNoise(angle* (float)i * .1, angle*.05) * 4;
                faceNormal = triangles[i].getFaceNormal();
                for(int j = 0; j < 3; j++ ) {
                    triangles[i].setVertex(j, triangles[i].getVertex(j) + faceNormal * frc );
                }
            }
            icoSphere.getMesh().setFromTriangles( triangles );
        }
        
        icoSphere.draw();
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill) ofSetColor(255);
        icoSphere.setScale(1.01f);
        icoSphere.drawWireframe();
        icoSphere.setScale(1.f);
    }
    
    
    // Cylinder //
    if(mode == 3) {
        topCap      = cylinder.getTopCapMesh();
        bottomCap   = cylinder.getBottomCapMesh();
        body        = cylinder.getCylinderMesh();
    }
    
    cylinder.setPosition(ofGetWidth()*.5, ofGetHeight()*.75, 0);
    cylinder.rotate(spinX, 1.0, 0.0, 0.0);
    cylinder.rotate(spinY, 0, 1.0, 0.0);
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            cylinder.transformGL();
            ofPushMatrix(); {
                if(topCap.getNumNormals() > 0) {
                    ofTranslate( topCap.getNormal(0) * (cos(ofGetElapsedTimef()*5)+1)*.5f * 100 );
                    topCap.draw();
                }
            } ofPopMatrix();
            ofPushMatrix(); {
                if(bottomCap.getNumNormals() > 0) {
                    ofTranslate( bottomCap.getNormal(0) * (cos(ofGetElapsedTimef()*4)+1)*.5f * 100 );
                    bottomCap.draw();
                }
            } ofPopMatrix();
            ofPushMatrix(); {
                float scale = (cos(ofGetElapsedTimef()*3)+1)*.5f + .2;
                ofScale( scale, scale, scale );
                body.draw();
            } ofPopMatrix();
            cylinder.restoreTransformGL();
        } else {
            cylinder.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill || mode == 3) ofSetColor(255);
        cylinder.setScale(1.01f);
        cylinder.drawWireframe();
        cylinder.setScale(1.0f);
    }
    
    
    // Cone //
    cone.setPosition(ofGetWidth()*.8, ofGetHeight()*.75, 0);
    cone.rotate(spinX, 1.0, 0.0, 0.0);
    cone.rotate(spinY, 0, 1.0, 0.0);
    
    if(mode == 3) {
        bottomCap   = cone.getCapMesh();
        body        = cone.getConeMesh();
    }
    if(bFill) {
        ofFill();
        ofSetColor(255);
        if(mode == 3) {
            cone.transformGL();
            ofPushMatrix();
            if(bottomCap.getNumNormals() > 0 ) {
                ofTranslate( bottomCap.getNormal(0) * cone.getHeight()*.5 );
                ofRotate( sin(ofGetElapsedTimef()*5) * RAD_TO_DEG, 1, 0, 0);
                bottomCap.draw();
            }
            ofPopMatrix();
            
            ofPushMatrix();
            ofRotate(90, 1, 0, 0);
            ofRotate( (cos(ofGetElapsedTimef()*6) +1)*.5 * 360 , 1, 0, 0 );
            body.draw();
            ofPopMatrix();
            cone.restoreTransformGL();
        } else {
            cone.draw();
        }
    }
    if(bWireframe) {
        ofNoFill();
        ofSetColor(0, 0, 0);
        if(!bFill || mode == 3) ofSetColor(255);
        cone.setScale(1.01f);
        cone.drawWireframe();
        cone.setScale(1.0f);
    }
    
    if(mode == 1 || mode == 3) texture.getTexture().unbind();
    if(mode == 2) vidGrabber.getTexture().unbind();
    
    material.end();
    ofDisableLighting();
    
    if(bDrawLights) {
        ofFill();
        ofSetColor(pointLight.getDiffuseColor());
        pointLight.draw();
        ofSetColor(pointLight2.getDiffuseColor());
        pointLight2.draw();
        ofSetColor(pointLight3.getDiffuseColor());
        pointLight3.draw();
    }
    
    if(bDrawNormals) {
        ofSetColor(225, 0, 255);
        plane.drawNormals(20, bSplitFaces);
        box.drawNormals(20, bSplitFaces);
        sphere.drawNormals(20, bSplitFaces);
        icoSphere.drawNormals(20, bSplitFaces);
        cylinder.drawNormals(20, bSplitFaces);
        cone.drawNormals(20, bSplitFaces);
    }
    if(bDrawAxes) {
        plane.drawAxes(plane.getWidth()*.5+30);
        box.drawAxes(box.getWidth()+30);
        sphere.drawAxes(sphere.getRadius()+30);
        icoSphere.drawAxes(icoSphere.getRadius()+30);
        cylinder.drawAxes(cylinder.getHeight()+30);
        cone.drawAxes(cone.getHeight()+30);
    }
    
    ofDisableDepthTest();
    
    ofFill();
    
    ofSetColor(0);
    ofDrawRectangle(plane.getPosition().x-154, plane.getPosition().y + 120, 140, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofPlanePrimitive", plane.getPosition().x-150, plane.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(box.getPosition().x-154, box.getPosition().y + 120, 126, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofBoxPrimitive", box.getPosition().x-150, box.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(sphere.getPosition().x-154, sphere.getPosition().y + 120, 148, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofSpherePrimitive", sphere.getPosition().x-150, sphere.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(icoSphere.getPosition().x-154, icoSphere.getPosition().y + 120, 168, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofIcoSpherePrimitive", icoSphere.getPosition().x-150, icoSphere.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(cylinder.getPosition().x-154, cylinder.getPosition().y + 120, 160, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofCylinderPrimitive", cylinder.getPosition().x-150, cylinder.getPosition().y+136 );
    
    ofSetColor(0);
    ofDrawRectangle(cone.getPosition().x-154, cone.getPosition().y + 120, 136, 24);
    ofSetColor(255);
    ofDrawBitmapString("ofConePrimitive", cone.getPosition().x-150, cone.getPosition().y+136 );
        
    if(bInfoText) {
        stringstream ss;
        ss << "Framerate: " << ofToString(ofGetFrameRate(),0) << "\n";
        ss << "(f): Toggle Fullscreen"<<endl<<"(s): Draw Solid Shapes"<<endl<<"(w): Draw Wireframes"<<endl;
        ss <<"(1/2/3/4): Set Resolutions" <<endl<<"(n): Draw Normals"<<"\n(LEFT/RIGHT): Set Mode "<<ofToString(mode,0)<<endl;
        ss <<"(z): Split Faces " <<bSplitFaces<<endl;
        ss <<"(a): Draw Axes"<<endl<<"(l): Render lights"<<endl<<"(t): Info Text"<<endl;
        
        ofDrawBitmapString(ss.str().c_str(), 20, 20);
    }
    
    
}
//-------------------------------------------
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();
    }
}
Exemplo n.º 9
0
//--------------------------------------------------------------
void ofApp::drawScene(bool isPreview){
	
	ofEnableDepthTest();

	if (isPreview) {
		ofPushStyle();
		ofSetColor(150, 100, 100);
		ofDrawGrid(1.0f, 5.0f, true);
		
		ofSetColor(255);
		
		//--
		//draw camera preview
		//
		headTrackedCamera.transformGL();
		
		ofPushMatrix();
		ofScale(0.002f, 0.002f, 0.002f);
		ofNode().draw();
		ofPopMatrix();
		
		ofMultMatrix(headTrackedCamera.getProjectionMatrix().getInverse());
		
		ofPushStyle();
		ofNoFill();
		ofDrawBox(2.0f);
		ofPopStyle();
		
		headTrackedCamera.restoreTransformGL();
		//
		//--
		
		//--
		//draw window preview
		//
		window.clear();
		window.addVertex(windowTopLeft);
		window.addVertex(windowBottomLeft);
		window.addVertex(windowBottomRight);
		window.setMode(OF_PRIMITIVE_LINE_STRIP);
		window.draw();
		glPointSize(3.0f);
		window.drawVertices();
		//
		//--
	}
	
	ofPushStyle();
	ofNoFill();
	ofColor col(200,100,100);
	for (float z = 0.0f; z > -40.0f; z-= 0.1f){
		col.setHue(int(-z * 100.0f + ofGetElapsedTimef() * 10.0f) % 360);
		ofSetColor(col);
		ofRect(-windowWidth / 2.0f, -windowHeight / 2.0f, z, windowWidth, windowHeight);
	}
	ofPopStyle();
	
	ofPushStyle();
	ofEnableSmoothing();
	ofSetColor(255);
	ofSetLineWidth(5.0f);
	ofBeginShape();
	for (unsigned int i=0; i<headPositionHistory.size(); i++) {
		ofPoint vertex(headPositionHistory[i].x, headPositionHistory[i].y, -float( headPositionHistory.size() - i ) * 0.05f);
		ofCurveVertex(vertex);
	}
	ofEndShape(false);
	ofPopStyle();
	
	ofDisableDepthTest();
}
Exemplo n.º 10
0
void Renderer::draw()
{
	ofBackground(0);

	ofPushMatrix();

		// afficher un repère visuel pour les lumières
		if(isActiveLightPoint)
			lightPoint->draw();
		if(isActiveLightDirectional)
			lightDirectional->draw();
		if(isActiveLightSpot)
			lightSpot->draw();

	ofPopMatrix();

	ofPushMatrix();

		// inverser l'axe Y pour qu'il pointe vers le haut
		ofScale(1, isFlipAxisY ? -1 : 1);

		// transformer l'origine de la scène au milieu de la fenêtre d'affichage
		ofTranslate(xCenter + xOffset, isFlipAxisY ? -yCenter : yCenter, zOffset);

		// légère rotation de la scène
		ofRotate(ofGetFrameNum() * 0.25f, 0, 1, 0);

		ofPushMatrix();

			// position
			ofTranslate(
				positionCube->x,
				positionCube->y,
				positionCube->z);

			// rotation locale
			ofRotate(ofGetFrameNum() * 1.0f, 0, 1, 0);

			// activer l'éclairage dynamique
			ofEnableLighting();

			// activer les lumières
			lightingOn();

			// activer le matériau
			materialCube->begin();

			// dessiner un cube
			ofDrawBox(0, 0, 0, scaleCube);

			// désactiver le matériau
			materialCube->end();

			// désactiver les lumières
			lightingOff();

			// désactiver l'éclairage dynamique
			ofDisableLighting();

		ofPopMatrix();

		ofPushMatrix();

			// position
			ofTranslate(
				positionSphere->x,
				positionSphere->y,
				positionSphere->z);

			// rotation locale
			ofRotate(ofGetFrameNum() * 1.0f, 0, 1, 0);

			// activer l'éclairage dynamique
			ofEnableLighting();

			// activer les lumières
			lightingOn();

			// activer le matériau
			materialSphere->begin();

			// dessiner une sphère
			ofDrawSphere(0, 0, 0, scaleSphere);

			// désactiver le matériau
			materialSphere->end();

			// désactiver les lumières
			lightingOff();

			// désactiver l'éclairage dynamique
			ofDisableLighting();

		ofPopMatrix();

		ofPushMatrix();

			// position
			teapot->setPosition(
				positionTeapot->x,
				positionTeapot->y + 15,
				positionTeapot->z);

			// rotation locale
			teapot->setRotation(0, ofGetFrameNum() * -1.0f, 0, 1, 0);

			// dimension
			teapot->setScale(
				scaleTeapot,
				scaleTeapot,
				scaleTeapot);

			// désactiver le matériau par défaut du modèle
			teapot->disableMaterials();

			// activer l'éclairage dynamique
			ofEnableLighting();

			// activer les lumières
			lightingOn();

			// activer le matériau
			materialTeapot->begin();

			// dessiner un teapot
			teapot->draw(OF_MESH_FILL);

			// désactiver le matériau
			materialTeapot->end();

			// désactiver les lumières
			lightingOff();

			// désactiver l'éclairage dynamique
			ofDisableLighting();

		ofPopMatrix();

	ofPopMatrix();
}
Exemplo n.º 11
0
void nebulaContourFinder::draw(int x, int y, int w, int h){
  if(!enabled || blurred.size() == cv::Size(0,0)) return;
  ofxCv::RectTracker& tracker = finder.getTracker();

  ofPushMatrix();
  ofScale(w/blurred.cols, h/blurred.rows);
  ofTranslate(x,y);

  if(showLabels) {
    finder.draw();
    for(int i = 0; i < finder.size(); i++) {
      ofPoint center = ofxCv::toOf(finder.getCenter(i));
      ofPushMatrix();
      ofTranslate(center.x, center.y);
      int label = finder.getLabel(i);
      string msg = ofToString(label) + ":" + ofToString(tracker.getAge(label));
      ofDrawBitmapString(msg, 0, 0);
      ofDrawCircle(0,0,2);
      ofVec2f pt = ofxCv::toOf(finder.getCentroid(i));
      pt.x /= blurred.cols;
      pt.y /= blurred.rows;
      msg = ofToString(pt);
      ofDrawBitmapString(msg, 0, 12);
      ofVec2f velocity = ofxCv::toOf(finder.getVelocity(i));
      ofScale(5, 5);
      ofDrawLine(0, 0, velocity.x, velocity.y);
      ofPopMatrix();
    }
  } else {
    for(int i = 0; i < finder.size(); i++) {
      unsigned int label = finder.getLabel(i);
      // only draw a line if this is not a new label
      if(tracker.existsPrevious(label)) {
        // use the label to pick a random color
        ofSeedRandom(label << 24);
        ofSetColor(ofColor::fromHsb(ofRandom(255), 255, 255));
        // get the tracked object (cv::Rect) at current and previous position
        const cv::Rect& previous = tracker.getPrevious(label);
        const cv::Rect& current = tracker.getCurrent(label);
        // get the centers of the rectangles
        ofVec2f previousPosition(previous.x + previous.width / 2, previous.y + previous.height / 2);
        ofVec2f currentPosition(current.x + current.width / 2, current.y + current.height / 2);
        ofDrawLine(previousPosition, currentPosition);
      }
    }
  }

  ofTranslate(x,y);
  // 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);
  }
  ofPopMatrix();
  ofPopStyle();
}
Exemplo n.º 12
0
//--------------------------------------------------------------
void testApp::draw() {
	glEnable( GL_DEPTH_TEST );
	
	camera.begin();
	
	ofSetLineWidth(1.f);
	if(bDrawDebug) world.drawDebug();
	
	ofEnableLighting();
	light.enable();
	light.setPosition(shapes[0]->getPosition());
	ofSetColor(255, 255, 255);
	shapes[0]->draw();
	
	ofSetColor(100., 100., 100.);
	
	if(!bDropBox) {
		boundsMat.begin();
		for(int i = 0; i < bounds.size()-1; i++) {
			bounds[i]->draw();
		}
		boundsMat.end();
	} else {
		ofNoFill();
        boundsShape->transformGL();
		ofDrawBox(ofVec3f(0, 0,0), boundsWidth);
		boundsShape->restoreTramsformGL();
		ofFill();
	}
	
	ofDisableAlphaBlending();
	ofDisableBlendMode();
	
	glPushAttrib(GL_ALL_ATTRIB_BITS);
    glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);
    glEnable(GL_NORMALIZE);
    glDisable(GL_CULL_FACE);
	ofPoint scale		= assimpModel.getScale();
	
	ofSetColor(0, 0, 0);
	logoMat.begin();
	for(int i = 0; i < logos.size(); i++) {
        logos[i]->transformGL();
		ofScale(scale.x,scale.y,scale.z);
		assimpModel.getMesh(0).drawFaces();
		logos[i]->restoreTramsformGL();
	}
	glPopAttrib();
	logoMat.end();
	
	ofSetColor(15,197,138);
	ofPushStyle();
	shapesMat.begin();
	for(int i = 0; i < shapes.size(); i++) {
		shapes[i]->draw();
	}
	shapesMat.end();
	ofPopStyle();
	
	light.disable();
	ofDisableLighting();
	
	camera.end();
	glDisable(GL_DEPTH_TEST);
	
	int totalShapes = shapes.size() + logos.size();
	ofVec3f gravity = world.getGravity();
	stringstream ss;
	ss << "Draw Debug (d): " << bDrawDebug << endl;
	ss << "Total Shapes: " << totalShapes << endl;
	ss << "Add logos(o)" << endl;
	ss << "add spherers (s)" << endl;
	ss << "add boxes (b)" << endl;
	ss << "Gravity(up/down/left/right): x=" << gravity.x << " y= " << gravity.y << " z= " << gravity.z << endl;
	ofSetColor(255, 255, 255);
	ofDrawBitmapString(ss.str().c_str(), 20, 20);
}
Exemplo n.º 13
0
//--------------------------------------------------------------
void testApp::draw()
{		

	ofPushMatrix();
	ofScale(scale_x, scale_y, 1.0);
	ofTranslate(mtrx, mtry, 1.0);

	if (debug) {
		 
		if (videosurce){
			colorImg.draw(20,20);
			grayImage.draw(360,20);
			grayBg.draw(20,280);
			grayDiff.draw(360,280);
			
			// then draw the contours:
			
			ofFill();
			ofSetColor(0x333333);
			ofRect(360,540,320,240);
			ofSetColor(0xffffff);
			
			// we could draw the whole contour finder
			//contourFinder.draw(360,540);
			
			// or, instead we can draw each blob individually,
			// this is how to get access to them:
			for (int i = 0; i < contourFinder.nBlobs; i++){
				contourFinder.blobs[i].draw(360,540);
			}
		
		} else {
			kinect.drawDepth(10, 10, 400, 300);
			kinect.draw(420, 10, 400, 300);
			contourFinder.draw(10, 320, 400, 300);	
		}


		
	} else {
		
		ofSetColor(205, 205, 205);
		
		if (videosurce){
			grayDiff.draw(0,0, camWidth, camHeight);

			//colorImg.draw(20,20, camWidth, camHeight);
			//grayImage.draw(0, 0, camWidth, camHeight);
		} else {
		
		grayImage.draw(0, 0, kinect.width, kinect.height);
	}
		
		for(int i = 0; i < contourFinder.blobs.size(); i++) {
			
			switch(colorz){
				case 1:
					ofSetColor(255, 255, 100);
					break;
				case 2:
					ofSetColor(255, 100, 255);
					break;
				case 3:
					ofSetColor(100, 255, 255);
					break;
				case 4:
					ofSetColor(100, 120, 150);
					break;
			}
			
			ofxCvBlob curr_blob = contourFinder.blobs[i];
			float cx = curr_blob.centroid.x;
			float cy = curr_blob.centroid.y;
			float blobarea = curr_blob.area;
			float blobheight = curr_blob.boundingRect.height;	
			float blobwidth = curr_blob.boundingRect.width;	
			float rectx = curr_blob.boundingRect.x;
			float recty = curr_blob.boundingRect.y;
			
			ofNoFill();
			ofRect(rectx,recty,blobwidth,blobheight);
			ofFill();
			
			//ofSetColor(255, 255, 255);
			if (circle) {
				float raggio = (blobheight >= blobwidth ? blobheight : blobwidth) / 2.0;
				ofCircle( cx, cy, raggio);
			}
			if (rectangle) {
				ofRect(rectx,0,blobwidth, 480);
			}
			
			
			//if (interface) {
				//ofSetColor(255, 255, 255);
				//ofDrawBitmapString("blob "+ ofToString(i, 0) + ": try " + ofToString(cy, 2) + " /trx " + ofToString(cx, 2) + " /area " + ofToString(blobarea, 0) , 20, 200+i*10 );
			//}
		}
		
	}

	

	// point cloud is commented out because we need a proper camera class to explore it effectively	
	if (cloud) {
		drawPointCloud();
	}
	
	ofPopMatrix();
	
	ofSetColor(255, 255, 255);
	
	// INTERFACE DEBUG
	if (interface) {
		ofDrawBitmapString("INTERFACE (press: h to hide)", 20, 20);
		ofDrawBitmapString("accel is: " + ofToString(kinect.getMksAccel().x, 2) + " / " 
						   + ofToString(kinect.getMksAccel().y, 2) + " / "
						   + ofToString(kinect.getMksAccel().z, 2), 20, 58 );
		
		char reportStr[1024];
		sprintf(reportStr, "using opencv threshold = %i (press spacebar)\nset near threshold %i (press: + -)\nset far threshold %i (press: < >) num blobs found %i, fps: %f",bThreshWithOpenCV, nearThreshold, farThreshold, contourFinder.nBlobs, ofGetFrameRate());
		ofDrawBitmapString(reportStr, 20, 90);
		ofDrawBitmapString("tilt angle: " + ofToString(angle) + " (press: s x). Contour (poress: t y): " + ofToString(contour_min) ,20,130);
		ofDrawBitmapString("scale: " + ofToString(scale_x) + "," + ofToString(scale_y) + " (press: a z)", 20,160);
		ofDrawBitmapString("translate: " + ofToString(mtrx) + "," + ofToString(mtry) + " (press: ARROWS)", 20,190);			
		ofDrawBitmapString("d: debug mode. c: toggle circle. r: reset scale and translate. p: point cloud", 20,220);

	}
}
Exemplo n.º 14
0
void Trigger :: draw(ofRectangle area, int motionTargetThreshold) {
	
	if(settings!=NULL) {
		settings->update(deltaTime, values);
		settings->draw(elapsedTime, pos,  unitPower, active, scale, angle);
		
		if(elapsedTime-lastTriggerTime<0.15) {
			ofPushMatrix();
			ofPushStyle();
			ofTranslate(pos.x, pos.y);
			float size = ofMap(elapsedTime - lastTriggerTime, 0, 0.15, 1, 0);
			size*=size;
			size*=settings->radius*5;
			ofScale(size, size);
			ofSetColor(settings->getColour());
			flashImage.draw(-0.5, -0.5, 1,1);
			ofScale(0.5,0.5);
			flashImage.draw(-0.5, -0.5, 1,1);
			
			ofPopStyle(); 
			ofPopMatrix();
		}
	}
	
	if(lastSettings!=NULL) {
		lastSettings->update(deltaTime, values);
		lastSettings->draw(elapsedTime, pos,  unitPower, active, lastScale, angle);
	}
	if(!active) return;


	
	if(showDebugData) {
		
		ofPushMatrix();
		ofPushStyle();
		ofTranslate(pos);
      
		ofSetColor(100,0,0);
		ofNoFill();
		ofRect(-triggerSampleSize/2, -triggerSampleSize/2, triggerSampleSize, triggerSampleSize);
		ofTranslate(0, motionValueCount*-2);
		
		ofFill();
		 
        for(float i = -0.5; i<=0.5 ; i++){
                  
            ofPushMatrix();
            
            ofBeginShape();
            
            ofScale(i,1);
            
            ofVertex(-1,0);
            float lastvalue = -1;
            
            for(int i = 0; i<motionValues.size(); i++) {
				
                float value = ofClamp(motionValues[i]*20, 0, 50);
                if(value!=lastvalue) {
                    ofVertex(lastvalue,(i*2)-1);
                    ofVertex(value,i*2);
                    ofVertex(value,(i*2)+1);
                }
                lastvalue = value;
             }
            ofVertex(0,motionValues.size()*2);
            ofVertex(-1,motionValues.size()*2);
            ofEndShape();
            
            ofPopMatrix();
        }
		
		ofPopMatrix();
		
		
		for(int i = 0; i<vertMotionSamples.size(); i++) {
			float sample = vertMotionSamples[i];
			ofSetColor(ofMap(sample, 0, 255,0,255,true));
			if(sample<motionTargetThreshold) ofSetColor(50,0,0);
			ofNoFill();
			float ypos = ofMap(i, 0, vertMotionSamples.size(), area.getTop(), area.getBottom());
			ofCircle(pos.x, ypos, 3);
			ofRect(pos.x - (multiSampleSize/2), ypos-(multiSampleSize/2), multiSampleSize, multiSampleSize);
			
		}
		
		
		
		ofPopStyle();

		
	} else if(sampleBrightness>0) {
	
		ofPushStyle();
		
		for(int i = 0; i<vertMotionSamples.size(); i++) {
			//			ofSetColor(ofMap(sample, 0, 255,0,255,true));
			//if(sample<motionTargetThreshold) ofSetColor(50,0,0);
			ofNoFill();
			float ypos = ofMap(i, 0, vertMotionSamples.size(), area.getTop(), area.getBottom());
			if(ypos > pos.y) {
				float sample = vertMotionSamples[i];
				ofSetColor(sampleBrightness * 100 );
				ofSetLineWidth(1* scale);
				ofCircle(pos.x, ypos, 3* scale);
				if(i<vertMotionSamples.size()-1) {
					
					ofLine(pos.x, ypos+(3* scale), pos.x, ofMap(i+1, 0, vertMotionSamples.size(), area.getTop(), area.getBottom())-(3* scale));
				}
				
				ofSetColor(ofMap(sample, 0, 255,0,80,true) * sampleBrightness);
				ofFill();
				ofCircle(pos.x, ypos, 2* scale);
				
			}
		}
		
		ofPopStyle();
	}
}
Exemplo n.º 15
0
//--------------------------------------------------------------
void testApp::draw(){

    ofSetColor(255);
    int scale = 4;
    ofPushMatrix();
    ofTranslate(-(vidGrabber.getWidth() * scale)/5, 0);
    ofScale(scale, scale);
    
    switch (state) {
        case 0:
            //show camera
            ofPushMatrix();
            ofScale(-1, 1);
            vidGrabber.draw(-vidGrabber.getWidth(),0);
            ofPopMatrix();
            ofSetColor(200, 0, 0);
            ofSetLineWidth(5);
            ofLine(vidGrabber.width/2, 0, vidGrabber.width/2, ofGetHeight());
            
            break;
        
        case 2:
            //show pic
            pic.draw(0, 0);
            
            break;
            
        case 3:
            mirror.draw(0, 0);
            //show mirror
            break;
            
        case 4:
            //show left sym
            left.draw(0, 0);
            break;
            
        case 5:
            right.draw(0, 0);
            //show right sym
            break;
            
        default:
            break;
    }
    
    ofPopMatrix();
    
    switch (state) {

        case 1:
            ofPushMatrix();
            pic.draw(0, 0);
            mirror.draw(ofGetWidth()/2, 0);
            left.draw(0, ofGetHeight()/2);
            right.draw(ofGetWidth()/2, ofGetHeight()/2);
            ofPopMatrix();
            break;
            
        default:
            break;
    }
    
    
}
Exemplo n.º 16
0
//--------------------------------------------------------------
void ofApp::draw(){
	
	ofSetColor(225);
	verdana14.drawString("Font Example - use keyboard to type", 30, 35);

	ofSetColor(245, 58, 135);
	verdana14.drawString("anti aliased", 155, 92);
	verdana14.drawString("anti aliased", 155, 195);
	verdana14A.drawString("aliased", 545, 92);
	
	ofSetColor(225);
	verdana14.drawString("verdana 14pt - ", 30, 92);
	verdana14.drawString(typeStr, 30, 111);

	verdana14A.drawString("verdana 14pt - ", 422, 92);
	ofDrawRectangle(420, 97, 292, 62);
	ofSetColor(54, 54, 54);	
	verdana14A.drawString(typeStr, 422, 111);
	

	ofSetColor(29,29,29);
	ofDrawLine(30, 169, ofGetWidth()-4, 169);

	ofSetColor(225);
	verdana14.drawString("verdana 30pt - ", 30, 195);
	verdana30.drawString(typeStr, 30, 229);

	ofSetColor(29,29,29);
	ofDrawLine(30, 312, ofGetWidth()-4, 312);

	ofSetColor(245, 58, 135);
	franklinBook14.drawString("anti aliased", 169, 338);
	franklinBook14A.drawString("aliased", 560, 338);
	
	ofSetColor(225);
	franklinBook14.drawString("franklin book 14pt - ", 30, 338);
	franklinBook14.drawString(typeStr, 30, 358);

	franklinBook14A.drawString("franklin book 14pt - ", 422, 338);
	ofDrawRectangle(420, 345, 292, 62);
	ofSetColor(54, 54, 54);	
	franklinBook14A.drawString(typeStr, 422, 358);

	ofSetColor(29,29,29);
	ofDrawLine(30, 418, ofGetWidth()-4, 418);

	ofSetColor(225);	
	verdana14.drawString("ROTATION", 30, 445);
	verdana14.drawString("SCALE", 422, 445);
	
	ofPushMatrix();
		string rotZ = "Rotate Z";
		ofRectangle bounds = verdana30.getStringBoundingBox(rotZ, 0, 0);
		
		ofTranslate(110 + bounds.width/2, 500 + bounds.height / 2, 0);
		ofRotateZ(ofGetElapsedTimef() * -30.0);
				
		verdana30.drawString(rotZ, -bounds.width/2, bounds.height/2 );
	ofPopMatrix();

	ofPushMatrix();
		string scaleAA = "SCALE AA";
		bounds = verdana14.getStringBoundingBox(scaleAA, 0, 0);
		
		ofTranslate(500 + bounds.width/2, 480 + bounds.height / 2, 0);
		ofScale(2.0 + sin(ofGetElapsedTimef()), 2.0 + sin(ofGetElapsedTimef()), 1.0);
				
		verdana14.drawString(scaleAA, -bounds.width/2, bounds.height/2 );
	ofPopMatrix();	

	ofPushMatrix();
		string scaleA = "SCALE ALIASED";
		bounds = verdana14A.getStringBoundingBox(scaleA, 0, 0);
		
		ofTranslate(500 + bounds.width/2, 530 + bounds.height / 2, 0);
		ofScale(2.0 + cos(ofGetElapsedTimef()), 2.0 + cos(ofGetElapsedTimef()), 1.0);
				
		verdana14A.drawString(scaleA, -bounds.width/2, bounds.height/2 );
	ofPopMatrix();	
	
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void testApp::draw(){
	
    ofTranslate(pos);
	ofScale(scale, scale);
    deep.draw();
}
Exemplo n.º 18
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackgroundGradient(ofColor(245), ofColor(200));
	//ofSetLineWidth(1);
	
	//The following is just to print the instructions to the screen.
	ofSetColor(80);
	ofDrawBitmapString("Click here to add horizontal oscilators.", LEFT_MARGIN +100, TOP_MARGIN-5 );
	
	ofDrawBitmapString("Click and drag\nover an\noscilator to\nmodify it's\nspeed and\namplitude", 15,25);
	ofDrawBitmapString("Click in this area and drag upwards/downwards to scale up/down.\nPress spacebar to delete all the oscilators.", LEFT_MARGIN + 200, ofGetHeight()-40);
	
	//All this bunch is to print the vertical text
	ofPushMatrix();
	ofTranslate(LEFT_MARGIN -5,  ofGetHeight() - 100, 0);
	ofRotate(-90, 0, 0, 1);
	ofDrawBitmapString("Click here to add vertical oscilators.",  0, 0 );
	ofPopMatrix();
	
	
	
	
	ofEnableSmoothing();
	
	//This are just the reference lines draw in the screen.
	ofSetColor(0, 0, 0, 150);
	ofLine(LEFT_MARGIN, 0, LEFT_MARGIN, ofGetHeight());
	ofLine(0, TOP_MARGIN, ofGetWidth(), TOP_MARGIN);
	
	ofSetColor(0, 0, 0, 80);
	ofLine(LEFT_MARGIN, center.y, ofGetWidth(), center.y);
	ofLine(center.x, TOP_MARGIN, center.x, ofGetHeight());
	
	//ofSetLineWidth(2);
	
	
	float horWave = 0;
	float vertWave = 0;
	
	//here we go through all the horizontal oscilators
	for (int i=0; i<horizontalOscilators.size(); i++) {
		ofSetColor(255, 127+i, 0,150);
		horizontalOscilators[i].draw(); //we draw each oscilator
		horWave += horizontalOscilators[i].waveSin;
		//THIS IS IMPORTANT. Here we are adding together all the current sine values of each oscilator.
																	  // This is what is creates all the crazy motion that we get.
	}
	//the same as above but for vertical oscilators
	for (int i=0; i<verticalOscilators.size(); i++) {
		ofSetColor(0, 127+i, 255, 150);
		verticalOscilators[i].draw();
		vertWave += verticalOscilators[i].waveSin;
	}
	//here we move all the elements of the array one position forward so to make space for a new value.
	for (int i=1; i<TAIL_LENGTH; i++) {
		waveHistory[i-1] = waveHistory[i];
	} 
	for (int i=1; i<WAVEFORM_HISTORY; i++) {
		horWaveHistory[i-1] = horWaveHistory[i];
		vertWaveHistory[i-1]= vertWaveHistory[i];
	}
	// here we save into our history
	horWaveHistory[WAVEFORM_HISTORY-1] = horWave;
	vertWaveHistory[WAVEFORM_HISTORY-1] = vertWave;
	waveHistory[TAIL_LENGTH-1] = ofVec3f(horWave, vertWave,0);
	
	
	
	ofMesh wave; // declaring a new ofMesh object with which we're drawing the motion path created by summing the vertical and horizontal oscilators
	wave.setMode(OF_PRIMITIVE_LINE_STRIP);
	for (int i=0; i<TAIL_LENGTH; i++) {
		wave.addColor(ofFloatColor(0.1f,0.1f,0.1f, 0.5f + 0.5f * i/float(TAIL_LENGTH) ));
		wave.addVertex(waveHistory[i]);
	}
	
	//all the following is to create and populate the horizontal and vertical waveforms.
	ofMesh hWave;
	hWave.setMode(OF_PRIMITIVE_LINE_STRIP);
	ofMesh vWave;
	vWave.setMode(OF_PRIMITIVE_LINE_STRIP);
	for (int i=0; i<WAVEFORM_HISTORY; i++) {
		hWave.addColor(ofFloatColor(255, 240,10, 255));
		hWave.addVertex(ofVec3f(i*hWaveMult, horWaveHistory[i]*0.1f*scale, 0));
		vWave.addColor(ofFloatColor(255, 240,10, 255));
		vWave.addVertex(ofVec3f(vertWaveHistory[i]*0.1f*scale, i*vWaveMult, 0));
	}
	
	//draw the vertical and horizontal wave.
	ofPushMatrix();
	ofTranslate(LEFT_MARGIN, TOP_MARGIN, 0);
	hWave.draw();
	vWave.draw();
	ofPopMatrix();
	
	//draw the composite wave.
	ofPushMatrix();
	ofTranslate(center.x, center.y, 0);
	ofScale(scale, scale, 0);
	wave.draw();
	ofSetColor(0,10, 255),
	ofCircle(horWave, vertWave, 10);
	ofPopMatrix();
	
}
Exemplo n.º 19
0
//--------------------------------------------------------------
void Leaf::draw(){
    //DRAW STUFF
//    ofRect(xPos, yPos, 20, 40);
    
    //Draw leave
    
    //draw leaf left
    
    ofPushMatrix();
        ofTranslate(xPos, yPos);
        ofRotateZ(rotation);
        ofScale(scaleFactor, scaleFactor);
    
        ofSetColor(leafColor);
        ofBeginShape();
        
            float x0 = 0;
            float x1 = x0 - leafWidth/2;
            float x2 = x0 - leafWidth/4;
            float x3 = 0;
        
            float y0 = 0 + stemLength;
            float y1 = y0 + leafLength/3;
            float y2 = y1 + leafLength/3;
            float y3 = y0 + leafLength;
        
            ofVertex(x0,y0);
            ofBezierVertex(x1,y1,x2,y2,x3,y3);
        
        ofEndShape();

        //draw leaf right
        ofBeginShape();
        
            x0 = 0;
            x1 = x0 + leafWidth/2;
            x2 = x0 + leafWidth/4;
            x3 = 0;
            
            y0 = 0 + stemLength;
            y1 = y0 + leafLength/3;
            y2 = y1 + leafLength/3;
            y3 = y0 + leafLength;
            
            ofVertex(x0,y0);
            ofBezierVertex(x1,y1,x2,y2,x3,y3);
        
        ofEndShape();
        
        //draw stem
        ofSetColor(stemColor);
        ofRect(0, 0 + stemLength/2, stemWidth, stemLength);
        
        //triangular stem through leaf
        ofTriangle(0 - stemWidth/2, 0 + stemLength, 0 + stemWidth/2, 0 + stemLength, 0, 0 + stemLength + 2*(leafLength/3));
    
    
    ofPopMatrix();
    
    
    
    
}
Exemplo n.º 20
0
void ofxScale(float scale) {
    ofScale(scale,scale,scale);
}
Exemplo n.º 21
0
//--------------------------------------------------------------
void testApp::draw(){
    
    ofBackgroundGradient(ofColor(40,40,40), ofColor(20,20,20), OF_GRADIENT_CIRCULAR);

    if(stage != 1){
        gui->toggleVisible();
        gui2->toggleVisible();
    }
    
    if (stage == 0) {
        ofSetColor(255);
        helveticafont30.drawString("DO YOU HAVE SOMETHING TO HIDE?", ofGetWindowWidth()/2-340 , ofGetWindowHeight()/2);
        helveticafont30.drawString("LET THE NSA KNOW WHERE YOU ARE!", ofGetWindowWidth()/2-345 , ofGetWindowHeight()/2 + 45);
        
    } else if (stage == 1) {
        ofSetColor(255);
        helveticafont30.drawString("IS IN NEW YORK", ofGetWindowWidth()/2 - 142 , ofGetWindowHeight()/2);
        helfont15.drawString("Latitude: 40.704196  | Longitude: -74.042358", ofGetWindowWidth()/2 - 132, ofGetWindowHeight()/2 + 25);
        
    } else if (stage == 2) {
        helveticafont30.drawString("THANK YOU FOR YOUR COOPERATION.", ofGetWindowWidth()/2 - 310 , ofGetWindowHeight()/2);
        if(counter >= 140) stage = 0;
    }
    
    if(tracker.getFound()) {
        bFirst = false;
        
        if(counter >= 100 && stage == 0) {
            stage = 1;
        }
        
        if (bSnapshot == true){
            
            unsigned char *camPixels = cam.getPixels();
            img.setFromPixels(camPixels, cam.width, cam.height, OF_IMAGE_COLOR);
            img.crop(tracker.getPosition().x-150, tracker.getPosition().y-150, 300,300);
            string fileName;
//            string dir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/PhotoFace/bin/data/img/";
//            string dir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/faces/";
            
            string dir = "/Users/gusfaria11/Documents/ofx_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/faces/";
            
//            if(typeStr == ""){
//                fileName = "snapshot_"+ofToString(10000+snapCounter)+".png";
//            } else {
                fileName = typeStr+".png";
//            }

            img.saveImage(dir+fileName);
            sprintf(snapString, "saved %s", fileName.c_str());
            
            //send text to another file.
//            string mydir = "/Users/gusfaria11/Documents/openframeworks_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/train2.txt";
            string mydir = "/Users/gusfaria11/Documents/ofx_v0.8.0/apps/thesis/RT_FaceDetect/bin/data/train2.txt";
//            myfile.open(mydir);
//            string str = "HELLO its me again!\n";
//            cout << str.length() << endl;
//            buffer.allocate(fileName.length());
//            buffer.append(fileName+"\n");
//            myfile.writeFromBuffer(buffer);

//            bool fileWritten = ofBufferToFile(mydir, buffer);
//            buffer.append(fileName+"\n");
//            myfile.close();
            

            
            snapCounter++;
            
            bSnapshot = false;
            bClick = false;
            bFirst = true;

            cam.draw(ofGetWindowWidth(),0);
            buffer = ofBufferFromFile(mydir);
            buffer.append(fileName+"\n");
            ofBufferToFile(mydir, buffer);
            typeStr.clear();
            
            stage = 2;
        }
    }

    if(bDebug){
//DEBUGGING
    ofDrawBitmapStringHighlight("stage: " + ofToString(stage), ofPoint(10,40));
    ofDrawBitmapString(ofToString(counter), ofPoint(10,ofGetWindowHeight()-70));
    ofDrawBitmapString(typeStr, ofPoint(10,ofGetWindowHeight()-50));
    ofPushMatrix();
    ofScale(0.25, 0.25);
    cam.draw(0,0);
    tracker.draw();
    ofPopMatrix();
    }

}
void Leaf::draw(float _xPos, float _yPos){
    
    ofPushMatrix();
    ofSetLineWidth(1);
    ofTranslate(_xPos, _yPos);
    ofScale(scaleFactor, scaleFactor);
    ofRotateZ(rotation);
    
    //draw leaf
    
    ofSetColor(leafColor);
    
    nCurveVertices = 7;
    
    curveVertices[0].x = 0;
    curveVertices[0].y = 0;
    curveVertices[1].x = 0-leafWidth/6;
    curveVertices[1].y = 0+leafLength/3;
    curveVertices[2].x = 0-leafWidth/2;
    curveVertices[2].y = 0+leafLength/2;
    curveVertices[3].x = 0-leafWidth/4;
    curveVertices[3].y = 0+leafLength-leafLength/6;
    curveVertices[4].x = 0+leafWidth/4;
    curveVertices[4].y = 0+leafLength-leafLength/6;
    curveVertices[5].x = 0+leafWidth/2;
    curveVertices[5].y = 0+leafLength/2;
    curveVertices[6].x = 0+leafWidth/6;
    curveVertices[6].y = 0+leafLength/3;
    
    ofBeginShape();
    
    for (int i = 0; i < nCurveVertices; 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 == nCurveVertices-1 (last point) we call vertex 0 twice
        // otherwise just normal ofCurveVertex call
        
        if (i == 0){
            ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
            ofCurveVertex(curveVertices[0].x, curveVertices[0].y); // we need to duplicate 0 for the curve to start at point 0
        } else if (i == nCurveVertices-1){
            ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
            ofCurveVertex(curveVertices[0].x, curveVertices[0].y);	// to draw a curve from pt 6 to pt 0
            ofCurveVertex(curveVertices[0].x, curveVertices[0].y);	// we duplicate the first point twice
        } else {
            ofCurveVertex(curveVertices[i].x, curveVertices[i].y);
        }
    }
    
    ofEndShape();
    
    //draw left half of leaf
    
    //        ofBeginShape();
    //
    //        float x0 = 0;
    //        float x1 = x0 - leafWidth;
    //        float x2 = x0 - leafWidth/leafCurvature;
    //        float x3 = x0;
    //
    //        float y0 = 0 - stemLength;
    //        float y1 = y0 - leafLength/3;
    //        float y2 = y1 - leafLength/3;
    //        float y3 = y0 - leafLength;
    //
    //        ofVertex(x0,y0);
    //        ofBezierVertex(x1,y1,x2,y2,x3,y3);
    //
    //        ofEndShape();
    //
    //    draw right half of leaf
    //
    //        ofBeginShape();
    //
    //        x0 = 0; //don't need to redefine as float, because we are just reusing the variables created above
    //        x1 = x0 + leafWidth;
    //        x2 = x0 + leafWidth/leafCurvature;
    //        x3 = x0;
    //
    //        y0 = 0 - stemLength;
    //        y1 = y0 - leafLength/3;
    //        y2 = y1 - leafLength/3;
    //        y3 = y0 - leafLength;
    //
    //        ofVertex(x0,y0);
    //        ofBezierVertex(x1,y1,x2,y2,x3,y3);
    //
    //        ofEndShape();
    
    //draw stem and veins of leaf
    
    
    
    
    
    //    cout << "x1 = ";
    //    cout << x1 << endl;
    //    cout << "x2 = ";
    //    cout << x2 << endl;
    
    ofPopMatrix();
    
}
Exemplo n.º 23
0
//--------------------------------------------------------------
void cyrilApp::draw(){

  if (fxOn) {
    _state.post.begin();
  }

  ofEnableDepthTest();
  
  if (lightsOn) {
    _state.light->enable();
    // The default position of the light (apply z-scale)
    _state.light->setPosition(0,0,1000);
  }
  else {
    ofDisableLighting();
  }
  
  //ofEnableAlphaBlending();
  
  _state.ms->clearStacks();
  float X_MAX = (*_state.sym)[REG_X_MAX];
  float Y_MAX = (*_state.sym)[REG_Y_MAX];
  float X_MID = (*_state.sym)[REG_X_MID];
  float Y_MID = (*_state.sym)[REG_Y_MID];
  float X_SCALE = (*_state.sym)[REG_X_SCALE];
  float Y_SCALE = (*_state.sym)[REG_Y_SCALE];
  float Z_SCALE = (*_state.sym)[REG_Z_SCALE];
  
  for (int i = 0; i < 10; ++i) {
    if (running[i]) {
      if (prog[i]->valid) {
        ofPushMatrix();
        ofTranslate(X_MID, Y_MID);
        _state.ms->pushMatrix();
        _state.ms->translate(X_MID, Y_MID);
        
        ofScale(X_SCALE, Y_SCALE, Z_SCALE);
        _state.ms->scale(X_SCALE, Y_SCALE, Z_SCALE);
        
        
        prog[i]->eval(_state);
        
        _state.ms->popMatrix();
        ofPopMatrix();
      }
    }
  }
  
  for(vector<Particle*>::iterator it = _state.ps->begin(); it != _state.ps->end(); ++it){
    (*it)->draw(&_state);
  }
  
  if (lightsOn) {
    _state.light->disable();
  }
  
  
  if (fxOn) {
    _state.post.end();
  }
  
	//mainOutputSyphonServer.publishScreen();
  
  // Draw the editor if enabled
  if (editorVisible) {
    ofDisableDepthTest();
    ofPushMatrix();
    ofPushStyle();
    ofSetColor(255);
    ofFill();
  	editor.draw();
    ofTranslate(X_MID - 50, 10);
    for (int i = 0; i < 10; ++i) {
      if (error[i]) {
        ofSetColor(255,0,0);
      }
      else if (running[i]) {
        ofSetColor(255);
      }
      else {
        ofSetColor(150);
      }
      ofRect(i * 10, 0, 8, 8);
      if (editor.currentBuffer == i) {
        ofSetColor(255);
        ofRect(i * 10, 10, 8, 5);
      }
    }
    ofPopStyle();
    ofPopMatrix();
  }
  
}
Exemplo n.º 24
0
void Cabin::draw() {
    
    //model->draw();
    toon.begin();
    
    toon.setUniform3f("uBaseColor", 1.0f, 0.0f, 0.0f );
    toon.setUniform3f("uDirLightPos", 0, 0, 0 );
    toon.setUniform3f("uDirLightColor", 20, 0, 0 );
    toon.setUniform3f("uAmbientLightColor", .7, .7, .7 );
//    toon.setAttribute3f("vNormal", 20, 0, 0 );
//    toon.setAttribute3f("vRefract", 20, 0, 0 );
//
//    uniform vec3 uBaseColor;
//    uniform vec3 uDirLightPos;
//    uniform vec3 uDirLightColor;
//    uniform vec3 uAmbientLightColor;
//    varying vec3 vNormal;
//    varying vec3 vRefract;
    ofPushMatrix();
    ofEnableAlphaBlending();
    ofSetColor(255);
    ofScale(5,5,5);
    ofRotateY(90);
    for(int i=0;i<ROWS;i++) {
        ofPushMatrix();
        ofTranslate(i*rowDist,0,0);
        if(windows.isAllocated()) {
            // Making the windows
            // First window
            ofPushMatrix();
            ofTranslate(0,-4,2);
            ofRotateX(90);
            ofRotateY(-180);
            ofRotateZ(0);
            windows.draw(0, 0, 2, 2);
            ofPopMatrix();
            
            //Second window
            ofPushMatrix();
            ofTranslate(0, seatSep*4*SEATS + (SEATS * 2 * .6),2);
            ofRotateX(90);
            ofRotateY(0);
            ofRotateZ(0);
            windows.draw(0, 0, 2, 2);
            ofPopMatrix();
            
        }
        ofSetColor(200);
        // Making the seats
        for(int j=0;j<SEATS;j++) {
            ofPushMatrix();
            
            
            ofScale(2,4,2);
            if(j%2) ofTranslate(0,2,0);
            ofTranslate(0, j*seatSep,0);
            
            // This defines the seatbelt above the seat
            ofPushMatrix();
            ofTranslate(0,0,3);
            ofRotateX(90);
            ofRotateY(45);
            ofSetColor(255);
            seatbelt->draw(0,0,1,seatbelt->getHeight() / seatbelt->getWidth() );
            ofSetColor(200);
            ofPopMatrix();
            
            ofBox(1);
            ofPopMatrix();
        }
        ofPopMatrix();
    }
    ofPopMatrix();
    toon.end();
}
Exemplo n.º 25
0
//--------------------------------------------------------------
void testApp::draw(){
    
    if (calibrateOn) drawGrid(); 
    if (calibrateOn) calibrate(); 
    drawText();
    
    
    //draw the cities------------------------------------------//
    ofPushMatrix(); 
    ofTranslate(gridX,gridY);
    ofScale(gridScaleX + scaleFactor, gridScaleY + scaleFactor);
    ofRotateZ(degreesFactor);
    ofEnableSmoothing();
    ofFill();

    for (int i = 0; i < 129; i++) {
        if (cities[i].isNear) {
            ofSetHexColor(0xe0be21);
        } else {
            ofSetColor(0);
        }
        cities[i].display(); 
    }
    ofFill();
    ofPopMatrix();
    
    
    //check distance------------------------------------------//
    for (int i = 0; i < 129; i++) {
        
        //we set the new coordinates of the cities to compare with mousePosition
        
        float loc_x_temp = cities[i].loc.x*(scaleFactor)+gridX;
        float loc_y_temp = cities[i].loc.y*(scaleFactor)+gridY;
        float d = ofDist(loc_x_temp, loc_y_temp,knob.x, knob.y); //magnitude
        
        
        if (rotation){
            ofVec2f locV(loc_x_temp,loc_y_temp);
            locV.rotate(degreesFactor);
            d= ofDist(locV.x, locV.y,knob.x, knob.y);
        }
        
        d = ofClamp(d, 0, 15);
        
        //add the station to the playlist. change later to "play"---------//
        if (d < 15) {
            int vol = ofMap(d, 0, 15, 100, 0);
            cities[i].volume = vol; 
            string setVol = "volume " + cities[i].volume; //for soundflower?
            
            cities[i].isNear = true;  
            
            if (!cities[i].isPlaying) {
                string command = "add " + cities[i].station;
                vlc.run(command); 
                nowPlaying = cities[i].name; 
                cities[i].isPlaying = true; 

            }
        } else {
            cities[i].isNear = false;  
            cities[i].isPlaying = false;              
        }
        
    }
    

    //tuio---------------------------//
    //render TUIO Cursors and Objects
	myTuio.drawCursors();
	myTuio.drawObjects();
    
    knob = myTuio.returnCursor();
    ofSetColor(100, 250, 100);
    ofCircle (knob.x, knob.y, 60); 
    

    
}
Exemplo n.º 26
0
//--------------------------------------------------------------
void ofApp::update(){
    
    pointLight.setPosition((ofGetWidth()*.8)+ cos(ofGetElapsedTimef()*.5)*(ofGetWidth()*.8), ofGetHeight()/2, 500);
    pointLight2.setPosition((ofGetWidth()*.8)+ cos(ofGetElapsedTimef()*.5)*(ofGetWidth()*.8), -ofGetHeight()/2, -500);
    heart_vertices[100].set(1400,1400,1400);
    int cnt =0;
    for(int i=0; i < 3;i++){
        for(int j=0; j < heart[i].getNumVertices(); j+=10){
            for(int k=0; k < nearest[cnt].size();k++){
                heart[i].setVertex(nearest[cnt][k],heart_[i].getVertex(nearest[cnt][k])*(ofNoise(ofGetFrameNum()/100.0f,j)*fftSmoothed[0]*0.4+1));
            }
            cnt++;
        }
    }
    
    float * val = ofSoundGetSpectrum(nBandsToGet);		// request 128 values for fft
    for (int i = 0;i < nBandsToGet; i++){
        
        // let the smoothed calue sink to zero:
        fftSmoothed[i] *= 0.96f;
        
        // take the max, either the smoothed or the incoming:
        if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i];
        
    }
    if(!beat.isPlaying())beat.play();
    
    
    myFbo.begin();
    ofClear(0,0,0,255);
    
    


    cam.begin();

    ofPushMatrix();
    ofTranslate(0, 0,-400);
    ofEnableAlphaBlending();
    for(int key=0; key<IMG_SIZE; key++){
        float n = ofNoise(key,ofGetFrameNum()/80.0f);
        if(n>0.9) {
            ofSetColor(255,255,255,255);
            images[key].draw(-ofGetWidth()/2, -ofGetHeight()/2, ofGetWidth(), ofGetHeight());
            cout<<key<<endl;
        }
    }
    ofDisableAlphaBlending();
    //mizukusa.draw(ofPoint(-ofGetWidth()/2, -ofGetHeight()/2,1500) ,ofGetWidth(), ofGetHeight());
    ofPopMatrix();
    ofEnableDepthTest();
    
    ofEnableLighting();
    pointLight.enable();
    pointLight2.enable();
    
    ofPushMatrix();
    {
        
        
        ofPushMatrix();
        {
            
            ofScale(0.3,0.3);
            ofTranslate(ofGetWidth()/2*0.8,ofGetHeight()/2*0.8);
            ofRotateY(ofGetFrameNum()/3.0f);
            
            for(int i=0; i < 3; i++){
                //heart[i].draw();
            }
        }ofPopMatrix();
        material.end();
        ofScale(2.6,2.6);
        ofRotateY(ofGetFrameNum()/3.0f);
        ofRotateX(ofGetFrameNum()/1.8f);
        material.begin();
        for(int i=0; i < 3; i++){
            heart[i].draw();
        }
        
    }
    ofPopMatrix();
    ofDisableLighting();
    cam.end();

    myFbo.end();
    
    for(int i=0; i < 6; i++){
        noises[i] = ofNoise(i+1,ofGetFrameNum()/100.0f);
    }
    
    for(int key=0; key<6; key++){
        if(noises[key]>0.9 && key == 0) myGlitch.setFx(OFXPOSTGLITCH_GLOW	, true); else if(key==0) myGlitch.setFx(OFXPOSTGLITCH_GLOW	, false);
        if(noises[key]>0.8 && key == 1) myGlitch.setFx(OFXPOSTGLITCH_CUTSLIDER	, true); else  if(key==1)  myGlitch.setFx(OFXPOSTGLITCH_CUTSLIDER	, false);
        if(noises[key]>0.8 && key == 2) myGlitch.setFx(OFXPOSTGLITCH_CONVERGENCE	, true); else  if(key==2)  myGlitch.setFx(OFXPOSTGLITCH_CONVERGENCE	, false);
        if(noises[key]>0.8 && key == 3) myGlitch.setFx(OFXPOSTGLITCH_SLITSCAN	, true); else  if(key==3)  myGlitch.setFx(OFXPOSTGLITCH_SLITSCAN	, false);
        if(noises[key]>0.8 && key == 4) myGlitch.setFx(OFXPOSTGLITCH_NOISE	, true); else  if(key==4)  myGlitch.setFx(OFXPOSTGLITCH_NOISE	, false);
        if(noises[key]>0.8 && key == 5) myGlitch.setFx(OFXPOSTGLITCH_TWIST	, true); else  if(key==5)  myGlitch.setFx(OFXPOSTGLITCH_TWIST	, false);
        
    }
    
}
Exemplo n.º 27
0
//--------------------------------------------------------------
void testApp::draw(){
	
	updateParticleSystem();
	updatePerlinLuminosity();

	renderTarget.begin();
	ofClear(0,0,0,255);
	cam.begin(ofRectangle(0,0,renderTarget.getWidth(), renderTarget.getHeight()));
			
    if(player.isLoaded()){
		drawGeometry();
	}

	ofPushMatrix();
//	ofScale(1,-1,1);
	ofTranslate(timeline.getValue("x offset"), 0, timeline.getValue("z offset"));
	glEnable(GL_DEPTH_TEST);
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	
	ofSetColor(0);
	ofPushMatrix();
	ofScale(1, -1, 1);
	meshBuilder.getMesh().disableColors();
	meshBuilder.getMesh().draw();
	meshBuilder.getMesh().enableColors();
	ofPopMatrix();
	ofSetColor(255);
	
	ambientShader.begin();
	ofEnablePointSprites();
	ofDisableArbTex();
	crossSprite.getTextureReference().bind();
	
	ambientShader.setUniform1f("maxDisance", particleMaxDistance) ;
	ambientShader.setUniform1f("maxSize", particeMaxSize) ;

	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	ofPushStyle();
	glPointSize(3.0);
	ofSetColor(particleFade*255);
	ambientParticles.drawVertices();
	ofPopStyle();
	ambientShader.end();

	crossSprite.getTextureReference().unbind();
	
	glDisable(GL_DEPTH_TEST);
	ofDisablePointSprites();
	ofEnableArbTex();

	ofPopMatrix();
	
//	randomUnits.drawVertices();
//	clusters.drawVertices();

	cam.end();
	
	renderTarget.end();
	
	ofEnableAlphaBlending();
	ofPushStyle();
	ofSetColor(0);
	ofRect(fboRect);
	ofPopStyle();

	
	renderTarget.getTextureReference().draw(fboRect.x,fboRect.getBottom(),fboRect.width,-fboRect.height);
	
	if(rendering){

		saveImage.setUseTexture(false);
		renderTarget.readToPixels(saveImage.getPixelsRef());
		saveImage.mirror(true, false);
		char filename[1024];
		sprintf(filename, "%sframe_%05d.png",renderFolder.c_str(), currentFrameNumber);
		saveImage.saveImage(filename);
		currentFrameNumber++;
		
	}
	timeline.draw();
    gui.draw();
}
void TriggerSettingsRocketOrb :: draw(float elapsedtime, ofVec3f pos, float unitPower, bool active, float scale, float angle) {

	elapsedTime = elapsedtime;
	map<string, float>& triggerValues = *values;
	
	float& rot1 = triggerValues["rot1"];
	float& rot2 = triggerValues["rot2"];
	float& rot3 = triggerValues["rot3"];
	float& vel1 = triggerValues["vel1"];
	float& vel2 = triggerValues["vel2"];
	float& vel3 = triggerValues["vel3"];
	float& smoothSize = triggerValues["smoothSize"]; 
	
	float speed = 1.5;
	
	if(unitPower<rechargeSettings->triggerPower ) speed = ofMap(unitPower, 0, rechargeSettings->triggerPower, 0, 0.5, true);
	rot1+= vel1 * deltaTime * speed;
	rot2+= vel2 * deltaTime * speed;
	rot3+= vel3 * deltaTime * speed;

	
	ofPushStyle();
	ofPushMatrix();
	
	float triggerPower = rechargeSettings->triggerPower;
    
	ofTranslate(pos);
	/*
	if(waitBrightness>0) {
		ofEnableBlendMode(OF_BLENDMODE_ADD);
	
		ofSetColor(waitBrightness*0.6 * abs(cos(elapsedtime*6)) );
		ofDrawBitmapString("WAIT", -16, -16, 0);
	}*/
	scale*=smoothSize;
	ofScale(0.75,0.75,0.75);
	ofScale(scale, scale, scale);
	
	float activeScale = 1;//ofMap(unitPower, 0, triggerPower, 0, 1, true);
	ofPushMatrix();
	ofScale(activeScale, activeScale, activeScale);
	
	ofDisableBlendMode();
	ofEnableAlphaBlending();
	ofFill();
	ofSetColor(0, 200);
	ofCircle(0,0, radius+2);
	ofSetColor(0, 70);
	ofCircle(0,0, radius+6);
	ofDisableAlphaBlending();
	
	ofEnableBlendMode(OF_BLENDMODE_ADD);
	
	
	ofColor dimColour = ofColor::white;
	//dimColour.setHue(hue);
	//dimColour.setSaturation(saturation);
  // WHY DOES IT HAVE A CHECK FOR RESTORE SPEED? 
	if((triggerPower<=unitPower)  || (rechargeSettings->restoreSpeed==0)) {
		
		//ofCircle(0, 0, radius*0.5);
		//ofNoFill();
		
		dimColour.setHsb(hue, saturation, ofMap(unitPower, 0, triggerPower, 10,150, true));
		
	
		ofSetColor(dimColour);
		ofCircle(0, 0, radius*unitPower*0.5);
		
		ofSetColor(ofMap(unitPower, 0, triggerPower, 10,255, true));
		ofCircle(0, 0, radius*unitPower*0.3);
		
		dimColour.setHsb(hue, saturation, ofMap(unitPower, 0, triggerPower, 10,200, true));
		
		//ofSetColor(200);
		smoothSize += (1-smoothSize)*0.5;
	} else {
		
		smoothSize += (-smoothSize)*0.01;
		
		//waitBrightness+=3;
		//if(waitBrightness>255) waitBrightness = 255;
		dimColour.setBrightness(ofMap(unitPower, 0, triggerPower, 0,50, true));
		
		
	}
	
	ofSetColor(dimColour);
	

	ofSetLineWidth(1);
	
	ofPushMatrix();
	ofRotateY(30);
	ofRotateX(rot1);
	ofNoFill();
	ofCircle(0, 0, radius/2, radius);
	ofPopMatrix();
	
	ofPushMatrix();
	ofRotateZ(120);
	ofRotateX(rot2);
	ofNoFill();
	ofCircle(0, 0, radius/2, radius);
	ofPopMatrix();
	
	ofPushMatrix();
	ofRotateZ(240);
	ofRotateX(rot3);
	ofNoFill();
	ofCircle(0, 0, radius/2, radius);
	ofPopMatrix();
	
	ofPopMatrix();
	if((rotateOnFire) || (rotationSpeed!=0)) {
		ofRotate(angle);
		ofTriangle(0, -10-(radius*2), radius*0.5, -10, radius*-0.5, -10);
		//0,0,0,-20);
	}
	
	
		
	ofPopStyle();
	ofPopMatrix();
	
	
	
}
Exemplo n.º 29
0
void testApp::drawScene()
{

    light.enable();
    ofPushMatrix();
    
    
    ofScale(whole_scene_scale,whole_scene_scale,whole_scene_scale);
    ofRotateX(scene_rx);
    ofRotateY(scene_ry);
    ofRotateZ(scene_rz);
    ofTranslate(whole_scene_x, whole_scene_y, whole_scene_z);
    ofPushMatrix();

    
    ofVboMesh theCloud;
    theCloud.setUsage(GL_DYNAMIC_DRAW);
    theCloud.setMode(OF_PRIMITIVE_POINTS);
    theCloud.getNormals().resize(cloudField,ofVec3f(0));
    for (int i=0; i<cloud.size();i++) {
        theCloud.addVertex(cloud[i].location);
        theCloud.setNormal(i,ofVec3f(
                                     ofMap(meditationLevel, 0, 100, 5, 0)
                                     +ofNoise(ofGetElapsedTimef()+i),0,0));
        
    }
    
    billboardShader.begin();
    glDisable(GL_DEPTH_TEST);
    ofEnablePointSprites();
    texture.getTextureReference().bind();
    theCloud.draw();
    texture.getTextureReference().unbind();
    ofDisablePointSprites();
    billboardShader.end();
    glEnable(GL_DEPTH_TEST);
	ofPopMatrix();
    
    
    //   ----   room   ----
    
    if(showRoom){
        ofPushMatrix();
        ofEnableDepthTest();
        ofSetColor(255);
        ofRotateX(270);
        ofRotateY(roomRotateY);
        ofTranslate(roomModelPos);
        roomModel.draw();
        ofPopMatrix();
    }
    //   ----   end room   ----
    
    ofPushMatrix();
    drawPointCloud();
    ofPopMatrix();
#ifdef USE_TWO_KINECTS
    ofPushMatrix();
    drawAnotherPointCloud();
    ofPopMatrix();
#endif
    ofPopMatrix();
}
Exemplo n.º 30
0
//--------------------------------------------------------------
void ofApp::scaleToRobotWorld() {
	ofScale(ofGetWidth() / dimensionX, ofGetHeight() / dimensionY);
	ofRotate(180.0f, 0.0, 0.0f, 1.0f);
	ofTranslate(-dimensionX, -dimensionY);
}