Exemplo n.º 1
0
// ofxLeapMotionSimpleHand
//--------------------------------------------------------------
void ofxLeapMotionSimpleHand::debugDraw(){
	ofPushStyle();
	
		ofSetColor(190);
		ofSetLineWidth(2);

		ofEnableLighting();
		ofPushMatrix();
			ofTranslate(handPos);
			//rotate the hand by the downwards normal
			ofQuaternion q;
			q.makeRotate(ofPoint(0, -1, 0), handNormal);
			ofMatrix4x4 m;
			q.get(m);
			glMultMatrixf(m.getPtr());
			
			
			//scale it to make it not a box
			ofScale(1, 0.35, 1.0);
#if (OF_VERSION_MAJOR == 0) && (OF_VERSION_MINOR < 8)
			ofBox(0, 0, 0, 60);
#else
			ofDrawBox(0, 0, 0, 60);
#endif
		ofPopMatrix();
	
		// sphere - hand openness debug draw
		ofSetColor(200, 0, 0, 80);
		ofDrawSphere(sphereCenter, sphereRadius);
	
		for(int i = 0; i < fingers.size(); i++){
			//ofDrawArrow(handPos, fingers[i].pos, 10);
		
			// fingers base debug draw
			ofSetColor(190);
			ofLine(handPos, fingers[i].base);
			ofDrawBox(fingers[i].base, 20);
			ofLine(fingers[i].base, fingers[i].pos);
			
			ofSetColor(0, 200, 0);
			ofDrawSphere(fingers[i].pos, 20);

		}
		
		ofSetColor(220, 220, 0);
		for(int i = 0; i < fingers.size(); i++){
			ofDrawArrow(fingers[i].pos + fingers[i].vel/20, fingers[i].pos + fingers[i].vel/10, 10);
		}
	
		ofDisableLighting();
	
	ofPopStyle();
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void testApp::draw() {
	
	ofEnableLighting();
	material.begin();
	if (bPointLight) pointLight.enable();
	if (bSpotLight) spotLight.enable();
	if (bDirLight) directionalLight.enable();
	ofSetColor(255, 255, 255, 255);
	ofSphere( center.x, center.y, center.z, radius);
	
	glPushMatrix();
	glTranslatef(300, 300, cos(ofGetElapsedTimef()*1.4) * 300.f);
	glRotatef(ofGetElapsedTimef()*.6 * RAD_TO_DEG, 1, 0, 0);
	glRotatef(ofGetElapsedTimef()*.8 * RAD_TO_DEG, 0, 1, 0);
	ofBox(0, 0, 0, 60);
	glPopMatrix();
	
	glPushMatrix();
	glTranslatef(center.x, center.y, -900);
	glRotatef(ofGetElapsedTimef() * .2 * RAD_TO_DEG, 0, 1, 0);
	ofBox( 0, 0, 0, 850);
	glPopMatrix();
	
	pointLight.disable();
	spotLight.disable();
	directionalLight.disable();
	material.end();
	ofDisableLighting();
	ofSetColor( pointLight.getDiffuseColor() );
	if(bPointLight) pointLight.draw();
	ofSetColor( spotLight.getDiffuseColor() );
	if(bSpotLight) spotLight.draw();
	
	ofSetColor(255, 255, 255);
	ofDrawBitmapString("Point Light On (1) : "+ofToString(bPointLight) +"\n"+
					   "Spot Light On (2) : "+ofToString(bSpotLight) +"\n"+
					   "Directional Light On (3) : "+ofToString(bDirLight)+"\n"+
					   "Shiny Objects On (s) : "+ofToString(bShiny) , 
					   20, 20);
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void testApp::draw(){
    
    cam.begin();
    
    
    ofNoFill();
  //  ofSetColor( 200,200,200);
    
    ofTranslate( 0,0,-500);
    ofRotateY( ofGetFrameNum()/4.0f );
    
    float radius = 500.f;
    float xPct, yPct, nx, ny, nz;
    
    float offset = ofGetFrameNum() * 0.25;
    
    float incr = 500.f/PI;
    ofColor clr = ofColor( 255,255,255);
    
    for( int i = 0; i < 500 ; i++ ){
        
        xPct = ( (((float)i*incr) + offset) * seedX ) * 0.0001;
        yPct = ( (((float)i*incr) + offset) * seedY ) * 0.0001;
        
        nx = radius * sin(xPct) * sin(yPct);
        ny = radius * cos(yPct) * sin(xPct);
        nz = radius * cos(xPct);
        
        clr.setHsb( ((float)i/500.f)*360.f , 200, 225 );
        ofSetColor( clr );
        ofBox( nx, ny, nz , 10.f );
    }
    
    
    cam.end();
    
    
    
    ofSetColor(255, 255, 255);
	stringstream reportStream;
	reportStream << "Radius = number of objects = 500" << endl
    << "target X :  " << ofToString( targX ) << "  actual: " << seedX << endl
	<< "target Y :  " << ofToString( targY ) << "  actual: " << seedY << endl
    << endl 
    << "adjust X   -1 = 1 | -10 = (shift+1) | -0.1 = q" << endl
    << "           +1 = 2 | +10 = (shift+2) | +0.1 = w" << endl
    << "adjust Y   -1 = 3 | -10 = (shift+3) | -0.1 = e" << endl
    << "           +1 = 4 | +10 = (shift+4) | +0.1 = r" << endl;
	ofDrawBitmapString(reportStream.str(), 20, ofGetHeight() - 120);
    
}
Exemplo n.º 4
0
//--------------------------------------------------------------
void testApp::draw()
{
	// as we are not drawing anything using the headset camera class, we need to tell it we wnt new sensor data this frame.
	oculusRift.setNeedSensorReadingThisFrame( true );
	
	glEnable( GL_DEPTH_TEST );
	
	cam.begin();
	
		ofPushMatrix();
		
			ofTranslate( 0.0f, 0.0f, 0.0f );

			ofPushMatrix();
				ofTranslate( 0.0f, 150.0f, 0.0f );
				ofSetColor( 0, 255, 0 );
				ofLine( ofVec3f(0,0,0), oculusRift.getAcceleration() * 100.0f );
			ofPopMatrix();
	
			ofPushMatrix();

				ofMultMatrix( oculusRift.getHeadsetOrientationMat() );

				ofSetColor( 255, 0, 0 );
				ofBox( 200 );
		
				ofTranslate( 0.0f, 0.0f, 100.0f );
				ofSetColor( 0, 0, 255 );
				ofBox( 100 );

			ofPopMatrix();
	
		ofPopMatrix();
	
	cam.end();
	
	glDisable( GL_DEPTH_TEST );	
}
// selfDraw draws in 3D using the default ofEasyCamera
// you can change the camera by returning getCameraRef()
void CloudsVisualSystemConnectors::selfDraw(){

	ofPushStyle();
	ofSetLineWidth(1.f);
	ofDisableDepthTest();
	ofDisableAlphaBlending();
	ofEnableBlendMode(OF_BLENDMODE_SCREEN);
	ofNoFill();
	ofSetColor(20);
	ofBox(0,0,0, generator.boundarySize*2);

	generator.draw();
	ofPopStyle();
}
void testApp::drawOnPoint(ofRectangle& drawRect){
	//	cam.begin();
	//gamecam.begin(drawRect);
	
	depthRGBAlignment.drawPointCloud();
	ofPushStyle();
	ofSetColor(255, 0, 0);
	ofBox(pointcloudNode.getPosition(), 2);
	ofPopStyle();
	
	//cam.end();
	//gamecam.end();
	
}
Exemplo n.º 7
0
//--------------------------------------------------------------
void Kepler::drawActor(ramActor &actor)
{
    pushAll();
    
    glEnable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    
    for (int i=0; i<actor.getNumNode(); i++)
	{
		ramNode &node = actor.getNode(i);
		float jointSize = (i==ramActor::JOINT_HEAD) ? 6.0 : 3.0;
		
		node.beginTransform();
		ofSetColor(ramColor::BLUE_LIGHT);
        ofNoFill();
		ofBox(jointSize);
        if (i==mNodeA || i==mNodeB) {
            ofSetColor(ramColor::RED_LIGHT);
            ofBox(jointSize*1.5f);
        }
		node.endTransform();
		
		if (node.hasParent())
		{
			ofSetColor(ramColor::RED_LIGHT);
			ofLine(node, *node.getParent());
		}
        
	}
    
    const ofVec3f lhp = actor.getNode(mNodeA).getGlobalPosition();
    const ofVec3f rhp = actor.getNode(mNodeB).getGlobalPosition();
    mPickerA.updatePosition(btVector3(lhp.x, lhp.y, lhp.z));
    mPickerB.updatePosition(btVector3(rhp.x, rhp.y, rhp.z));
    
    popAll();
}
void testApp::draw(){
	ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
	// カメラ開始
	cam.begin();
	// 描画色を設定
	ofSetHexColor(0xffffff);
	// 塗り潰し無し(ワイヤーフレーム)
	ofNoFill();
	// 立方体の描画
	ofBox(-150, 0, 0, 200);
	// 球体の描画
	ofSphere(150, 0, 0, 100);
	//カメラ終了
	cam.end();
}
//----------------------------------------
void ofLight::customDraw() {
    ofPushMatrix();
    glMultMatrixf(getGlobalTransformMatrix().getPtr());
    if(getIsPointLight()) {
        ofSphere( 0,0,0, 10);
    } else if (getIsSpotlight()) {
        float coneHeight = (sin(spotCutOff*DEG_TO_RAD) * 30.f) + 1;
        float coneRadius = (cos(spotCutOff*DEG_TO_RAD) * 30.f) + 8;
        ofCone(0, 0, -(coneHeight*.5), coneHeight, coneRadius);
    } else {
        ofBox(10);
    }
    ofDrawAxis(20);
    ofPopMatrix();
}
Exemplo n.º 10
0
//--------------------- ENVIRRONEMENT 3D -----------------------
void testApp::customDraw3d(){
    
    ofBox(30);

    ofSetColor(255,100,0);
    //do the same thing from the first example...
    ofMesh mesh;
    mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
    for(int i = 1; i < points.size(); i++){
        
        //find this point and the next point
        ofVec3f thisPoint = points[i-1];
        ofVec3f nextPoint = points[i];
        
        //get the direction from one to the next.
        //the ribbon should fan out from this direction
        ofVec3f direction = (nextPoint - thisPoint);
        
        //get the distance from one point to the next
        float distance = direction.length();
        
        //get the normalized direction. normalized vectors always have a length of one
        //and are really useful for representing directions as opposed to something with length
        ofVec3f unitDirection = direction.normalized();
        
        //find both directions to the left and to the right
        ofVec3f toTheLeft = unitDirection.getRotated(-90, ofVec3f(0,0,1));
        ofVec3f toTheRight = unitDirection.getRotated(90, ofVec3f(0,0,1));
        
        //use the map function to determine the distance.
        //the longer the distance, the narrower the line.
        //this makes it look a bit like brush strokes
        float thickness = ofMap(distance, 0, 30, 10, 1, true);
        
        //calculate the points to the left and to the right
        //by extending the current point in the direction of left/right by the length
        ofVec3f leftPoint = thisPoint+toTheLeft*thickness;
        ofVec3f rightPoint = thisPoint+toTheRight*thickness;
        
        //add these points to the triangle strip
        mesh.addVertex(ofVec3f(leftPoint.x, leftPoint.y, leftPoint.z));
        mesh.addVertex(ofVec3f(rightPoint.x, rightPoint.y, rightPoint.z));
    }
    
    //end the shape
    mesh.draw();

}
Exemplo n.º 11
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackground(.15*255);
	ofPushMatrix();
	
	ofSetColor(currentColor);
	
	ofTranslate(ofGetWidth()*.5, ofGetHeight()*.5, 40);	
//	ofRotate(timeline.getKeyframeValue("Rotate X"), 1, 0, 0);
//	ofRotate(timeline.getKeyframeValue("Rotate Y"), 0, 1, 0);
	
	ofBox(0,0,0,200);
	
	ofPopMatrix();

	timeline.draw();
}
Exemplo n.º 12
0
void TComTransform::Render(const TRenderSettings& RenderSettings,const TTransform2& ParentTransform,const TMaterial& Material)
{
	auto WorldTransform = GetTransform();
	ParentTransform.Transform( WorldTransform );

	//	render a box at the center...
	ofSetColor( Material.mColour );
	ofBox( WorldTransform.mPosition.x, WorldTransform.mPosition.y, Material.mZ, 4.f );

	//	and it's direction
	vec2f Normal = ofNormalFromAngle( WorldTransform.GetRotationDeg() );
	Normal += WorldTransform.mPosition;
	ofLine(	WorldTransform.mPosition.x, WorldTransform.mPosition.y, Material.mZ,
			Normal.x, Normal.y, Material.mZ );

}
Exemplo n.º 13
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackground(0);
	ofNoFill();
	
	easyCam.begin();

	ofDrawAxis(32);
	pathLines.draw(); // draw the path of the box
	
	// translate and rotate to the current position and orientation
	ofTranslate(current.x, current.y, current.z);
	rotateToNormal(current - previous);
	ofBox(32);
	ofDrawAxis(32);
	
	easyCam.end();
}
Exemplo n.º 14
0
//--------------------------------------------------------------
void testApp::draw(){

	cam.begin();
	
	ofDrawAxis(200);	
	ofSetColor(255, 255, 0);
	ofBox(20);
//	target.draw();
//	cam.getTarget().draw();
	
	
	cam.end();
	
	ofDisableLighting();
	ofSetColor(255, 255, 255);
	ofDrawBitmapString("This text is not affected by camera because it is after cam.end()", 10, 30);
}
Exemplo n.º 15
0
//--------------------------------------------------------------
void testApp::draw(){
    //ofTranslate(ofGetWindowWidth()/2, ofGetWindowHeight()/2);
   // ofRotateY(ct);
    ofCircle(xC, yC,30);
    ofCircle(pos, 25);
    //ofBox(100, 100, yC, 50);
    ofBox(pos, 50);
   /*
    for( int i = 0 ; i < TOTAL; i++){
    
        ofCircle (ofRandom(ofGetWindowWidth()),ofRandom(ofGetWindowHeight()), 30);
    
    }
*/
    
    ente.dibujar();
}
void wSatellite::draw(){
    ofPoint vectorToCenter = ofPoint(0,0,0)-*this;
    vectorToCenter.normalize();
    ofPoint objectLookAt = ofVec3f(0,0,1);
    float theta = objectLookAt.angle(vectorToCenter);
    ofPoint angleToCenter = vectorToCenter.crossed(objectLookAt);
    angleToCenter.normalize();
    
    ofPushMatrix();
    ofTranslate(*this);
    glRotatef(-theta, angleToCenter.x, angleToCenter.y, angleToCenter.z);
    float blinking = abs(sin(ofGetElapsedTimef()*freq));
    ofSetColor(200,blinking*200,blinking*200,200);
    ofFill();
    ofBox(ofPoint(0,0,0), 1);
    
    ofPopMatrix();
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void testApp::draw(){

    //light.enable();
    ofEnableLighting();

    glClearDepth(1.0);
    glEnable(GL_DEPTH_TEST);                       // Enables Depth Testing
    glDepthFunc(GL_LEQUAL);                        // Type of Depth Test to perform



    glShadeModel(GL_SMOOTH);


    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    cam.begin();
    fogShader.begin();


    ofBox(20);


    fogShader.end();

    cam.end();


    ofDisableLighting();
    glDisable(GL_DEPTH_TEST);



    if( bHide ){

        fog.disable();
		gui.draw();

    }

    ofSetColor(220,10,0);
    ofDrawBitmapString("I'm a string not coloured by the fog!", 10,720);

    }
Exemplo n.º 18
0
	//---------
	void Handles::Translate::drawStencil() const {
		if (parent == 0 || !this->enabled)
			return;
		
		ofPushMatrix();
		ofTranslate(parent->getNode().getPosition());
		ofTranslate(parent->getNode().getOrientationQuat() * parent->getOrigin());
		ofScale(scale, scale, scale);
		
		if (this->axis == NO_AXIS) {
			ofBox(GRABSCENE_HANDLES_RADIUS_2 * 2);
		} else {
			this->rotateAxis();
			fill.draw();
			
		}
		
		ofPopMatrix();
	}
Exemplo n.º 19
0
//--------------------------------------------------------------
void testApp::draw(){
    lut.draw(5, 5);
    
    cam.begin();
    
    float weight = ofMap(mouseX, 0, ofGetWidth(), 0.5, 1);
    
    shader.begin();
    shader.setUniformTexture("Tex0", lut.getTextureReference(), 0);
    shader.setUniform2f("textureSize", lut.getWidth(), lut.getHeight());
    shader.setUniform1f("alpha", weight);
    shader.setUniform4f("eyePosition", 0.0, 0.0, 1000.0, 0.0);
    
    ofBox(0, 0, 0, 200);
    
    shader.end();
    
    
    cam.end();
}
Exemplo n.º 20
0
void Maze::draw(ofCamera *cam, ofVec3f &lightPos)
{
    ofPushMatrix();
    ofTranslate(pos);
    
    int camCellY = (int)(cam->getPosition().z / cellSize);
    camCellY = max(0, camCellY-30);
    int lastVisibleLine = (int)MIN((int)camCellY + settings->showAhead, NUM_CELLS_Y);
    
    // draw surface
    float length = (float)lastVisibleLine - camCellY;
    float middle = (float)camCellY + length/2;
    
    // draw the ground
    ofFill();
    ofSetColor(settings->getGroundColor());
    ofPushMatrix();
    ofTranslate(NUM_CELLS_X*cellSize/2, -wallHeight/2, middle*cellSize);
    ofScale(NUM_CELLS_X*cellSize+120, 1, length*cellSize);
    ofBox(2);
    ofPopMatrix();
    
    // draw maze geometry
    ofSetColor(settings->getWallColor());
	glEnable(GL_CULL_FACE);
#ifdef OCULUS_RIFT
	glCullFace(GL_BACK);
#else
	glCullFace(GL_FRONT);
#endif
	geometry.draw(GL_TRIANGLES, vertexIndexForLines[camCellY], vertexIndexForLines[lastVisibleLine]-vertexIndexForLines[camCellY]);
	glDisable(GL_CULL_FACE);

    // draw moving balls
    for (int i=0; i<balls.size(); i++)
    {
        balls[i]->draw();
    }
    
    ofPopMatrix();
}
Exemplo n.º 21
0
void View::draw()
{
	ofPushView();
	ofViewport(getBounds());
	
	ofSetupScreenPerspective(getWidth(), getHeight());
	ofNoFill();
	ofSetColor(getColor());
	
	ofPushMatrix();
	ofTranslate(getWidth()*.5, getHeight()*.5, 0);
	ofTranslate(offset);
	ofRotateX(ofNoise(rotX)*360);
	ofRotateY(ofNoise(rotY)*360);
	float s = (ofNoise(scale)-.5)*30;
	ofScale(s, s, s);
	ofBox(200);
	
	ofPopMatrix();
	ofPopView();
}
Exemplo n.º 22
0
//--------------------------------------------------------------
void testApp::draw(){
    ofBackground(0);
    
    ofPushMatrix();
    cam.begin();
    light.enable();
    ofEnableLighting();
    glEnable(GL_DEPTH_TEST);
    
    ofNoFill();
    ofSetColor(150,255,255);
    ofBox(200);
    ofFill();

    for (int i = 0; i < boids.size(); i++){
		boids[i]->draw();
    }
    
    for(int i = 0; i < cellMeshes.size(); i++){
        ofSetColor(0,200,200, 30);
        cellMeshes[i].drawFaces();
        
        ofPushStyle();
        
        ofSetLineWidth(3);
        ofSetColor(0,255,255);
        cellMeshWireframes[i].draw();
        ofPopStyle();
    }
    
    glDisable(GL_DEPTH_TEST);
    ofDisableLighting();
    light.disable();
    cam.end();
    ofPopMatrix();
}
Exemplo n.º 23
0
	//---------
	void Handles::Translate::draw() const {
		if (parent == 0 || !this->enabled)
			return;
		
		GLboolean hadLighting;
		glGetBooleanv(GL_LIGHTING, &hadLighting);
		if (hadLighting)
			ofDisableLighting();
		
		ofPushMatrix();
		ofTranslate(parent->getNode().getPosition());
		ofTranslate(parent->getNode().getOrientationQuat() * parent->getOrigin());
		ofScale(scale, scale, scale);
								 
		ofPushStyle();
		if (this->axis == NO_AXIS) {
			this->setStyleFill();
			ofBox(GRABSCENE_HANDLES_RADIUS_2 * 2);
		} else {
			this->rotateAxis();
			this->setStyleFill();
			fill.draw();
		}
		ofPopStyle();
		
		if (this->rollover) {
			ofTranslate(0, 0, GRABSCENE_HANDLES_RADIUS_1 + GRABSCENE_HANDLES_RADIUS_2 * 2);
			ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
			ofDrawBitmapString(this->getReading(), ofPoint());
		}
		
		ofPopMatrix();
		
		if (hadLighting)
			ofEnableLighting();
	}
//--------------------------------------------------------------
void testApp::draw(){
	
	ofBackground(.15*255);
	ofPushMatrix();
	
	ofPushStyle();
    //set the color to whatever the last color we encountered was
	ofSetColor(timeline.getColor("Colors"));
	
    //translate to the center of the screen
	ofTranslate(ofGetWidth()*.5, ofGetHeight()*.66, 40);
    
    //Read the values out of the timeline and use them to change the viewport rotation
	ofRotate(timeline.getValue("Rotate X"), 1, 0, 0);
	ofRotate(timeline.getValue("Rotate Y"), 0, 1, 0);
	
	ofBox(0,0,0, 200);
	
	ofPopMatrix();

	ofPopStyle();
	
	timeline.draw();
}
Exemplo n.º 25
0
void MyObj::customDraw()
{
	ofBox(0.0f, 0.0f, 0.0f, size);
}
Exemplo n.º 26
0
//--------------------------------------------------------------
void testApp::draw(){
	
	
	glShadeModel(GL_SMOOTH);
	glProvokingVertex(GL_LAST_VERTEX_CONVENTION);

	ofBackgroundGradient(ofColor::fromHsb(0, 0, 120), ofColor::fromHsb(0, 0, 0));
	
	mCamMainCam.begin();
	
	ofEnableLighting();

	mLigDirectional.setGlobalPosition(1000, 1000, 1000);
	mLigDirectional.lookAt(ofVec3f(0,0,0));

	ofEnableSeparateSpecularLight();
	
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);

	mLigDirectional.enable();
	ofSetColor(mLigDirectional.getDiffuseColor());
	mMatMainMaterial.begin();

	mShdPhong->begin();

	if (shouldRenderNormals){
		mShdPhong->setUniform1f("shouldRenderNormals", 1.0);
	} else {
		mShdPhong->setUniform1f("shouldRenderNormals", 0.0);
	}

	glPushAttrib(GL_SHADE_MODEL);
	if (shouldUseFlatShading){
		mShdPhong->setUniform1f("shouldUseFlatShading", 1.0);
		glShadeModel(GL_FLAT);
		glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);		// OpenGL default is GL_LAST_VERTEX_CONVENTION
	} else {
		mShdPhong->setUniform1f("shouldUseFlatShading", 0.0);
		glShadeModel(GL_SMOOTH);
		glProvokingVertex(GL_LAST_VERTEX_CONVENTION);
	}
	
	if (shouldDrawBuiltinBox) {
		ofBox(0, 0, 0, 100);
	} else {
		ofPushMatrix();
		ofScale(50, 50,50);
		mMshCube.draw();
		ofPopMatrix();
	}
	
	// restores shade model
	glPopAttrib();
	// restores vertex convention defaults.
	glProvokingVertex(GL_LAST_VERTEX_CONVENTION);
	
	mShdPhong->end();
	
	// we revert to default values, to not end up 

	
	mMatMainMaterial.end();
	mLigDirectional.disable();

	glDisable(GL_CULL_FACE);
	glDisable(GL_DEPTH_TEST);

	ofDisableLighting();

	ofSetColor(255);
	for (int i=0; i<8; i++){
		// we do a manual scale by scaling the mesh vertex coord by 50.f to render the point at the vertex position
		ofDrawBitmapString(ofToString(i), mMshCube.getVertex(i) * 50.0f);
	}

	mCamMainCam.end();

	// draw HUD items outside of camera.
	
	string builtInIndicator = ((shouldDrawBuiltinBox) ? "built-in" : "mesh-based");
	ofDrawBitmapStringHighlight( "Rendering " + builtInIndicator + " box. Press 'b' to toggle."  , ofVec3f(10,20), ofColor(255), ofColor(0));
	
	string normalsIndicator = ((shouldRenderNormals) ? "normals" : "faces");
	ofDrawBitmapStringHighlight( "Showing " + normalsIndicator + ". Press 'n' to toggle."  , ofVec3f(10,40), ofColor(255), ofColor(0));

	string flatShadingIndicator = ((shouldUseFlatShading) ? "on" : "off");
	ofDrawBitmapStringHighlight( "Flat Shading is " + flatShadingIndicator + ". Press 'f' to toggle."  , ofVec3f(10,60), ofColor(255), ofColor(0));

	ofDrawBitmapStringHighlight( "Press SPACEBAR to reload shader."  , ofVec3f(10,80), ofColor(0), ofColor(255));

}
Exemplo n.º 27
0
void testApp::drawPointCloud()
{
	int w = 640;
	int h = 480;
	    /* 
     Change the color based on time. You can use ofGetElapsedTimef() which returns
     a float for how many seconds this app has been running
     
     in can be used such as :
        sin( ofGetElapsedTimef() )
        ofNoise( ofGetElapsedTimef() )
     
     for interesting repeating animation patterns
     
     ofColor has a function called "fromHSB( hue , saturation , brightness )" that allows for easy color offset
     */
    
    //ofColor offset = ?
    ofPushMatrix();
    glEnable(GL_DEPTH_TEST);
    ofScale(1, -1, -1);
    ofTranslate(0, 0, -1000); // center the points a bit
    ofEnableBlendMode( OF_BLENDMODE_ALPHA ) ;

   

    ofColor offset = ofColor::fromHsb((ofGetFrameNum()/2  )%255, 255, 255 ) ;
   // ofEnableBlendMode( OF_BLENDMODE_ADD ) ;
	int step = 5 ;
    float boxSize = step ;//16.5f ;
	for(int y = 0; y < h; y += step) {
		for(int x = 0; x < w; x += step) {
			if(kinect.getDistanceAt(x, y) > 0) {
				
                ofVec3f vertex = kinect.getWorldCoordinateAt(x, y) ;
                if ( vertex.z > pointCloudMinZ && vertex.z < pointCloudMaxZ )
                {
                    float normalizedZ = ofMap( vertex.z , pointCloudMinZ , pointCloudMaxZ , -360.0f , 360.0f ) ; 
                    //mesh.addVertex( vertex );
                    
                    //Offset the color here
                    ofColor col = kinect.getColorAt(x,y) + offset ; // + offset ;
                    
                    //mesh.addColor( col );
                    ofSetColor( col ) ;
                    ofPushMatrix() ;
                        ofQuaternion rot ;
                        ofQuaternion rotX = ofQuaternion( sin( ofGetElapsedTimef() + y + x * 2.5f ) * 360.0f , ofVec3f( 0.0f , 1.0f , 0.0f ) ) ;
                        ofQuaternion rotY = ofQuaternion( normalizedZ , ofVec3f( 1.0f , 0.0f , 0.0f ) ) ;
                        rot = rotX * rotY ;
                        ofVec3f axis ;
                        float angle ;
                        rot.getRotate( angle , axis ) ;
                                          
                        ofTranslate( vertex ) ; 
                        ofRotate( angle , axis.x , axis.y , axis.z ) ;
                        ofBox( ofVec3f( )  , boxSize ) ;
                    ofPopMatrix() ;
                }
				
			}
		}
	}
    glDisable(GL_DEPTH_TEST);
    ofPopMatrix();
    ofEnableBlendMode( OF_BLENDMODE_ADD ) ; 
	//glPointSize(3);
	        // the projected points are 'upside down' and 'backwards' 
       
        
            //mesh.drawVertices();
    
       	
     
}
Exemplo n.º 28
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);
}
Exemplo n.º 29
0
//--------------------------------------------------------------
void testApp::drawScene(bool isPreview){
	
	glEnable(GL_DEPTH_TEST);
	
	if (isPreview) {
		
		ofPushStyle();
		ofSetColor(150, 100, 100);
		ofDrawGrid(1.0f, 5.0f, true);
		
		ofSetColor(255);
		
		//--
		//draw camera preview
		//
		headTrackedCamera.transformGL();
		
		ofPushMatrix();
		ofScale(0.002f, 0.002f, 0.002f);
		ofNode().draw();
		ofPopMatrix();
		
		ofMultMatrix(headTrackedCamera.getProjectionMatrix().getInverse());
		
		ofPushStyle();
		ofNoFill();
		ofBox(2.0f);
		ofPopStyle();
		
		headTrackedCamera.restoreTransformGL();
		//
		//--
		
		//--
		//draw window preview
		//
		ofMesh window;
		window.addVertex(windowTopLeft);
		window.addVertex(windowBottomLeft);
		window.addVertex(windowBottomRight);
		window.setMode(OF_PRIMITIVE_LINE_STRIP);
		window.draw();
		glPointSize(3.0f);
		window.drawVertices();
		
		//
		//--
	}
	
	ofPushStyle();
	ofNoFill();
	ofColor col(200,100,100);
	for (float z = 0.0f; z > -40.0f; z-= 0.1f){
		col.setHue(int(-z * 100.0f + ofGetElapsedTimef() * 10.0f) % 360);
		ofSetColor(col);
		ofRect(-windowWidth / 2.0f, -windowHeight / 2.0f, z, windowWidth, windowHeight);
	}
	ofPopStyle();
	
	ofPushStyle();
	ofEnableSmoothing();
	ofSetColor(255);
	ofSetLineWidth(5.0f);
	ofBeginShape();
	for (int i=0; i<headPositionHistory.size(); i++) {
		ofPoint vertex(headPositionHistory[i].x, headPositionHistory[i].y, -float( headPositionHistory.size() - i ) * 0.05f);
		ofCurveVertex(vertex);
	}
	ofEndShape(false);
	ofPopStyle();
	
	glDisable(GL_DEPTH_TEST);
}
Exemplo n.º 30
0
//--------------------------------------------------------------
void ofxOpenNITT::draw3dUsers()
{

//    ofPoint p1 = ofPoint( 10,10,10 );
//    ofPoint projective = g_worldToProjective( p1 );
//    cout << "projective: " << projective << endl;
//    ofPoint world = openNIDevice.projectiveToWorld(p1);
//    cout << "world: " << world << endl;


    glEnable(GL_DEPTH_TEST);
    ofPushStyle();
    glMatrixMode(GL_PROJECTION);
    ofPushMatrix();

    float flipped[] = {
        1, 0, 0, 0,
        0, 1, 0, 0,
        0, 0, -1, 0,
        0, 0, 0, 1
    };
    glMultMatrixf( flipped );

    for(int i = 0; i < openNIDevice.getNumTrackedUsers(); i++) {
        ofxOpenNIUser & user = openNIDevice.getTrackedUser(i);
        for(int j = 0; j < user.getNumJoints(); j++) {
            ofxOpenNIJoint & joint = user.getJoint((Joint)j);

//            cout << joint.getName();

            if (j==0) {
                ofSetColor( 255,0,0);
//                ofLogNotice("TT") << "getWorldPosition:      " << joint.getWorldPosition();
//                ofLogNotice("TT") << "getProjectivePosition: " << joint.getProjectivePosition();
            } else {
                ofSetColor( 255,255,255);
            }

            ofBox(joint.getWorldPosition(), 20);

            //do something with the joint, or:
            if(joint.isParent()) { // ie., it's like a limb...
                // ...do something with the "limb"
                ofSetColor( 255,255,0);
                ofLine(ofVec3f(joint.getWorldPosition()), ofVec3f(joint.getParent().getWorldPosition()));
            }
        }
    }

//    int numUsers = openNIDevice.getNumTrackedUsers();
//    for (int nID = 0; nID < numUsers; nID++){
//        ofxOpenNIUser & user = openNIDevice.getTrackedUser(nID);
//        ofPoint p = user.getCenter();
//        ofLogNotice("TT") << p;
//        ofSetColor(255, 255, 0);
//        ofBox(p, 100);
//        ofSetColor(0, 0, 255);
//        ofBox(p.x,p.y,0, 100);
//    }

    ofPopMatrix();
    ofPopStyle();
    glDisable(GL_DEPTH_TEST);
}