Example #1
0
void Sensing::draw()
{
    if(_recordMode)
    {
        vector <Balloon *> balloons = getBalloons();

        for(int i = 0; i < balloons.size(); i++)
        {
            // draw circle around
            ofSetColor(255, 255, 255);
            //ofFill();
            //ofEllipse(balloons[i]->getCenterX(), balloons[i]->getCenterY(), balloons[i]->getWidth(),balloons[i]->getHeight());
            ofNoFill();
            ofEllipse(balloons[i]->getCenterX(), balloons[i]->getCenterY(), balloons[i]->getWidth(), balloons[i]->getHeight());

            ofRectangle bounds = balloons[i]->getBoundsFromSize(_head.getWidth(), _head.getHeight());

            ofSetColor(255, 255, 255, 255);

            ofEnableAlphaBlending();
            _head.draw(bounds.x, bounds.y + _offSet, bounds.width, bounds.height);
            ofDisableAlphaBlending();

            ofSetColor(0, 255, 0);

            if(i == _selectedBalloon)
            {
                drawBalloon(balloons[i]->getCenterX(), balloons[i]->getCenterY(), 0x000FF00);
            }
            else
            {
                drawBalloon(balloons[i]->getCenterX(), balloons[i]->getCenterY(), 0xFF0000);
            }
        }
    }
}
//---------------------------------------------------------------------
void
ofxSimpleGuiButton::drawWidget(float x, float y)
{
	setPos(x, y);
	
	glPushMatrix();
	glTranslatef(x, y, 0);
	
	ofEnableAlphaBlending();
	ofFill();
	
	// if a toggle
	if((*value) && !momentary)
		checkedImage.draw(width - height - config->padding.y, 0, height, height);

	ofFill();
	
	setTextColor();
	config->font.drawString(name, config->fontOffset.x, config->fontOffset.y+6);
	
	ofDisableAlphaBlending();
	
	glPopMatrix();
}
Example #3
0
void KinectScene2::draw() 
{
	ofEnableAlphaBlending();
	ofSetColor(255, 255, 255, 255*alpha);

	//img.draw(0,0,parentApp->getRenderWidth(), parentApp->getRenderHeight());

	ofPushStyle();
	if(parentApp->isDebug()) {
		diffImg.draw(0,0);
		parentApp->depthImage.draw(512,0);
	}

	for (int i = 0; i < parentApp->contourFinder.nBlobs; i++)  
	{  
		contour.clear();
		contour = parentApp->contourFinder.blobs[i].pts;   ;
		contour = contour.getSmoothed(3, 0);
		contour.close();

		//ofSetLineWidth(4);
		ofPolyline scaledContour = contour;
		for(int j=0;j<(int)scaledContour.size();j++){
			scaledContour[j].x*=parentApp->getRenderWidth()/512;
			scaledContour[j].y*=parentApp->getRenderHeight()/424;
		}
		scaledContour.draw();  

	}

	drawFlowfield();

	ofPopStyle();
	ofDisableAlphaBlending();

}
Example #4
0
void Windmill::draw()
{
	ofSetColor(r, g, b, a);
	ofFill();
	ofPushMatrix();
	ofTranslate(pos.x, pos.y);
	ofRotateZ(angle);
	ofScale(scale, scale);
	
	ofEnableAlphaBlending();
	
	ofBeginShape();
	ofVertex(-20, -140);
	ofVertex(80, -140);
	ofVertex(0, 100);
	ofVertex(20, 140);
	ofVertex(-80, 140);
	ofVertex(10, -100);
	ofEndShape(true);
	
	ofDisableAlphaBlending();
	
	ofPopMatrix();
}
//--------------------------------------------------------------
void testApp::draw()
{
	// draw to the FBO
	ofEnableAlphaBlending();	
	fbo.begin();
	ofClear(0, 0, 0, 0);
		autoShader.begin();
		autoShader.setUniform1f("u_time", ofGetElapsedTimef() );
			image.draw(0,0, ofGetWidth(), ofGetHeight() );
		autoShader.end();
	fbo.end();
	ofDisableAlphaBlending();

	// draw the FBO to screen
	fbo.draw(0, 0);

	// draw the FPS
	sprintf(tempStr, "%4.1f", ofGetFrameRate() );
	ofVec2f pos( ofGetWidth()-30, ofGetHeight()-5 );
	ofSetColor(0);
	font.drawString( tempStr, pos.x + 1, pos.y + 1 );
	ofSetColor( 255 );
	font.drawString( tempStr, pos.x, pos.y );
}
void dgRotationBtnObject::draw () {
	
	dgSceneObject::draw();
	
	ofEnableAlphaBlending();
	
	ofPushMatrix();
	
	ofTranslate(pos.x - width *.5, pos.y - height * .5, 0);
	
	ofPushMatrix();
	ofTranslate(img->getWidth()*.5, img->getHeight()*.5, 0);
	ofRotate(btnRotation, 0, 0, 1);
	img->draw(-img->getWidth()*.5, -img->getHeight()*.5);
	ofPopMatrix();
	
	for (int i=0; i<frontImages.size(); i++) {
		frontImages[i]->draw(0, 0 );
	}
	
	ofPopMatrix();
	
	ofDisableAlphaBlending();
}
void ofApp::drawAnim() {
    ofBackground(0, 0, 0);
    ofSetColor(ofColor::white);
    ofEnableAlphaBlending();
    masker.draw();
    
    if(fadeIn) {
        alpha -= 10;
        if(alpha <= 0) fadeIn = false;
    }
    
    if(fadeOut) {
        alpha += 10;
        if(alpha >= 300) renderGif();
    }
    
    ofSetColor(0, 0, 0, alpha);
    ofRect(0, 0, width, height);

    if(ofGetFrameNum() == 80) {
        fadeOut = true;
    }
    ofDisableAlphaBlending();
}
Example #8
0
	//--------------------------------------------------------------
	void CmbSceneGL3D::copyResult()
	{
		m_fbos[m_currIdx].begin();
		{
			ofDisableAlphaBlending();

			m_copyShader.begin();
			{
				m_copyShader.setUniformTexture("uCopyBuffer", m_textures[m_tempIdx].texData.textureTarget, m_textures[m_tempIdx].texData.textureID, 1);
				m_copyShader.setUniform3f("uDims", m_dimensions);
				{
					for (int i = 0; i < m_dimensions.z; ++i)
					{
						m_copyShader.setUniform1i("uLayer", i);
						m_mesh.draw();
					}
				}
			}
			m_copyShader.end();
		}
		m_fbos[m_currIdx].end();

		m_volumetrics.setup(&m_textures[m_currIdx], ofVec3f(1, 1, 1));
	}
//--------------------------------------------------------------
void DroneAttack::drawAttackPosition(){

    
    cam.begin();

    ofEnableAlphaBlending();
    
    ofPushStyle();
    ofSetColor( ofColor(colorAttack) );
    for (int i=0; i<dronData.size(); i++) {
        ofVec3f _v = dronData[i].coord;
        
        float _ratio = ofMap(dronData[i].deathMax, 1, 30, 1.1, 1.2);
        
        ofDrawLine( _v, _v * _ratio );
    }
    
    ofPopStyle();
    
    ofDisableAlphaBlending();
    
    cam.end();

}
Example #10
0
void ofApp::draw() {
    ofBackground(0);
   
    fbo.begin();
    
    ofEnableAlphaBlending();
    ofSetColor(ofColor::black,2);
    
    ofDrawRectangle(0,0, ofGetWidth(), ofGetHeight());
    ofDisableAlphaBlending();
    ofFill();
    for (int i=0; i < particles.size(); i++){
        particles[i].draw();
        gui.draw();
        
    }

    
    
    fbo.end();
    ofSetColor(ofColor::white);
    fbo.draw(0,0);
    
}
//--------------------------------------------------------------
void testApp::draw(){

	ofDisableAlphaBlending(); //Kinect alpha channel is default 0;
	kinect.draw(0,0);
}
Example #12
0
//--------------------------------------------------------------
void testApp::draw(){
    
	ofBackground(red, blue, green);
    
    ofEnableAlphaBlending();
    ofSetColor(255, 255, 255, 25);	
    drawGrid(8,8);
    ofDisableAlphaBlending();

	ofSetColor(255, 255, 255);
    
    ofPushMatrix();
    ofTranslate(255, 0);

        glPushMatrix();
        glScalef(0.75, 0.75, 0.75);

        if (isLive) {

            recordDepth.draw(0,0,640,480);
            recordImage.draw(640, 0, 640, 480);

            depthRangeMask.draw(0, 480, 320, 240);	// can use this with openCV to make masks, find contours etc when not dealing with openNI 'User' like objects

            if (isTracking) {
                recordUser.draw();

                if (isMasking) drawMasks();
                if (isCloud) drawPointCloud(&recordUser, 1);	// 0 gives you all point clouds; use userID to see point clouds for specific users

            }
            if (isTrackingHands)
                recordHandTracker.drawHands();

        } else {

            playDepth.draw(0,0,640,480);
            playImage.draw(640, 0, 640, 480);

            depthRangeMask.draw(0, 480, 320, 240);	// can use this with openCV to make masks, find contours etc when not dealing with openNI 'User' like objects

            if (isTracking) {
                playUser.draw();

                if (isMasking) drawMasks();
                if (isCloud) drawPointCloud(&playUser, 0);	// 0 gives you all point clouds; use userID to see point clouds for specific users

            }
            if (isTrackingHands)
                playHandTracker.drawHands();
        }

        glPopMatrix();

        ofSetColor(255, 255, 0);

        string statusPlay		= (string)(isLive ? "LIVE STREAM" : "PLAY STREAM");
        string statusRec		= (string)(!isRecording ? "READY" : "RECORDING");
        string statusSkeleton	= (string)(isTracking ? "TRACKING USERS: " + (string)(isLive ? ofToString(recordUser.getNumberOfTrackedUsers()) : ofToString(playUser.getNumberOfTrackedUsers())) + "" : "NOT TRACKING USERS");
        string statusSmoothSkel = (string)(isLive ? ofToString(recordUser.getSmoothing()) : ofToString(playUser.getSmoothing()));
        string statusHands		= (string)(isTrackingHands ? "TRACKING HANDS: " + (string)(isLive ? ofToString(recordHandTracker.getNumTrackedHands()) : ofToString(playHandTracker.getNumTrackedHands())) + ""  : "NOT TRACKING");
        string statusFilter		= (string)(isFiltering ? "FILTERING" : "NOT FILTERING");
        string statusFilterLvl	= ofToString(filterFactor);
        string statusSmoothHand = (string)(isLive ? ofToString(recordHandTracker.getSmoothing()) : ofToString(playHandTracker.getSmoothing()));
        string statusMask		= (string)(!isMasking ? "HIDE" : (isTracking ? "SHOW" : "YOU NEED TO TURN ON TRACKING!!"));
        string statusCloud		= (string)(isCloud ? "ON" : "OFF");
        string statusCloudData	= (string)(isCPBkgnd ? "SHOW BACKGROUND" : (isTracking ? "SHOW USER" : "YOU NEED TO TURN ON TRACKING!!"));

        string statusHardware;

    #ifdef TARGET_OSX // only working on Mac at the moment
        ofPoint statusAccelerometers = hardware.getAccelerometers();
        stringstream	statusHardwareStream;

        statusHardwareStream
        << "ACCELEROMETERS:"
        << " TILT: " << hardware.getTiltAngle() << "/" << hardware.tilt_angle
        << " x - " << statusAccelerometers.x
        << " y - " << statusAccelerometers.y
        << " z - " << statusAccelerometers.z;

        statusHardware = statusHardwareStream.str();
    #endif

        stringstream msg;

        msg
        << "    s : start/stop recording  : " << statusRec << endl
        << "    p : playback/live streams : " << statusPlay << endl
        << "    t : skeleton tracking     : " << statusSkeleton << endl
        << "( / ) : smooth skely (openni) : " << statusSmoothSkel << endl
        << "    h : hand tracking         : " << statusHands << endl
        << "    f : filter hands (custom) : " << statusFilter << endl
        << "[ / ] : filter hands factor   : " << statusFilterLvl << endl
        << "; / ' : smooth hands (openni) : " << statusSmoothHand << endl
        << "    m : drawing masks         : " << statusMask << endl
        << "    c : draw cloud points     : " << statusCloud << endl
        << "    b : cloud user data       : " << statusCloudData << endl
        << "- / + : nearThreshold         : " << ofToString(nearThreshold) << endl
        << "< / > : farThreshold          : " << ofToString(farThreshold) << endl
        << endl
        << "File  : " << oniRecorder.getCurrentFileName() << endl
        << "FPS   : " << ofToString(ofGetFrameRate()) << "  " << statusHardware << endl;

        ofDrawBitmapString(msg.str(), 20, 560);
  
    ofPopMatrix();

}
void StSyncopationMonitorColor::draw() {
	ofPushMatrix();
	ofTranslate(top, left);
	drawGrid();
	ofDisableAlphaBlending();

	float LH_weight[16] = { 0, -4, -3, -4, -2, -4, -3, -4, -1, -4, -3, -4, -2, -4, -3, -4 };

	//draw matrix
	ofDisableSmoothing();
	if (app->tidal->instNumMax > 0) {
		for (int i = 0; i < app->tidal->notes.size(); i++) {
			instNames[app->tidal->notes[i].instNum] = app->tidal->notes[i].instName;
		}
		for (int i = 0; i < app->tidal->instNumMax; i++) {
			float x, y, h;
			for (int j = 0; j < app->tidal->max2; j++) {
				if (app->tidal->noteMatrix[i][j] == 1) {
					x = ofMap(j, 0, app->tidal->max2, 0, width);
					h = height / (app->tidal->instNumMax);
					float y = h * i;
					int count = j % 16;
					int weight = LH_weight[count];
					ofColor col;
					float hue = ofMap(weight, 0, -4, 64, 0);
					float saturation = ofMap(weight, 0, -4, 20, 200);
					float brightness = 255;
					col.setHsb(hue, saturation, brightness);
					ofSetColor(col);
					ofDrawRectangle(x, y, ofGetWidth()/256.0, h);
				}
			}
			ofDrawBitmapStringHighlight(instNames[i], 4, height / (app->tidal->instNumMax) * i + 14, ofColor(63));
			if (i > 0) {
				ofSetColor(127);
				ofDrawLine(0, height / (app->tidal->instNumMax) * i, width, height / (app->tidal->instNumMax) * i);
			}
		}
	}
	ofEnableSmoothing();
	ofPopMatrix();

	//draw graph
	float x, y, gwidth, gheight, graphX;
	float graphWidth;
	x = 20;
	y = ofGetHeight() / 2 + 20;
	graphX = 70;
	gwidth = ofGetWidth() - 40 - graphX;
	gheight = 10;

	ofTranslate(x, y);
	ofPushMatrix();
	ofSetColor(255);
	ofDrawBitmapString("Syncopation Degree", 0, 0);
	ofTranslate(0, -8);
	for (int i = 0; i < app->tidal->instNumMax; i++) {
		ofTranslate(0, 14);
		graphWidth = ofMap(app->tidal->syncopation[i], 0, 20, 0, gwidth);
		ofSetColor(63);
		ofDrawRectangle(graphX, 0, gwidth, gheight);
		ofSetColor(63, 127, 255);
		ofDrawRectangle(graphX, 0, graphWidth, gheight);
		ofSetColor(255);
		//ofDrawBitmapString("S"
		//                   + ofToString(i) + ":"
		//                   + ofToString(app->tidal->syncopation[i]), 0, 12);
		ofDrawBitmapString(instNames[i], 0, 10);
		ofDrawBitmapString(ofToString(app->tidal->syncopation[i]), graphX + 5, 10);
	}
	ofTranslate(0, 40);
	ofDrawBitmapString("Note Number", 0, 0);
	ofTranslate(0, -8);
	for (int i = 0; i < app->tidal->instNumMax; i++) {
		ofTranslate(0, 14);
		graphWidth = ofMap(app->tidal->noteNum[i], 0, 32, 0, gwidth);
		ofSetColor(63);
		ofDrawRectangle(graphX, 0, gwidth, gheight);
		ofSetColor(63, 127, 255);
		ofDrawRectangle(graphX, 0, graphWidth, gheight);
		ofSetColor(255);
		//ofDrawBitmapString("E"
		//                   + ofToString(i) + ":"
		//                   + ofToString(app->tidal->entropy[i], 2), 0, 10);
		ofDrawBitmapString(instNames[i], 0, 10);
		ofDrawBitmapString(ofToString(app->tidal->noteNum[i]), graphX + 5, 10);
	}
	/*
	ofTranslate(0, 40);
	ofDrawBitmapString("Entropy", 0, 0);
	ofTranslate(0, -8);
	for (int i = 0; i < app->tidal->instNumMax; i++) {
	ofTranslate(0, 14);
	graphWidth = ofMap(powf(app->tidal->entropy[i], 10), 0, 1, 0, gwidth);
	ofSetColor(63);
	ofDrawRectangle(graphX, 0, gwidth, gheight);
	ofSetColor(63, 127, 255);
	ofDrawRectangle(graphX, 0, graphWidth, gheight);
	ofSetColor(255);
	//ofDrawBitmapString("E"
	//                   + ofToString(i) + ":"
	//                   + ofToString(app->tidal->entropy[i], 2), 0, 10);
	ofDrawBitmapString(instNames[i], 0, 10);
	ofDrawBitmapString(ofToString(app->tidal->entropy[i]), graphX + 5, 10);
	}
	*/
	ofPopMatrix();
}
Example #14
0
//--------------------------------------------------------------
void ofApp::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();
	ofSetHexColor(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.
    // 使用 bitMap 样式
    // 须知,有些显卡会变慢
    // 因为这段代码使用来glDrawPixels,这个语句的速度在每个系统上都不同。如果bitMap式样太慢的话,可以试试看ofTrueTypeFont。
	ofSetHexColor(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));
	}
	ofSetHexColor(0x000000);
	ofDrawBitmapString("rectangles", 275,500);

	//---------------------------  transparency
    //透明
	ofSetHexColor(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
                                // 红色,50% 透明度
	ofRect(450,430,100,33);
	ofSetColor(255,0,0,(int)(counter * 10.0f) % 255);   // red, variable transparent
                                                        // 红色,透明度变化

	ofRect(450,370,100,33);
	ofDisableAlphaBlending();

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

	//---------------------------  lines
	// a bunch of red lines, make them smooth if the flag is set
    // 这里我们会画一堆红色的线。如果平滑标记设置为True,我们会让他们看起来更平滑。

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

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

}
Example #15
0
//--------------------------------------------------------------
void Interplay::draw(){
//	ofSetColor(0xff0000);
//	for (int i = 0; i < 100; i++){
//		ofLine(ofRandom(0,200), ofRandom(0,200), ofRandom(0,200), ofRandom(0,200));
//	}

	ofEnableAlphaBlending();



	videos.at(12)->draw(0, 0);
	videos.at(12)->draw(320, 0);
	videos.at(12)->draw(640, 0);
	videos.at(12)->draw(960, 0);
	videos.at(12)->draw(0, 240);
	videos.at(12)->draw(320, 240);
	videos.at(12)->draw(640, 240);
	videos.at(12)->draw(960, 240);
	videos.at(12)->draw(0, 480);
	videos.at(12)->draw(320, 480);
	videos.at(12)->draw(640, 480);
	videos.at(12)->draw(960, 480);

	// DRAW RGBA TEXTURES
//	ofSetColor(0xffffff);
//	results.at(0)->draw(0, 0);
//	results.at(1)->draw(320, 0);
//	results.at(2)->draw(640, 0);
//	results.at(3)->draw(960, 0);
//	results.at(4)->draw(0, 240);
//	results.at(5)->draw(320, 240);
//	results.at(6)->draw(640, 240);
//	results.at(7)->draw(960, 240);
//	results.at(8)->draw(0, 480);
//	results.at(9)->draw(320, 480);
//	results.at(10)->draw(640, 480);
//	results.at(11)->draw(960, 480);


	ofSetColor(0xffffff);


	// store frame information in shader's (mask's) fbo
	for (int i = 0; i < 12; i++){
		mask.beginRender();
		videos.at(i)->draw(0, 0);
		mask.endRender();
		switch (i){
			case 0:
				mask.draw(0, 0, w, h, true);
				break;
			case 1:
				mask.draw(320, 0, w, h, true);
				break;
			case 2:
				mask.draw(640, 0, w, h, true);
				break;
			case 3:
				mask.draw(960, 0, w, h, true);
				break;
			case 4:
				mask.draw(0, 240, w, h, true);
				break;
			case 5:
				mask.draw(320, 240, w, h, true);
				break;
			case 6:
				mask.draw(640, 240, w, h, true);
				break;
			case 7:
				mask.draw(960, 240, w, h, true);
				break;
			case 8:
				mask.draw(0, 480, w, h, true);
				break;
			case 9:
				mask.draw(320, 480, w, h, true);
				break;
			case 10:
				mask.draw(640, 480, w, h, true);
				break;
			case 11:
				mask.draw(960, 480, w, h, true);
				break;

		}
	}


	// use shader
//	mask.draw(0, 0, w, h, true); // TODO

	// DRAW REGULAR VIDEOS WITH NO EDITS
//	ofSetColor(0xffffff);
//	videos.at(0)->draw(0, 0);
//	videos.at(1)->draw(320, 0);
//	videos.at(2)->draw(640, 0);
//	videos.at(3)->draw(960, 0);
//	videos.at(4)->draw(0, 240);
//	videos.at(5)->draw(320, 240);
//	videos.at(6)->draw(640, 240);
//	videos.at(7)->draw(960, 240);
//	videos.at(8)->draw(0, 480);
//	videos.at(9)->draw(320, 480);
//	videos.at(10)->draw(640, 480);
//	videos.at(11)->draw(960, 480);



	ofDisableAlphaBlending();

//	ofEnableAlphaBlending();	// drawing rgba will not work without this function
//	result.draw(0, 0);
//	ofDisableAlphaBlending();	// disable alpha blending when no longer manipulating rgba
}
Example #16
0
 static int lua_graphics_disable_alpha_blending(lua_State *L) {
     ofDisableAlphaBlending();
     return 0;
 }
Example #17
0
//------------------------------------------------------------------
void uiPresent::draw(ofTrueTypeFont& basicFont) {

    sprintf (timeString, "time: %0.2i:%0.2i:%0.2i \nelapsed time %i", ofGetHours(), ofGetMinutes(), ofGetSeconds(), ofGetElapsedTimeMillis());
	
    ofSetHexColor(0x000000);
	basicFont.drawString(timeString, 10,ofGetHeight()-90);
	basicFont.drawString(eventString, 10,ofGetHeight()-20);
    
    ofEnableAlphaBlending();
    
    ofSetColor(170, 170, 170);
    ofRect(*pencilBox);
    ofRect(*fontBox);
    ofRect(*tableBox);
    ofRect(*okSaveBox);
    
    ofSetHexColor(0x000000);

    pencil->draw(10, 310);
    font->draw(10, 355);
    table->draw(10, 400);
    okSave->draw(10, 445);

    if (*fontSelected) {
        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        basicFont.drawString("text selected", 10, ofGetHeight()/3);
        
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }

    }
    
    if (*pencilSelected) {

        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        basicFont.drawString("pencil selected", 10, ofGetHeight()/3);
        
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }
        
        if (currentDrawing.size()>0) {
            for (int i = 1; i < currentDrawing.size(); i++) {
                ofLine(currentDrawing[i-1].x, currentDrawing[i-1].y, currentDrawing[i].x, currentDrawing[i].y);
            }
        }
    }
    
    if (*tableSelected) {
        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }
        basicFont.drawString("table selected", 10, ofGetHeight()/3);
    }

    if (*okSaveSelected) {
        basicFont.drawString(theText, 40, 40);
        thisText->draw(basicFont);
        for (int i = 0; i < drawThese.size(); i++) {
            drawThese[i].draw();
        }

        basicFont.drawString("ok save selected", 10, ofGetHeight()/3);
    }

    
    ofDisableAlphaBlending();

}
//--------------------------------------------------------------
void testApp::draw(){
	ofFill();
	ofSetHexColor(0xe0be21);

	//------(a)--------------------------------------
	// 
	// 		draw a star
	//
	// 		use poly winding odd, the default rule
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	ofSetPolyMode(OF_POLY_WINDING_ODD);	// this is the normal mode
	ofBeginShape();
		ofVertex(200,135);
		ofVertex(15,135);
		ofVertex(165,25);
		ofVertex(105,200);
		ofVertex(50,25);
	ofEndShape();
	
	
	//------(b)--------------------------------------
	// 
	// 		draw a star
	//
	// 		use poly winding nonzero
	//
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	ofSetHexColor(0xb5de10);
	ofSetPolyMode(OF_POLY_WINDING_NONZERO);
	ofBeginShape();
		ofVertex(400,135);
		ofVertex(215,135);
		ofVertex(365,25);
		ofVertex(305,200);
		ofVertex(250,25);
	ofEndShape();
	//-------------------------------------
	
	
	
	//------(c)--------------------------------------
	// 
	// 		draw a star dynamically
	//
	// 		use the mouse position as a pct
	//		to calc nPoints and internal point radius
	//
	float xPct = (float)(mouseX) / (float)(ofGetWidth());
	float yPct = (float)(mouseY) / (float)(ofGetHeight());
	int nTips = 5 + xPct * 60;
	int nStarPts = nTips * 2;
	float angleChangePerPt = TWO_PI / (float)nStarPts;
	float innerRadius = 0 + yPct*80;
	float outerRadius = 80;
	float origx = 525;
	float origy = 100;
	float angle = 0;
	
	ofSetHexColor(0xa16bca);
	ofBeginShape();
	for (int i = 0; i < nStarPts; i++){
		if (i % 2 == 0) {
			// inside point:
			float x = origx + innerRadius * cos(angle);
			float y = origy + innerRadius * sin(angle);
			ofVertex(x,y);
		} else {
			// outside point
			float x = origx + outerRadius * cos(angle);
			float y = origy + outerRadius * sin(angle);
			ofVertex(x,y);
		}
		angle += angleChangePerPt;
	}
	ofEndShape();
	//-------------------------------------
	
	//------(d)--------------------------------------
	// 
	// 		poylgon of random points
	//
	// 		lots of self intersection, 500 pts is a good stress test
	// 
	// 
	ofSetHexColor(0x0cb0b6);
	ofSetPolyMode(OF_POLY_WINDING_ODD);
	ofBeginShape();
	for (int i = 0; i < 10; i++){
		ofVertex(ofRandom(650,850), ofRandom(20,200));
	}
	ofEndShape();
	//-------------------------------------
	
	
	//------(e)--------------------------------------
	// 
	// 		use sin cos and time to make some spirally shape
	//
	glPushMatrix();
		glTranslatef(100,300,0);
		ofSetHexColor(0xff2220);
		ofFill();
		ofSetPolyMode(OF_POLY_WINDING_ODD);
		ofBeginShape();
		float angleStep 	= TWO_PI/(100.0f + sin(ofGetElapsedTimef()/5.0f) * 60); 
		float radiusAdder 	= 0.5f;
		float radius 		= 0;
		for (int i = 0; i < 200; i++){
			float anglef = (i) * angleStep;
			float x = radius * cos(anglef);
			float y = radius * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		ofEndShape(OF_CLOSE);
	glPopMatrix();
	//-------------------------------------
	
	//------(f)--------------------------------------
	// 
	// 		ofCurveVertex
	// 
	// 		because it uses catmul rom splines, we need to repeat the first and last 
	// 		items so the curve actually goes through those points
	//

	ofSetHexColor(0x2bdbe6);
	ofBeginShape();
	
		for (int i = 0; i < nCurveVertexes; i++){
			
			
			// sorry about all the if/states here, but to do catmull rom curves
			// we need to duplicate the start and end points so the curve acutally 
			// goes through them.
			
			// for i == 0, we just call the vertex twice
			// for i == nCurveVertexes-1 (last point) we call vertex 0 twice
			// otherwise just normal ofCurveVertex call
			
			if (i == 0){
				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 == nCurveVertexes-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();
	
	
	// show a faint the non-curve version of the same polygon:
	ofEnableAlphaBlending();
		ofNoFill();
		ofSetColor(0,0,0,40);
		ofBeginShape();
			for (int i = 0; i < nCurveVertexes; i++){
				ofVertex(curveVertices[i].x, curveVertices[i].y);
			}
		ofEndShape(true);
		
		
		ofSetColor(0,0,0,80);
		for (int i = 0; i < nCurveVertexes; i++){
			if (curveVertices[i].bOver == true) ofFill();
			else ofNoFill();
			ofCircle(curveVertices[i].x, curveVertices[i].y,4);
		}
	ofDisableAlphaBlending();
	//-------------------------------------
	
	
	//------(g)--------------------------------------
	// 
	// 		ofBezierVertex
	// 
	// 		with ofBezierVertex we can draw a curve from the current vertex
	//		through the the next three vertexes we pass in.
	//		(two control points and the final bezier point)
	//		
	
	float x0 = 500;
	float y0 = 300;
	float x1 = 550+50*cos(ofGetElapsedTimef()*1.0f);
	float y1 = 300+100*sin(ofGetElapsedTimef()/3.5f);
	float x2 = 600+30*cos(ofGetElapsedTimef()*2.0f);
	float y2 = 300+100*sin(ofGetElapsedTimef());
	float x3 = 650;
	float y3 = 300;
	
	
	
	ofFill();
	ofSetHexColor(0xFF9933);
	ofBeginShape();
	ofVertex(x0,y0);
	ofBezierVertex(x1,y1,x2,y2,x3,y3);
	ofEndShape();
	
	
	ofEnableAlphaBlending();
		ofFill();
		ofSetColor(0,0,0,40);
		ofCircle(x0,y0,4);
		ofCircle(x1,y1,4);
		ofCircle(x2,y2,4);
		ofCircle(x3,y3,4);
	ofDisableAlphaBlending();
	
	
	
	//------(h)--------------------------------------
	// 
	// 		holes / ofNextContour
	// 
	// 		with ofNextContour we can create multi-contour shapes
	// 		this allows us to draw holes, for example... 
	//
	ofFill();
	ofSetHexColor(0xd3ffd3);
	ofRect(80,480,140,70);
	ofSetHexColor(0xff00ff);
	
	ofBeginShape();
		
		ofVertex(100,500);
		ofVertex(180,550);
		ofVertex(100,600);
		
		ofNextContour(true);
		
		ofVertex(120,520);
		ofVertex(160,550);
		ofVertex(120,580);
		
	ofEndShape(true);
	//-------------------------------------
	
	
	//------(i)--------------------------------------
	// 
	// 		CSG / ofNextContour
	// 
	// 		with different winding rules, you can even use ofNextContour to 
	// 		perform constructive solid geometry 
	// 		
	// 		be careful, the clockwiseness or counter clockwisenss of your multiple
	// 		contours matters with these winding rules.
	//
	// 		for csg ideas, see : http://glprogramming.com/red/chapter11.html
	// 
	// 		info about the winding rules is here:
	//		http://glprogramming.com/red/images/Image128.gif
	// 
	ofNoFill();
	
	
	glPushMatrix();
	
	ofSetPolyMode(OF_POLY_WINDING_ODD);
	
	ofBeginShape();
		
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		

	ofEndShape(true);
	
	glTranslatef(100,0,0);
	
	ofSetPolyMode(OF_POLY_WINDING_NONZERO);	
	ofBeginShape();
		
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		
	ofEndShape(true);
	
	glTranslatef(100,0,0);
	ofSetPolyMode(OF_POLY_WINDING_ABS_GEQ_TWO);
	ofBeginShape();
		ofVertex(300,500);
		ofVertex(380,550);
		ofVertex(300,600);
		ofNextContour(true);
		
		for (int i = 0; i < 20; i++){
			float anglef = ((float)i / 19.0f) * TWO_PI;
			float x = 340 + 30 * cos(anglef);
			float y = 550 + 30 * sin(anglef); 
			ofVertex(x,y);
			radius 	+= radiusAdder; 
		}
		
		
	ofEndShape(true);
	
	glPopMatrix();

	//-------------------------------------
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(a) star\nwinding rule odd", 20,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(b) star\nwinding rule nonzero", 220,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(c) dynamically\ncreated shape", 420,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(d) random points\npoly", 670,210);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(e) fun with sin/cos", 20,410);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(f) ofCurveVertex\nuses catmull rom\nto make curved shapes", 220,410);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(g) ofBezierVertex\nuses bezier to draw curves", 460,410);
	
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(h) ofNextContour\nallows for holes", 20,610);
	
	ofSetHexColor(0x000000);
	ofDrawBitmapString("(i) ofNextContour\ncan even be used for CSG operations\nsuch as union and intersection", 260,620);
	
}
Example #19
0
		//--------------------------------------------------------------
		void Lighting::drawWorld()
		{
			auto cullFaceEnabled = glIsEnabled(GL_CULL_FACE);
			GLint cullFaceMode[1];
			glGetIntegerv(GL_CULL_FACE_MODE, cullFaceMode);

			ofDisableAlphaBlending();

			glEnable(GL_CULL_FACE);
			glCullFace(GL_FRONT);

			this->viewUbo.bind();
			{
				this->skyboxMap.bind(14);
				this->irradianceMap.bind(2);
				this->radianceMap.bind(3);

				this->viewUbo.update(this->getCamera());
				this->lightingSystem.update(this->getCamera());

				ofSetColor(255, 255, 255, 255);

				if (this->parameters.debug)
				{
					this->lightingSystem.debugDrawFrustum(this->getCamera());

					this->lightingSystem.debugDrawCulledPointLights();
					this->lightingSystem.debugDrawClusteredPointLights();
					this->lightingSystem.debugDrawOccupiedClusters(this->getCamera());
				}
				else
				{
					this->drawSkybox();

					this->lightingSystem.begin();
					{
						this->shader.begin();
						{
							this->material.setUniforms(this->shader);
							this->shader.setUniform1f("uExposure", this->parameters.camera.exposure);
							this->shader.setUniform1f("uGamma", this->parameters.camera.gamma);
							this->shader.setUniform1i("uIrradianceMap", 2);
							this->shader.setUniform1i("uRadianceMap", 3);

							this->drawScene();
						}
						this->shader.end();
					}
					this->lightingSystem.end();
				}

				this->skyboxMap.unbind(14);
				this->irradianceMap.unbind(2);
				this->radianceMap.unbind(3);
			}
			this->viewUbo.unbind();

			// Restore state.
			if (GL_TRUE == cullFaceEnabled)
			{
				glCullFace(cullFaceMode[0]);
			}
			else
			{
				glDisable(GL_CULL_FACE);
			}
		}
Example #20
0
void facade::draw()
{
	ofBackground(0, 0, 0);
	ofSetColor(255);

	//Particles
	if(doRender) {
		
		ofEnableAlphaBlending();
		
		// center scene
		glPushMatrix();
		glTranslatef(width/2, 0, -width / 3);
		glRotatef(rotation, 0, 1, 0);
		
		if(forceTimer) {
			float translateMax = forceTimer;
			glTranslatef(ofRandom(-translateMax, translateMax), ofRandom(-translateMax, translateMax), ofRandom(-translateMax, translateMax));
			forceTimer--;
		}

		
		/*
		// enable back-face culling (so we can see through the walls)
		glCullFace(GL_BACK);
		glEnable(GL_CULL_FACE);

		glEnable(GL_DEPTH_TEST);

		ofFill();
		
		glBegin(GL_QUADS);
		// draw right wall
		glColor3f(.1, 0.1, 0.1);		glVertex3f(width/2, height+1, width/2);
		glColor3f(0, 0, 0);				glVertex3f(width/2, -height, width/2);
		glColor3f(0.05, 0.05, 0.05);	glVertex3f(width/2, -height, -width/2);
		glColor3f(.15, 0.15, 0.15);		glVertex3f(width/2, height+1, -width/2);
		
		// back wall
		glColor3f(.1, 0.1, 0.1);		glVertex3f(width/2, height+1, -width/2);
		glColor3f(0, 0, 0);				glVertex3f(width/2, -height, -width/2);
		glColor3f(0.05, 0.05, 0.05);	glVertex3f(-width/2, -height, -width/2);
		glColor3f(.15, 0.15, 0.15);		glVertex3f(-width/2, height+1, -width/2);
		
		// left wall
		glColor3f(.1, 0.1, 0.1);		glVertex3f(-width/2, height+1, -width/2);
		glColor3f(0, 0, 0);				glVertex3f(-width/2, -height, -width/2);
		glColor3f(0.05, 0.05, 0.05);	glVertex3f(-width/2, -height, width/2);
		glColor3f(.15, 0.15, 0.15);		glVertex3f(-width/2, height+1, width/2);
		
		// front wall
		glColor3f(0.05, 0.05, 0.05);	glVertex3f(width/2, -height, width/2);
		glColor3f(.15, 0.15, 0.15);		glVertex3f(width/2, height+1, width/2);
		glColor3f(.1, 0.1, 0.1);		glVertex3f(-width/2, height+1, width/2);
		glColor3f(0, 0, 0);				glVertex3f(-width/2, -height, width/2);
		
		// floor
		glColor3f(.2, 0.2, 0.2);
		glVertex3f(width/2, height+1, width/2);
		glVertex3f(width/2, height+1, -width/2);
		glVertex3f(-width/2, height+1, -width/2);
		glVertex3f(-width/2, height+1, width/2);
		glEnd();
		glDisable(GL_DEPTH_TEST);
		glDisable(GL_CULL_FACE);
		*/

		//canvas
		glRotatef(rotation, 0, -1, 0);
		if(config::useCanvas) {
			canvas.begin();

			ofSetColor(255, canvasFade);
			canvasTrace.draw(0,0);
			glTranslatef(width/2, 0, -width / 3);
		}
		glRotatef(rotation, 0, 1, 0);

		//particles
		//glAlphaFunc(GL_GREATER, 0.5);


		if(currentSkeletonIndex>=0 && false){
			ofPolyline pLine;
			ofPushStyle();
			ofSetColor(255, 0, 0);
			ofNoFill();
			ofSetLineWidth(4);
			// HEAD
			pLine.clear();
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().x, bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().y, bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_SPINE]->getPosition().x, bone[NUI_SKELETON_POSITION_SPINE]->getPosition().y, bone[NUI_SKELETON_POSITION_SPINE]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().x, bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().y, bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HEAD]->getPosition().x, bone[NUI_SKELETON_POSITION_HEAD]->getPosition().y, bone[NUI_SKELETON_POSITION_HEAD]->getPosition().z);
			pLine.draw();
	
			// BODY_LEFT
			pLine.clear();
			pLine.addVertex(bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().x, bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().y, bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_SHOULDER_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_SHOULDER_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_SHOULDER_LEFT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_ELBOW_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_ELBOW_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_ELBOW_LEFT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_WRIST_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_WRIST_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_WRIST_LEFT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HAND_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_HAND_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_HAND_LEFT]->getPosition().z);
			pLine.draw();

			// BODY_RIGHT
			pLine.clear();
			pLine.addVertex(bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().x, bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().y, bone[NUI_SKELETON_POSITION_SHOULDER_CENTER]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_SHOULDER_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_SHOULDER_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_SHOULDER_RIGHT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_ELBOW_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_ELBOW_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_ELBOW_RIGHT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_WRIST_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_WRIST_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_WRIST_RIGHT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HAND_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_HAND_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_HAND_RIGHT]->getPosition().z);
			pLine.draw();

			// LEG_LEFT
			pLine.clear();
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().x, bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().y, bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HIP_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_HIP_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_HIP_LEFT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_KNEE_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_KNEE_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_KNEE_LEFT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_ANKLE_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_ANKLE_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_ANKLE_LEFT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_FOOT_LEFT]->getPosition().x, bone[NUI_SKELETON_POSITION_FOOT_LEFT]->getPosition().y, bone[NUI_SKELETON_POSITION_FOOT_LEFT]->getPosition().z);
			pLine.draw();

			// LEG_RIGHT
			pLine.clear();
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().x, bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().y, bone[NUI_SKELETON_POSITION_HIP_CENTER]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_HIP_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_HIP_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_HIP_RIGHT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_KNEE_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_KNEE_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_KNEE_RIGHT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_ANKLE_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_ANKLE_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_ANKLE_RIGHT]->getPosition().z);
			pLine.addVertex(bone[NUI_SKELETON_POSITION_FOOT_RIGHT]->getPosition().x, bone[NUI_SKELETON_POSITION_FOOT_RIGHT]->getPosition().y, bone[NUI_SKELETON_POSITION_FOOT_RIGHT]->getPosition().z);
			pLine.draw();
			ofPopStyle();
		}

		ofEnableNormalizedTexCoords();
		ballImage.getTextureReference().bind();
		msa::physics::Particle3D *p;
		float alpha;
		int red, green, blue;
		for(int i=0; i<physics.numberOfParticles(); i++) {
			p = physics.getParticle(i);
			if(!p->isFixed()){
				
				red = particleColor.r*colorSpaceVariation + ofMap(p->getPosition().x, -width/2, width/2, 0, 255-(255*colorSpaceVariation));
				green = particleColor.g*colorSpaceVariation + ofMap(p->getPosition().y, -height, height, 0, 255-(255*colorSpaceVariation));
				blue = particleColor.b*colorSpaceVariation + ofMap(p->getPosition().z, -width/2, width/2, 0, 255-(255*colorSpaceVariation));
					
				// draw ball
				glPushMatrix();
					glTranslatef(p->getPosition().x, p->getPosition().y, p->getPosition().z);
					glRotatef(180-rotation, 0, 1, 0);
					ofSetColor(red, green, blue);
					drawParticle(p->getRadius());
				glPopMatrix();
			
				//draw shadow
				alpha = ofMap(p->getPosition().y, -height * 1.5, height, 0, 1);
				if(alpha>0) {
					glPushMatrix();
						glTranslatef(p->getPosition().x, height, p->getPosition().z);
						glRotatef(-90, 1, 0, 0);
						ofSetColor(red, green, blue, alpha * alpha * alpha * alpha * 255);
						drawParticle(p->getRadius() * alpha);
					glPopMatrix();
				}
			}
			
		}
		ballImage.getTextureReference().unbind();
		ofDisableNormalizedTexCoords();

		if(config::useCanvas) {
			canvas.end();
		}
		glPopMatrix();

		
		
		
		if(config::useCanvas) {
			canvasTrace.begin();

				/*glColorMask(FALSE, FALSE, FALSE, TRUE);
				glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				glColorMask(TRUE, TRUE, TRUE, TRUE);*/

				ofSetColor(255);
				canvas.draw(0,0);
			canvasTrace.end();
		
			canvasTrace.draw(0,canvasY);
		
			canvas.begin();
				ofClear(0);
			canvas.end();
		}
		
		if(blackout>0){
			ofSetColor(0,0,0,blackout);
			ofRect(0,0,0,width, height);
		}

		ofDisableAlphaBlending();
	}

	


	/*
	// HEAD
	pLine.clear();
	pLine.addVertex(src[NUI_SKELETON_POSITION_HIP_CENTER].x, src[NUI_SKELETON_POSITION_HIP_CENTER].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_SPINE].x, src[NUI_SKELETON_POSITION_SPINE].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_SHOULDER_CENTER].x, src[NUI_SKELETON_POSITION_SHOULDER_CENTER].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_HEAD].x, src[NUI_SKELETON_POSITION_HEAD].y);
	pLine.draw();
	
	// BODY_LEFT
	pLine.clear();
	pLine.addVertex(src[NUI_SKELETON_POSITION_SHOULDER_CENTER].x, src[NUI_SKELETON_POSITION_SHOULDER_CENTER].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_SHOULDER_LEFT].x, src[NUI_SKELETON_POSITION_SHOULDER_LEFT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_ELBOW_LEFT].x, src[NUI_SKELETON_POSITION_ELBOW_LEFT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_WRIST_LEFT].x, src[NUI_SKELETON_POSITION_WRIST_LEFT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_HAND_LEFT].x, src[NUI_SKELETON_POSITION_HAND_LEFT].y);
	pLine.draw();

	// BODY_RIGHT
	pLine.clear();
	pLine.addVertex(src[NUI_SKELETON_POSITION_SHOULDER_CENTER].x, src[NUI_SKELETON_POSITION_SHOULDER_CENTER].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_SHOULDER_RIGHT].x, src[NUI_SKELETON_POSITION_SHOULDER_RIGHT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_ELBOW_RIGHT].x, src[NUI_SKELETON_POSITION_ELBOW_RIGHT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_WRIST_RIGHT].x, src[NUI_SKELETON_POSITION_WRIST_RIGHT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_HAND_RIGHT].x, src[NUI_SKELETON_POSITION_HAND_RIGHT].y);
	pLine.draw();

	// LEG_LEFT
	pLine.clear();
	pLine.addVertex(src[NUI_SKELETON_POSITION_HIP_CENTER].x, src[NUI_SKELETON_POSITION_HIP_CENTER].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_HIP_LEFT].x, src[NUI_SKELETON_POSITION_HIP_LEFT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_KNEE_LEFT].x, src[NUI_SKELETON_POSITION_KNEE_LEFT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_ANKLE_LEFT].x, src[NUI_SKELETON_POSITION_ANKLE_LEFT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_FOOT_LEFT].x, src[NUI_SKELETON_POSITION_FOOT_LEFT].y);
	pLine.draw();

	// LEG_RIGHT
	pLine.clear();
	pLine.addVertex(src[NUI_SKELETON_POSITION_HIP_CENTER].x, src[NUI_SKELETON_POSITION_HIP_CENTER].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_HIP_RIGHT].x, src[NUI_SKELETON_POSITION_HIP_RIGHT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_KNEE_RIGHT].x, src[NUI_SKELETON_POSITION_KNEE_RIGHT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_ANKLE_RIGHT].x, src[NUI_SKELETON_POSITION_ANKLE_RIGHT].y);
	pLine.addVertex(src[NUI_SKELETON_POSITION_FOOT_RIGHT].x, src[NUI_SKELETON_POSITION_FOOT_RIGHT].y);
	pLine.draw();*/

	

	//glDisable(GL_BLEND);

	
	if(showFPS)
	{
		glColor4f(1, 1, 1, 1);
		ofDrawBitmapString(" FPS: " + ofToString(ofGetFrameRate(), 2)
					+ " | particles: " + ofToString(physics.numberOfParticles(), 2)
					+ " | springs: " + ofToString(physics.numberOfSprings(), 2)
				   , 20, 15);
	}
}
Example #21
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();
		btScalar	m[16];
		ofGetOpenGLMatrixFromRigidBody( boundsShape->getRigidBody(), m );
		glPushMatrix(); 
		glMultMatrixf( m );
		ofBox(ofVec3f(0, 0,0), boundsWidth);
		glPopMatrix();
		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++) {
		btScalar	m[16];
		ofGetOpenGLMatrixFromRigidBody( logos[i]->getRigidBody(), m );
		glPushMatrix(); 
		glMultMatrixf( m );
		glTranslatef(-logos[i]->getCentroid().x, -logos[i]->getCentroid().y, -logos[i]->getCentroid().z);
		ofScale(scale.x,scale.y,scale.z);
		assimpModel.getMesh(0).drawFaces();
		glPopMatrix();
	}
	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);
}
//--------------------------------------------------------------
void ofApp::drawPlayer(){
	
	
	// draw the (warped) player
	ofSetColor(255, 255, 255);
	playerScaleFactor = (float)(ofGetHeight() - unwarpedH)/(float)warpedH;
	player.draw(0, 0, playerScaleFactor*warpedW, playerScaleFactor*warpedH);
	
	// draw the center point, as a red cross
	ofSetColor(255,0,0);
	glEnable(GL_LINE_SMOOTH);
	ofEnableAlphaBlending();
	float f = playerScaleFactor;
	ofDrawLine((f*(warpedCx))-5, (f*(warpedCy)),   (f*(warpedCx))+5, (f*(warpedCy)));
	ofDrawLine((f*(warpedCx))  , (f*(warpedCy))-5, (f*(warpedCx)),   (f*(warpedCy))+5);
	ofDisableAlphaBlending();
	glDisable(GL_LINE_SMOOTH);
	
	
	// draw informational text about the app.
	ofSetColor(255,255,255);
	float ty = 10;
	float dy = 11;
	ofDrawBitmapString("BLOGGIE UNWARPER (OSX)",    10,ty+=dy);file://localhost/Users/golan/Desktop/OF61_106/apps/golan_of61_osx63/BloggieUnwarp/BloggieUnwarp.xcodeproj/
	ofDrawBitmapString("Made in OpenFrameworks",    10,ty+=dy);
	ofDrawBitmapString("By G.Levin & S.Bisker",     10,ty+=dy);
	ty+=dy;
	
	ofSetColor(255,0,0);
	ofDrawBitmapString("Drag cross or use",                  10, ty+=dy);
	ofDrawBitmapString("arrow keys to recenter.",            10, ty+=dy);
	ofDrawBitmapString("Other key commands:",                 10, ty+=dy);
	ofDrawBitmapString("'s' to Save settings.",                 10, ty+=dy);
	ofDrawBitmapString("'r' to Restore settings.",              10, ty+=dy);
	ofDrawBitmapString("'v' to export Video.",                  10, ty+=dy);
	ofDrawBitmapString("cx: "   + ofToString((warpedCx)),    10, ty+=dy);
	ofDrawBitmapString("cy: "   + ofToString((warpedCy)),    10, ty+=dy);
	ofDrawBitmapString("rot:"   + ofToString((angularOffset)), 10, ty+=dy);
	
	
	/*
	if (bSavingOutVideo){
		ofSetColor(255,255,100);
		
		float pos = player.getPosition(); // nWrittenFrames
		ofDrawBitmapString("SAVING VIDEO to:",				10, playerScaleFactor*warpedH - 20);
		int currF = player.getCurrentFrame();
		int nF    = player.getTotalNumFrames();
		sprintf(handyString, "data/%s (%d/%dF / %1.1f%c)...", outputFileName.c_str(), currF,nF, (pos*100.0), '%');
		ofDrawBitmapString(handyString,						10, playerScaleFactor*warpedH - 10);
	} else {
		ofSetColor(200,200,200);
		
		sprintf(handyString, "Codec (-/+): %s", (videoRecorder->getCodecName(currentCodecId)).c_str());
		ofDrawBitmapString("Press 'v' to export video.",	10, playerScaleFactor*warpedH - 10);
		ofDrawBitmapString(handyString,			            10, playerScaleFactor*warpedH - 20);
	}
	 */
	
	
}
Example #23
0
		//----------
		Crossfader::Crossfader(int targetWidth, int targetHeight) {
			this->caption = "Crossfader";

			this->slider = this->elementGroup->addBlank();
			this->slider->onDraw += [this] (DrawArguments& args) {
				const float yCenter = this->getHeight() / 2.0f;
				const float width = this->getWidth();
				const float xCenter = width / 2.0f;

				ofPushStyle();

				//--
				//major ticks
				//
				ofSetColor(100);
				ofSetLineWidth(1.0f);
				float x = this->getX(-1.0f);
				ofLine(x, yCenter - 50.0f, x, yCenter + 50.0f);
				x = this->getX(0.0f);
				ofLine(x, yCenter - 50.0f, x, yCenter + 50.0f);
				x = this->getX(1.0f);
				ofLine(x, yCenter - 50.0f, x, yCenter + 50.0f);
				//
				//--

				//--
				//coloured ticks
				//
				for(float position = -1.0f; position <= 1.0f; position += 0.01f) {
					this->drawTicks(position);
				}
				//
				//--

				//--
				//handle
				//
				ofSetLineWidth(1.0f);
				float handleX = this->getX(this->position);

				ofFill();
				ofEnableAlphaBlending();
				ofSetColor(0,0,0,50);
				ofRect(handleX - 10.0f, yCenter - VMIG_CROSSFADE_HANDLE_HEIGHT / 2.0f, 20.0f, VMIG_CROSSFADE_HANDLE_HEIGHT);

				ofNoFill();
				ofSetColor(255);
				ofLine(handleX, yCenter - VMIG_CROSSFADE_ROW_HEIGHT / 2.0f, handleX, yCenter - VMIG_CROSSFADE_ROW_HEIGHT);
				ofLine(handleX, yCenter + VMIG_CROSSFADE_ROW_HEIGHT / 2.0f, handleX, yCenter + VMIG_CROSSFADE_ROW_HEIGHT);
				ofPopStyle();
				//
				//--
			};

			//--
			//select mode buttons
			//
			vector<ElementPtr> modeButtons;
			auto selectDefault = this->elementGroup->addBlank();
			auto selectHalfRange = this->elementGroup->addBlank();
			auto selectThroughBlack = this->elementGroup->addBlank();
			auto selectCut = this->elementGroup->addBlank();
			modeButtons.push_back(selectThroughBlack);
			modeButtons.push_back(selectDefault);
			modeButtons.push_back(selectHalfRange);
			modeButtons.push_back(selectCut);

			selectDefault->onDraw += [this] (DrawArguments& args) {
				ofEnableAlphaBlending();
				this->defaultMode->preview.draw(0,0,args.parentBounds.width, args.parentBounds.height);
				ofDisableAlphaBlending();
				if (this->selectedMode == this->defaultMode) {
					ofPushStyle();
					ofSetColor(255);
					ofNoFill();
					ofSetLineWidth(1.0f);
					ofRect(0,0,args.parentBounds.width, args.parentBounds.height);
					ofPopStyle();
				}
			};
			selectHalfRange->onDraw += [this] (DrawArguments& args) {
				ofEnableAlphaBlending();
				this->halfRangeMode->preview.draw(0,0,args.parentBounds.width, args.parentBounds.height);
				ofDisableAlphaBlending();
				if (this->selectedMode == this->halfRangeMode) {
					ofPushStyle();
					ofSetColor(255);
					ofNoFill();
					ofSetLineWidth(1.0f);
					ofRect(0,0,args.parentBounds.width, args.parentBounds.height);
					ofPopStyle();
				}
			};
			selectThroughBlack->onDraw += [this] (DrawArguments& args) {
				ofEnableAlphaBlending();
				this->throughBlackMode->preview.draw(0,0,args.parentBounds.width, args.parentBounds.height);
				ofDisableAlphaBlending();
				if (this->selectedMode == this->throughBlackMode) {
					ofPushStyle();
					ofSetColor(255);
					ofNoFill();
					ofSetLineWidth(1.0f);
					ofRect(0,0,args.parentBounds.width, args.parentBounds.height);
					ofPopStyle();
				}
			};
			selectCut->onDraw += [this] (DrawArguments& args) {
				ofEnableAlphaBlending();
				this->cutMode->preview.draw(0,0,args.parentBounds.width, args.parentBounds.height);
				ofDisableAlphaBlending();
				if (this->selectedMode == this->cutMode) {
					ofPushStyle();
					ofSetColor(255);
					ofNoFill();
					ofSetLineWidth(1.0f);
					ofRect(0,0,args.parentBounds.width, args.parentBounds.height);
					ofPopStyle();
				}
			};
			
			selectDefault->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->selectedMode = this->defaultMode;
				}
			};
			selectHalfRange->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->selectedMode = this->halfRangeMode;
				}
			};
			selectThroughBlack->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->selectedMode = this->throughBlackMode;
				}
			};
			selectCut->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->selectedMode = this->cutMode;
				}
			};
			//
			//--


			//--
			//auto fade buttons
			//
			auto autoToA_1 = this->elementGroup->addBlank();
			auto autoToA_2 = this->elementGroup->addBlank();
			auto autoToA_5 = this->elementGroup->addBlank();
			auto autoToA_10 = this->elementGroup->addBlank();
			
			auto autoToB_1 = this->elementGroup->addBlank();
			auto autoToB_2 = this->elementGroup->addBlank();
			auto autoToB_5 = this->elementGroup->addBlank();
			auto autoToB_10 = this->elementGroup->addBlank();

			autoToA_1->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("1s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};
			autoToA_2->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("2s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};
			autoToA_5->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("5s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};
			autoToA_10->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("10s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};
			autoToB_1->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("1s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};
			autoToB_2->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("2s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};
			autoToB_5->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("5s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};
			autoToB_10->onDraw += [] (DrawArguments&) {
				ofxCvGui::AssetRegister.drawText("10s", 0, 0, "", true, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE);
			};

			autoToA_1->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_A;
					this->autoFadeSpeed = (-1.0f - this->position) / 1.0f;
				}
			};
			autoToA_2->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_A;
					this->autoFadeSpeed = (-1.0f - this->position) / 2.0f;
				}
			};
			autoToA_5->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_A;
					this->autoFadeSpeed = (-1.0f - this->position) / 5.0f;
				}
			};
			autoToA_10->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_A;
					this->autoFadeSpeed = (-1.0f - this->position) / 10.0f;
				}
			};
			autoToB_1->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_B;
					this->autoFadeSpeed = (+1.0f - this->position) / 1.0f;
				}
			};
			autoToB_2->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_B;
					this->autoFadeSpeed = (+1.0f - this->position) / 2.0f;
				}
			};
			autoToB_5->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_B;
					this->autoFadeSpeed = (+1.0f - this->position) / 5.0f;
				}
			};
			autoToB_10->onMouse += [this] (MouseArguments& args) {
				if (args.isLocalPressed()) {
					this->autoFade = AutoFade_B;
					this->autoFadeSpeed = (+1.0f - this->position) / 10.0f;
				}
			};
			//
			//--

			this->onMouse += [this] (MouseArguments& args) {
				if (args.action == MouseArguments::Pressed) {
					this->draggingCrossfader = (args.local.y >= this->getHeight() / 2.0f - VMIG_CROSSFADE_HANDLE_HEIGHT &&
						args.local.y <= this->getHeight() / 2.0f + VMIG_CROSSFADE_HANDLE_HEIGHT);
				}

				if (args.action == MouseArguments::Dragged && this->draggingCrossfader) {
					float dx = args.movement.x;
					float dPosition = this->getPosition(args.local.x) - this->getPosition(args.local.x - dx);
					this->setPosition(this->position + dPosition);
				}
			};

			this->onBoundsChange += [this, modeButtons, autoToA_1, autoToA_2, autoToA_5, autoToA_10, autoToB_1, autoToB_2, autoToB_5, autoToB_10] (BoundsChangeArguments&) {
				this->slider->setBounds(ofRectangle(0,0,this->getWidth(), this->getHeight()));
				float spread = modeButtons.size() * VMIG_CROSSFADE_MODE_BUTTON_SPACING;
				for(int i=0; i<modeButtons.size(); i++) {
					auto & button = modeButtons[i];
					float x = ofMap(i, 0, modeButtons.size() - 1, -spread / 2.0f, spread / 2.0f) + this->getWidth() / 2.0f;
					button->setBounds(ofRectangle(x - VMIG_CROSSFADE_MODE_BUTTON_SIZE / 2.0f, this->getHeight() / 2.0f + VMIG_CROSSFADE_MODE_BUTTON_Y_OFFSET, VMIG_CROSSFADE_MODE_BUTTON_SIZE, VMIG_CROSSFADE_MODE_BUTTON_SIZE));
				}

				float autoToAx = VMIG_CROSSFADE_INDENT - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f;
				autoToA_1->setBounds(ofRectangle(autoToAx, this->getHeight() / 2.0f - 2 * VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));
				autoToA_2->setBounds(ofRectangle(autoToAx, this->getHeight() / 2.0f - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));
				autoToA_5->setBounds(ofRectangle(autoToAx, this->getHeight() / 2.0f - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));
				autoToA_10->setBounds(ofRectangle(autoToAx, this->getHeight() / 2.0f + VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));

				float autoToBx = this->getWidth() - VMIG_CROSSFADE_INDENT + VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f;
				autoToB_1->setBounds(ofRectangle(autoToBx, this->getHeight() / 2.0f - 2 * VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));
				autoToB_2->setBounds(ofRectangle(autoToBx, this->getHeight() / 2.0f - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));
				autoToB_5->setBounds(ofRectangle(autoToBx, this->getHeight() / 2.0f - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));
				autoToB_10->setBounds(ofRectangle(autoToBx, this->getHeight() / 2.0f + VMIG_CROSSFADE_AUTO_FADE_BUTTON_SPACING - VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE / 2.0f,
					VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE, VMIG_CROSSFADE_AUTO_FADE_BUTTON_SIZE));
			};

			this->onUpdate += [this] (UpdateArguments&) {
				this->drawFade();
				if (this->autoFade != AutoFade_None) {
					this->position += this->autoFadeSpeed * ofGetLastFrameTime();
					if (this->position < -1.0f || this->position > 1.0f) {
						this->setPosition(this->position); // this will clear auto and clamp
					}
				}
			};

			this->defaultMode = ofPtr<BaseMode>(new DefaultMode());
			this->halfRangeMode = ofPtr<BaseMode>(new HalfRangeMode());
			this->throughBlackMode = ofPtr<BaseMode>(new ThroughBlackMode());
			this->cutMode = ofPtr<BaseMode>(new CutMode());
			this->selectedMode = this->defaultMode;

			this->defaultMode->updatePreview();
			this->halfRangeMode->updatePreview();
			this->throughBlackMode->updatePreview();
			this->cutMode->updatePreview();

			this->position = 0.0f;
			this->A = 0;
			this->B = 0;
			this->targetWidth = targetWidth;
			this->targetHeight = targetHeight;
			this->target.allocate(this->targetWidth, this->targetHeight, GL_RGBA);
			this->draggingCrossfader = false;
		}
Example #24
0
void SequenceTrail::draw( int curFrame )
{

    AbstractParticle& _drawMe = sequence[0]  ;
    ofPoint& p = _drawMe.position ;
    ofEnableAlphaBlending() ;

    ofSetColor ( color.r ,color.g , color.b  , 50 ) ;
    ofRect((ofGetWidth() / 4.0f) * index, ofGetHeight()-50, ofGetWidth() / 4.0f , 50 ) ;

    ofSetColor ( color.r ,color.g , color.b  , 75 ) ;
    ofFill();
    int trailLength = trailSize ;  ;

    int prevIndex = curFrame ;
    if ( curFrame == 0 )
        runningTotal = 0 ;

    for ( int i = 0 ; i < trailLength ; i++ )
    {

        if ( curFrame > 0 )
            prevIndex = curFrame - i ;
        else {
            prevIndex = curFrame;
        }

        if ( prevIndex < 0 )
            prevIndex += numFrames-1 ;

        if ( prevIndex < numFrames )
        {
            _drawMe = sequence[prevIndex] ;
            p = _drawMe.position ;

            if ( _drawMe.active == true && p.x > 0 && p.y > 0 )
            {
                //float ratio = 1.0f +- ( (float)i / (float)trailLength ) ;
                float ratio = ( (float)i / (float)trailLength ) ;

                ofColor curColor = ofColor() ;
                curColor.r = ofLerp( color.r , secondary.r , ratio ) ;
                curColor.g = ofLerp( color.g , secondary.g , ratio ) ;
                curColor.b = ofLerp( color.b , secondary.b , ratio ) ;
                ratio = 1.0f +- ( (float)i / (float)trailLength ) ;
                _drawMe.draw( ratio, (float)i , curColor );

                //if ( curFrame +- (playRates[playRateIndex]+runningTotal) == 0 )
                if ( (curFrame-runningTotal) == playRates[playRateIndex] )
                {
                    ofSetColor ( color.r , color.g , color.b  , 125 ) ;
                    ofRect( (ofGetWidth() / 4.0f) * index, ofGetHeight()-50, ofGetWidth() / 4.0f , 50 ) ;

                    if (soundPlayer.bLoadedOk == true )
                    {
                        float ratio = (1.0f)-((p.y) / (float)ofGetHeight() ) ;
                        //8 steps
                        //Round to the nearest 8th step.
                        int _step = ratio * 8.0f ;
                        float ratioStep = (float)_step / 8.0f ;

                        //int _step = (int)(ratio*100.0f) | 0 ;
                        //ratio = (float)_step / 8.0f ;
                        float newSpeed = startSpeed + range * ratioStep;
                        soundPlayer.setSpeed( newSpeed );
                        soundPlayer.play();
                        runningTotal += playRates[playRateIndex] ;

                        playRateIndex++ ;
                        if ( playRateIndex > playRates.size()-1 )
                        {
                            playRateIndex = 0 ;
                        }

                    }


                }
            }
        }
    }
    ofDisableAlphaBlending() ;

}
Example #25
0
//----------------------------------------------------
void ofxSimpleSlider::draw(ofEventArgs& event){
	
	ofEnableAlphaBlending();
	ofDisableSmoothing();
	ofPushMatrix();
	ofTranslate(x,y,0);
	
	// Use different alphas if we're actively maniupulating me. 
	float sliderAlpha = (bHasFocus) ? 128:64;
	float spineAlpha  = (bHasFocus) ? 192:128;
	float thumbAlpha  = (bHasFocus) ? 255:160;
	
	// draw box outline
	ofNoFill();
	ofSetLineWidth(1.0);
	ofSetColor(200,200,200, sliderAlpha);
	ofSetRectMode(OF_RECTMODE_CORNER);
	ofRect(0,0, width,height); 
	
	// draw spine
	ofSetLineWidth(1.0);
	ofSetColor(255,255,255, spineAlpha); 
	if (bVertical){
		ofLine(width/2,0, width/2,height); 
	} else {
		ofLine(0,height/2, width,height/2); 
	}
	
	// draw thumb
	ofSetLineWidth(5.0);
	ofSetColor(255,255,255, thumbAlpha);
	if (bVertical){
		float thumbY = ofMap(percent, 0,1, height,0, true);
		ofLine(0,thumbY, width,thumbY); 
	} else {
		float thumbX = ofMap(percent, 0,1, 0,width, true);
		ofLine(thumbX,0, thumbX,height); 
	}
	
	
	
	// draw numeric value 
	if (bHasFocus){
		ofSetColor(255); 
	} else {
		ofSetColor(200); 
	}
	if (bVertical){
		ofDrawBitmapString( ofToString(getValue(),numberDisplayPrecision), width+5,height);
		
		//float labelStringWidth = labelString.size();
		ofDrawBitmapString(labelString, width+5, height-14); 
	} else {
		ofDrawBitmapString( ofToString(getValue(),numberDisplayPrecision), width+5,height/2 + 4);
		
		float labelStringWidth = labelString.size();
		ofDrawBitmapString( labelString, 0-labelStringWidth*8-5, height/2 + 4); 
	}	

	
	ofPopMatrix();
	ofSetLineWidth(1.0);
	ofDisableAlphaBlending();
}
Example #26
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackground(0,0,0);

	ofSetHexColor(0xffffff);
    
    int row = 0;
    int col = 0;
    
    int x = 0;
    int y = 0;
    
    int w = 320;
    int h = 240;
    
    float totalKBPS = 0;
    float totalFPS = 0;
    
    for(int i = 0; i < NUM_CAMERAS; i++) {
        x = col * w;
        y = row * h;

        
        row = (row + 1) % NUM_ROWS;
        
        if(row == 0) {
            col = (col + 1) % NUM_COLS;
        }

        
        ofPushMatrix();
        ofTranslate(x,y);
        ofSetColor(255,255,255,255);
        ipGrabber[i].draw(0,0,w,h);
        
        
        ofEnableAlphaBlending();
        
        ofSetColor(0,0,0,127);
        ofRect(10,h-45,w-20,35);
        
        float kbps = ipGrabber[i].getBps() / 1000.0;
        totalKBPS+=kbps;
        
        float fps = ipGrabber[i].getFps();
        totalFPS+=fps;
        
        ofSetColor(255,255,255);
        ofDrawBitmapString(" FPS: " + ofToString(fps, 2), 20, h-35);
        ofDrawBitmapString("KB/S: " + ofToString(kbps,2), 20, h-20);
        
        ofDisableAlphaBlending();
        
        ofPopMatrix();
    }
    
    float avgFPS = totalFPS / NUM_CAMERAS;
    float avgKBPS = totalKBPS / NUM_CAMERAS;

    ofEnableAlphaBlending();
    ofSetColor(255,255,255,80);
    ofRect(0,0, 50, 20);
    ofSetColor(0,0,0,80);
    
    ofDrawBitmapString(" AVG_FPS: " + ofToString(avgFPS,   2), 5,10);
    ofDrawBitmapString("AVG_KBPS: " + ofToString(avgKBPS,  2), 5,20);
    ofDrawBitmapString("TOT_KBPS: " + ofToString(totalKBPS,2), 5,30);
    ofDisableAlphaBlending();

}
Example #27
0
void testApp::drawString()
{
	glEnable(GL_TEXTURE_2D);
	
	glPushMatrix(); {
	
		glTranslatef(ofGetWidth()/2, ofGetHeight()/2 + 10, 0);

		//glRotatef(60, 1, 0, 0);
	
		static float rot = 0;
		glRotatef(-rot, 0, 1, 0);
		if (rot > 360) rot = 0;
		rot += 0.2;

		ofPushStyle(); {
			ofEnableAlphaBlending();
			ofSetColor(255, 255, 255, 127);

			glPushMatrix(); {
				glTranslatef(30, -50, 0);
				glScalef(32, -32, 1);
				char *c;
				sprintf(c, "#%02d", current+1);
				glcRenderString(c);
			} glPopMatrix();

			glPushMatrix(); {
				glTranslatef(30, 0, 0);
				glScalef(32, -32, 1);
				glcRenderString(cities[current].address.c_str());
			} glPopMatrix();
	
			glPushMatrix(); {
				glTranslatef(30, 50, 0);
				glScalef(32, -32, 1);

				time_t rawtime;
				time(&rawtime);
				tm *ptm = gmtime(&rawtime);
				
				time_t localtime = mktime(ptm);
				localtime += cities[current].offset * 3600;
				char *str = ctime(&localtime);
				glcRenderString(str);
			} glPopMatrix();

			ofDisableAlphaBlending();
		} ofPopStyle();

		// draw input string
		glPushMatrix();
		glTranslatef(30, 100, 0);
		glScalef(32, -32, 1);
		//glColor3f(0.f, 1.f, 0.f);
		ofPushStyle();
		ofSetColor(0, 255, 0);
		if (showError) {
			glcRenderString(error.c_str());
		} else {
			glcRenderString(input.c_str());
		}		
		ofPopStyle();
		glPopMatrix();

	} glPopMatrix();
	
}
Example #28
0
void StCvOpSparkle::draw(){
    ofxUIIntSlider *gskip = (ofxUIIntSlider *)gui->getWidget("SKIP"); int skip = gskip->getValue();
    ofxUIIntSlider *gmax = (ofxUIIntSlider *)gui->getWidget("MAX"); int max = gmax->getValue();
    ofxUISlider *gthresh = (ofxUISlider *)gui->getWidget("THRESH"); float thresh = gthresh->getValue();
    ofxUISlider *gradius = (ofxUISlider *)gui->getWidget("RADIUS"); float radius = gradius->getValue();
    ofxUISlider *gfriction = (ofxUISlider *)gui->getWidget("FRICTION"); float friction = gfriction->getValue();
    ofxUISlider *gaccel = (ofxUISlider *)gui->getWidget("ACCEL"); float accel = gaccel->getValue();
    ofxUISlider *ghue = (ofxUISlider *)gui->getWidget("HUE"); float hue = ghue->getValue();
    ofxUISlider *gsat = (ofxUISlider *)gui->getWidget("SAT"); float sat = gsat->getValue();
    ofxUISlider *gbr = (ofxUISlider *)gui->getWidget("BR"); float br = gbr->getValue();
    
    ofPixelsRef pix = ((ofApp*)ofGetAppPtr())->blackmagic->colorPixels;
    int camWidth = SCREEN_WIDTH;
    int camHeight = SCREEN_HEIGHT;
    pix.resize(camWidth, camHeight);
    
    app->drawFbo->fbo.begin();
    app->drawFbo->blendMode = 1;
    
    ofScale(1.0 / fxRatio, 1.0 / fxRatio);
    post->begin();
    ofScale(fxRatio, fxRatio);
    ofDisableAlphaBlending();
    ofClear(0,0,0);
    ofTranslate(0, -app->drawFbo->top);
    if (flow.getWidth() > 0) {
        ofVec2f scale = ofVec2f(SCREEN_WIDTH / float(flow.getWidth()), SCREEN_HEIGHT / float(flow.getHeight()));
        ofPushMatrix();
        ofScale(scale.x, scale.y);
        
        int controlMax = powf(app->oscControl->controlVal[4] * 0.125, 1.5);
        
        for (int i = 0; i < controlMax; i++) {
            int x = ofRandom(flow.getWidth()-skip);
            int y = ofRandom(flow.getHeight()-skip);
            ofRectangle region = ofRectangle(x, y, skip, skip);
            ofVec2f average = flow.getAverageFlowInRegion(region);
            
            if (average.length() > thresh) {
                average = ofVec2f(0, 0);
            }
            
            if (abs(average.x) + abs(average.y) > 0.5) {
                ofColor col;
                col.setHsb(ofRandom(255), sat * 255, br * 255);
                
                NoteParticle *p = new NoteParticle();
                p->setup(ofVec2f(x + ofRandom(skip), y + ofRandom(skip)), ofVec2f(average.x * accel, average.y * accel), col);
                p->radius = (abs(average.x) + abs(average.y)) * radius;
                p->friction = friction;
                if (abs(p->radius) > skip) {
                    p->radius = skip;
                }
                particles.push_back(p);
                
                while (particles.size() > controlMax) {
                    delete particles[0];
                    particles.pop_front();
                }
            }
        }
        ofEnableBlendMode(OF_BLENDMODE_ADD);
        for (int i = 0; i < particles.size(); i++) {
            // ofSetColor(particles[i]->color);
            
            float controlHue;
            controlHue = ofMap(app->oscControl->controlVal[5], 0, 127, 0, 0.6);
            ofColor col; col.setHsb(controlHue * 255, sat * 255, br * 255);
            ofSetColor(col);
            
            ofSetRectMode(OF_RECTMODE_CENTER);
            ofPushMatrix();
            ofTranslate(particles[i]->position);
            ofRotateZ(particles[i]->rot.z);
            img[particles[i]->imgNum].draw(0, 0, 0, particles[i]->radius * radius, particles[i]->radius * radius);
            ofPopMatrix();
            ofSetRectMode(OF_RECTMODE_CORNER);
        }
        ofDisableBlendMode();
        ofPopMatrix();
    }
    post->end();
    app->drawFbo->fbo.end();
    
    gui->setVisible(getSharedData().guiVisible);
}
Example #29
0
//--------------------------------------------------------------
void ofApp::update(){
    ofPushStyle();
    ofEnableAlphaBlending();
    sampler.begin();
    ofClear(0, 0, 0);
    ofSetColor(255, 255, 255);
    if(dir.isValidIndex(dirIdx)){
        client.draw(0, (sampler.getHeight()-sampler.getWidth()*client.getHeight()/client.getWidth())/2, sampler.getWidth(), sampler.getWidth()*client.getHeight()/client.getWidth());
    }else{
        float time = ofGetElapsedTimef();
        if(standBymode == 0){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10*(i+1)))*255, 0, abs(sin(time/20*(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 1){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/3))*255, abs(sin(time))*255, abs(sin(time/2)*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 2){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10+(i+1)))*255, 0, abs(sin(time/10+(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 3){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10*(j+1)))*255, 0, abs(sin(time/20*(j+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 4){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/100+(i+1)))*255, abs(sin(time/200+(i+1))*255), abs(sin(time/200+(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 5){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10/(i+1)))*255, 0, abs(sin(time/20/(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 6){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10*(i+1)))*255, 0, abs(sin(time/20*(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 7){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10*(i+1)))*255, 0, abs(sin(time/20*(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 8){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10*(i+1)))*255, 0, abs(sin(time/20*(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 9){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10*(i+1)))*255, 0, abs(sin(time/20*(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }else if(standBymode == 10){
            for(int i = 0; i < numCols; i++){
                for(int j = 0; j < numRows; j++){
                    c = ofColor(abs(sin(time/10*(i+1)))*255, 0, abs(sin(time/20*(i+1))*255));
                    ofSetColor(c);
                    ofRect(i*sampler.getWidth()/numCols, j*sampler.getHeight()/numRows, sampler.getWidth()/numCols, sampler.getHeight()/numRows);
                    
                }
            }
        }
    }
    
    sampler.end();
    ofDisableAlphaBlending();
    
    
    
    sampler.readToPixels(pix);
    
    for(int i = 0; i < colorPoints.size(); i++){
        ofVec2f pt = colorPoints.get(i).position;
        ofColor currentColor;
        for(int j = -24; j <= 24; j++){
            for(int k = -24; k <= 24; k++){
                currentColor = currentColor.lerp(pix.getColor(pt.x+j, pt.y+k), 0.5);
            }
        }
        dmxColors[i] =  dmxColors[i].lerp(currentColor, lerpColor);
    }
    ofPopStyle();
    
    int channel = 1;
    for(int module = 0; module < numCols*numRows; module++) {
        string label = "mod" + ofToString(module);
        dmx.setLevel(channel++, dmxColors[module].r);
        dmx.setLevel(channel++, dmxColors[module].g);
        dmx.setLevel(channel++, dmxColors[module].b);
    }
    if(dmx.isConnected()) {
        dmx.update();
    }
    
    if(resetPos){
        int count = 0;
        for(int i = 0; i <  numCols; i++) {
            for(int j = 0; j < numRows; j++){
                colorPoints.get(count).position.set(ofVec2f(ofGetWidth()/((numCols)*2)+i*ofGetWidth()/(numCols), ofGetHeight()/((numRows)*2)+j*ofGetHeight()/(numRows)));
                count++;
            }
        }
        resetPos = false;
    }
    
}
Example #30
0
//--------------------------------------------------------------
void testApp::draw(){
    
    float templatesScale = 0.5f;
    ofBackgroundGradient(ofColor(2), ofColor(40), OF_GRADIENT_CIRCULAR);
    ofPushMatrix();
    
    if(rotate)
    {
        // rotate gesture related graphics around the center of the screen
        ofTranslate(scrW/2, scrH/2);
        ofRotateY(viewYRotation);
        ofRotateX(viewXRotation);
        ofTranslate(-scrW/2, -scrH/2);
    }
    
    // draw the current templates on a small scale
    gvfh.drawTemplates(templatesScale);
    
    
    if(gvfh.get_state() != STATE_FOLLOWING && isMouseDrawing)
        currentGesture.draw();
    else if(displayCurrentGesture)
        currentGesture.draw();
    
    ofDisableAlphaBlending();

    // string used to comunicate to the user of possible commands and of the current state of the application

    string state_string;
    state_string.append("'l' to learn a new template\n'c' to clear\n"
                        "numbers 1 to 4 to toggle visual feedback "
                        "(1 - particles; 2 - template; 3 - estimated gesture; 4 - current gesture)"
                        "\nSTATE_LEARINING [");
    
    int state = gvfh.get_state();
    if(state == STATE_FOLLOWING){
        state_string.append(" ]\nSTATE_FOLLOWING [X]\nSTATE_CLEAR     [ ]");
        
        if(displayParticles)
            gvfh.printParticleInfo(currentGesture);

        // temp will have the partial representation of how gvf is recognising the gesture being performed
        gvfGesture temp = gvfh.getRecognisedGestureRepresentation();
        if(temp.isValid)
        {
            // the estimated gesture will be drawn on the same area
            // as the gesture being performed and starting on the same point
            ofRectangle da = currentGesture.getDrawArea();
            ofPoint p = currentGesture.getInitialOfPoint();
            
            if(displayEstimatedGesture)
            {
                temp.setAppearance(ofColor(0,255,0), 5, 255, 180, 1);
                temp.draw(templatesScale);
                
                temp.setDrawArea(da);
                temp.setInitialPoint(p + 1);
                temp.centraliseDrawing = false;
                temp.draw();
            }
            
            if(displayTemplate)
            {
                // draw the original template for the gesture being recognised
                gvfGesture g = gvfh.getTemplateGesture(gvfh.getIndexMostProbable());
                g.setDrawArea(da);
                g.setInitialPoint(p + 1);
                g.centraliseDrawing = false;

                // the template's opacity is determined by how probable the recognition is
                g.setAppearance(g.getColor(),
                                1.5, 255, 50,
                                ofLerp(1/gvfh.getTemplateCount(),
                                1,
                                gvfh.getRecogInfoOfMostProbable().probability));
               g.draw();
            }
        }
        
    }else if (state == STATE_LEARNING)
        state_string.append("X]\nSTATE_FOLLOWING [ ]\nSTATE_CLEAR     [ ]");
    else
        state_string.append(" ]\nSTATE_FOLLOWING [ ]\nSTATE_CLEAR     [X]");
    
    ofPopMatrix();
    
    ofSetColor(198);
    
    ofDrawBitmapString(state_string.c_str(), 30, 25);

    // show the current frame rate
    ofDrawBitmapString("FPS " + ofToString(ofGetFrameRate(), 0), ofGetWidth() - 200, 25);
}