Example #1
0
void ofApplication::drawPoiSprites()
{
    float shapeRadius = ofMap(audioHiPSF, 0.0, 1.0, POI_MIN_SCALE_FACTOR*ofGetWidth(), poiMaxScaleFactor*ofGetWidth(), true);
    
#ifdef USE_KINECT
    for (int i=0; i<handPhysics->getNumTrackedHands(); i++)
    {

        ofPoint hp = handPhysics->getNormalizedSpritePositionForHand(i);
        ofPoint hp1 = handPhysics->getNormalizedSpritePositionForHand(i, 1);
        hp *= ofGetWindowSize();
        hp1 *= ofGetWindowSize();
        
        ofxHandPhysicsManager::ofxHandPhysicsState physState = handPhysics->getPhysicsStateForHand(i);
        float spriteVel = physState.spriteVelocity.length();
        //float drawAlpha = ofMap(spriteVel, 0, 500, 180, 255);
        //ofSetColor(poiSpriteColor.r, poiSpriteColor.g, poiSpriteColor.b, drawAlpha);

#else
    {
        ofPoint hp = (ofGetWindowSize()/2.0f) + ofPoint(cosf(elapsedPhase/2.0f), sinf(elapsedPhase/2.0f))*100.0f;
        ofPoint hp1 = hp;
#endif
        
        ofSetColor(poiSpriteColorHSB.getOfColor());
        ofFill();
        
        // --------- fake "waveform" drawing algorithm -------------
        ofVec2f pDiff = hp - hp1;

        float pointDistance = pDiff.length();
        int nSegments = 5;
        
        ofPolyline spriteShape;
        spriteShape.addVertex(ofPoint(0,0));
        
        if (pointDistance > 5.0f){
            nSegments = MAX(5, pointDistance/15);
            for (int n=0; n<nSegments; n++){
                spriteShape.lineTo(ofPoint(pointDistance*(n+1)/(nSegments+1), ofRandom(-shapeRadius, shapeRadius)));
            }
            spriteShape.lineTo(ofPoint(pointDistance, 0));
        }
        else{
            for (int n=0; n<nSegments; n++){
                float angle = ofRandom(0, M_PI*2.0);
                spriteShape.lineTo(ofPoint(cosf(angle),sinf(angle))*shapeRadius);
            }
            spriteShape.close();
        }
        
        float dirAngle = ofVec2f(1.0f,0.0f).angle(pDiff);
        
        ofSetLineWidth(4.0f);
        ofPushMatrix();
        ofTranslate(hp1);
        ofRotate(dirAngle, 0, 0, 1);
        spriteShape.draw();
        ofPopMatrix();
        
    }
}

void ofApplication::drawHandSprites()
{
    ofSetColor(handsColorHSB.getOfColor());
    float radius = ofMap(audioMidEnergy, 0.1f, 4.0f, 2.0f, HANDS_MAX_SCALE_FACTOR*ofGetWidth(), false);
    
#ifdef USE_KINECT
    for (int i=0; i<handPhysics->getNumTrackedHands(); i++)
    {
        
        ofPoint handPos = handPhysics->getPhysicsStateForHand(i).handPositions[0];
        handPos *= ofGetWindowSize()/ofPoint(640,480);
#else
    {
        ofPoint handPos = ofGetWindowSize()/2.0f;
#endif
        if (radius > 4.0f){
            ofSetLineWidth(3.0f);
            ofPolyline randomShape;
            randomShape.addVertex(ofPoint(0,0));
            for (int s=0; s<4; s++){
                float angle = M_PI*2.0f*ofRandomf();
                randomShape.addVertex(ofPoint(cosf(angle)*radius, sinf(angle)*radius));
            }
            randomShape.close();
            ofPushMatrix();
            ofTranslate(handPos);
            randomShape.draw();
            ofPopMatrix();
        }
        else{
            ofFill();
            ofCircle(handPos, 4.0f);
        }
    }
}
    
void ofApplication::drawUserOutline()
{
#ifdef USE_KINECT
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    float scale = debugMode ? 1.0 : ofMap(audioLowEnergy, 0.0f, 1.0f, 1.0f, userShapeScaleFactor, true);
    ofSetColor(userOutlineColorHSB.getOfColor());
    ofPushMatrix();
    ofScale(scale, scale);
    ofTranslate(-ofPoint(mainFbo.getWidth(), mainFbo.getHeight())*(scale - 1.0f)/2.0f);
    userFbo.getTextureReference().draw(0,0,mainFbo.getWidth(),mainFbo.getHeight());
    ofPopMatrix();
#endif
}
Example #2
0
void Particle::draw(float _brightness){
    ofFill();
    ofSetColor(255, lifeSpan * _brightness);
    ofDrawCircle(loc, size);
}
Example #3
0
//--------------------------------------------------------------
void testApp::draw(){
	
	
	ofNoFill();
	
	pitchIn = (float)AA.pitch; //pitch input
	myPos = (pitchIn * 100) / 3000 ;  // x position on screen
	
	ofSetHexColor(0x000000);
	//ofDrawBitmapString( "pitch is : " + ofToString(myPos) + "\namplitude is : " + ofToString(scaledVol * 100.0, 0), 32,ofGetHeight()-20);
	ofDrawBitmapString("alexmilesdesign.com \npitch 1.1\n\nf = toggle fullscreen\nn = more sensitive \nm = less sensitive", 20, 30);
	
	//ofDrawBitmapString("Scaled average vol (0-100): " + ofToString(scaledVol * 100.0, 0), 32, 18);

	if (myPos <= 10.0f) {
		ofSetColor(20, 249, 135);
	}
	else if (myPos > 10.0f && myPos < 20.0f){
		ofSetColor(90, 81, 81);
	}
	else if ( myPos > 20.0f && myPos <= 30.0f) {
		ofSetColor(180, 16, 0);
	}
	else if ( myPos >= 31.0f && myPos <= 40.0f ) {
		ofSetColor(155, 46, 18);
	}
	else if ( myPos >= 41.0f && myPos <= 50.0f ) {
		ofSetColor(18, 255,140);
	}
	else if ( myPos >= 51.0f && myPos <= 60.0f ) {
		ofSetColor(90, 255, 19);
	}
	else if ( myPos >= 61.0f && myPos <= 70.0f ) {
		ofSetColor(81, 220, 44);
	}
	else if ( myPos >= 71.0f && myPos <= 80.0f ) {
		ofSetColor(38, 158, 254);
	}
	else if ( myPos >= 81.0f && myPos <= 90.0f ) {
		ofSetColor(47, 38, 233);
	}
	else if ( myPos >= 91.0f && myPos <= 100.0f ) {
		ofSetColor(233, 125, 38);
	}
	else if ( myPos >= 101.0f && myPos <= 110.0f ) {
		ofSetColor(233, 38, 116);
	}
	else if ( myPos >= 111.0f && myPos <= 120.0f ) {
		ofSetColor(114, 4, 48);
	}
	else if ( myPos >= 121.0f && myPos <= 130.0f ) {
		ofSetColor(228, 216, 79);
	}
	else if ( myPos >= 131.0f && myPos <= 140.0f ) {
		ofSetColor(228, 114, 79);
	}
	else if ( myPos >= 141.0f ) {
		ofSetColor(233, 255, 0);
	}
	
	ofFill();		
	ofCircle(ofGetWidth()/2, ofGetHeight()/2, scaledVol * 890.0f);
	
	/*  //lets draw the volume history as a graph
	ofBeginShape();
	for (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);	 */	

	
}
//--------------------------------------------------------------
void testApp::draw(){
    
    // gray rectangle
    ofSetColor(240);
    ofRect(0, 430, ofGetWindowWidth(), 40);
    
    // black dot
    ofSetColor(0);
    ofCircle(50, 450, 15);
    
    // red dot
    ofSetColor(255, 0, 0);
    ofCircle(100, 450, 15);
    
    // green dot
    ofSetColor(0, 255, 0);
    ofCircle(150, 450, 15);
    
    // blue dot
    ofSetColor(0, 0, 255);
    ofCircle(200, 450, 15);
    
    // heart indicator
    ofSetColor(255);
    gHeart.draw(400, 450);
    
    // if the drawer has requested to save, draw a half-heart
    // (will just draw on top of other one
    if ( bSaveRequestSent ) {
        rHeart.draw(400, 450);
    }
    if ( bSaveRequestReceived ) {
        lHeart.draw(400, 450);
    }
    
    if (bSaveRequestSent && bSaveRequestReceived ) {
        fullHeart.draw(400, 450);
    }
    
    // drawing indicator for what color is selected
    ofNoFill();
    ofSetColor(100);
    if (penColor == ofColor(0, 0, 0) ) {
        ofCircle(50, 450, 18);
    } else if (penColor == ofColor(255, 0, 0) ) {
        ofCircle(100, 450, 18);
    } else if (penColor == ofColor(0, 255, 0) ) {
        ofCircle(150, 450, 18);
    } else if (penColor == ofColor(0, 0, 255) ) {
        ofCircle(200, 450, 18);
    }
    ofFill();
    
    ofSetColor( penColor );
    
    // local drawing
    if ( bIsDrawing ) {
        ofLine(lastX, lastY, mouseX, mouseY);
        
        // every time we draw a line, send a message to the remote app
        spacebrew.sendRange("lastPosX", lastX);
        spacebrew.sendRange("lastPosY", lastY);
        spacebrew.sendRange("posX", mouseX);
        spacebrew.sendRange("posY", mouseY);
        
        lastX = mouseX;
        lastY = mouseY;
    }
    
    // draw remote information
    // note, the remote variables will update only when
    // the app receives all four within one frame
    ofSetColor(remoteColor);
    ofLine(remoteLastX, remoteLastY, remoteX, remoteY);
    
    if ( bSaveRequestReceived && bSaveRequestSent ) {
        // fullHeart.draw(400, 450); // note: if draw heart here, is black in saved .png file
        ofSaveFrame();
        bSaveRequestReceived = false;
        bSaveRequestSent = false;
        ofSetColor( 255, 255, 255 );
        ofRect(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
    }
}
Example #5
0
void Canvas::draw()
{
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofSetColor(ResourceManager::getInstance().getBackgroundColor());
    ofFill();
    ofRect(0, 0, ofGetWindowWidth(), ofGetWindowHeight());
    ofDisableBlendMode();
    
//    bgImg.draw(0, 0);

    if (Params::colorMode == 0)
    {
        ofEnableBlendMode(OF_BLENDMODE_SUBTRACT);
    }
    else {
        ofEnableBlendMode(OF_BLENDMODE_ADD);
    }
    
    // Draw normal strokes (#1)
    for (int i=0; i<strokes.size(); i++)
    {
        strokes[i]->draw();
    }
    if (currentStroke) {
        currentStroke->draw();
    }
    
    // Draw surface strokes (#2)
    ofSetColor(Params::surfaceColor);
    ofFill();
    for (int i=0; i<surfaceStrokes.size(); i++)
    {
        surfaceStrokes[i]->drawSurface();
    }
    if (currentSurfaceStroke) {
        currentSurfaceStroke->drawSurface();
    }

    // Draw particle strokes (#3)
    for (int i=0; i<particleStrokes.size(); i++)
    {
        particleStrokes[i]->draw();
    }
    if (currentParticleStroke) {
        currentParticleStroke->draw();
    }
    
    // Draw repeatable strokes (#4)
    for (int i=0; i<repeatableStrokes.size(); i++)
    {
        repeatableStrokes[i]->draw();
    }
    if (currentRepeatableStroke) {
        currentRepeatableStroke->draw();
    }

    // Draw spring strokes (#5)
    for (int i=0; i<springStrokes.size(); i++)
    {
        springStrokes[i]->draw();
    }
    if (currentSpringStroke) {
        currentSpringStroke->draw();
    }
    
    // Draw particle emitters (#7)
    for (int i=0; i<emitters.size(); i++)
    {
        emitters[i]->draw();
    }
    
    // Draw flow field ('f')
    if (bShowFlowfield) {
        flowField.draw();
    }

    
    // draw cursor
    ofSetColor(ResourceManager::getInstance().getStrokeColor());
    ofNoFill();
    if (strokeType == 4) {
        ofLine(ofGetMouseX()-7, ofGetMouseY()-7, ofGetMouseX()+7, ofGetMouseY()+7);
        ofLine(ofGetMouseX()+7, ofGetMouseY()-7, ofGetMouseX()-7, ofGetMouseY()+7);
        ofLine(bladePrev, blade);
    }
    else {
        ofEllipse(ofGetMouseX(), ofGetMouseY(), 15, 15);
    }
    
    ofDisableBlendMode();

}
Example #6
0
//--------------------------------------------------------------
void testApp::draw(){

	//--------------------------- circles
	//let's draw a circle:
	ofSetColor(255,130,0);
	float radius = 50 + 10 * sin(counter);
	ofFill();		// draw "filled shapes"
	ofCircle(100,400,radius);

	// now just an outline
	ofNoFill();
	ofSetColor(0xCCCCCC);
	ofCircle(100,400,80);

	// use the bitMap type
	// note, this can be slow on some graphics cards
	// because it is using glDrawPixels which varies in
	// speed from system to system.  try using ofTrueTypeFont
	// if this bitMap type slows you down.
	ofSetColor(0x000000);
	ofDrawBitmapString("circle", 75,500);


	//--------------------------- rectangles
	ofFill();
	for (int i = 0; i < 200; i++){
		ofSetColor((int)ofRandom(0,255),(int)ofRandom(0,255),(int)ofRandom(0,255));
		ofRect(ofRandom(250,350),ofRandom(350,450),ofRandom(10,20),ofRandom(10,20));
	}
	ofSetColor(0x000000);
	ofDrawBitmapString("rectangles", 275,500);

	//---------------------------  transparency
	ofSetColor(0x00FF33);
	ofRect(400,350,100,100);
	// alpha is usually turned off - for speed puposes.  let's turn it on!
	ofEnableAlphaBlending();
	ofSetColor(255,0,0,127);   // red, 50% transparent
	ofRect(450,430,100,33);
	ofSetColor(255,0,0,(int)(counter * 10.0f) % 255);   // red, variable transparent
	ofRect(450,370,100,33);
	ofDisableAlphaBlending();

	ofSetColor(0x000000);
	ofDrawBitmapString("transparency", 410,500);

	//---------------------------  lines
	// a bunch of red lines, make them smooth if the flag is set

	if (bSmooth){
		ofEnableSmoothing();
	}

	ofSetColor(0xFF0000);
	for (int i = 0; i < 20; i++){
		ofLine(600,300 + (i*5),800, 250 + (i*10));
	}

	if (bSmooth){
		ofDisableSmoothing();
	}

	ofSetColor(0x000000);
	ofDrawBitmapString("lines\npress 's' to toggle smoothness", 600,500);

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

	// draw a light grid:

	if (!bPreAutomatic || !bAutomatic) panel.draw();

	ofEnableAlphaBlending();
	ofSetColor(30, 30, 30, (int) (255 - 255 *  menuEnergy));
	ofRect(0,0,ofGetWidth(), ofGetHeight());

//	ofSetColor(255, 255, 255, 40);
//	for (int i = 0; i < nDivisionsWidth; i++){
//		float xLine = calibrationRectangle.x + ((float)calibrationRectangle.width / (float)(nDivisionsWidth-1)) * i;
//		ofLine(xLine, calibrationRectangle.y,xLine, calibrationRectangle.y + calibrationRectangle.height);
//	}
//
//	for (int i = 0; i < nDivisionsHeight; i++){
//		float yLine = calibrationRectangle.y + calibrationRectangle.height - ((float)calibrationRectangle.height / (float)(nDivisionsHeight-1)) * i;
//		ofLine(calibrationRectangle.x,yLine, calibrationRectangle.x + calibrationRectangle.width,yLine);
//	}

	//-----------------------------------------------------------------------
	//-----------------------------------------------------------------------
	if (fitter.bBeenFit != true){

		ofEnableAlphaBlending();

		float rad = 30;
		glLineWidth(4);
		ofSetColor(255, 255, 255, 100);
		ofLine (xp, yp-rad, xp, yp+rad);
		ofLine (xp-rad, yp, xp+rad, yp);;


		ofSetColor(255, 255, 255, 255);

		if (bAutomatic == true && bAmInAutodrive == true && bInAutoRecording){
		} else {
			ofCircle(xp, yp, rad*0.33);
		}

		ofFill();

		//
		// TODO: do some animation stuff here:
		if (bAutomatic == true && bAmInAutodrive == true){

			if (bInAutoRecording){

				ofSetColor(255, 0, 0, 200);
				ofCircle(xp, yp, 26);

				ofSetColor(255, 255,255);
				ofCircle(xp, yp, 5);

			} else {
				ofNoFill();
				ofSetColor(255, 255, 255, 150);
				ofCircle(xp, yp, 200 - 200* autoPct);
				ofFill();
			}
		}

		glLineWidth(1);
		ofFill();

		if (!bAutomatic)
		if (inputEnergy > 0){
			ofSetColor(255, 0, 127, (int) (60*inputEnergy));
			ofCircle(xp, yp, rad * 3.5 );

			ofSetColor(255, 0, 127, (int) (150*inputEnergy));
			ofCircle(xp, yp, rad );
		}

		ofSetColor(255, 255, 255);
		//calibrationInfo.draw(100,100);
	}
	
	//-----------------------------------------------------------------------
	//-----------------------------------------------------------------------

	if (!bAutomatic && !bPreAutomatic){

		if (!fitter.bBeenFit)	{
			ofSetColor(255, 0, 0,127);
			font.drawString("not calibrated", 100,100);
		} else {
			ofSetColor(0, 255, 0, 127);
			font.drawString("calibrated", 100,100);
		}
	}

	if (bPreAutomatic == true){
		calibrationInfo.draw(100,100);
//		cout << bPreAutomatic << endl;
	}

	fitter.draw();
}
Example #8
0
void ofxTLColorTrack::drawModalContent() {
    if(drawingColorWindow) {

        //this happens when a new keyframe is added
        //we need to wait until the draw cycle for the new
        //key to be in the array so we can determine it's
        //surrounding samples
        if(setNextAndPreviousOnUpdate) {
            setNextAndPreviousSamples();
            setNextAndPreviousOnUpdate = false;
        }

        if(selectedKeyframe == NULL) {
            ofLogError("ofxTLColorTrack::drawModalContent") << "The selected keyframe is null" << endl;
            drawingColorWindow = false;
            timeline->dismissedModalContent();
            return;
        }

        if(!colorPallete.bAllocated()) {
            ofLogError("ofxTLColorTrack::drawModalContent") << "The color palette is not allocated" << endl;
            timeline->dismissedModalContent();
            drawingColorWindow = false;
        }
        ofPushStyle();
        ofFill();
        ofSetColor(255);

        ofxTLColorSample* selectedSample = (ofxTLColorSample*)selectedKeyframe;
        colorWindow = ofRectangle( millisToScreenX(selectedKeyframe->time), bounds.y+bounds.height, 200, 200);
        if(colorWindow.getMaxY()+25 > timeline->getBottomLeft().y) {
            colorWindow.y = bounds.y - 25 - colorWindow.height;
        }
        if(colorWindow.getMaxX() > ofGetWidth()) {
            colorWindow.x -= colorWindow.width;
        }
        colorPallete.draw(colorWindow);

        ofVec2f selectionPoint = colorWindow.getMin() + selectedSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
        ofSetColor(selectedSample->color.getInverted());
        ofLine(selectionPoint - ofVec2f(8,0), selectionPoint + ofVec2f(8,0));
        ofLine(selectionPoint - ofVec2f(0,8), selectionPoint + ofVec2f(0,8));

        ofPushStyle();
        ofNoFill();
        if(previousSample != NULL) {
            ofVec2f previousSamplePoint = colorWindow.getMin() + previousSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
            ofSetColor(previousSample->color.getInverted(), 150);
            ofCircle(previousSamplePoint, 3);
            ofLine(previousSamplePoint,selectionPoint);
        }
        if(nextSample != NULL) {
            ofVec2f nextSamplePoint = colorWindow.getMin() + nextSample->samplePoint * ofVec2f(colorWindow.width,colorWindow.height);
            ofSetColor(nextSample->color.getInverted(), 150);

            //draw a little triangle pointer
            ofVec2f direction = (nextSamplePoint - selectionPoint).normalized();
            ofVec2f backStep = nextSamplePoint-direction*5;
            ofTriangle(nextSamplePoint,
                       backStep + direction.getRotated(90)*3,
                       backStep - direction.getRotated(90)*3);
            ofLine(nextSamplePoint,selectionPoint);
        }
        ofPopStyle();

        previousColorRect = ofRectangle(colorWindow.x, colorWindow.getMaxY(), colorWindow.width/2, 25);
        newColorRect = ofRectangle(colorWindow.x+colorWindow.width/2, colorWindow.getMaxY(), colorWindow.width/2, 25);

        ofSetColor(colorAtClickTime);
        ofRect(previousColorRect);
        ofSetColor(selectedSample->color);
        ofRect(newColorRect);
        ofSetColor(timeline->getColors().keyColor);
        ofNoFill();
        ofSetLineWidth(2);
        ofRect(colorWindow);
        ofPopStyle();
    }
}
Example #9
0
void ofxTLColorTrack::draw() {

    if(bounds.height == 0) {
        return;
    }

    if(viewIsDirty || shouldRecomputePreviews) {
        updatePreviewPalette();
    }

    if(keyframes.size() == 0) {
        ofPushStyle();
        ofSetColor(defaultColor);
        ofFill();
        ofRect(bounds);
        ofPopStyle();
    }
    else if(keyframes.size() == 1) {
        ofPushStyle();
        ofxTLColorSample* s = (ofxTLColorSample*)keyframes[0];
        ofSetColor(s->color);
        ofFill();
        ofRect(bounds);
        ofPopStyle();
    }
    else {
        previewPalette.draw(bounds);
    }

    for(int i = 0; i < keyframes.size(); i++) {

        if(!isKeyframeIsInBounds(keyframes[i])) {
            continue;
        }

        float screenX = millisToScreenX(keyframes[i]->time);

        ofPoint a = ofPoint(screenX-10,bounds.y);
        ofPoint b = ofPoint(screenX+10,bounds.y);
        ofPoint c = ofPoint(screenX,bounds.y+10);

        ofPushStyle();
        ofFill();
        ofxTLColorSample* s = (ofxTLColorSample*)keyframes[i];
        ofSetColor(s->color);
        ofTriangle(a,b,c);
        ofNoFill();
        ofSetColor(s->color.getInverted());
        ofSetLineWidth(1);
        ofTriangle(a,b,c);

        if(keyframes[i] == hoverKeyframe) {
            ofSetColor(timeline->getColors().highlightColor);
            ofSetLineWidth(3);
        }
        else if(isKeyframeSelected(keyframes[i])) {
            ofSetColor(timeline->getColors().textColor);
            ofSetLineWidth(2);
        }
        else {
            ofSetColor(s->color.getInverted());
        }
        ofLine(c, ofVec2f(screenX, bounds.getMaxY()));
        ofPopStyle();
    }
}
Example #10
0
void testApp::generateArcText(string sampleStr, int min,int max, float _xoff, float _yoff) {
    
    int i = 0;
    int totalLen = 0;
    float xoff = _xoff;
 
    for (float x = _xoff; x < ofGetWidth(); x += 20) {
        
		
        // Calculate a y value according to noise, map to
        float y = _yoff+ofMap(ofNoise(xoff+_xoff, yoff), 0, 1, min,max); // Option #1: 2D Noise
        
        
        if(x >_xoff){
            ofSetLineWidth(1);
            ofFill();
            ofSetColor(40);
            ofSetColor(0, 255, 0);
            //ofLine(xPrev,yPrev,x,y);
           /* ofSetColor(225);
            */
            if(i < sampleStr.length()){
                
                string currentChar = utf8_substr2(sampleStr,i,1);
                
                
                //cout << currentChar << endl;
                
                totalLen = totalLen+font.getStringBoundingBox(currentChar, 0, 0).width;
                
                ofVec2f tanVec = ofVec2f(xPrev,yPrev) - ofVec2f(x,y);
                
                float yDiff = tanVec.y;
                float xDiff = tanVec.x;
                
                float arcTan = ofRadToDeg(atan(yDiff / xDiff));
                
                ofPushMatrix();
                ofTranslate(x,y);
                ofRotateZ(arcTan);
                float scaleVal = ofMap(x-_xoff, 0, ofGetWidth(), 0.1, 1);
                float alphaVal = ofMap(x-_xoff,0,ofGetWidth(),10,255);
                ofScale(1-scaleVal,1-scaleVal,1);
                
                //ofSetColor(255-(alphaVal));
               // if(i < sampleStr.length())
                //ofSetColor(0, 255, 0, ofMap(mouseX,0,ofGetWidth(),20,255));
                font.drawString(currentChar, 0, 0);
                ofPopMatrix();
            }
            
            i++;
            
        }
        
        
        xPrev = x;
        yPrev = y;
        // Increment x dimension for noise
        xoff += ofMap(mouseX, 0, ofGetWidth(), 0,0.01);
        //xoff += 0.01;
	}
	// increment y dimension for noise
	yoff += ofMap(mouseY, 0, ofGetHeight(), 0,0.01);
	//yoff += 0.003;
    
    curTextLength = 0;
}
void pclSystem::animate() {

	double x,y,d,theta,force;

	for (int i = 0;i < particles.size();i++) {
		for (int j = 0;j < fields.size();j++) {
				y = abs(particles[i].y-fields[j].y);
				x = abs(particles[i].x-fields[j].x);
				d = sqrt(pow(abs(particles[i].x-fields[j].x),2)+pow(abs(particles[i].y-fields[j].y),2));
				theta = asin(y/d);
				force = (fields[j].strength*particles[i].mass)/(pow(d,2));

				if (particles[i].x > fields[j].x) {
					particles[i].xSpeed -= force*cos(theta);
				}
				else{
					particles[i].xSpeed += force*cos(theta);
				}

				if (particles[i].y > fields[j].y) {
					particles[i].ySpeed -= force*sin(theta);
				}
				else{
					particles[i].ySpeed += force*sin(theta);
				}
		}
		particles[i].x += particles[i].xSpeed;
		particles[i].y += particles[i].ySpeed;

		particles[i].red += particles[i].redIncrease;
		particles[i].blue += particles[i].blueIncrease;
		particles[i].green += particles[i].greenIncrease;

		particles[i].alpha += particles[i].alphaDecay;
		if (particles[i].size > 0) {
			particles[i].size  -= particles[i].sizeDecay;
			if (particles[i].size < 0) {
				particles[i].size = 0;
			}
		}

		particles[i].ySpeed += gravityY;
		particles[i].xSpeed += gravityX;


		if (particles[i].shape == "circle") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofFill();
			ofCircle(particles[i].x,particles[i].y,particles[i].size);
		}
		else if (particles[i].shape == "square") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofFill();
			ofRect(particles[i].x,particles[i].y,particles[i].size,particles[i].size);
		}
		else if (particles[i].shape == "hor_line") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofFill();
			ofLine(particles[i].x,particles[i].y,particles[i].x+particles[i].size,particles[i].y);
		}
		else if (particles[i].shape == "circle_hollow") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofNoFill();
			ofCircle(particles[i].x,particles[i].y,particles[i].size);
		}
		else if (particles[i].shape == "square_hollow") {
			ofEnableAlphaBlending();
			ofSetColor(particles[i].red,particles[i].green,particles[i].blue,255-particles[i].alpha);
			ofNoFill();
			ofRect(particles[i].x,particles[i].y,particles[i].size,particles[i].size);
		}
	}

	for (int i = 0;i < particles.size();i++) {
		if (particles[i].alpha > 255) {
			vector<pclType>::iterator loc = particles.begin();
			particles.erase(loc+i);
		}
	}
	for (int i = 0;i < particles.size();i++) {
		if ( (abs(particles[i].xSpeed) > 35)||(abs(particles[i].ySpeed) > 35) ) {
			vector<pclType>::iterator loc = particles.begin();
			particles.erase(loc+i);
		}
	}
	for (int i = 0;i < particles.size();i++) {
		for (int j = 0;j < fields.size();j++) {
			y = abs(particles[i].y-fields[j].y);
			x = abs(particles[i].x-fields[j].x);
			if ((x < 10)&&(y<10)) {
				vector<pclType>::iterator loc = particles.begin();
				particles.erase(loc+i);
			}
		}
	}

}
Example #12
0
void ofxSymbolInstance::drawLayer(layer *ly,float alpha) {
    if (!ly) {
        return;
    }
    
    ofPushMatrix();
    glMultMatrixf(mat.getPtr());
    frame &f = ly->frames[ly->currentFrame];
    for (vector<ofxSymbolInstance>::iterator iter=f.instances.begin(); iter!=f.instances.end(); iter++) {
        if (iter->bVisible) {
            switch (iter->type) {
                case BITMAP_INSTANCE: {
                    ofPushMatrix();
                    glMultMatrixf(iter->mat.getPtr());
                    ofSetColor(255, 255, 255,alpha*alphaMultiplier*255.0);
                    iter->bitmapItem->draw();
                    ofSetColor(255, 255, 255,255);
                    ofPopMatrix();
                } break;
                    
                    
                case SHAPE: {
                    
                    ofxShape &shape = symbolItem->shapes[iter->shapeIndex]; 
                    if (!shape.curve.empty()) {
                        vector<curvePath>::iterator citer=shape.curve.begin(); 
                        ofBeginShape();
                        ofVertex(citer->p0.x,citer->p0.y);
                        for (vector<vector<ofVec2f> >::iterator iter=citer->segments.begin(); iter!=citer->segments.end(); iter++) {
                            
                            ofBezierVertex(iter->at(0).x,iter->at(0).y,iter->at(1).x,iter->at(1).y,iter->at(2).x,iter->at(2).y);
                        }
                        ofEndShape();
                    }
                    
                    
                    
                    if (!shape.line.empty()) {
                        //linePath l = shape.line.front();
                        vector<linePath>::iterator liter = shape.line.begin();
                        
                        if (liter->bClosed) {
                            
                            if (!shape.solidColorFill.empty()) {
                                
                                ofPushStyle();
                                ofSetHexColor(shape.solidColorFill.front());
                                
                                ofFill();
                                ofBeginShape();
                                ofVertex(liter->p0.x,liter->p0.y);
                                
                                for (vector<ofVec2f>::iterator iter=liter->segments.begin(); iter!=liter->segments.end()-1; iter++) { // roikr: we don't need the end
                                    ofVertex(iter->x,iter->y);
                                }
                                
                                ofEndShape();
                                ofPopStyle();
                                
                            };
                            
                            if (!shape.solidColorStroke.empty()) {
                                
                                ofPushStyle();
                                ofSetHexColor(shape.solidColorStroke.front());
                                
                                ofNoFill();
                                ofBeginShape();
                                ofVertex(liter->p0.x,liter->p0.y);
                                
                                for (vector<ofVec2f>::iterator iter=liter->segments.begin(); iter!=liter->segments.end(); iter++) {
                                    ofVertex(iter->x,iter->y);
                                }
                                
                                ofEndShape();
                                ofPopStyle();
                                
                            };
                            
                            if (!shape.bitmapFill.empty()) {
                                
                                ofxBitmapFill &bitmapFill = shape.bitmapFill.front();
                                
                                
//                                
//                                glEnable(GL_SCISSOR_TEST);
//                                ofRectangle &rect = bitmapFill.rect;
//                                
//#ifndef TARGET_OPENGLES                   
//                                ofVec2f p = (ofVec2f(rect.x,rect.y+rect.height)+doc->offset)*doc->zoom+0.5*ofVec2f(ofGetWidth(),ofGetHeight());
//                                
//                                glScissor(p.x, ofGetHeight()-p.y, rect.width*doc->zoom , rect.height*doc->zoom);
//                                
//#else                    
//                                ofVec2f q = (ofVec2f(rect.x+rect.width,rect.y+rect.height)+offset)*zoom+0.5*ofVec2f(ofGetWidth(),ofGetHeight());
//                                ofVec2f p = ofVec2f(ofGetHeight(),ofGetWidth())-ofVec2f(q.y,q.x);
//                                
//                                glScissor(p.x, p.y, rect.height*zoom , rect.width*zoom);
//#endif
                                
                                ofPushMatrix();
                                glMultMatrixf(bitmapFill.mat.getPtr());
                                bitmapFill.bitmapItem->draw();
                                ofPopMatrix();
                                
//                                glDisable(GL_SCISSOR_TEST);
            
                            }
                        } else {
                            
                            if (!shape.solidColorStroke.empty()) {
                                ofPushStyle();
                                ofSetHexColor(shape.solidColorStroke.front());
                                ofLine(liter->p0, liter->segments.front());
                                for (vector<ofVec2f>::iterator iter=liter->segments.begin(); iter!=liter->segments.end()-1; iter++) {
                                    ofLine(*iter, *(iter+1));
                                }
                                ofPopStyle();
                            }
                        }
                        
                    }
                }   break;
                    
            
            
            
                
                case SYMBOL_INSTANCE: 
                    iter->draw(alpha*alphaMultiplier);
                    break;
                    
                default:
                    break;
                    
            }

            
        }
    }
    
    ofPopMatrix();
     
/*    
        
        
    
    ofPushStyle();
    for (vector<tlfText>::iterator titer=ly.texts.begin();titer!=ly.texts.end();titer++) {
        
        float v = 0;
        
        for (vector<span>::iterator iter=titer->spans.begin(); iter!=titer->spans.end(); iter++) {
            ofPushMatrix();
//                ofTranslate(titer->translation+ofVec2f(0,v+iter->fontSize));
            ofTranslate(titer->translation+ofVec2f(0,v+(float)font.stringHeight(iter->text)*(float)iter->fontSize/(float)font.getSize()));
            float scale = (float)iter->fontSize/(float)font.getSize();
            ofScale(scale, scale);
            ofSetHexColor(iter->color);
            font.drawString(iter->text, 0, 0);
            ofPopMatrix();
            v+= (float)iter->fontSize*lineHeight;
        }
                        
    }
    ofPopStyle();
*/
    
    
}
Example #13
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(int 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(int 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(int 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);
    }
    
    
}
Example #14
0
//--------------------------------------------------------------
void testApp::draw(){
    
//    ofFill();
//	ofSetRectMode( OF_RECTMODE_CORNER );
//    ofSetColor(0,0,0,255*0.01);
//    ofRect( ofGetWindowRect() );
    
    ofSetColor(255, 255, 255, 255);
	float xorig = 500;
	float yorig = 300;
	float angle = ofGetElapsedTimef()*3.5;
	float radius = 200;
	float x = xorig + 200*(sin(ofGetElapsedTimef()/10)) * cos(angle * 3.4);    // 3.4
	float y = yorig + 200*(cos(ofGetElapsedTimef()/10)) * sin(angle * 4.7);   // 4.7
	
	ofPoint temp;
	temp.x = x;
	temp.y = y;
	points.push_back(temp);
	if (points.size() > (1000*(sin(ofGetElapsedTimef())))){
		points.erase(points.begin());
	}
	
	ofPushMatrix();{
//        ofTranslate(ofGetScreenWidth()/2, ofGetScreenHeight()/2);
//        ofRotateX(rotation.z);
//        ofRotateY(rotation.z);
//        ofRotateZ(rotation.z);

        
	ofSetRectMode(OF_RECTMODE_CENTER);
	ofSetColor(255,0,127);
	ofFill();
	ofCircle(x,y,10);
	
	ofSetColor(255,255,255);
	
	ofNoFill();
	ofBeginShape();
	for (int i = 0; i < points.size(); i++){
		ofVertex(points[i].x, points[i].y);
	}
	ofEndShape();
    
    
    ofBeginShape();
	for (int i = 0; i < points.size(); i++){
        if(i>4){
            ofVertex(points[i-5].x+ofRandom(10), points[i-5].y+ofRandom(10));
        }
	}
	ofEndShape();
    
    ofBeginShape();
	for (int i = 0; i < points.size(); i++){
        if(i>9){
            ofVertex(points[i-10].x, points[i-10].y);
        }
	}
	ofEndShape();
    
    ofBeginShape();
	for (int i = 0; i < points.size(); i++){
        if(i>14){
            ofVertex(points[i-15].x, points[i-15].y);
        }
	}
	ofEndShape();
    };ofPopMatrix();
	
	
	
	
}
Example #15
0
void testApp::draw() {
	ofBackground(245);
    ofSetColor(255);  //everything drawn with white tint
	kinect.drawDepth(0, 0);
	easyCam.begin();
    
    ofScale(1, -1, -1);
    //ofTranslate(0, 0, -200);
    
   

    ofSetColor(0);
	int width = kinect.getWidth();
	int height = kinect.getHeight();
	
	float* distancePixels = kinect.getDistancePixels(); 
    ofMesh cloud;
    cloud.setMode(OF_PRIMITIVE_POINTS);

    float minZ = 1500;
    float minX = 0;
    float minY = 0;
    float dist = 1500;
    float secondZ = 1500;
    float secondX = 0;
    float secondY = 0;
    
	for(int y = 0; y < height; y++) {
		for(int x = 0; x < width; x++) {
			int i = y * width + x;
			float z = distancePixels[i];
            
            if(z !=0 && z < 1500 && drawCloud == true) cloud.addVertex(ConvertProjectiveToRealWorld(x, y, z));
			
            if(z != 0 && z < minZ) {
                minZ= z;
                minX = x;
                minY = y;
                forepoint = ConvertProjectiveToRealWorld(minX, minY, minZ);
			}
            else if ( z !=0 && z > minZ && z-minZ < dist) {
                dist = z - minZ;
                secondZ = z;
                secondX = x;
                secondY = y;
                
            }
		}
	}
    if(drawCloud) cloud.draw();
    
    //secondPoint = ConvertProjectiveToRealWorld(secondX, secondY, secondZ);

    ofSetColor(50);
    if(doDrawing) {
        drawing.addVertex(forepoint);
        //drawing2.addVertex(secondPoint);
    }
    //drawing.draw();
    //drawing2.draw();
    
   
    //ofCircle(secondPoint.x, secondPoint.y, 5);
    
    if(drawCopy) {
        meshCopy.draw();
    }
        
    easyCam.end();
    
    //averaging the data in a region around the forepoint
    ofNoFill();
    int searchRadius = 64;
    int searchDistance = 100;
    int count = 0;
    ofVec3f sum = ofVec3f(0, 0, 0);

    ofRect(minX-searchRadius/2, minY+searchRadius/2, searchRadius, searchRadius);
    for(int x = -searchRadius/2; x < searchRadius/2; x++) {
        for (int y = -searchRadius/2; y < searchRadius/2; y++) {
            int curx = x+minX;
            int cury = y+ minY;
            if( curx < width && curx >0 && y + cury >0 && cury < height) {
                int i = cury*width + curx;
                float z = distancePixels[i];
                if(z!=0 && z-minZ < searchDistance) {
                    sum.x+= curx;
                    sum.y+= cury;
                    //unlike x and y, z is taken from distancePixels[i] so dont adjust for current (x, y) like curx cury
                    sum.z+= z;
                    count++;
                }
            }
        }
    }
    
    //we are only looking at a single point. no perspective issue involed?
    //ofVec3f avg = ConvertProjectiveToRealWorld(sum.x/count, sum.y/count, sum.z/count);
    
    ofSetColor(0, 255, 0);
    ofFill();
    ofCircle(avg.x, avg.y, 5);
    ofSetColor(255, 0, 0);
    ofFill();
    ofCircle(forepoint.x, forepoint.y, 5);
    
    ofSetColor(0);
    ofDrawBitmapString( "space bar to render / t to resume", 50, 100);
    ofDrawBitmapString( ofToString(forepoint.x) + "/" + ofToString(avg.x), 50, 150);
}
Example #16
0
void GmlModel::drawRadii()
{
	ofEnableAlphaBlending();
	glEnable(GL_DEPTH_TEST);
	
	glPushMatrix();
		
		glTranslatef(position.x,position.y,position.z);

		// center on screen
		glTranslatef(ofGetWidth()*.5f, ofGetHeight()*.5, 0);	
				
		// rotate
		glRotatef(rotation.x,0,1,0);
		glRotatef(rotation.y,1,0,0);
		glRotatef(rotation.z,0,0,1); 
		
		// center tag
		glTranslatef(-min.x*drawScale,-min.y*drawScale,-min.z);
		glTranslatef(-center.x*drawScale,-center.y*drawScale,-center.z);

		//cout << "pos z " << position.z << endl;

		// draw circles and connecting lines
		for( int i = 0; i < myData.size(); i++)
		{
			for( int j = 0; j < myData[i].rings.size()-1; j++)
			{
					glBegin(GL_LINES);
					ofNoFill();
					glColor4f(1,1,1,.5);
					for( int k = 0; k < myData[i].rings[j].rPoints.size(); k++)
					{
						if( k == 0 )	glColor4f(1,0,0,1);
						else			glColor4f(1,1,1,.5);
						
						glVertex3f(myData[i].rings[j].ePoints[k].x, myData[i].rings[j].ePoints[k].y,myData[i].rings[j].ePoints[k].z);
						glVertex3f(myData[i].rings[j].rPoints[k].x, myData[i].rings[j].rPoints[k].y,myData[i].rings[j].rPoints[k].z);
						/*if( j > 1 )
						{
							glVertex3f(myData[i].rings[j-1].rPoints[k].x, myData[i].rings[j-1].rPoints[k].y,myData[i].rings[j-1].rPoints[k].z);
							glVertex3f(myData[i].rings[j].rPoints[k].x, myData[i].rings[j].rPoints[k].y,myData[i].rings[j].rPoints[k].z);
						}*/
					}
					glEnd();						
					
					ofFill();
					glColor4f(0,0,0,1);
					for( int k = 0; k < myData[i].rings[j].rPoints.size(); k++)
					{
						glPushMatrix();
							glTranslatef(myData[i].rings[j].rPoints[k].x, myData[i].rings[j].rPoints[k].y,myData[i].rings[j].rPoints[k].z);
							ofCircle(0, 0, 1);
						glPopMatrix();
						
					}
					
			}
		}
		
	
	glPopMatrix();
	glDisable(GL_DEPTH_TEST);

	
}
void Alien::draw(){
    ofSetColor(r,g,b,alpha);
    ofFill();
    ofDrawCircle(xPos, yPos, diam);
}
Example #18
0
//------------------------------------------------------------
void particle::draw(){
    ofSetColor(100,255,220);
    ofFill();
    ofCircle(pos.x, pos.y, 3);
}
//--------------------------------------------------------------
void testApp::draw(){


if (isColor == true) {
ofSetColor((int)ofRandom(0,255),(int)ofRandom(0,255),(int)ofRandom(0,255));
}
else {
ofSetColor (255);
}
  ofFill();
  ofRect (xVrrznPos, yVrrznPos, xVrrzn, yVrrzn);

  ofSetColor(0);
  ofFill();
  ofRect (xVrrznPos+50, yVrrznPos+150, xVrrzn/2, yVrrzn-150);
  ofSetCircleResolution(100);
  ofCircle(xVrrznPos+100, yVrrzn+50, xBall);


  //Bouncing Balls
  //BallA
  ofSetColor(0,200,200);
  ofSetCircleResolution(100);
  ofFill();
  ofCircle(xPosA, yPosA, xBall/2);
  //BallB
  ofSetColor(255,0,200);
  ofSetCircleResolution(100);
  ofFill();
  ofCircle(xPosB, yPosB, xBall/2);
  //BallC
  ofSetColor(255,255,0);
  ofSetCircleResolution(100);
  ofFill();
  ofCircle(xPosC, yPosC, xBall/2);

  xPosA=xPosA+xVelA;
  yPosA=yPosA+yVelA;

  xPosB=xPosB+xVelB;
  yPosB=yPosB+yVelB;

  xPosC=xPosC+xVelC;
  yPosC=yPosC+yVelC;


  //Ball Collision with borders
  //BallA Right and Left
  if (xPosA>800 -xBall/2||xPosA<xBall/2) {
    xVelA=-xVelA;
  }
  //BallA Bottom and Top
  if (yPosA>800-xBall/2||yPosA<xBall/2) {
    yVelA=-yVelA;
  }
  //BallB Right and Left
  if (xPosB>800-xBall/2||xPosB<xBall/2) {
    xVelB=-xVelB;
  }
  //BallB Bottom and Top
  if (yPosB>800-xBall/2||yPosB<xBall/2) {
    yVelB=-yVelB;
  }
  //BallC Right and Left
  if (xPosC>800-xBall/2||xPosC<xBall/2) {
    xVelC=-xVelC;
  }
  //Ball C Bottom and Top
  if (yPosC>800-xBall/2||yPosC<xBall/2) {
    yVelC=-yVelC;
  }

  //Ball Collision (with each other)
  if (ofDist(xPosA, yPosA, xPosB, yPosB)<=xBall) { //BallA and BallB
    xVelA=-xVelA;
    yVelA=-yVelA;
    xVelB=-xVelB;
    yVelB=-yVelB;
  }
  if (ofDist(xPosA, yPosA, xPosC, yPosC)<=xBall) { //BallA and BallC
    xVelA=-xVelA;
    yVelA=-yVelA;
    xVelC=-xVelC;
    yVelC=-yVelC;
  }
  if (ofDist(xPosB, yPosB, xPosC, yPosC)<=xBall) { //BallB and BallC
    xVelB=-xVelB;
    yVelB=-yVelB;
    xVelC=-xVelC;
    yVelC=-yVelC;
  }

  //Balls - Bridge Collision
  //BallA - BridgeLeft
  if (ofDist(xPosA, yPosA, 300, 350)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 400)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 450)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 500)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 550)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 600)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 650)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 700)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 300, 750)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  //BallA - BridgeRight
  if (ofDist(xPosA, yPosA, 500, 350)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 400)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 450)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 500)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 550)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 600)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 650)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 700)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 500, 750)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  //BallA - BridgeTop
  if (ofDist(xPosA, yPosA, 350, 350)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 350, 400)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  if (ofDist(xPosA, yPosA, 350, 450)<=xBall/2) {
    xVelA = -xVelA;
    yVelA = -yVelA;
  }
  //BallB - BridgeLeft
  if (ofDist(xPosB, yPosB, 300, 350)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 400)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 450)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 500)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 550)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 600)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 650)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 700)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 300, 750)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  //BallB - BridgeRight
  if (ofDist(xPosB, yPosB, 500, 350)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 400)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 450)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 500)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 550)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 600)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 650)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 700)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 500, 750)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  //BallB - BridgeTop
  if (ofDist(xPosB, yPosB, 350, 350)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 350, 400)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  if (ofDist(xPosB, yPosB, 350, 450)<=xBall/2) {
    xVelB = -xVelB;
    yVelB = -yVelB;
  }
  //BallC - BridgeLeft
  if (ofDist(xPosC, yPosC, 300, 350)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 400)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 450)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 500)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 550)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 600)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 650)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 700)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 300, 750)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  //BallC - BridgeRight
  if (ofDist(xPosC, yPosC, 500, 350)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 400)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 450)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 500)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 550)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 600)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 650)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 700)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 500, 750)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  //BallC - BridgeTop
  if (ofDist(xPosC, yPosC, 350, 350)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 350, 400)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }
  if (ofDist(xPosC, yPosC, 350, 450)<=xBall/2) {
    xVelC = -xVelC;
    yVelC = -yVelC;
  }

     ofSetColor(225);
	verdana14.drawString("Click on the Bridge!", mouseX, mouseY);


}
void creature::draw() {
    
    
    ofFill();
    ofSetColor(color);

//    for (int i = 0; i < particles.size(); i++){
//        particles[i]->draw();
//    }
//
//    for (int i = 0; i < springs.size(); i++){
//        springs[i].draw();
//    }
    
    //HEAD
    ofBeginShape();
        ofVertex(particles[0]->pos.x, particles[0]->pos.y);
        ofVertex(particles[1]->pos.x, particles[1]->pos.y);
        ofVertex(particles[2]->pos.x, particles[2]->pos.y);
        ofVertex(particles[3]->pos.x, particles[3]->pos.y);
	ofEndShape();
    
    //BODY
    ofBeginShape();
        ofVertex(particles[4]->pos.x, particles[4]->pos.y);
        ofVertex(particles[5]->pos.x, particles[5]->pos.y);
        ofVertex(particles[6]->pos.x, particles[6]->pos.y);
        ofVertex(particles[7]->pos.x, particles[7]->pos.y);
	ofEndShape();
    
    //LEFT FEET
    ofBeginShape();
        ofVertex(particles[8]->pos.x, particles[8]->pos.y);
        ofVertex(particles[9]->pos.x, particles[9]->pos.y);
        ofVertex(particles[10]->pos.x, particles[10]->pos.y);
        ofVertex(particles[11]->pos.x, particles[11]->pos.y);
	ofEndShape();
    
    //RIGHT FEET
    ofBeginShape();
        ofVertex(particles[12]->pos.x, particles[12]->pos.y);
        ofVertex(particles[13]->pos.x, particles[13]->pos.y);
        ofVertex(particles[14]->pos.x, particles[14]->pos.y);
        ofVertex(particles[15]->pos.x, particles[15]->pos.y);
	ofEndShape();
    
    //LEFT ARM
    ofBeginShape();
        ofVertex(particles[16]->pos.x, particles[16]->pos.y);
        ofVertex(particles[17]->pos.x, particles[17]->pos.y);
        ofVertex(particles[4]->pos.x, particles[4]->pos.y);
	ofEndShape();
    
    //RIGHT ARM
    ofBeginShape();
        ofVertex(particles[18]->pos.x, particles[18]->pos.y);
        ofVertex(particles[19]->pos.x, particles[19]->pos.y);
        ofVertex(particles[7]->pos.x, particles[7]->pos.y);
	ofEndShape();
    
    ofPushMatrix();
        ofTranslate(particles[0]->pos.x, particles[0]->pos.y);
            ofPushMatrix();
                ofTranslate(size/2, size+size/2);
                ofSetColor(50,50,50);
                //TEETH
                ofTriangle(-size*3/8, 0, -size/4, size/3, -size/8, 0);
                ofTriangle(size/8,0, size/4, size/3, size*3/8,0);
                ofLine(-size/4, 0, size/4, 0);
            ofPopMatrix();
    ofPopMatrix();

//    ofPopMatrix();
    //    ofPoint righteyes;
    //    righteyes.x = particles[0]->pos.x + size/5;
    //    righteyes.y = particles[0]->pos.y + size/3;
    //
    //    ofPoint lefteyes;
    //    lefteyes.x = particles[3]->pos.x - size/5;
    //    lefteyes.y = particles[3]->pos.y + size/3;
    
    //    ofCircle(righteyes, size/5);
    //    ofCircle(lefteyes, size/6);
    
    
    float myLeftEyeX = (particles[3]->pos.x - particles[0]->pos.x)/4;
    float myLeftEyeY = (particles[1]->pos.y - particles[0]->pos.y)/4;
    
    float myRightEyeX = -(particles[3]->pos.x - particles[0]->pos.x)/4;
    float myRightEyeY = (particles[2]->pos.y - particles[3]->pos.y)/4;
    
    ofSetColor(50,50,50);

    ofPushMatrix();
        ofTranslate(particles[0]->pos.x, particles[0]->pos.y);
        ofCircle(myLeftEyeX, myLeftEyeY, size/5);
    ofPopMatrix();
    
    ofPushMatrix();
        ofTranslate(particles[3]->pos.x, particles[3]->pos.y);
        ofCircle(myRightEyeX, myRightEyeY, size/5);
    ofPopMatrix();

    
}
Example #21
0
void locCloud::drawMic()
{
    ofSetColor(micColor);
    ofFill();
    ofCircle(micPosition,10);
}
Example #22
0
void Boid::draw() {
    
    // Draw a triangle rotated in the direction of velocity
	
    
    if(loc.x == 0 || loc.x == ofGetWindowWidth()) vel.x *= -1;
    if(loc.y == 0 || loc.y == ofGetWindowHeight()) vel.y *= -1;


	
	float angle = (float)atan2(-vel.y, vel.x);
    float theta =  -1.0*angle;
	float heading2D = ofRadToDeg(theta)+90;
	
	ofEnableAlphaBlending();
    ofSetColor(255, 255, 255);
    ofFill();
    ofPushMatrix();
    ofTranslate(loc.x, loc.y);
    ofRotateZ(heading2D);
    
	/* DRAW BOID ARROW - REPLACED WITH PNG IN FINAL VERSION
    ofBeginShape();
    ofVertex(0, -r*2);
    ofVertex(-r, r*2);
    ofVertex(r, r*2);
    ofEndShape(true);
    */
    
    // DRAW PNG IMAGE FOR AIRPLANE
    i.setAnchorPoint(10, 12);
    i.draw(0,0);
    
    ofPopMatrix();
	ofDisableAlphaBlending();
    
    
    // Draw the predicted location
    if (debug) {
		ofFill();
        
		ofSetColor(0,191,255); // BLUE
		ofLine(loc.x,loc.y,predictLoc.x, predictLoc.y);
        
        // PREDICTED LOCATION 
		ofEllipse(predictLoc.x, predictLoc.y,4,4);

		// Draw normal location
		ofSetColor(255, 69, 0); //ORANGE
		ofLine(predictLoc.x, predictLoc.y, target.x, target.y);
		ofEllipse(target.x,target.y,4,4);
		
		// Draw actual target (red if steering towards it)
		ofLine(predictLoc.x,predictLoc.y,target.x,target.y);
		

        // VIOLET CIRCLE IS TARGET + DIR
		ofSetColor(255, 20, 147);
		ofEllipse(target.x+dir.x, target.y+dir.y, 8, 8);
    }

    
}
Example #23
0
void creature::draw() {
	
	ofSetColor(color);
	ofFill();
	
	//	for (int i = 0; i < particles.size(); i++){
	//		particles[i]->draw();
	//	}
	//
	
	ofSetLineWidth(size/15);
	for (int i = springs.size() - 1; i >= springs.size() - 2; i--){
	//for (int i = 0; i < springs.size(); i++) {
		springs[i].draw();
	}
	
	// draw the whole thing as one shape so that you can tell
	// when the feet are inside the body. kind of cute!
	
	ofSetLineWidth(0);
	
	/*
	ofBeginShape();
	
	ofVertex(particles[0]->pos.x, particles[0]->pos.y);
	ofVertex(particles[1]->pos.x, particles[1]->pos.y);
	
	ofVertex(particles[4]->pos.x, particles[4]->pos.y);
	
	ofVertex(particles[6]->pos.x, particles[6]->pos.y);
	ofVertex(particles[7]->pos.x, particles[7]->pos.y);
	
	ofVertex(particles[5]->pos.x, particles[5]->pos.y);
	
	ofVertex(particles[2]->pos.x, particles[2]->pos.y);
	ofVertex(particles[3]->pos.x, particles[3]->pos.y);
	
	ofVertex(particles[0]->pos.x, particles[0]->pos.y);
	
	ofEndShape();
	*/
	
	
	// different method for drawing the creature with different
	// shapes for body and legs. i like it a bit more.
//	ofBeginShape();
//	ofVertex(particles[0]->pos.x, particles[0]->pos.y);
//	ofVertex(particles[1]->pos.x, particles[1]->pos.y);
//	ofVertex(particles[2]->pos.x, particles[2]->pos.y);
//	ofVertex(particles[3]->pos.x, particles[3]->pos.y);
//	ofEndShape();
//	
//	ofBeginShape();
//	ofVertex(particles[1]->pos.x, particles[1]->pos.y);
//	ofVertex(particles[4]->pos.x, particles[4]->pos.y);
//	ofVertex(particles[6]->pos.x, particles[6]->pos.y);
//	ofEndShape();
//
//	ofBeginShape();
//	ofVertex(particles[2]->pos.x, particles[2]->pos.y);
//	ofVertex(particles[5]->pos.x, particles[5]->pos.y);
//	ofVertex(particles[7]->pos.x, particles[7]->pos.y);
//	ofEndShape();
	
	ofMesh mesh;
	mesh.setMode(OF_PRIMITIVE_TRIANGLES);
	
	mesh.addVertex(particles[0]->pos);
	mesh.addVertex(particles[1]->pos);
	mesh.addVertex(particles[2]->pos);
	
	mesh.addVertex(particles[2]->pos);
	mesh.addVertex(particles[3]->pos);
	mesh.addVertex(particles[0]->pos);
	
	mesh.draw();
	mesh.clear();
	
	mesh.addVertex(particles[1]->pos);
	mesh.addVertex(particles[4]->pos);
	mesh.addVertex(particles[6]->pos);

	mesh.draw();
	mesh.clear();

	mesh.addVertex(particles[2]->pos);
	mesh.addVertex(particles[5]->pos);
	mesh.addVertex(particles[7]->pos);

	mesh.draw();

	// draw the eyes
	// calculate a point partway between the top two points
	// calculate a point partway between the bottom two points
	// then calculate a point partway between these two points
	ofPoint leftShiftedTop = particles[0]->pos.getInterpolated(particles[3]->pos, 0.15);
	ofPoint leftShiftedBot = particles[1]->pos.getInterpolated(particles[2]->pos, 0.15);
	ofPoint leftEye = leftShiftedTop.getInterpolated(leftShiftedBot, 0.15);

	ofPoint rightShiftedTop = particles[0]->pos.getInterpolated(particles[3]->pos, 0.85);
	ofPoint rightShiftedBot = particles[1]->pos.getInterpolated(particles[2]->pos, 0.85);
	ofPoint rightEye = rightShiftedTop.getInterpolated(rightShiftedBot, 0.15);
	
	ofSetColor(50, 200);
	ofCircle(leftEye, size/13);
	ofCircle(rightEye, size/13);
	
}
Example #24
0
//--------------------------------------------------------------
void ofxMuiColorPicker::draw() {
    
    //if(name == "MCP") {
    //    cout << "in here" << endl;
    //}
    
    ofPushStyle();
	ofPushMatrix(); // initial push
    
    ofTranslate(getHitBoxX(),getHitBoxY());
    

    
    ofSetColor(255);
    picker.draw(0,0);

    ofFill();
    ofSetColor(getValue());
    ofxRect(colorPickerPreview);

    ofFill();
    ofSetColor(30);
    ofLine(colorPickerPreview.x,colorPickerPreview.y,getHitBoxWidth(),colorPickerPreview.y);
    
    ofNoFill();
    
    
    if(showEyeDroperPreview) {
        
        eyeDropperPreview.loadScreenData(mousePosition.x-eyeDropperPreviewPixelWidth/2.0f,
                                         mousePosition.y-eyeDropperPreviewPixelHeight/2.0f
                                         ,eyeDropperPreviewPixelWidth,eyeDropperPreviewPixelHeight);

        
        ofPushMatrix();
        ofTranslate(screenToHitBox(mousePosition));

        
        ofSetColor(255);
       // ofxRect(0,0,
       // ofPushMatrix(

        ofPushMatrix();
        ofScale(defaults->colorPickerEyeDropperZoom,defaults->colorPickerEyeDropperZoom);
        ofTranslate(-eyeDropperPreviewPixelWidth/2.0, -eyeDropperPreviewPixelHeight/2.0f);
        eyeDropperPreview.draw(0,0);
        ofPopMatrix();
        
        ofCircle(0,0,4,4);

        
        ofPopMatrix();
     
    } else {
        //ofSetColor(getValue().getInverted().getBrightness());
        ofCircle(cursor.x-2, cursor.y-2, 4);
    }
    
    /*
    if(isDragging) {
        ofFill();
        ofSetColor(255);
        ofxRect(0,0,40,40);
    }
    */
        
        
    ofPopMatrix(); // HIT RECT PUSH
    ofPopStyle();
    
    
}
Example #25
0
//--------------------------------------------------------------
void testApp::draw(){
	

	ofSetPolyMode(OF_POLY_WINDING_ODD);

	//if we are smoothing the pts - might as well draw the line smooth too :)
	ofEnableSmoothing();
	
	//if we are recording we just draw all points as a red line
	if(recording){	
		ofSetColor(255, 50, 50);

		ofNoFill();
		ofBeginShape();
		
		for( unsigned int i = 0; i < ptsList.size(); i++){
			ofVertex(ptsList[i].x, ptsList[i].y);
		}
		
		ofEndShape(false);
	
	}else{

		ofSetColor(255, 255, 255);

		float max = MIN(1, playPos);
		int drawTo = max * (float)ptsList.size();


//      Drawing with GL triangle strips
//
//		glBegin(GL_TRIANGLE_STRIP);
//		for(int i = 0; i < drawTo; i++){
//			ofxVec2f pt1;
//			pt1 = ptsList[i] + leftNormals[i] * speedList[i] * 2; 
//
//			ofxVec2f pt2;
//			pt2 = ptsList[i] + rightNormals[i] * speedList[i] * 2; 
//			
//			glVertex2f(pt1.x, pt1.y);
//			glVertex2f(pt2.x, pt2.y);
//		}
//		glEnd();


		//For Evan Roth Style Rotating Stroke

		glTranslated(ofGetWidth()/2, ofGetHeight()/2, 0);
		glRotatef( -20 * ( ofGetElapsedTimef()-storeTime), 0, 1, 0);
	
		float midX = ofGetWidth()/2;
		float midY = ofGetHeight()/2;
		
		//float speed = 2;
		
		
		ofSetPolyMode(OF_POLY_WINDING_NONZERO);
		ofFill();
		ofBeginShape();
			for(int i = 0; i < drawTo; i++){
			
				ofxVec2f pt;
				pt = ptsList[i] + leftNormals[i] * speedList[i]; 
				ofVertex(pt.x-midX, pt.y-midY);
			}
		
			for(int i = drawTo-1; i >= 0; i--){			

				ofxVec2f pt;
				pt = ptsList[i] + rightNormals[i] * speedList[i]; 
				ofVertex(pt.x-midX, pt.y-midY);
			}
		ofEndShape(false);
		
	}

}
Example #26
0
//--------------------------------------------------------------
void testApp::draw() {

	ofSetColor(255, 255, 255);

	if(bDrawPointCloud) {
		ofPushMatrix();
		ofTranslate(420, 320);
		// we need a proper camera class
		drawPointCloud();
		ofPopMatrix();
	}
    else {
		if(!bPlayback) {
			// draw from the live kinect
			kinect.drawDepth(10, 10, 400, 300);
			kinect.draw(420, 10, 400, 300);
		}
        else {
			// draw from the player
			kinectPlayer.drawDepth(10, 10, 400, 300);
			kinectPlayer.draw(420, 10, 400, 300);
		}

		grayImage.draw(10, 320, 400, 300);
		contourFinder.draw(10, 320, 400, 300);
	
        #ifdef USE_TWO_KINECTS
        kinect2.draw(420, 320, 400, 300);
        #endif
    }

	// draw recording/playback indicators
	ofPushMatrix();
	ofTranslate(25, 25);
	ofFill();
	if(bRecord) {
		ofSetColor(255, 0, 0);
		ofCircle(0, 0, 10);
	}
	if(bPlayback) {
		ofSetColor(0, 255, 0);
		ofTriangle(-10, -10, -10, 10, 10, 0);
	}
	ofPopMatrix();


	// draw instructions
	ofSetColor(255, 255, 255);
	stringstream reportStream;
	reportStream << "accel is: " << ofToString(kinect.getMksAccel().x, 2) << " / "
								 << ofToString(kinect.getMksAccel().y, 2) << " / "
								 << ofToString(kinect.getMksAccel().z, 2) << endl
				 << "press p to switch between images and point cloud, rotate the point cloud with the mouse" << endl
				 << "using opencv threshold = " << bThreshWithOpenCV <<" (press spacebar)" << endl
				 << "set near threshold " << nearThreshold << " (press: + -)" << endl
				 << "set far threshold " << farThreshold << " (press: < >) num blobs found " << contourFinder.nBlobs
				 	<< ", fps: " << ofGetFrameRate() << endl
				 << "press c to close the connection and o to open it again, connection is: " << kinect.isConnected() << endl
				 << "press UP and DOWN to change the tilt angle: " << angle << " degrees" << endl
				 << "press r to record and q to playback, record is: " << bRecord << ", playback is: " << bPlayback;
	ofDrawBitmapString(reportStream.str(),20,652);
}
void ofxSimpleGuiPage::draw(float x, float y, bool alignRight) {
	setPos(x += config->offset.x, y += config->offset.y);
	if(alignRight) x = ofGetWidth() - x -  config->gridSize.x;
	
	int posX		= 0;
	int posY		= 0;
	int stealingX = 0;
	int stealingY = 0;
	
	ofSetRectMode(OF_RECTMODE_CORNER);
	
	for(int i=0; i<controls.size(); i++) {
		ofxSimpleGuiControl &control = *controls[i];
        
        if(posY + y >= height - control.height - config->padding.y || control.newColumn) {
			if(alignRight) posX -= config->gridSize.x;
			else posX += config->gridSize.x;
			posY = 0;
		}
		
		float controlX = posX + x;
		float controlY = posY + y;
		
		//we don't draw the event stealing controls until the end because they can expand and overlap with other controls (e.g. combo box)
		if(eventStealingControl == &control) {
			stealingX = controlX;
			stealingY = controlY;
		} else {
//			printf("drawing control: %s %s\n", control.controlType.c_str(), control.name.c_str());
			control.draw(controlX, controlY);
		}
		
		if(control.hasTitle) {
			ofNoFill();
			ofSetHexColor(config->borderColor);
			glLineWidth(0.5f);
			ofRect(controlX, controlY, control.width, control.height);
		}
        
        if (control.isFixed()) {
            ofEnableAlphaBlending();
            ofFill();
            ofSetColor(33,33,33,80);
            ofRect(controlX, controlY, control.width, control.height);
            ofDisableAlphaBlending();
        }
        
		posY = getNextY(posY + control.height + config->padding.y);
		
		
		
		//		if(guiFocus == controls[i]->guiID) controls[i]->focused = true;		// MEMO
		//		else							   controls[i]->focused = false;
	}
	//event stealing controls get drawn on top
	if(eventStealingControl) {
		eventStealingControl->draw(stealingX, stealingY);
		if(eventStealingControl->hasTitle) {
			ofNoFill();
			ofSetHexColor(config->borderColor);
			glLineWidth(0.5f);
			ofRect(stealingX, stealingY, eventStealingControl->width, eventStealingControl->height);
		}
	}
    
    
}
Example #28
0
void Flower::draw(){
    
// flowers fade as the die
    long timeDiff = ofGetElapsedTimeMillis() - birthTime;
    float alpha = ofNormalize(timeDiff, 5000, 0);
    
    ofEnableAlphaBlending();
    
// TRIANGLES / CIRCLES
    
    if (tri == true){
        
    ofFill();
    ofSetColor(r, g, b, 255 * alpha);
    ofSetCircleResolution(20);
    ofDrawCircle(pos.x, pos.y, 35);}
    
// COLOR FLOWERS
    
    if (cFlowers == true){
    ofSetColor(255, 255, 255, 255 * alpha);
    if(dice == 0){
        flower_1.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 1){
        flower_2.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 9){
        flower_3.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 3){
        flower_4.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 4){
        flower_5.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 5){
        flower_6.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 6){
        flower_7.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 2){
        flower_8.draw(pos.x-50, pos.y-50, 100, 100);
    }
    if(dice == 8){
        flower_9.draw(pos.x-50, pos.y-50, 100, 100);
    }

    }
    
// WHITE FLOWERS
    if (wFlowers == true) {
    ofSetColor(255, 255, 255, 255 * alpha);
    
    if(dice == 0){
        BW1.draw(pos.x-25, pos.y-25, 50, 50);
    }
    if(dice == 1){
        BW2.draw(pos.x-25, pos.y-25, 50, 50);
    }
    if(dice == 2){
        BW3.draw(pos.x-25, pos.y-25, 50, 50);
    }
    if(dice == 3){
        BW4.draw(pos.x-25, pos.y-25, 50, 50);
    }
    if(dice == 4){
        BW5.draw(pos.x-25, pos.y-25, 50, 50);
    }
    if(dice == 5){
        BW6.draw(pos.x-25, pos.y-25, 50, 50);
    }
    if(dice == 6){
        BW7.draw(pos.x-25, pos.y-25, 50, 50);
        }
    }
    ofDisableAlphaBlending();
};
void ofxSimpleGuiTextBox::draw(float x, float y) {
	setPos(x, y);
	
	if (isOpen) {
		setSize(config->gridSize.x - config->padding.x, expandedHeight);	
	} else {
		setSize(config->gridSize.x - config->padding.x, closedHeight);		
	}
	
	if (fbo == NULL) {
		fbo = new ofxFBOTexture();
		fbo->allocate(textBlock.getWidth(),textBlock.getHeight()+5);
		fbo->begin();
		fbo->clear(0,0,0,1);
		//glColor4f(0,0,0,1);
		//setTextBGColor(false);
		ofSetColor(config->textBGColor);
		ofRect(0, 0, fbo->getWidth(), fbo->getHeight());
		textBlock.setColor(255, 255, 255, 255);
		textBlock.draw(0, 0);
		fbo->end();
	}	
	
	if(hasTitle == false) return;
	
	glPushMatrix();
	glTranslatef(x, y, 0);
	
	ofEnableAlphaBlending();
	ofFill();
			
	
	//		ofSetColor(0, 0, 0);

	//setTextBGColor(false);
	ofSetColor(config->textBGColor);
	ofRect(0, 0, width, height);
	
	//setTextColor(value != NULL);
	
	
	/*
	if(isOpen){
		ofDrawBitmapString(name, 3, 15);
	} else {
		ofDrawBitmapString(name+" ...", 3, 15);
	}
	*/
	
	ofDisableAlphaBlending();
	ofSetColor(255, 255, 255);
	if (isOpen) {
		fbo->draw(3,0);
	} else {
		//fbo->draw(3,0,fbo->getWidth(),height);
		
		glPushMatrix(); 
		
		glTranslatef(3,0,0.0f);
		
		GLfloat px0 = 0;
		GLfloat py0 = 0;
		GLfloat px1 = fbo->getWidth();
		GLfloat py1 = height - 3;
		
		GLfloat tx0 = 0;
		GLfloat ty0 = fbo->getHeight();
		GLfloat tx1 = fbo->getWidth();
		GLfloat ty1 = fbo->getHeight() - height +3;
		
		GLfloat tex_coords[] = {
			tx0,ty0,
			tx1,ty0,
			tx1,ty1,
			tx0,ty1
		};
		GLfloat verts[] = {
			px0,py0,
			px1,py0,
			px1,py1,
			px0,py1
		};
		fbo->bind();
		glEnableClientState( GL_TEXTURE_COORD_ARRAY );
		glTexCoordPointer(2, GL_FLOAT, 0, tex_coords );
		glEnableClientState(GL_VERTEX_ARRAY);		
		glVertexPointer(2, GL_FLOAT, 0, verts );
		glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
		glDisableClientState( GL_TEXTURE_COORD_ARRAY );
		fbo->unbind();
		glPopMatrix();
		
	}
	glPopMatrix();
	
	//glScissor(x, y, width, height);
	//glEnable(GL_SCISSOR_TEST);
	
	//glScissor(0, 0, ofGetWidth(), ofGetHeight());
	//glDisable(GL_SCISSOR_TEST);
	
	ofDisableAlphaBlending();
}
Example #30
0
//------------------------------------------------------------------
void rectangle::draw() {
	ofFill();
	ofSetRectMode(OF_RECTMODE_CENTER); // center around the position
    ofSetColor(255, 255, 255);
    ofRect(pos.x, pos.y, w, h);
}