コード例 #1
0
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackgroundGradient(ofColor(255), ofColor(212));
    ofEnableDepthTest();
    ofEnableLighting();
    cam.begin();
    light1.enable();
    vtfShader.begin();
    vtfShader.setUniform4f("COMMON_Ambient",0.1,0.1,0.1,1.0);
    vtfShader.setUniform4f("COMMON_Diffuse",0.5,0.5,0.5,1.0);
    vtfShader.setUniform4f("COMMON_Specular",0.5,0.5,0.5,1.0);
    vtfShader.setUniform1f("COMMON_Shininess",100.0);
    vtfShader.setUniform1i("ADS_NumLights",ofGetLightingEnabled());
    vtfShader.setUniformTexture("posTex", posTex,0);
    vtfShader.setUniformTexture("sizeTex", sizeTex,1);
    vtfShader.setUniformTexture("rotTex", rotTex,2);
    vtfShader.setUniformTexture("colorTex", colorTex,3);
    vtfShader.setUniform1f("iCount", textureRes);
    object.drawInstanced(OF_MESH_FILL, textureRes*textureRes);
    vtfShader.end();
    if(lookAtSphere)ofDrawSphere(target, 50);
    light1.disable();
    cam.end();
    ofDisableLighting();
    ofDisableDepthTest();
}
コード例 #2
0
ファイル: ofApp.cpp プロジェクト: chrisjwei/senselDraw
//--------------------------------------------------------------
void ofApp::draw(){
  if (viewMode == 0){
    cam.begin();
    ofPushMatrix();
      ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2);
      for (int i =0; i < MAX_CONTACTS; i++ ){ellipse[i].drawCursor(mode);} 
      mesh.drawWireframe();
    ofPopMatrix();
    cam.end();
  } else if (viewMode == 1){
    ofEnableLighting();
    cam.begin();
    light.enable();
    ofPushMatrix();
      ofTranslate(-ofGetWidth()/2, -ofGetHeight()/2);
      mesh.draw();  
    ofPopMatrix();
    light.disable();
    cam.end();

    ofDisableLighting();
  }
  if (viewMode == 2){
    ofSetColor(ofColor::white);
    fbo[fboIndex].draw(0,0);
  }
  if (!hideMenu) drawUi();
}
コード例 #3
0
ファイル: ofApp.cpp プロジェクト: Opensemble/lhcvmm
//--------------------------------------------------------------
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();
}
コード例 #4
0
ファイル: Cloud.cpp プロジェクト: vanish87/Jungle-of
	void Cloud::Draw()
	{
		ofSetColor(color_.r, color_.g, color_.b,color_.a);
		if(enable_)
		{
			switch (flower_state_)
			{
			case GROWING:
			case DISAPPEARING:
			case WAITING:
				drawFaces();
				break;
			case FALLING:

				drawFaces();
				ofDisableLighting();
				ofEnableAlphaBlending();
				rain_emitter_.draw(0,0);
				ofEnableLighting();
				break;
			case HOLDING:
				break;
			}
		}
	}
コード例 #5
0
ファイル: ofApp.cpp プロジェクト: UIKit0/ofxTablet
//--------------------------------------------------------------
void ofApp::draw(){
    float gridsize = 500;
    
    cam.begin();
    
    ofDrawGrid(gridsize/2.0, 8.0f, false, false, false, true);
    
    ofPushMatrix();
   
    ofMultMatrix(tabmtx);
    
    ofDrawAxis(30);
    
    ofEnableLighting();
    light.enable();
    
    ofPushMatrix();
    ofRotateX(90);
    ofDrawCylinder(0,52,0,3,100);
    ofPopMatrix();
    
    // you can also get global tablet data at any time
    TabletData& data = ofxTablet::tabletData;
    float p= data.pressure*25;
    if (p<10) p = 10;
    
    ofDrawArrow(ofVec3f(0,0,100), ofVec3f(0,0,0), p);

    ofDisableLighting();

    ofPopMatrix();
    
    cam.end();
    
}
コード例 #6
0
ファイル: ofApp.cpp プロジェクト: JoshuaBatty/sims2014
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackground(0);

    cam.begin();
    
    light.draw();
    
    ofEnableLighting();
    light.enable();
    ofPushMatrix();
    
    //  Center the mesh;
    //
    ofTranslate(-ofGetWidth()*0.5, -ofGetHeight()*0.5);
    
    //  Draw the mesh applying the shader that will move the points to different height
    //  acording to the texture
    //
    terrainShader.begin();
    terrainShader.setUniformTexture("heightMap", heightMap,0);
    terrainShader.setUniformTexture("normalMap", normalFbo,1);
    terrainShader.setUniform1f("time",ofGetElapsedTimef());
    if(bWireframe){
        terrain.drawWireframe();
    } else {
        terrain.draw();
    }
    terrainShader.end();
    
    ofPopMatrix();
    light.disable();
    ofDisableLighting();
    
    cam.end();
}
コード例 #7
0
void ofxEditor::draw() {
  ofPushStyle();
  ofDisableLighting();
  ofSetColor(255, 255, 255, 255);
  editorFbo.draw(0, 0);
  ofPopStyle();
}
コード例 #8
0
ファイル: FFTTracer.cpp プロジェクト: bimyoo/AudioVisualApps
void FFTTracer::draw(){
    glEnable(GL_DEPTH_TEST);
    //ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofDisableLighting();
    ofPushMatrix();
    ofScale(1.0, 1.0, 1.0);
    ofRotateX(ofGetElapsedTimef() * 4);
    ofRotateY(ofGetElapsedTimef() * 3);
    ofRotateZ(ofGetElapsedTimef() * 2);
    for (int i=0; i<fft_size; i++) {
        if(magnitude[i] > 1){
            ofSetColor(ofColor::fromHsb(255 * i / fft_size, 200, 120));
            float w = powf(((testApp*)ofGetAppPtr())->power[i],4.0);
            if (w > 10) {
                w = 10;
            }
            ofSetLineWidth(w);
            trackers[i]->draw();
        }
    }
    ofPopMatrix();
    ofEnableLighting();
    glDisable(GL_DEPTH_TEST);
    //ofEnableBlendMode(OF_BLENDMODE_ADD);
}
コード例 #9
0
ファイル: Rotate.cpp プロジェクト: elliotwoods/ofxGrabScene
	//---------
	void Handles::Rotate::draw() const {
		if (parent == 0 || !this->enabled)
			return;
		
		GLboolean hadLighting;
		glGetBooleanv(GL_LIGHTING, &hadLighting);
		if (hadLighting)
			ofDisableLighting();
		
		ofPushMatrix();
		this->doTransform();
		
		ofPushStyle();
		shader("fixed").begin();
		
		this->rotateAxis();
		this->setStyleFill();
		fill.draw();
		
		shader("fixed").end();
		
		ofSetColor(255);
		if (this->rollover) {
			ofTranslate(0, GRABSCENE_HANDLES_RADIUS_1 + GRABSCENE_HANDLES_RADIUS_2 * 2);
			ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
			ofDrawBitmapString(this->getReading(), ofPoint());
		}
		
		ofPopStyle();
		
		ofPopMatrix();
		
		if (hadLighting)
			ofEnableLighting();
	}
コード例 #10
0
ファイル: ofApp.cpp プロジェクト: DEM0915/florr422_sims2014
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofBackground(0);
	ofSetColor(255);
    
    //note that easy cam gives you the ability to move the "camera" w/ mouse
    ofPushMatrix();
    
    cam.begin();
    light.enable();
    ofEnableLighting();
    glEnable(GL_DEPTH_TEST);
    
    //drawn=ing my particles
    for(int i = 0; i < num; i++){
        MyParticles[i].draw();
    }
    
    glDisable(GL_DEPTH_TEST);
    ofDisableLighting();
    light.disable();
    cam.end();
    
    ofPopMatrix();
    
}
コード例 #11
0
ファイル: ofApp.cpp プロジェクト: thelastbaldwin/of
//--------------------------------------------------------------
void ofApp::draw(){
    fbo.begin();
    ofEnableLighting();
    ofEnableDepthTest();


    pointLight.enable();
    pointLight.draw();
    
    //somehow this allows the light color and material color to blend
    glDisable(GL_COLOR_MATERIAL);
    if(applyMaterial){
        material.begin();
    }
    
    sphere.draw();
    
    pointLight.disable();
    if(applyMaterial){
        material.end();
    }
    ofDisableDepthTest();
    ofDisableLighting();
    fbo.end();

    //prevents strange layering of gui
    fbo.draw(0, 0);
    if(!hideGui){
        gui.draw();
    }
}
コード例 #12
0
void FFTFnwrNoise::draw(){
    float br = 2.5;
    float pow = powf(((testApp*)ofGetAppPtr())->avg_power, 0.9) * 10.0;
    int skip = pow/4.0 + 2;
    ofRotateX(180);
    //ofScale(pow/100+1.2,pow/100+1.2);
    ofScale(1.2,1.2);
    ofTranslate(-fnwr.width/2, -fnwr.height/2);
    
    //ofSetRectMode(OF_RECTMODE_CENTER);
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    //ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    for (int i = 0; i < fnwr.width; i+=skip) {
        for (int j = 0; j < fnwr.height; j+=skip) {
            int r = pixels[j * fnwr.width * 3 + i * 3] * br;
            int g = pixels[j * fnwr.width * 3 + i * 3 + 1]* br;
            int b = pixels[j * fnwr.width * 3 + i * 3 + 2]* br;
            
            ofSetColor(r, 0, 0);
            ofRect(i, int(j - magnitude[i] * pow / 4.0), skip, skip);
            ofSetColor(0, g, 0);
            ofRect(i, j, skip, skip);
            ofSetColor(0, 0, b);
            ofRect(i, int(j + magnitude[fft_size - i] * pow / 4.0), skip, skip);
        }
    }
    //ofSetRectMode(OF_RECTMODE_CORNER);
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    ofDisableLighting();
    ofSetColor(120,120,120,255-pow*3);
    fnwr.draw(0, 0);
    ofEnableLighting();
    ofEnableBlendMode(OF_BLENDMODE_ADD);
}
コード例 #13
0
ファイル: ofApp.cpp プロジェクト: elaye/ofxKUI
void ofApp::drawHelp(){
  ofSetColor(ofColor::white);
  ofDisableLighting();
  float y = 20;
  ofDrawBitmapString("First press 'c' to enter camera mode.", 5, y);
  y += 20;
  ofDrawBitmapString("Then, use the following keys to move the camera.", 5, y);
  y += 30;
  ofDrawBitmapString("Position:", 5, y);
  y += 30;
  ofDrawBitmapString("[s] Move down", 10, y);
  y += 20;
  ofDrawBitmapString("[d] Move up", 10, y);
  y += 30;
  ofDrawBitmapString("[f] Move right", 10, y);
  y += 20;
  ofDrawBitmapString("[a] Move left", 10, y);
  y += 30;
  ofDrawBitmapString("[w] Move forward", 10, y);
  y += 20;
  ofDrawBitmapString("[x] Move backward", 10, y);
  y += 30;
  ofDrawBitmapString("Rotation:", 5, y);
  y += 30;
  ofDrawBitmapString("[k] Rotate down around horizontal axis", 10, y);
  y += 20;
  ofDrawBitmapString("[l] Rotate up around horizontal axis", 10, y);
  y += 30;
  ofDrawBitmapString("[j] Rotate left around vertical axis", 10, y);
  y += 20;
  ofDrawBitmapString("[;] Rotate right around vertical axis", 10, y);
  y += 30;
  ofDrawBitmapString("Press 'Esc' to exit camera mode.", 5, y);
}
コード例 #14
0
ファイル: testApp.cpp プロジェクト: appmaker23/eden
void testApp::draw(){
    if(bEdit)    
        ofBackgroundGradient(ofColor::gray, ofColor::black);
    else
        ofBackground(ofColor::black);

    if (bCalibrated && bTerrain){
        ofPushMatrix();
        
        ofSetColor(255,255);
        
		cam.begin();
		ofEnableLighting();
		light.enable();
        
		drawTerrain();
		
		light.disable();
		ofDisableLighting();
		cam.end();
        ofPopMatrix();
	}
    
    ofSetColor(255,255);
    composer.draw();
    
    if(bEdit)
        data.draw();
}
コード例 #15
0
ファイル: testApp.cpp プロジェクト: 3snail/openFrameworks
//--------------------------------------------------------------
void testApp::draw() {
    
    ofSetColor(pointLight.getDiffuseColor());
    ofSphere(pointLight.getPosition(), 20.f);
    
    // enable lighting //
    ofEnableLighting();
    // the position of the light must be updated every frame, 
    // call enable() so that it can update itself //
    pointLight.enable();
    material.begin();
    
    if(bDrawWireframe) ofNoFill();
    else ofFill();
    
    ofPushMatrix();
    ofTranslate(center.x, center.y, 0);
    ofRotate(rotation, 0, 0, 1);
	for(int i = 0; i < numSpheres; i++) {
        float angle = TWO_PI / (float)numSpheres * i;
        float x = cos(angle) * radius;
        float y = sin(angle) * radius;
        ofSphere(x, y, -200, sphereRadius);
    }
    ofPopMatrix();
	material.end();
	// turn off lighting //
    ofDisableLighting();
    
    ofSetColor(255, 255, 255);
    ofDrawBitmapString("Draw Wireframe (w) : "+ofToString(bDrawWireframe, 0), 20, 20);
    
}
コード例 #16
0
 //--------------------------------------------------------------
 void Gui::draw() {
     if(!checkOkToRun()) return;
     
     ofPushStyle();
     ofEnableSmoothing();
     ofDisableNormalizedTexCoords();
     ofDisableLighting();
     glDisable(GL_DEPTH_TEST);
     
     Renderer::instance().clearControls();
     
     // iterate all controls on page, set position and add to render queue
     Page &page = getCurrentPage();
     page.layout.x = getConfig()->layout.scrollbarWidth;
     pLayoutManager->clearParentRect(*this);
     page.arrangeControls(true);
     _pGuiControls->arrangeControls(true);
     pLayoutManager->update();
     
     // sort and draw
     Renderer::instance().draw();
     
     ofPopStyle();
     
     // draw debug boxes around containers
     //                ofPushStyle();
     //                ofSetRectMode(OF_RECTMODE_CORNER);
     //                ofNoFill();
     //                ofSetColor(0, 255 ,0);
     //                ofDrawRectangle(page.x, page.y, page.width, page.height);
     //                ofSetColor(0, 0, 255);
     //                ofDrawRectangle(x, y, width, height);
     //                ofPopStyle();
 }
コード例 #17
0
ファイル: ofApp.cpp プロジェクト: DHaylock/ofxBullet
//--------------------------------------------------------------
void ofApp::draw() {
	glEnable( GL_DEPTH_TEST );
	camera.begin();

	ofSetLineWidth(1.f);
	ofSetColor(255, 0, 200);
	if(bDrawDebug) world.drawDebug();

	ofEnableLighting();
	light.enable();

	if(bRenderShapes) {
		ofSetColor(100, 100, 100);
		for(int i = 0; i < bounds.size()-1; i++) {
			bounds[i]->draw();
		}

		for(int i = 0; i < shapes.size(); i++) {
			if(shapes[i]->getType() == ofxBulletBaseShape::OFX_BULLET_BOX_SHAPE) {
				ofSetColor(15,197,138);
			} else {
				ofSetColor(220, 0, 220);
			}
			if(mousePickIndex == i) {
				ofSetColor(255, 0, 0);
			} else if (bColliding[i] == true) {
				if(shapes[i]->getType() == ofxBulletBaseShape::OFX_BULLET_BOX_SHAPE) {
					ofSetColor(220, 180, 60);
				} else {
					ofSetColor(255, 20, 50);
				}
			}
			shapes[i]->draw();
		}
	}
	light.disable();
	ofDisableLighting();

	camera.end();
	glDisable(GL_DEPTH_TEST);

	ofEnableAlphaBlending();
	ofSetColor(0, 0, 0, 150);
	ofRect(0, 0, 250, 120);
	ofDisableAlphaBlending();

	ofSetColor(255, 255, 255);
	stringstream ss;
	ss << "framerate: " << ofToString(ofGetFrameRate(),0) << endl;
	ss << "num shapes: " << (shapes.size()+bounds.size()) << endl;
	ss << "draw debug (d): " << ofToString(bDrawDebug, 0) << endl;
	ss << "render shapes (r): " << ofToString(bRenderShapes, 0) << endl;
	ss << "mouse force with spacebar: " << bSpacebar << endl;
	ss << "force direction(f): " << bAddCenterAttract << endl;
	ss << "add spherers (s)" << endl;
	ss << "add boxes (b)" << endl;
	ofDrawBitmapString(ss.str().c_str(), 10, 10);
}
コード例 #18
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();
	}
}
コード例 #19
0
//--------------------------------------------------------------
void testApp::draw(){
	ofEnableLighting();
	light.enable();
	if(rotating) t++;
	fbo.begin();
	glColor4f(1, 1, 1, 1);
	ofClear(0, 0, 0, 0);
	
	glPushMatrix();
	glScalef(2, 2, 2);
	glTranslatef(ofGetWidth()/2, ofGetHeight()/2, 0);
	glRotatef(t, 0, 1, 1);
	/*glBegin(GL_QUADS);
	glVertex2f(-100, -100);
	glVertex2f(100, -100);
	glVertex2f(100, 100);
	glVertex2f(-100, 100);
	
	glEnd();*/
	ofBox(0, 0, 0, 100);
	glPopMatrix();
	fbo.end();
	
	ofDisableLighting();

	if(shading) {
		fxaa.begin();
		fxaa.setUniformTexture("bgl_RenderedTexture", fbo.getTextureReference(0), 0);
		fxaa.setUniform1f("bgl_RenderedTextureWidth", fbo.getWidth());
		fxaa.setUniform1f("bgl_RenderedTextureHeight", fbo.getHeight());
	} else {
		fbo.getTextureReference(0).bind();
	}
	glBegin(GL_QUADS);
	
	glTexCoord2f(0, 0);
	glVertex2f(0, 0);
	
	glTexCoord2f(fbo.getWidth(), 0);
	glVertex2f(ofGetWidth(), 0);
	
	glTexCoord2f(fbo.getWidth(), fbo.getHeight());
	glVertex2f(ofGetWidth(), ofGetHeight());
	
	glTexCoord2f(0, fbo.getHeight());
	glVertex2f(0, ofGetHeight());
	
	glEnd();

	if(shading) {
		fxaa.end();
	} else {
		fbo.getTextureReference(0).unbind();
	}

}
コード例 #20
0
ファイル: Scene.cpp プロジェクト: elaye/ofxKUI
void Scene::draw(){
  ofEnableLighting();
    ofEnableDepthTest();
    material.begin();
      for(auto& o : objects){
        o.draw();
      }
    material.end();
  ofDisableLighting();
}
コード例 #21
0
//--------------------------------------------------------------
void PinballChinoManager::draw(){
    
	
	camera.begin();
	glEnable( GL_DEPTH_TEST );
    
   
    chinoLights.setMainLightPosition(myScenario.lightPos);
    
    
	ofEnableLighting();
    chinoLights.enable();
    

    // debug draw
    if(bDrawDebug){
        //myScenario.drawDebug();
        
        world.drawDebug();
        // draw the box that is used to detect if the ball is outside the scenario
        ofNoFill();
        ofDrawBox(0, 0, 0, myScenario.ballLimitsBoxSize);
        ofDrawSphere(myScenario.lightPos, 2);
        ofFill();
         
    }
	
	//Draw Scenario
	myScenario.draw(ScenarioEditor::getInstance()->bEscenarioEditorMode);
	
	//Draw Sceario shadow Map
	//simple_shadow.begin();
    //myScenario.draw(ScenarioEditor::getInstance()->bEscenarioEditorMode);
	//simple_shadow.end();
	
	chinoLights.disable();
	ofDisableLighting();

 
	glDisable(GL_DEPTH_TEST);
	camera.end();

    
    statusDisplay.draw();
    missionDisplay.draw();
    
    ScenarioEditor::getInstance()->draw();
    
    if(bDrawDebug){

        (currentMissions)[idcurrentMission]->debugDraw();
    }
    
    chinoLights.draw();
}
コード例 #22
0
ファイル: testApp.cpp プロジェクト: aleonard/KinectWorkshop
void testApp::draw() {
	ofBackground(0);
	
	easyCam.begin();
	ofScale(1, -1, -1); // orient the point cloud properly
	ofTranslate(0, 0, -650); // rotate about z = 150 cm
	glEnable(GL_DEPTH_TEST);
	ofSetColor(255, 100, 30);
	if(drawWireframe) {
		ofDisableLighting();
		mesh.drawWireframe();
	} else {
		ofEnableLighting();
		mesh.drawFaces();
	}
	easyCam.end();
	
	ofDisableLighting();
	ofDrawBitmapString(drawWireframe ? "rendering wireframe" : "rendering mesh", 10, 20);
}
コード例 #23
0
ファイル: ofApp.cpp プロジェクト: Daandelange/openFrameworks
//--------------------------------------------------------------
void ofApp::draw(){
    ofEnableLighting();
    ofBackgroundGradient(ofColor(65,62,50),ofColor(25,22,10) );
    
    // disable normals if a key is pressed
    if(ofGetKeyPressed() || ofGetMousePressed()){
        mesh.disableNormals();
    }else{
        mesh.enableNormals();
    }
    
    cam.begin();
    mesh.enableColors();
    mesh.drawWireframe();
    mesh.disableColors();
    ofSetColor(137,137,140);
    ofFill();

    #ifndef TARGET_OPENGLES
    glEnable(GL_POLYGON_OFFSET_LINE);
    glPolygonOffset(-1,-1);
    #endif

    mesh.drawFaces();
    ofSetColor(255,255,255);
    light.draw();
    
    
    // draw our normals, and show that they are perpendicular to the vector from the center to the vertex
    vector<ofVec3f> n = mesh.getNormals();
    vector<ofVec3f> v = mesh.getVertices();
    float normalLength = 50.;
    
    if(!ofGetKeyPressed()){
        ofDisableLighting();
        ofSetColor(255,255,255,70);         
        for(unsigned int i=0; i < n.size() ;i++){
            ofDrawLine(v[i].x,v[i].y,v[i].z,
                   v[i].x+n[i].x*normalLength,v[i].y+n[i].y*normalLength,v[i].z+n[i].z*normalLength);

            ofDrawLine(.98*v[i].x,.98*v[i].y,.98*v[i].z,
                   .98*v[i].x+n[i].x*normalLength*.2,.98*v[i].y+n[i].y*normalLength*.2,.98*v[i].z+n[i].z*normalLength*.2);
            ofDrawLine(.98*v[i].x+n[i].x*normalLength*.2,.98*v[i].y+n[i].y*normalLength*.2,.98*v[i].z+n[i].z*normalLength*.2,
                   v[i].x+n[i].x*normalLength*.2,v[i].y+n[i].y*normalLength*.2,v[i].z+n[i].z*normalLength*.2);
        }
    }
               

    cam.end();

    ofSetColor(255,255,255);
    ofDrawBitmapString("press any key or mouse button to disable mesh normals", 20,20);
    ofDrawBitmapString("light", cam.worldToScreen(light.getGlobalPosition()) + ofPoint(10,0));
}
コード例 #24
0
ファイル: ofApp.cpp プロジェクト: elaye/ofxKUI
void ofApp::draw(){
  ofDisableLighting();
  ofBackgroundGradient( ofColor(40,40,40), ofColor(0,0,0), OF_GRADIENT_CIRCULAR); 

  cam.begin();
    scene.draw();
  cam.end();

  drawHelp();

  kui.draw();
}
コード例 #25
0
ファイル: ofApp.cpp プロジェクト: 6uclz1/openFrameworks
//--------------------------------------------------------------
void ofApp::draw(){
    ofSetColor(255);
    
    ofEnableBlendMode(OF_BLENDMODE_ALPHA);
    
	ofEnableDepthTest();
    
    glShadeModel(GL_SMOOTH); //some model / light stuff
    light.enable();
    ofEnableSeparateSpecularLight();

    ofPushMatrix();
    ofTranslate(model.getPosition().x+100, model.getPosition().y, 0);
    ofRotate(-mouseX, 0, 1, 0);
    ofTranslate(-model.getPosition().x, -model.getPosition().y, 0);
    model.drawFaces();
    ofPopMatrix();

    glEnable(GL_NORMALIZE);

    ofPushMatrix();
    ofTranslate(model.getPosition().x-300, model.getPosition().y, 0);
    ofRotate(-mouseX, 0, 1, 0);
    ofTranslate(-model.getPosition().x, -model.getPosition().y, 0);
    
    ofxAssimpMeshHelper & meshHelper = model.getMeshHelper(0);
    
    ofMultMatrix(model.getModelMatrix());
    ofMultMatrix(meshHelper.matrix);
    
    ofMaterial & material = meshHelper.material;
    if(meshHelper.hasTexture()){
        meshHelper.getTextureRef().bind();
    }
    material.begin();
    mesh.drawWireframe();
    material.end();
    if(meshHelper.hasTexture()){
        meshHelper.getTextureRef().unbind();
    }
    ofPopMatrix();
    
    ofDisableDepthTest();
    light.disable();
    ofDisableLighting();
    ofDisableSeparateSpecularLight();
    
    ofSetColor(255, 255, 255 );
    ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate(), 2), 10, 15);
    ofDrawBitmapString("keys 1-5 load models, spacebar to trigger animation", 10, 30);
    ofDrawBitmapString("drag to control animation with mouseY", 10, 45);
    ofDrawBitmapString("num animations for this model: " + ofToString(model.getAnimationCount()), 10, 60);
}
コード例 #26
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();
}
コード例 #27
0
ファイル: ofApp.cpp プロジェクト: Avatarchik/ofxEasyAR
//--------------------------------------------------------------
void ofApp::draw(){

	/*mEasyAR.augmenter_.drawVideoBackground();*/

	mVideoFrame.draw(0, 0);
	ofSetColor(255, 255, 255);
	ofDrawBitmapString("fps: " + ofToString(ofGetFrameRate(), 2), 10, 15);

	EasyAR::Frame _frame = mEasyAR.augmenter_.newFrame(mEasyAR.tracker_);

	EasyAR::AugmentedTarget::Status status = _frame.targets()[0].status();

	if (status == EasyAR::AugmentedTarget::kTargetStatusTracked) 
	{
		EasyAR::Matrix44F projectionMatrix = EasyAR::getProjectionGL(mEasyAR.camera_.cameraCalibration(), 0.2f, 500.f);
		EasyAR::Matrix44F cameraview = EasyAR::getPoseGL(_frame.targets()[0].pose());
		EasyAR::ImageTarget target = _frame.targets()[0].target().cast_dynamic<EasyAR::ImageTarget>();
		
		ofEnableBlendMode(OF_BLENDMODE_ALPHA);

		ofEnableDepthTest();
#ifndef TARGET_PROGRAMMABLE_GL    
		glShadeModel(GL_SMOOTH); //some model / light stuff
#endif
		mLight.enable();
		ofEnableSeparateSpecularLight();

		ofPushMatrix();

		glViewport(0, 0, 640, 480);
		glMatrixMode(GL_PROJECTION);
		glLoadMatrixf(&projectionMatrix.data[0]);

		glMatrixMode(GL_MODELVIEW);
		glLoadMatrixf(&cameraview.data[0]);

		//mBox.setScale(0.02f);
		//mBox.draw();

		mModel.drawFaces();
		ofPopMatrix();

		ofDisableDepthTest();
		mLight.disable();
		ofDisableLighting();
		ofDisableSeparateSpecularLight();

		//ofLog() << "marker detected" << std::endl;
	}


}
コード例 #28
0
ファイル: ofApp.cpp プロジェクト: chimanaco/ofStudies
//--------------------------------------------------------------
void ofApp::draw(){
    ofBackgroundGradient(30, 0);
    float t = ofGetElapsedTimef();
    //bg.draw(0, 0);
    
    cam.begin();
    cam.setPosition(ofVec3f(cameraXRadius * cos(t * 0.1f), 300, cameraZRadius * sin(t * 0.1f)));
    //cam.setPosition(ofVec3f(0, 300, 1000));
    cam.lookAt(ofVec3f(0, 0, 0));
    
    ofEnableDepthTest();
    ofEnableLighting();
    
    pointLight.enable();
    pointLight2.enable();
    pointLight3.enable();
    
    material.begin();
    texture.getTextureReference().bind();
				
				ofPushMatrix();
				//ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2, 0);
				ofRotateZ(t * 10.0f);
				
				// Box
				for (int i = 0; i < NUM; i++)
                {
                    ofPushMatrix();
                    //ofScale(cos(t * 0.01) * i / NUM * 5, 1.0, 1.0);
                    //ofScale(cos( (t + i) * 0.8) * 3.0, 1.0, 1.0);
                    
                    //float spinX = sin(ofGetElapsedTimef()*.35f)*i;
                    //float spinY = cos(ofGetElapsedTimef()*.075f)*(i+1);
                    //float spinY = (t + i) *5.075f;
                    //float spinY = sin( (t + i * 0.3) * 0.001f ) * speed;
                    float spinY = i * 0.001f * speed;
                    boxes[i].rotate(spinY, 0, 1.0, 0.0);
                    //boxes[i].rotate(i/NUM*360,0,1.0,0.0);
                    boxes[i].draw();
                    ofPopMatrix();
                }
    
				ofPopMatrix();
    material.end();
    
    ofDisableLighting();
    
    ofDisableDepthTest();
    cam.end();
    // gui
    gui.draw();
}
コード例 #29
0
//--------------------------------------------------------------
void ofApp::draw(){
	ofClear(0);
	ofBackground(0);

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LEQUAL);
	glDepthMask(true);

    //zoom / distance
    if(zoomDistance < 400) zoomDistance = 400;
    if(zoomDistance > 6000) zoomDistance = 6000;
	cam.setDistance(zoomDistance);

	cam.begin();

	ofPushMatrix();
		//earth
		//rot += 1;
		// ofRotate(rot, 0, 1, 0);
		ofScale(scaler, scaler, scaler);
		sun.enable();
		sun.orbit(sunCoordinates.x, sunCoordinates.y, earthSphere.getRadius(), earthSphere.getGlobalPosition());
		ofSetColor(255);
		colorMap.bind();
    ofPushMatrix();
            ofScale(1, -1, 1);
			earthSphere.draw();
    ofPopMatrix();
		colorMap.unbind();
		Manager.draw();
		sun.draw();
		sun.disable();

		//background
		backgroundMap.bind();
			backgroundSphere.draw();
		backgroundMap.unbind();

	ofPopMatrix();

	cam.end();

	glDisable(GL_DEPTH_TEST);
	ofDisableAlphaBlending();
	ofDisableBlendMode();
	ofDisableLighting();


	//UI
	interface.draw();

}
コード例 #30
0
ファイル: ofApp.cpp プロジェクト: gewang/ofxChucK
//------------------------------------------------------------------------------
// name: draw()
// desc: draw the scene
//------------------------------------------------------------------------------
void ofApp::draw()
{
    // check
    if( m_message != "" )
    {
        // draw it
        ofDrawBitmapString( m_message, 30, 30, 0 );
    }
    
    // synchronize
    VR::instance()->lock();
    //--------------------------------------------------------------------------
    // draw ChucK-controlled elements
    //--------------------------------------------------------------------------
    // enable depth test
    ofEnableDepthTest();
    
    // Camera params
    m_camera.setFov( 90 );                             // set fov
    m_camera.setNearClip( .1 );                        // set near clipping plane
    m_camera.setPosition( ofVec3f(0,0,10) );           // set position
    m_camera.lookAt( ofVec3f(0,0,0), ofVec3f(0,1,0) ); // look at
    
    // Start camera
    m_camera.begin();

    // Render light
    if( VR::instance()->lightSwitch() ) ofEnableLighting();
    else ofDisableLighting();
    
    // Update it!
    vr->root()->renderAll();
    
    // Stop rendering light
    ofDisableLighting();
    
    // Sychronize
    VR::instance()->release();
}