Пример #1
0
void testApp::drawScene() {

	ofPushStyle();
	ofEnableDepthTest();

    ofPushMatrix();    
	ofTranslate(0, 0, 10);
	ofRotate(90, 0, 1, 0);
    ofSetColor(0,200,0);
    ofDrawGridPlane(12.0f, 8.0f, false);
	ofPopMatrix();

    ofPushMatrix();    
	ofTranslate(0, 0, -3);
	ofRotate(90, 0, 1, 0);    
	ofSetColor(200,0,0);
    ofDrawGridPlane(12.0f, 8.0f, false);
	ofPopMatrix();

    ofPushMatrix();    
	ofTranslate(0, 0, -6);
	ofRotate(90, 0, 1, 0);    
	ofSetColor(100,100,0);
    ofDrawGridPlane(12.0f, 8.0f, false);
	ofPopMatrix();

	ofDisableDepthTest();

	ofPopStyle();
}
Пример #2
0
//--------------------------------------------------------------
void testApp::drawSceneGeometry()
{
	ofSetColor(120);
	
	ofPushMatrix();
		ofRotate(90, 0, 0, -1);
		ofDrawGridPlane(500.0f, 40.0f, false );
	ofPopMatrix();
	
	ofSetColor( 255, 0, 0 );
	
	ofPushMatrix();
		ofTranslate( ofPoint(10,0,-80) );
		for( int i = 0; i < 20; i ++ )
		{
			ofBox( ofPoint(0,25,i * -100), 50);
		}
	ofPopMatrix();
	
	string tmpStr = "Do Warping: " + ofToString( oculusRift.getDoWarping() ) + "\n";
	tmpStr += "Inter Ocular Distance: "  + ofToString( oculusRift.getInterOcularDistance() ) + "\n";
	tmpStr += "Shader Scale Factor: "  + ofToString( oculusRift.getShaderScaleFactor() ) + "\n";
	
	ofSetColor( 255 );
	
	ofPushMatrix();
		ofTranslate( ofPoint(-60,280,-200) );
		ofRotateZ( 180 );
		ofRotateY( 180 );
		fontWorld.drawString( tmpStr, 0.0f, 0.0f );
	ofPopMatrix();
	
	ofSetColor(255);
}
Пример #3
0
void ofApp::drawFloor() {
	ofSetColor(150, 150, 150);
	ofPushMatrix();
	ofRotate(90, 0, 0, -1);
	ofDrawGridPlane(10, 10);
	ofPopMatrix();
}
Пример #4
0
void ofApp::draw(){
    //背景
    ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30),  OF_GRADIENT_BAR);
    
    //ログ表示
    ofSetColor(200);
    ofDrawBitmapString("ofxLeapMotion - Example App\nLeap Connected? " + ofToString(leap.isConnected()), 20, 20);
    
    ofEnableDepthTest();
    cam.begin();
    
    //地面のグリッドを描画
    ofPushMatrix();
    ofRotate(90, 0, 0, 1);
    ofSetColor(20);
    ofDrawGridPlane(800, 20, false);
    ofPopMatrix();
    
    //検出した手を描画
    fingerType fingerTypes[] = {THUMB, INDEX, MIDDLE, RING, PINKY};
    
    for(int i = 0; i < simpleHands.size(); i++){
        bool isLeft = simpleHands[i].isLeft;
        ofPoint handPos = simpleHands[i].handPos;
        ofPoint handNormal = simpleHands[i].handNormal;
        
        //手の中心位置を描画
        ofSetColor(0, 0, 255);
        ofDrawSphere(handPos.x, handPos.y, handPos.z, 20);
        
        //手の平の向きを描画
        ofSetColor(255, 255, 0);
        ofDrawArrow(handPos, handPos + 100*handNormal);
        
        //5本の指をそれぞれ描画
        for (int f=0; f<5; f++) {
            ofPoint mcp = simpleHands[i].fingers[ fingerTypes[f] ].mcp;  // 関節1
            ofPoint pip = simpleHands[i].fingers[ fingerTypes[f] ].pip;  // 関節2
            ofPoint dip = simpleHands[i].fingers[ fingerTypes[f] ].dip;  // 関節3
            ofPoint tip = simpleHands[i].fingers[ fingerTypes[f] ].tip;  // 指先
            
            //関節と指先を描画
            ofSetColor(0, 255, 0);
            ofDrawSphere(mcp.x, mcp.y, mcp.z, 12);
            ofDrawSphere(pip.x, pip.y, pip.z, 12);
            ofDrawSphere(dip.x, dip.y, dip.z, 12);
            ofDrawSphere(tip.x, tip.y, tip.z, 12);
            
            //線で結ぶ
            ofSetColor(255, 0, 0);
            ofSetLineWidth(20);
            ofDrawLine(mcp.x, mcp.y, mcp.z, pip.x, pip.y, pip.z);
            ofDrawLine(pip.x, pip.y, pip.z, dip.x, dip.y, dip.z);
            ofDrawLine(dip.x, dip.y, dip.z, tip.x, tip.y, tip.z);
        }
    }
    
    cam.end();
    ofDisableDepthTest();
}
Пример #5
0
//-----------------------------------------------------------------------------------------
//
void ofApp::draw()
{
	ofBackgroundGradient( ofColor(40,40,40), ofColor(0,0,0), OF_GRADIENT_CIRCULAR);	
	
	ofEnableDepthTest();
	
	camera.begin();
	
		// draw a grid on the floor
		ofSetColor( ofColor(60) );
		ofPushMatrix();
			ofRotate(90, 0, 0, -1);
			ofDrawGridPlane( 12 );
		ofPopMatrix();

		ofPushMatrix(); //rotate and translate the mesh
		ofRotate(90, 1, 0, 0);
		ofTranslate(0, 0, -3);
			mesh.draw();
		ofPopMatrix();
	
	camera.end();

	ofSetColor( ofColor::white );
	ofDisableDepthTest();


	fontSmall.drawStringShadowed(ofToString(ofGetFrameRate(),2), ofGetWidth()-35, ofGetHeight() - 6, ofColor::whiteSmoke, ofColor::black );
}
Пример #6
0
void ofApp::drawGrid(){
	ofSetColor(ofColor(60));
	ofPushMatrix();
		ofRotate(90, 0, 0, -1);
		ofDrawGridPlane(500, 10);
	ofPopMatrix();	
}
Пример #7
0
void ofApp::draw(){
    //背景
    ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30),  OF_GRADIENT_BAR);
    
    //ログ表示
    ofSetColor(200);
    ofDrawBitmapString("ofxLeapMotion - Example App\nLeap Connected? " + ofToString(leap.isConnected()), 20, 20);
    
    ofEnableDepthTest();
    cam.begin();
    
    //地面のグリッドを描画
    ofPushMatrix();
    ofRotate(90, 0, 0, 1);
    ofSetColor(20);
    ofDrawGridPlane(800, 20, false);
    ofPopMatrix();
    
    //検出した手を描画
    for(int i = 0; i < simpleHands.size(); i++){
        simpleHands[i].debugDraw();
    }
    
    cam.end();
    ofDisableDepthTest();
}
Пример #8
0
//----------
void ofApp::drawScene() {
	//--
	//draw room
	//
	ofPushStyle();
	ofFill();
	glEnable(GL_CULL_FACE);
	glCullFace(GL_FRONT);
	this->light.enable();
	room.draw();
	this->light.disable();
	glCullFace(GL_BACK);
	glDisable(GL_CULL_FACE);
	ofDisableLighting();
	ofPopStyle();
	//
	//--
	
	this->lineSet.draw(this->shift, this->shadow);
	
	if (this->state == Adding) {
		newLine.draw(NEWLINE_SIZE, ofColor::green);
	}
	
	if (this->grid) {
		ofPushMatrix();
		ofRotate(90, 0.0f, 0.0f, 1.0f);
		ofDrawGridPlane(7.0f, 7);
		ofPopMatrix();
		
		ofPushStyle();
		ofSetColor(0);
		ofNoFill();
		for(float x = roomMin.x; x<= roomMax.x; x++) {
			ofPushMatrix();
			ofTranslate(x, 0, 0);
			ofRotate(-90, 0, 1.0f, 0);
			ofRect(roomMin.z, roomMin.y, roomMax.z - roomMin.z, roomMax.y - roomMin.y);
			ofPopMatrix();
		}
		
		for(float z = roomMin.z; z<= roomMax.z; z++) {
			ofPushMatrix();
			ofTranslate(0, 0, z);
			ofRect(roomMin.x, roomMin.y, roomMax.x - roomMin.x, roomMax.y - roomMin.y);
			ofPopMatrix();
		}
		
		for(float y = roomMin.y; y<= roomMax.y; y++) {
			ofPushMatrix();
			ofTranslate(0, y, 0);
			ofRotate(90, 1.0f, 0, 0);
			ofRect(roomMin.x, roomMin.z, roomMax.x - roomMin.x, roomMax.z - roomMin.z);
			ofPopMatrix();
		}
		ofPopStyle();
	}
}
Пример #9
0
void AHRS::drawGrid(){
    ofPushMatrix();
    ofTranslate(0, -100);
    ofRotateZ(90);
    ofPushStyle();
    ofSetColor(90, 90, 90);
    ofDrawGridPlane(750);
    ofPopStyle();
    ofPopMatrix();
}
Пример #10
0
//--------------------------------------------------------------
void ofDrawGrid(float scale, float ticks, bool labels, bool x, bool y, bool z) {
	
	ofColor c = ofGetStyle().color;
	if (c == ofColor::white)
		c = ofColor(255,0,0);
	
	ofPushStyle();
	
	if (x) {
		c.setHue(0.0f);
		ofSetColor(c);
		ofDrawGridPlane(scale, ticks, labels);
	}
	if (y) {
		c.setHue(255.0f / 3.0f);
		ofSetColor(c);
		ofPushMatrix();
		ofRotate(90, 0, 0, -1);
		ofDrawGridPlane(scale, ticks, labels);
		ofPopMatrix();
	}
	if (z) {
		c.setHue(255.0f * 2.0f / 3.0f);
		ofSetColor(c);
		ofPushMatrix();
		ofRotate(90, 0, 1, 0);
		ofDrawGridPlane(scale, ticks, labels);
		ofPopMatrix();
	}
	
	if (labels) {
		ofPushStyle();
		ofSetColor(255, 255, 255);
		float labelPos = scale * (1.0f + 0.5f / ticks);
		ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
		ofDrawBitmapString("x", labelPos, 0, 0);
		ofDrawBitmapString("y", 0, labelPos, 0);
		ofDrawBitmapString("z", 0, 0, labelPos);
		ofPopStyle();
	}
	ofPopStyle();
}
Пример #11
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30),  OF_GRADIENT_BAR);
	ofSetColor(200);
	ofDrawBitmapString("ofxLeapMotion - Example App\nLeap Connected? " + ofToString(leap.isConnected()), 20, 20);
        // cam.setTarget(cam_position.x,cam_position.y,cam_position.z);
	cam.begin();
    cam.setTarget(ofVec3f(cam_position.x,cam_position.y,cam_position.z));
	ofPushMatrix();
    ofRotate(90, 0, 0, 1);
    ofSetColor(20);
    ofDrawGridPlane(800, 20, false);
	ofPopMatrix();
    ofSetColor(255,0,0);
    //
    // Threaded Gromacs Calls
    threadedObject.draw();    
    //
    // Leap Motion
    //
    fingerType fingerTypes[] = {THUMB, INDEX, MIDDLE, RING, PINKY};
    for(int i = 0; i < simpleHands.size(); i++){
        bool isLeft        = simpleHands[i].isLeft;
        ofPoint handPos    = simpleHands[i].handPos;
        ofPoint handNormal = simpleHands[i].handNormal;
        
        ofSetColor(0, 0, 255);
        ofDrawSphere(handPos.x, handPos.y, handPos.z, 20);
        ofSetColor(255, 255, 0);
        ofDrawArrow(handPos, handPos + 100*handNormal);
        
        for (int f=0; f<5; f++) {
            ofPoint mcp = simpleHands[i].fingers[ fingerTypes[f] ].mcp;  // metacarpal
            ofPoint pip = simpleHands[i].fingers[ fingerTypes[f] ].pip;  // proximal
            ofPoint dip = simpleHands[i].fingers[ fingerTypes[f] ].dip;  // distal
            ofPoint tip = simpleHands[i].fingers[ fingerTypes[f] ].tip;  // fingertip
            
            ofSetColor(0, 255, 0);
            ofDrawSphere(mcp.x, mcp.y, mcp.z, 12);
            ofDrawSphere(pip.x, pip.y, pip.z, 12);
            ofDrawSphere(dip.x, dip.y, dip.z, 12);
            ofDrawSphere(tip.x, tip.y, tip.z, 12);
            
            ofSetColor(255, 0, 0);
            ofSetLineWidth(20);
            ofLine(mcp.x, mcp.y, mcp.z, pip.x, pip.y, pip.z);
            ofLine(pip.x, pip.y, pip.z, dip.x, dip.y, dip.z);
            ofLine(dip.x, dip.y, dip.z, tip.x, tip.y, tip.z);
        }
    }
    
    
    
	cam.end();
}
Пример #12
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    
    ofNoFill();
    ofSetColor(255,255,255,102);
        
    ofPushMatrix();
    ofTranslate( ofGetWidth() * 0.5, ofGetHeight() * 0.5 );
    
    ofRotateX(count * 0.1 );
    ofRotateY(count * 0.1 );
    
    mesh.draw();
    
    ofSetColor(255,0,0,255);
    ofSpherePrimitive sphere;
    sphere.set(200,8);
    sphere.drawWireframe();
    
    ofSetColor(0,255,0,255);
    ofBoxPrimitive box;
    box.set( 200, 200, 200, 2, 2, 2 );
    box.drawWireframe();
    
    ofSetColor(0,0,255,255);
    ofCylinderPrimitive cylinder;
    cylinder.set( 100, 250, 8, 2 );
    cylinder.drawWireframe();
    
    ofSetColor(255,0,255,255);
    ofConePrimitive cone;
    cone.set( 100,300, 5, 3 );
    cone.drawWireframe();
    
    ofSetColor(0,255,255,128);
    ofIcoSpherePrimitive icoSphere;
    icoSphere.set( 250, 1 );
    icoSphere.drawWireframe();
    
    
    ofSetColor(255,255,255,128);
    ofDrawGridPlane(3000);
    
    ofSetColor(255,0,0,128);
    ofDrawAxis(1000);
    ofDrawArrow(ofVec3f(0,0,0),ofVec3f(1000,0,0));
    
    ofPopMatrix();
    
    
    ofSetColor( 255 );
    ofDrawBitmapString("sketch_20150924", 15, 15);
    
}
Пример #13
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    cam.begin();
    
    ofPushMatrix();
    ofRotate(90, 0, 0, 1);
    ofSetColor(20);
    ofDrawGridPlane(800, 20, false);
    ofPopMatrix();
    
    fingerType fingerTypes[] = {THUMB, INDEX, MIDDLE, RING, PINKY};
    
    for(int i = 0; i < simpleHands.size(); i++){
        bool isLeft        = simpleHands[i].isLeft;
        ofPoint handPos    = simpleHands[i].handPos;
        ofPoint handNormal = simpleHands[i].handNormal;
        
        ofSetColor(0, 0, 255);
        ofDrawSphere(handPos.x, handPos.y, handPos.z, 20);
        
        height = handPos.y;
        
    }
    cam.end();
    
    if(height < -400){
        height = -400;
    }
    else if(height > 150){
        height = 150;
    }
    
    height = ofMap(height, -400, 150, 1, 7);
    

    ofBackground(ofColor::fromHsb(ofMap(height, 1, 7, 0, 255), 255, 255, 100));
    
    ofSetColor(255, 255, 255, 100);
    note.draw(ofGetWidth()/2-note.getWidth()/2, ofGetHeight()/2-note.getHeight()/2);
    
    ofSetColor(255, 255, 255);
    ofCircle(ofGetWidth()/2, ofGetHeight()/2, radius_1);
    radius_1 += (20 + height*5);
    if(radius_1 > ofGetWidth()/2){
        radius_1 = 0;
    }
    player.draw(ofGetWidth()-600,ofGetHeight()-700);
    theremin.draw(30,ofGetHeight()-600);
    
    sound.setSpeed(ofMap(height, 1, 8, 1.0, 2.0));
    
    ofDrawBitmapStringHighlight(ofToString(height), 30, 10);
    
}
Пример #14
0
void LeapVisualizer::drawGrid(){
	
	// Draw a grid plane.
	if (bDrawGrid){
		ofPushMatrix();
		ofEnableSmoothing();
		ofRotate(90, 0, 0, 1);
		ofSetColor(160,160,160, 200);
		ofDrawGridPlane(200, 10, false);
		ofPopMatrix();
	}
}
Пример #15
0
//--------------------------------------------------------------
void testApp::drawScene()
{

    ofPushMatrix();
    ofRotate(90, 0, 0, -1);
    ofSetColor(30);
    ofDrawGridPlane(12.0f, 8.0f, false );
	ofPopMatrix();

    if(ofIsGLProgrammableRenderer()) bshader.begin();
    ofLogo.getTextureReference().bind();

    for(int i = 0; i < demos.size(); i++){
		ofPushMatrix();
		ofTranslate(demos[i].floatPos);

        ofFloatColor col;
        if (demos[i].bMouseOver)
            col = ofColor::white;
        else
            col = demos[i].color;
        
        if(ofIsGLProgrammableRenderer()) {
            bshader.setUniform3f("color", col.r, col.g, col.b);
        } else {
            ofSetColor(col);
        }
        
        demos[i].box.draw();
        
		ofPopMatrix();
	}
    
    ofLogo.getTextureReference().unbind();
    if(ofIsGLProgrammableRenderer()) bshader.end();
    
	//billboard and draw the mouse
    
	if(oculusRift.isSetup()){
		
		ofPushMatrix();
		oculusRift.multBillboardMatrix();
		ofSetColor(255, 0, 0);
		ofCircle(0,0,.5);
		ofPopMatrix();

	}
    

}
Пример #16
0
// ------------------------------------------------------------------------------------------------------
//
void ofApp::drawScene()
{
	ofEnableDepthTest();
	
	camera.begin();
	
		if( drawUI )
		{
			// draw a grid on the floor
			ofSetColor( ofColor(10) );
			ofPushMatrix();
				ofRotate(90, 0, 0, -1);
				ofDrawGridPlane( 100, 10, false );
			ofPopMatrix();
		}
		//ofDrawAxis( 100 );
	
		ofSetColor( light[0].getDiffuseColor() );
		ofDrawSphere( light[0].getGlobalPosition(), 0.2 );
	
		//ofDrawAxis(100);

		if( drawPointCloud )
		{
			glPointSize( 3.0 );
			pointCloudMesh.draw();
			glPointSize( 1.0 );
		}

		ofEnableLighting();
		light[0].enable();

		ofSetColor( ofColor::white );
		particles.draw( &camera );
	
		ofDisableLighting();

		if( opticalFlowDebugDrawer.isEnabled() ) opticalFlowDebugDrawer.draw(  particles.opticalFlowTexture, worldToKinect, particles.getFlowMaxLength() );
	
		//ofSetColor( ofColor::blue );
		//ofDrawSphere( testPos, 1.0 );
	
		//ofSetColor( ofColor::red );
		//ofDrawSphere( testPos * worldToKinect, 10.0 );
	
	camera.end();
}
Пример #17
0
//--------------------------------------------------------------
void testApp::draw(){
	ofDisableLighting();
    ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30),  OF_GRADIENT_BAR);
	
	ofSetColor(200);
	ofDrawBitmapString("ofxLeapMotion - Example App\nLeap Connected? " + ofToString(leap.isConnected()), 20, 20);

	cam.begin();	

	ofPushMatrix();
		ofRotate(90, 0, 0, 1);
		ofSetColor(20);
		ofDrawGridPlane(800, 20, false);
	ofPopMatrix();
	
	ofEnableLighting();
	l1.enable();
	l2.enable();
	
	m1.begin(); 
	m1.setShininess(0.6);
	
	for(int i = 0; i < fingersFound.size(); i++){
		ofxStrip strip;
		int id = fingersFound[i];
		
		ofPolyline & polyline = fingerTrails[id];
		strip.generate(polyline.getVertices(), 15, ofPoint(0, 0.5, 0.5) );
		
		ofSetColor(255 - id * 15, 0, id * 25);
		strip.getMesh().draw();
	}
	
    l2.disable();
    
    for(int i = 0; i < simpleHands.size(); i++){
        simpleHands[i].debugDraw();
    }

	m1.end();
	cam.end();
    
    
    ofSetColor(255);
    ofDrawBitmapString(screenStr, 20,300);
	
}
Пример #18
0
//--------------------------------------------------------------
void testApp::draw() {
    ofDisableLighting();
    ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30),  OF_GRADIENT_BAR);

    ofSetColor(200);
    ofDrawBitmapString("ofxLeapMotion - Example App\nMake sure the Leap.app is running while running this example\nYou may need to restart Leap.app to get data", 20, 20);

    cam.begin();

    ofPushMatrix();
    ofRotate(90, 0, 0, 1);
    ofSetColor(20);
    ofDrawGridPlane(800, 20, false);
    ofPopMatrix();

    ofEnableLighting();
    l1.enable();
    l2.enable();

    m1.begin();
    m1.setShininess(0.6);


    for(int i = 0; i < fingersFound.size(); i++) {
        ofxStrip strip;
        int id = fingersFound[i];

        ofPolyline & polyline = fingerTrails[id];
        strip.generate(polyline.getVertices(), 15, ofPoint(0, 0.5, 0.5) );

        ofSetColor(255 - id * 15, 0, id * 25);
        strip.getMesh().draw();
    }

    l2.disable();

    for(int i = 0; i < simpleHands.size(); i++) {
        simpleHands[i].debugDraw();
    }

    m1.end();
    cam.end();

}
Пример #19
0
//--------------------------------------------------------------
void ofApp::drawScene()
{
    
    ofPushMatrix();
    ofRotate(90, 0, 0, -1);
    ofSetColor(30);
    ofDrawGridPlane(12.0f, 8.0f, false );
    ofPopMatrix();
    
    //--------------------------------------------------------------------------
    // Draw ChucK-controlled elements
    //--------------------------------------------------------------------------
    // entity pointer
    VREntity * e = NULL;
    // db
    OFCKDB * db = OFCKDB::instance();
    // draw list
    map<string,VREntity *>::iterator i;
    for( i = db->string2entity.begin(); i != db->string2entity.end(); i++ )
    {
        // get entity
        e = i->second;
        // draw it
        e->renderAll();
    }
    
    
    //--------------------------------------------------------------------------
    //billboard and draw the mouse
    //--------------------------------------------------------------------------
    if(oculusRift.isSetup()){
        
        ofPushMatrix();
        oculusRift.multBillboardMatrix();
        ofSetColor(255, 0, 0);
        ofCircle(0,0,.5);
        ofPopMatrix();
        
    }
    
}
Пример #20
0
void ofApp::drawScene()
{
    drawHands();
    
    ofPushMatrix();
    ofRotate(90, 0, 0, -1);
    ofDrawGridPlane(5000.0f, 10.0f, false );
    ofPopMatrix();
    
    ofPushStyle();
    ofNoFill();
    for(int i = 0; i < demos.size(); i++){
        ofPushMatrix();
        //		ofRotate(ofGetElapsedTimef()*(50-demos[i].radius), 0, 1, 0);
        ofTranslate(demos[i].floatPos);
        //		ofRotate(ofGetElapsedTimef()*4*(50-demos[i].radius), 0, 1, 0);
        
        if (demos[i].bMouseOver)
            ofSetColor(ofColor::white.getLerped(ofColor(200, 50, 0), sin(ofGetElapsedTimef()*10.0)*.5+.5));
        else if (demos[i].bGazeOver)
            ofSetColor(ofColor::white.getLerped(ofColor(50, 200, 0), sin(ofGetElapsedTimef()*10.0)*.5+.5));
        else
            ofSetColor(demos[i].color);
        
        ofSphere(demos[i].radius);
        ofPopMatrix();
    }
    
    //billboard and draw the mouse
    if(oculusRift.isSetup()){
        
        ofPushMatrix();
        oculusRift.multBillboardMatrix();
        ofSetColor(255, 0, 0);
        ofCircle(0,0,.5);
        ofPopMatrix();
    }
    ofPopStyle();
}
Пример #21
0
//-----------------------------------------------------------------------------------------
//
void ofApp::draw()
{
	ofBackgroundGradient( ofColor(40,40,40), ofColor(0,0,0), OF_GRADIENT_CIRCULAR);	

	particles.update( time, timeStep );
	
	camera.begin();
	
		// draw a grid on the floor
		ofSetColor( ofColor(60) );
		ofPushMatrix();
			ofRotate(90, 0, 0, -1);
			ofDrawGridPlane( 0.5, 12, false );
		ofPopMatrix();
		 
		ofSetColor( ofColor::white );
	
		particles.draw( &camera );
	
	camera.end();
	
	ofDisableDepthTest();
	ofEnableBlendMode( OF_BLENDMODE_ALPHA );
	ofSetColor( ofColor::white );
	
	int size = 196;
	//particles.particleDataFbo.source()->getTextureReference(0).draw( 0,	 0, size, size );
	
	if( drawGui )
	{
		particles.gui.draw();
	}
	
	ofDisableDepthTest();
	fontSmall.drawStringShadowed(ofToString(ofGetFrameRate(),2), ofGetWidth()-35, ofGetHeight() - 6, ofColor::whiteSmoke, ofColor::black );
}
Пример #22
0
	//----------
	void Device::drawWorld() {
		auto colorSource = this->getColorSource();
		auto depthSource = this->getDepthSource();
		auto bodySource = this->getBodySource();

		if (!depthSource) {
			ofLogError("ofxKinectForWindows2::Device::drawPrettyMesh") << "No depth source initialised";
			return;
		}
		
		//point cloud
		{
			//setup some point cloud properties for kicks
			bool usePointSize = true;

#if OF_VERSION_MAJOR > 0 || OF_VERSION_MINOR >= 10
			auto mainWindow = std::static_pointer_cast<ofAppGLFWWindow>(ofGetCurrentWindow());
			usePointSize = mainWindow ? mainWindow->getSettings().glVersionMajor <= 2 : false;
#endif

			usePointSize = false;

			if (usePointSize) {
				glPushAttrib(GL_POINT_BIT);
				glPointSize(5.0f);
				glEnable(GL_POINT_SMOOTH);
			}

			ofPushStyle();

			bool useColor = colorSource.get();
			if (useColor) {
				useColor &= colorSource->getTexture().isAllocated();
			}

			if (useColor) {
				//bind kinect color camera texture and draw mesh from depth (which has texture coordinates)
				colorSource->getTexture().bind();
			}

			auto opts = Source::Depth::PointCloudOptions(true, Source::Depth::PointCloudOptions::TextureCoordinates::ColorCamera);
			auto mesh = depthSource->getMesh(opts);

			//draw point cloud
			mesh.drawVertices();

			//draw triangles
			ofSetColor(255, 150);
			mesh.drawWireframe();

			//draw fills faded
			ofSetColor(255, 50);
			mesh.drawFaces();

			if (useColor) {
				//unbind colour camera
				colorSource->getTexture().unbind();
			}

			ofPopStyle();

			//clear the point cloud drawing attributes
			if (usePointSize) {
				glPopAttrib();
			}
		}
		
		//bodies and floor
		if (bodySource) {
			bodySource->drawWorld();

			ofPushMatrix();
			ofRotateDeg(90, 0, 0, 1);
			ofMultMatrix(bodySource->getFloorTransform());
			ofDrawGridPlane(5.0f);
			ofPopMatrix();
		}

		//draw the view cones of depth and colour cameras
		ofPushStyle();
		ofNoFill();
		ofSetLineWidth(2.0f);
		ofSetColor(100, 200, 100);
		depthSource->drawFrustum();
		if (colorSource) {
			ofSetColor(200, 100, 100);
			colorSource->drawFrustum();
		}
		ofPopStyle();
	}
Пример #23
0
//--------------------------------------------------------------
void ofApp::drawScene()
{
	ofEnableDepthTest();
		
		// Draw the floor
		ofSetColor(20, 20, 20);
		ofPushMatrix();
			ofRotate(90,	1, 0, 0);
			ofDrawPlane( 1600.0f, 1600.0f );
		ofPopMatrix();

		ofDisableDepthTest();
		ofSetColor(40, 40, 40);
		ofPushMatrix();
			ofRotate(90,	0, 0, -1);
			ofDrawGridPlane(800.0f, 10.0f, false );
		ofPopMatrix();
		ofEnableDepthTest();
	
		//ofDrawPlane( 1000.0f, 1000.0f );

		ofSetColor( ofColor::white );
		linesMesh.draw();
		
		// Draw the spheres
		for(int i = 0; i < demos.size(); i++)
		{
			ofPushMatrix();
				ofTranslate(demos[i].pos);
				ofSetColor(demos[i].isMouseOvered ? ofColor::white.getLerped(ofColor::red, sin(ofGetElapsedTimef()*10.0)*.5+.5) : demos[i].color); // pulse red to white when it's 'mouseovered'
				//ofSetColor(demos[i].color);
				ofSphere(demos[i].radius);
				//ofSphere(demos[i].isMouseOvered ? demos[i].radius * 10.0f: demos[i].radius ); // draw the sphere larger when it's 'mouseovered'
			ofPopMatrix();
		}
		
		// Draw the text and an indicator for the distance form the mouse we are using to reveal or hide the sculpture
	
		ofSetColor( ofColor::white );
		meshFont.drawStringAsShapes("Lines Max Connection Distance: " + ofToString(lineConnectionMaxDistance, 1), -450, 170 );
		ofPushMatrix();
			ofTranslate( ofVec3f(-450, 150, 0 ) );
			ofNoFill();
				ofRect( 0,0, 250, 10 );
			ofFill();
				ofRect( 0,0, 250 * ofMap( lineConnectionMaxDistance, lineConnectionMaxDistanceMin, lineConnectionMaxDistanceMax, 0.0f, 1.0f), 10 );
		ofPopMatrix();
	
		meshFont.drawStringAsShapes("Mouse Affection Radius: " + ofToString(mouseAffectionRadius, 1), -450, 130 );
	
	
		ofNoFill();
		// Billboard and draw the mouse
		if(oculusRift.isSetup())
		{
			ofPushMatrix();
				ofSetColor(255, 0, 0);
				oculusRift.multBillboardMatrix();
				ofCircle(0,0,.5);
			ofPopMatrix();
		}
		
		ofSetColor( ofColor::white );
		ofFill();
	
	ofDisableDepthTest();
	
}
Пример #24
0
//--------------------------------------------------------------
void testApp::draw(){
	ofDisableLighting();
    ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30),  OF_GRADIENT_BAR);
	
	ofSetColor(200);
	ofDrawBitmapString("ofxLeapMotion - Example App\nLeap Connected? " + ofToString(leap.isConnected()), 20, 20);
    
	cam.begin();
    
	ofPushMatrix();
    ofRotate(90, 0, 0, 1);
    ofSetColor(20);
    ofDrawGridPlane(800, 20, false);
	ofPopMatrix();
	
	ofEnableLighting();
	l1.enable();
	l2.enable();
	
	m1.begin();
	m1.setShininess(0.6);
	
	for(int i = 0; i < fingersFound.size(); i++){
		ofxStrip strip;
		int id = fingersFound[i];
		
		ofPolyline & polyline = fingerTrails[id];
		strip.generate(polyline.getVertices(), 15, ofPoint(0, 0.5, 0.5) );
		
		ofSetColor(255 - id * 15, 0, id * 25);
		strip.getMesh().draw();
	}
	
    l2.disable();
    
    for(int i = 0; i < simpleHands.size(); i++){
        simpleHands[i].debugDraw();
    }
    
	m1.end();
	cam.end();
	
    
    for(int i=0; i<circles.size(); i++) {
		ofFill();
		ofSetHexColor(0x90d4e3);
		circles[i].get()->draw();
	}
	
	for(int i=0; i<boxes.size(); i++) {
		ofFill();
		ofSetHexColor(0xe63b8b);
		boxes[i].get()->draw();
	}
	
	for(int i=0; i<customParticles.size(); i++) {
		customParticles[i].get()->draw();
	}
	
	ofNoFill();
	ofSetHexColor(0x444342);
	if(drawing.size()==0) {
        edgeLine.updateShape();
        edgeLine.draw();
    }
	else drawing.draw();
	
	
	string info = "";
	info += "Press [s] to draw a line strip ["+ofToString(bDrawLines)+"]\n";
	info += "Press [f] to toggle Mouse Force ["+ofToString(bMouseForce)+"]\n";
	info += "Press [c] for circles\n";
	info += "Press [b] for blocks\n";
	info += "Press [z] for custom particle\n";
	info += "Total Bodies: "+ofToString(box2d.getBodyCount())+"\n";
	info += "Total Joints: "+ofToString(box2d.getJointCount())+"\n\n";
	info += "FPS: "+ofToString(ofGetFrameRate())+"\n";
	ofSetHexColor(0x444342);
	ofDrawBitmapString(info, 30, 30);
}
Пример #25
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackgroundGradient(ofColor(90, 90, 90), ofColor(30, 30, 30),  OF_GRADIENT_BAR);
    
    ofSetColor(200);
    ofDrawBitmapString("ofxLeapMotion - Example App\nLeap Connected? " + ofToString(leap.isConnected()), 20, 20);
    
    cam.begin();
    
    ofPushMatrix();
    ofRotate(90, 0, 0, 1);
    ofSetColor(20);
    ofDrawGridPlane(1000, 50, false); //creates the grid (columns , rows)
    ofPopMatrix();
    
    
    fingerType fingerTypes[] = {THUMB, INDEX, MIDDLE, RING, PINKY};
    
    for(int i = 0; i < simpleHands.size(); i++){
        bool isLeft        = simpleHands[i].isLeft;
        ofPoint handPos    = simpleHands[i].handPos;
        ofPoint handNormal = simpleHands[i].handNormal;
        
        ofSetColor(0, 0, 255);
        ofDrawSphere(handPos.x, handPos.y, handPos.z, 20);
        ofSetColor(255, 255, 0);
        ofDrawArrow(handPos, handPos + 100*handNormal);
        
        for (int f=0; f<5; f++) {
            ofPoint mcp = simpleHands[i].fingers[ fingerTypes[f] ].mcp;  // metacarpal
            ofPoint pip = simpleHands[i].fingers[ fingerTypes[f] ].pip;  // proximal
            ofPoint dip = simpleHands[i].fingers[ fingerTypes[f] ].dip;  // distal
            ofPoint tip = simpleHands[i].fingers[ fingerTypes[f] ].tip;  // fingertip
            
            ofSetColor(0, 255, 0);
            ofDrawSphere(mcp.x, mcp.y, mcp.z, 12);
            ofDrawSphere(pip.x, pip.y, pip.z, 12);
            ofDrawSphere(dip.x, dip.y, dip.z, 12);
            ofDrawSphere(tip.x, tip.y, tip.z, 12);
            
            ofSetColor(255, 0, 0);
            ofSetLineWidth(20);
            ofLine(mcp.x, mcp.y, mcp.z, pip.x, pip.y, pip.z);
            ofLine(pip.x, pip.y, pip.z, dip.x, dip.y, dip.z);
            ofLine(dip.x, dip.y, dip.z, tip.x, tip.y, tip.z);
        }
        
        
        if ((handPos.x > -100) && (handPos.x < 100)) {
            
            synth.play();
        }
        if ((handPos.x > 50) && (handPos.x < 250)) {
            
            beats.play();
        }
        
        
        
        /*if (handPos.y > 100) {
            
            synth.play();
        }*/
        /*if (handPos.z > 100) {
            
            synth.play();
        }*/
        
    }
    cam.end();
    
    
    //sound player
    
    
    /*
    //---------------------------------- synth:
    if (synth.getIsPlaying()) ofSetHexColor(0xFF0000);
    else ofSetHexColor(0x000000);
    font.drawString("synth !!", 50,50);
    
    ofSetHexColor(0x000000);
    string tempStr = "click to play\npct done: "+ofToString(synth.getPosition())+"\nspeed: " + ofToString(synth.getSpeed()) + "\npan: " + ofToString(synth.getPan()) ;
    ofDrawBitmapString(tempStr, 50,ofGetHeight()-50);
    
    
    
    //---------------------------------- beats:
    if (beats.getIsPlaying()) ofSetHexColor(0xFF0000);

    
    ofSetHexColor(0x000000);
    tempStr = "click and drag\npct done: "+ofToString(beats.getPosition())+"\nspeed: " +ofToString(beats.getSpeed());
    
    //---------------------------------- vocals:
    if (vocals.getIsPlaying()) ofSetHexColor(0xFF0000);
    else ofSetHexColor(0x000000);
    
    ofSetHexColor(0x000000);
    tempStr = "click to play (multiplay)\npct done: "+ofToString(vocals.getPosition())+"\nspeed: " + ofToString(vocals.getSpeed());
        */
}
Пример #26
0
void Scene::draw(vector<SkeletonDataObject> skeletons)
{
	ofEnableAlphaBlending();
    glEnable(GL_DEPTH_TEST);

	if (isMouseCam)
		easyCam.begin(viewport);
	else
		cam.begin(viewport);

	if (isGridVisible)
	{
		ofSetColor(255, 100);
		ofPushMatrix();
		ofRotateZ(90);
		ofDrawGridPlane(400);
		ofPopMatrix();
	}

    ofEnableLighting();
    light.enable();
    
	//printf("skeletons.size() = %i \n", skeletons.size());
	
	if (skeletons.size() > 0)
	{
		ofSetColor(255, modelAlpha);


		ofVec3f legOrigin = ofVec3f(skeletons[0].skeletonPositions[KINECT_SDK_HIP_CENTRE].x, 0, skeletons[0].skeletonPositions[KINECT_SDK_HIP_CENTRE].z);
		// set origins for head and torso to shoulder centre
		legs.originPoint = &legOrigin;
		abdomen.originPoint = &legs.connectingPointsAbsolute[0];
		torso.originPoint = &abdomen.connectingPointsAbsolute[0];
		head.originPoint = &torso.connectingPointsAbsolute[2];
		upperArmL.originPoint = &torso.connectingPointsAbsolute[0];
		upperArmR.originPoint = &torso.connectingPointsAbsolute[1];
		forearmL.originPoint = &upperArmL.connectingPointsAbsolute[0];
		forearmR.originPoint = &upperArmR.connectingPointsAbsolute[0];
		handL.originPoint = &forearmL.connectingPointsAbsolute[0];
		handR.originPoint = &forearmR.connectingPointsAbsolute[0];


		if (BodyPart::isDrawModel)
		{
			if (isDrawFaces)
			{
				torso.drawFaces();
				head.drawFaces();
				abdomen.drawFaces();
				legs.drawFaces();
				upperArmL.drawFaces();
				upperArmR.drawFaces();
				forearmL.drawFaces();
				forearmR.drawFaces();
				handL.drawFaces();
				handR.drawFaces();

				//mixer.drawFaces();
			}
			else
			{
				torso.drawWireframe();
				head.drawWireframe();
				abdomen.drawWireframe();
				legs.drawWireframe();
				upperArmL.drawWireframe();
				upperArmR.drawWireframe();
				forearmL.drawWireframe();
				forearmR.drawWireframe();
				handL.drawWireframe();
				handR.drawWireframe();
			}
		}
    
		if (BodyPart::isDrawDebug)
		{
			torso.drawDebug(ofColor(255, 0, 255));
			head.drawDebug(ofColor(255, 255, 0));
			abdomen.drawDebug(ofColor(255, 255, 0));
			legs.drawDebug(ofColor(255, 255, 0));
			upperArmL.drawDebug(ofColor(255, 255, 0));
			upperArmR.drawDebug(ofColor(255, 255, 0));
			forearmL.drawDebug(ofColor(255, 255, 0));
			forearmR.drawDebug(ofColor(255, 255, 0));
			handL.drawDebug(ofColor(255, 255, 0));
			handR.drawDebug(ofColor(255, 255, 0));
		}

		
		if (isEquipmentVisible)
		{
			ofSetColor(255, 255);
			ofPushMatrix();
			ofTranslate(decks1Pos.x, decks1Pos.y, decks1Pos.z);
			decksImg.getTextureReference().bind();
			decks.drawFaces();
			decksImg.getTextureReference().unbind();
			ofPopMatrix();
			
			ofPushMatrix();
			ofTranslate(decks2Pos.x, decks2Pos.y, decks2Pos.z);
			decksImg.getTextureReference().bind();
			decks.drawFaces();
			decksImg.getTextureReference().unbind();
			ofPopMatrix();
			
			ofPushMatrix();
			ofTranslate(mixerPos.x, mixerPos.y, mixerPos.z);
			ofSetColor(100, 255);
			mixer.drawFaces();
			ofPopMatrix();
		}

		if (isDebugSkeletonVIsible)
		{
			ofPushMatrix();
			ofTranslate(80, 0);
			drawLineSkeleton(skeletons[0]);
			ofPopMatrix();
		}
	}


    light.disable();
    ofDisableLighting();
    
	if (isMouseCam)
		easyCam.end();
	else
		cam.end();
    
	glDisable(GL_DEPTH_TEST);
	
	ofDisableAlphaBlending();
}
Пример #27
0
//--------------------------------------------------------------
void ofApp::drawFboTest_00(){
    
    float movementSpeed = .3;
    float cloudSize = ofGetWidth();
    float minBoxSize = 50;
    float spacing = 50;
    int boxCount = 30;
    
    
    ofEnableAlphaBlending();
    ofClear(255, 255, 255, 0);
    ofBackgroundGradient(ofColor(0,0,255), ofColor(85, 78, 68), OF_GRADIENT_LINEAR);
    
    
    for (int i=0; i<kNumCameras; i++) {
        if (lookatIndex[i] >= 0) {
            cam[i].lookAt(testNodes[lookatIndex[i]]);
        }
    }
    
    cam[0].begin();
    
//  grids
    for(int i = -3; i < 3; i++) {
        ofPushMatrix();
        
        ofTranslate(i*300, 0, 0);
        ofSetColor(0,255,200);
        ofDrawGridPlane(1000);
        
        ofPopMatrix();
        
        
        ofPushMatrix();
        
        ofTranslate(0, i*300, 0);
        ofRotate(90, 0, 0, -1);
        ofSetColor(0,255,200);
        ofDrawGridPlane(1000);
        
        ofRotate(90, 0, 0, -1);
        
        ofPopMatrix();
    }
    
//  boxes
    for(int i = 0; i < boxCount; i++) {
        ofPushMatrix();
        float t = (ofGetElapsedTimef() + i * spacing) * movementSpeed;
        ofVec3f pos(
                    ofSignedNoise(t, 0, 0),
                    ofSignedNoise(0, t, 0),
                    ofSignedNoise(0, 0, t));
        
        float boxSize = minBoxSize + magnitude[i]*10;
        
        pos *= cloudSize;
        ofTranslate(pos);
        ofRotateX(pos.x*.8);
        ofRotateY(pos.y*.8);
        ofRotateZ(pos.z*.8);
        
        ofFill();
        ofSetColor(255);
        ofDrawBox(boxSize);
        ofPopMatrix();
    }

    cam[0].end();
    
    
// waves
    //FFT解析した結果をもとに、グラフを生成
    float w = (float)ofGetWidth()/ (float)fft_size / 2.0f;
    for (int i = 0; i < fft_size; i++) {
        
        //塗りのアルファ値でFFT解析結果を表現
//        ofColor col;
//        col.setHsb(i * 255.0f / (float)fft_size, 255, 255, 255);
//        ofSetColor(col);
        float h = magnitude[i] * ofGetHeight();
        ofRect(ofGetWidth()/2 - w * i, ofGetHeight()/2, w, h);
        ofRect(ofGetWidth()/2 + w * i, ofGetHeight()/2, w, -h);
    }
}