Exemplo n.º 1
0
void Panel::display() {
    if(bFlipping) {
        if(curr != NULL && next != NULL) {
            ofPushStyle();
            ofEnableDepthTest();
            ofSetColor(255);
            ofPushMatrix();
            ofTranslate(bounds.getX(), bounds.getY());
            next->drawSubsection(0, 0, bounds.getWidth(), bounds.getHeight()/2, 0, 0);
            curr->drawSubsection(0, bounds.getHeight()/2, bounds.getWidth(), bounds.getHeight()/2, 0, bounds.getHeight()/2);
            if(rot > rotThreshold) {
                ofPushMatrix();
                ofTranslate(0, bounds.getHeight()/2);
                ofRotateX(rot);
                ofTranslate(0, -bounds.getHeight()/2);
                curr->drawSubsection(0, 0, bounds.getWidth(), bounds.getHeight()/2, 0, 0);
                ofPopMatrix();
            }
            else {
                ofPushMatrix();
                ofTranslate(0, bounds.getHeight()/2);
                ofRotateX(180 + rot);
                next->drawSubsection(0, 0, bounds.getWidth(), bounds.getHeight()/2, 0, bounds.getHeight()/2);
                ofPopMatrix();
            }
            ofPopMatrix();
            ofDisableDepthTest();
            ofPopStyle();
        }
        else {
            ofLogWarning("Panel::display()", "one or more of you images have not been set");
        }
    }
    else {
        if(curr != NULL && next != NULL) {
            ofEnableDepthTest();
            ofPushMatrix();
            ofSetColor(255);
            ofTranslate(bounds.getX(), bounds.getY());
            curr->drawSubsection(0, 0, bounds.getWidth(), bounds.getHeight(), 0, 0);
            //            cout<<bounds.getWidth()<<endl;
            ofPopMatrix();
            ofDisableDepthTest();
        }
        else {
            ofLogWarning("Panel::display()", "one of more of your images have not been set");
        }
    }
}
Exemplo n.º 2
0
//--------------------------------------------------------------
void testApp::draw()
{
    
    // update hue map
    colorMap.begin();
    ofClear(0,0,0,0);
    gobStopper.begin();
    gobStopper.setUniformTexture("depth_tex", kinect.getDepthTextureReference(), 0);
    gobStopper.setUniform3fv("colors", colorsGLSL, 10);
    gobStopper.setUniform3f("center", (float) center.x, (float) center.y, center.z);
    gobStopper.setUniform1f("minVal", shaderMin);
    gobStopper.setUniform1f("maxVal", shaderMax);
    ofScale((float) colorMap.getWidth() / kinect.getWidth(), (float) colorMap.getHeight() / kinect.getHeight());
    colorMesh.draw();
    gobStopper.end();
    colorMap.end();
    
    if ( bUseCL ){
        cml->render();
        
    // non-camara Lucida
    } else {
        ofEnableDepthTest();
        ofPushMatrix();
//        ofRotateX(rotateX);
//        ofRotateX(rotateY);
//        ofRotateX(rotateZ);
        ofTranslate(translateX, translateY,translateZ);
        colorMap.begin();
        cml->getMesh()->render();
        colorMap.end();
        ofPopMatrix();
    }
    ofSetColor(255);
}
Exemplo n.º 3
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();
}
Exemplo n.º 4
0
void SceneE::setup(){
    ofEnableDepthTest();
    ofEnableSmoothing();
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    
    // 視点の初期設定
    cam.setDistance(500);
    
    // ライトの初期設定
    light.enable();
    light.setSpotlight();
    light.setPosition(200, 2000, 5000);
    light.setAmbientColor(ofFloatColor(0.3, 0.3, 0.3, 0.5));
    light.setDiffuseColor(ofFloatColor(0.5, 0.5, 0.8, 0.5));
    light.setSpecularColor(ofFloatColor(0.8, 0.8, 0.8, 0.5));
    
    myVbo1.setVertexData(myVerts1, NUM_PERTICLES, GL_DYNAMIC_DRAW);
    myVbo2.setVertexData(myVerts2, NUM_PERTICLES, GL_DYNAMIC_DRAW);
    myVbo3.setVertexData(myVerts3, NUM_PERTICLES, GL_DYNAMIC_DRAW);
    myVbo4.setVertexData(myVerts4, NUM_PERTICLES, GL_DYNAMIC_DRAW);
    
    _noiseSeed = ofRandom(0.1);
    
    step = 5;

}
Exemplo n.º 5
0
//--------------------------------------------------------------
void ofApp::draw() {
    ofDrawBitmapString("ofxKinectV2: Work in progress addon.\nBased on the excellent work by the OpenKinect libfreenect2 team\n\n-Only supports one Kinect v2 at a time. \n-Requires USB 3.0 port ( superspeed )\n-Requires patched libusb. If you have the libusb from ofxKinect ( v1 ) linked to your project it will prevent superspeed on Kinect V2", 10, 14);

    texDepth.draw(10, 100);
    texRGB.draw(10, 110 + texDepth.getHeight(), 1920/4, 1080/4);

    // draw mesh
    camera.begin();
    {
        ofPushMatrix();
        {
            ofScale(1, -1, -1);
            ofTranslate(-100, -200, -500);
            ofEnableDepthTest();
            {
                kinectMesh.setMode(OF_PRIMITIVE_TRIANGLES);
                glLineWidth(int(1));
                kinectMesh.drawWireframe();
            }
            ofDisableDepthTest();
        }
        ofPopMatrix();
    }
    camera.end();

    // gui
    panel.draw();

    // debug
    ofSetWindowTitle(ofToString(ofGetFrameRate(), 0));
}
Exemplo n.º 6
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();
}
Exemplo n.º 7
0
//--------------------------------------------------------------
void ofApp::update()
{
    canvas.begin();
    {
        ofClear(0, 0);
        
        cam.begin();
        {
            ofEnableDepthTest();
            
            ofPushMatrix();
            {
                ofTranslate(ofVec3f(500 * -0.5, 500 * -0.5, 0));
                
                for (unsigned int i = 0; i < positions.size(); ++i) {
                    shader.begin();
                    {
                        shader.setUniformTexture("imageMask", mask.getTextureReference(), 1);
                        image.draw(positions[i].x, positions[i].y, positions[i].z);
                    }
                    shader.end();
                }
            }
            ofPopMatrix();
        }
        cam.end();
    }
    canvas.end();
}
Exemplo n.º 8
0
//--------------------------------------------------------------
void ofApp::setup(){
    ofBackground(50, 0);

    bAnimate = false;
    bAnimateMouse = false;
    animationPosition = 0;
    currentModel = 0;

    model.loadModel("astroBoy_walk.dae", true);
    model.setPosition(ofGetWidth() * 0.5, (float)ofGetHeight() * 0.75 , 0);
    model.setLoopStateForAllAnimations(OF_LOOP_NORMAL);
    model.playAllAnimations();
    if(!bAnimate) {
        model.setPausedForAllAnimations(true);
    }

    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofDisableAlphaBlending();

	ofEnableDepthTest();

    glShadeModel(GL_SMOOTH); //some model / light stuff
    light.enable();
    ofEnableSeparateSpecularLight();
}
Exemplo n.º 9
0
//--------------------------------------------------------------
void ofApp::drawFboParticles() {

    fboParticles.begin();
    ofClear(255,255,255, 0);
    //----------------------------
    if(gUseLight) {
        ofEnableLighting();
        light.enable();
    }

    if(gUseCam)cam.begin();


    ofEnableDepthTest();
    ofEnableAlphaBlending();

    ///DRAW pair
    pair.drawScene();


    if(gUseCam)cam.end();

    if(gUseLight) {
        light.disable();
        ofDisableLighting();
    }

    ofDisableDepthTest();
    //----------------------------
    fboParticles.end();
}
Exemplo n.º 10
0
//--------------------------------------------------------------
void ofApp::setup(){
    
    ofSetLogLevel(OF_LOG_NOTICE);
//    ofSetDataPathRoot("../Resources/data/");
    
    // Load map objects from JSON file
    JsonLoader jsonLoader = JsonLoader("vectorTile_1.json");
    rootNode = jsonLoader.loadNodeGraph();
    rootNode->setPosition(0, 0, 0);
    
    rootNode->printPosition("");
    
    // General graphics setup
    ofBackground(0, 0, 0);
    ofSetFrameRate(60);
    ofEnableDepthTest();
    
    // Camera setup
    camera = ofEasyCam();
    camera.setPosition(rootNode->getGlobalPosition());
    camera.move(0, 0, 300);
    camera.setTarget(rootNode->getGlobalPosition());
    
    // Lighting setup
    mainLight = ofLight();
    mainLight.setPointLight();
    mainLight.setGlobalPosition(-100, 0, 500);
    mainLight.setDiffuseColor(ofColor(35, 35, 35));
    mainLight.setSpecularColor(ofColor(255));
    
    ofLog(OF_LOG_VERBOSE, "Camera at " + ofToString(camera.getX()) + ", " + ofToString(camera.getY()) + ", " + ofToString(camera.getZ()));
}
Exemplo n.º 11
0
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofBackground(0,0,0);
    
    ofEnableAlphaBlending();
    ofEnableLighting();
    ofEnableDepthTest();
    
    cam.begin();
    
    
    for(int i=0; i<links.size(); i++) {

        if(links[i].getParent()){
            
            ofLine(links[i].getGlobalPosition(), links[i].getParent()->getGlobalPosition());
        }
        
        
        
        links[i].draw();


        
    }
    
    cam.end();
    
    syphon.publishScreen();

}
Exemplo n.º 12
0
//--------------------------------------------------------------
void ofApp::draw()
{
    // start drawing the 3d scene from the point of view
    // of the camera
    camera.begin();
    
    // enable depth testing so that the box mesh masks
    // the wireframe at the back of the box
    ofEnableDepthTest();
    
    // draw our box mesh in black
    ofSetColor(0);
    boxMesh.draw();
    
    // now draw a the wireframe
    ofSetColor(255);
    wireframeMesh.drawWireframe();
    
    // disable depth testing
    ofDisableDepthTest();
    
    // finish drawing the 3d scene from the point of view
    // of the projector
    camera.end();
}
Exemplo n.º 13
0
//--------------------------------------------------------------
void testApp::drawInitScene(){

//    ofDrawGrid(1000.0f, 8.0f, true, true, true, true);

    

    ofEnableDepthTest();
    tvroom.drawFaces();

    light.enable();
    light.setPosition(0, 0, tv_z + 50);
    light.draw();
    tv.setScale(ofMap(tv_z, -1000, 0, 0.1, 1), ofMap(tv_z, -1000, 0, 0.1, 1), ofMap(tv_z, -1000, 0, 0.1, 1));
 
    ofTranslate(tv_x, tv_y,tv_z);
  
//    tv.setPosition(tv_x, tv_y, tv_z);
    tv.drawFaces();
    ofScale(image_scale * ofMap(tv_z, -1000, 0, 0.1, 1), image_scale * ofMap(tv_z, -1000, 0, 0.1, 1),image_scale * ofMap(tv_z, -1000, 0, 0.1, 1));
    ofRotateX(180);
    ofTranslate(image_x, image_y, image_z);

    tvScreen.draw(0, 0);


  
    light.disable();

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

	ofEnableDepthTest(); 

	cam.begin();
	light.enable(); 

	if (drawGrid)
	{
		ofDrawGrid(200);
	}

	if (drawBox)
	{
		//ofNoFill(); 
		ofSetColor(255,255,255,100);
		ofDrawBox(800, 800, 800);
		ofFill(); 
	}

	ball.draw();
	ball2.draw(); 

	light.disable();
	cam.end(); 
	ofDisableDepthTest(); 
}
Exemplo n.º 15
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();
}
Exemplo n.º 16
0
void testApp::drawPointCloud() {
	int w = 640;
	int h = 480;
	ofMesh mesh;
	mesh.setMode(OF_PRIMITIVE_POINTS);
	int step = 2;
	for(int y = 0; y < h; y += step) {
		for(int x = 0; x < w; x += step) {
			if(kinect.getDistanceAt(x, y) > 0) {
			    if(colorize)
                    mesh.addColor(kinect.getColorAt(x,y));
				mesh.addVertex(kinect.getWorldCoordinateAt(x, y));
			}
		}
	}
	glPointSize(size);
	ofPushMatrix();
	// the projected points are 'upside down' and 'backwards'
	ofScale(1, -1, -1);
	ofTranslate(0, 0, -1000); // center the points a bit
	ofEnableDepthTest();
	mesh.drawVertices();
	ofDisableDepthTest();
	ofPopMatrix();
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void ofApp::renderScene() {
    ofEnableDepthTest();

    pbr.begin(&cam, &particlesShader);
    pbr.getShader()->setUniformTexture("posTex", *tf.getTexture(0), 11);
    pbr.getShader()->setUniformTexture("velTex", *tf.getTexture(1), 12);
    pbr.getShader()->setUniformTexture("ageTex", *tf.getTexture(2), 13);
    pbr.getShader()->setUniformTexture("lifetimeTex", *tf.getTexture(3), 14);
    pbr.getShader()->setUniform3f("maxSize", boxSize);
    material1.begin(&pbr);
    mesh.drawInstanced(OF_MESH_FILL, numParticles);
    material1.end();
    pbr.end();

    pbr.begin(&cam);
    jointMaterial.begin(&pbr);
    for (int i = 0; i < bvh.getNumJoints(); i++) {
        ofMatrix4x4 m = bvh.getJoint(i)->getMatrix();
        ofPushMatrix();
        float angle;
        ofVec3f axis;
        m.getRotate().getRotate(angle, axis);
        ofTranslate(bvh.getJoint(i)->getPosition() * 10);
        ofRotate(angle, axis.x, axis.y, axis.z);
        ofDrawSphere(0, 0, 0, 10);
        ofPopMatrix();
    }
    jointMaterial.end();
    floorMaterial.begin(&pbr);
    ofDrawBox(0, -25, 0, 5000, 1, 5000);
    floorMaterial.end();
    pbr.end();

    ofDisableDepthTest();
}
Exemplo n.º 18
0
void testApp::drawLines() {
    
	int w = 640;
	int h = 480;
	ofMesh mesh;
	mesh.setMode(OF_PRIMITIVE_TRIANGLES);
	int step = 2;
    
	for(int y = 0; y < h; y += step) {
		for(int x = 0; x < w; x += step) {
			if(kinect.getDistanceAt(x, y) > 0) {
                
                ofColor realColor = ofColor(kinect.getColorAt(x,y));
                // how to add random?
				mesh.addColor(realColor);
                mesh.addVertex(kinect.getWorldCoordinateAt(x, y));
			}
		}
	}
	glLineWidth(2);
    ofPushMatrix();
    ofScale(-1, -1, -1);
	ofTranslate(0, 0, -1000); // center the points a bit
	ofEnableDepthTest();
    //mesh.draw();
    mesh.drawFaces();
	ofDisableDepthTest();
	ofPopMatrix();
}
Exemplo n.º 19
0
//--------------------------------------------------------------
void ofApp::draw(){

	fbo.begin();
		if (mvp.key1){
			ofBackground( (int)ofRandom(0,255),(int)ofRandom(0,255),(int)ofRandom(0,255)  );	
			mvp.key1 = 0;
		}

    ofSetColor(mvp.knob6*255,mvp.knob7*255,mvp.knob8*255);    
    
    ofEnableDepthTest();
    
    texture.getTexture().bind();
    // Plane //
    plane.setPosition(ofGetWidth()*mvp.knob4, ofGetHeight()*mvp.knob5, 0);
    plane.rotate(mvp.knob1 * 360, 1.0, 0.0, 0.0);
    plane.rotate(mvp.knob2 * 360, 0, 1.0, 0.0);
    plane.rotate(mvp.knob3 * 360, 0, 0, 1.0);
    //plane.set( mouseX, mouseY );
    plane.set( 500, 500 );
    
    material.begin();
    ofFill();
    plane.draw();
    material.end();
    
    texture.getTexture().unbind();
    // End plane stuff

	
	fbo.end();
	fbo.draw(0,0);

}
Exemplo n.º 20
0
void ofxPBR::drawEnvironment(){

	glm::mat4 projectionMatrix = ofGetCurrentMatrix(OF_MATRIX_PROJECTION);
	float m22 = projectionMatrix[2][2];
	float m32 = projectionMatrix[3][2];
\
	float nearClip = (2.0f*m32) / (2.0f*m22 - 2.0f);
	float farClip = ((m22 - 1.0f) * nearClip) / (m22 + 1.0);

	if (enableCubemap && cubeMap != nullptr && cubeMap->isAllocated()) {
		float scale = (farClip - nearClip) / 2;
		glm::mat4 invCurrentViewMatrix = glm::inverse(ofGetCurrentViewMatrix());
		glm::vec3 translate = glm::vec3(invCurrentViewMatrix[3][0], invCurrentViewMatrix[3][1], invCurrentViewMatrix[3][2]);

		ofDisableDepthTest();
		ofPushMatrix();
		ofTranslate(translate);
		cubeMap->bind(1);
		envShader->begin();
		envShader->setUniform1f("envLevel", cubeMap->getEnvLevel());
		envShader->setUniform1i("envMap", 1);
		envShader->setUniform1i("numMips", cubeMap->getNumMips());
		envShader->setUniform1f("cubeMapExposure", cubeMap->getExposure());
		envShader->setUniform1f("cubeMapRotation", cubeMap->getRotation());
		ofPushMatrix();
		ofScale(scale, scale, scale);
		sphereMesh.draw();
		ofPopMatrix();
		envShader->end();
		cubeMap->unbind();
		ofPopMatrix();
		ofEnableDepthTest();
	}
}
Exemplo n.º 21
0
//--------------------------------------------------------------
void ofApp::draw(){
	ofBackgroundGradient(ofColor::skyBlue, colorSlider);


	ofEnableDepthTest();
	sun.enable();
	cam.begin();
	if(loadedMesh.hasMeshes())
	{
		loadedMesh.enableMaterials();
		loadedMesh.enableNormals();
		loadedMesh.enableTextures();
		loadedMesh.enableColors();
		loadedMesh.drawFaces();
		loadedMesh.disableMaterials();
		loadedMesh.disableNormals();
		loadedMesh.disableTextures();
		loadedMesh.disableColors();
	}
	cam.end();
	sun.disable();

	ofDisableDepthTest();
	gui.draw();
}
Exemplo n.º 22
0
//--------------------------------------------------------------
void ofApp::draw(){
    //隠面消去
    ofEnableDepthTest();
    //テクスチャー適用
    image.getTexture().bind();
    
    
    
    cam.begin();
    
    //球から生成したメッシュを描画
    ofSetColor(255);
    sphereMesh.drawFaces();

    
    //メッシュの頂点の数だけくりかえし
    for (int i = 0; i < sphereMesh.getVertices().size(); i++) {
        
        ofPushMatrix();
        //メッシュのそれぞれの頂点の位置を取得
        ofTranslate(sphereMesh.getVertices()[i]);
        //頂点番号を表示
        ofDrawBitmapString(ofToString(i), 0, 0);
        ofPopMatrix();
        
        
        
    }
    cam.end();

    image.getTexture().unbind();
    ofDisableDepthTest();
}
Exemplo n.º 23
0
//--------------------------------------------------------------
void ofApp::draw() {

	ofEnableDepthTest();
	cam.begin();
	light.enable();
	if (drawGrid) ofDrawGrid(200);
	if (drawBox) {

		ofNoFill();
		ofSetColor(ofColor::white);
		ofDrawBox( BoxSize_X , BoxSize_Y , BoxSize_Z );
	}
        ball_1.draw();
		ball_2.draw();
		ball_3.draw();
		ball_4.draw();
		ball_5.draw();
		ball_6.draw();
		ball_7.draw();
		ball_8.draw();
		ball_9.draw();
		ball_10.draw();
		light.disable();
		cam.end();
		ofDisableDepthTest();
		
}
Exemplo n.º 24
0
//--------------------------------------------------------------
void testApp::draw(){
	ofEnableDepthTest();				//Enable z-buffering

	//Set a gradient background from white to gray
	ofBackgroundGradient( ofColor( 255 ), ofColor( 128 ) );

	ofPushMatrix();						//Store the coordinate system

	//Move the coordinate center to screen's center
	ofTranslate( ofGetWidth()/2, ofGetHeight()/2, 0 );

	//Calculate the rotation angle
	float time = ofGetElapsedTimef();   //Get time in seconds
	float angle = time * 20;			//Compute angle. We rotate at speed
	//20 degrees per second
	ofRotate( 30, 1, 0, 0 );			//Rotate coordinate system
	ofRotate( angle, 0, 0, 1 );

	//Draw mesh
	//Here ofSetColor() does not affects the result of drawing,
	//because the mesh has its own vertices' colors
	mesh.draw();

	ofPopMatrix();      //Restore the coordinate system
}
Exemplo n.º 25
0
//--------------------------------------------------------------
void SceneSurfaceBezier::Draw()
{
	if (!isPlaying)
		startGui.draw();
	else {
		ofEnableDepthTest();
		cam.begin();

		surfaceBezier.Draw();

		ofPushMatrix();
		ofTranslate(surfaceBezier.controlPoints[selectedControlX][selectedControlY]);
		ofFill();
		ofSetColor(ofColor::white);
		ofDrawBox(10);
		ofNoFill();
		ofSetColor(ofColor::black);
		ofDrawBox(10);
		ofPopMatrix();

		cam.end();
		ofDisableDepthTest();

		mainGui.draw();
	}
}
Exemplo n.º 26
0
void ofApp::draw(){

    if (!bDrawPointCloud) {
        ofSetColor(ofColor::white);
        astra.draw(0, 0);
        astra.drawDepth(640, 0);
    } else {
        cam.begin();
        ofEnableDepthTest();
        ofRotateY(180);
        ofScale(1.5, 1.5);

        mesh.draw();

        ofDisableDepthTest();
        cam.end();
    }

    stringstream ss;
    ss << "r: toggle registration between color & depth images (";
    ss << (bUseRegistration ? "on)" : "off)") << endl;
    ss << "p: switch between images and point cloud" << endl;
    ss << "c: toggle point cloud using color image or gradient (";
    ss << (bPointCloudUseColor ? "color image)" : "gradient)") << endl;
    ss << "rotate the point cloud with the mouse";

    ofSetColor(ofColor::white);
    ofDrawBitmapStringHighlight(ss.str(), 20, 500);
}
Exemplo n.º 27
0
//--------------------------------------------------------------
void testApp::setup() {
    ofSetLogLevel(OF_LOG_VERBOSE);
    ofEnableDepthTest();
    ofSetVerticalSync(false);

    showOverlay = false;

    oculusRift.baseCamera = &cam;
    oculusRift.setup();

    for (int i = 0; i < 80; i++) {
        DemoBox d;
        demos.push_back(d);
    }
    setupBoxes();

    if (ofIsGLProgrammableRenderer())
        bshader.load("Shaders_GL3/simple.vert", "Shaders_GL3/simple.frag");

    // ofBox uses texture coordinates from 0-1, so you can load whatever
    // sized images you want and still use them to texture your box
    // but we have to explicitly normalize our tex coords here
    ofEnableNormalizedTexCoords();

    // loads the OF logo from disk
    ofLogo.loadImage("of.png");

    //enable mouse;
    cam.setAutoDistance(false);
    cam.begin();
    cam.end();

    // set camera y to user eye height
    cam.setGlobalPosition(0, oculusRift.getUserEyeHeight(), 3);
}
Exemplo n.º 28
0
void ofApp::setup(){
    ofSetFrameRate(60);

    ofBackground(30,30,30);

    drawGrid = false;
    drawLight = false;

    planet01.setup("Sun");
    planetParams.add(planet01.planetParamGroup);

    planet02.setup("Earth");
    planetParams.add(planet02.planetParamGroup);
    
    planet03.setup("Mars");
    planetParams.add(planet03.planetParamGroup);
    
    planet04.setup("Jupiter");
    planetParams.add(planet04.planetParamGroup);

    gui.setup(planetParams);
    image1.load("earth.jpg");
    image2.load("jupiter.jpg");
    image3.load("mars.jpg");
    image4.load("sun.jpg");

    // plaats een light in de 3d ruimte
    light.setPointLight();
    light.setPosition(200,200,200);
    
    ofEnableDepthTest();
}
Exemplo n.º 29
0
//--------------------------------------------------------------
void ofApp::drawScene()
{
    ofPushStyle();
    //billboard and draw the mouse
   //if(oculusRift.isSetup())
    {
        /*
        ofPushMatrix();
        oculusRift.multBillboardMatrix();
        ofSetColor(255, 0, 0);
        ofCircle(0,0,.5);
        ofPopMatrix();
        */
        
        
        ofScale(1, -1, -1);
        //ofTranslate( 0 ,0 ,0);
        
        //ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
        ofEnableDepthTest();
        mesh.draw();
        //kinect.draw(0, 0, 640, 480);
        //kinect.drawDepth(0, 0, 640, 480);
        
        
        ofDisableDepthTest();
        ofPopMatrix();

        
    }
    
    ofPopStyle();
    
}
Exemplo n.º 30
0
//--------------------------------------------------------------
void testApp::setup(){	
	ofBackground(255,255,255);
		
	ofSetVerticalSync(true);

    //some model / light stuff
    ofEnableDepthTest();
    glShadeModel (GL_SMOOTH);

    /* initialize lighting */
    glLightfv (GL_LIGHT0, GL_POSITION, lightOnePosition);
    glLightfv (GL_LIGHT0, GL_DIFFUSE, lightOneColor);
    glEnable (GL_LIGHT0);
    glLightfv (GL_LIGHT1, GL_POSITION, lightTwoPosition);
    glLightfv (GL_LIGHT1, GL_DIFFUSE, lightTwoColor);
    glEnable (GL_LIGHT1);
    glEnable (GL_LIGHTING);
    glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE);
    glEnable (GL_COLOR_MATERIAL);

    //load the squirrel model - the 3ds and the texture file need to be in the same folder
    squirrelModel.loadModel("squirrel/NewSquirrel.3ds", 20);

    //you can create as many rotations as you want
    //choose which axis you want it to effect
    //you can update these rotations later on
    squirrelModel.setRotation(0, 90, 1, 0, 0);
    squirrelModel.setRotation(1, 270, 0, 0, 1);
    squirrelModel.setScale(0.9, 0.9, 0.9);
    squirrelModel.setPosition(ofGetWidth()/2, ofGetHeight()/2, 0);

}