Beispiel #1
0
//--------------------------------------------------------------
void testApp::draw() {
    ofBackgroundGradient(ofColor(50), ofColor(0));
    // draw from the live kinect
//    ofSetColor(255);
//    kinect.drawDepth(10, 10, 400, 300);
//    kinect.draw(420, 10, 400, 300);

    
    glEnable(GL_DEPTH_TEST);
    static ofEasyCam cam;
    cam.begin();
    ofScale(1, -1);
    ofTranslate(-320, -240);
    
    ofSetColor(255);
    mesh.drawFaces();

//    glPointSize(10);
//    mesh.drawVertices();
    
    cam.end();
    
    ofSetColor(0);
    ofDrawBitmapString(ofToString(ofGetFrameRate()), 20, 20);
}
	void draw()
	{
		ofEnableDepthTest();
		
		cam.begin();
		
		ofDisableLighting();
		cube->draw(5000);
		
		cube->enable();
		cube->bind();
		{
			light.enable();
			light.setAmbientColor(ofColor(50, 50, 50));
			
			float t = ofGetElapsedTimef() * 0.5;
			light.setPosition(ofSignedNoise(1, 0, 0, t) * 2000,
							  ofSignedNoise(0, 1, 0, t) * 2000,
							  ofSignedNoise(0, 0, 1, t) * 2000);

			ofDrawSphere(0, 0, 0, 200);
			
			light.disable();
		}
		cube->unbind();
		cube->disable();
		
		cam.end();
	}
Beispiel #3
0
//--------------------------------------------------------------
void testApp::draw()
{
    shader.begin();
    shader.setUniform1f("elapsedTime", ofGetElapsedTimef());
    shader.setUniform2f("mouse", mouseX, mouseY);
    shader.setUniform2f("resolution", ofGetWindowWidth(), ofGetWindowHeight());
    shader.end();
    
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_BACK);
	
	ofEnableAlphaBlending();
    
	cam.begin();

    shader.begin();

	for (int i = 0; i < abc.size(); i++)
	{
		ofMesh mesh;
		if (abc.get(i, mesh))
		{
			ofSetColor(255);
			mesh.draw();
			// mesh.drawWireframe();
		}
	}

    shader.end();

	cam.end();
    
    glDisable(GL_DEPTH_TEST);
}
Beispiel #4
0
	void draw()
	{
		ofEnableDepthTest();
		
		cam.begin();
		mesh.draw();
		cam.end();
	}
//--------------------------------------------------------------
void testApp::draw()
{
	cam.begin();
	
	root.draw();
	
	cam.end();
}
Beispiel #6
0
 void draw()
 {
     ofClear(0);
     cam.begin();
     neuron.debugDraw();
     ofDrawAxis(100);
     cam.end();
 }
Beispiel #7
0
//--------------------------------------------------------------
void ofApp::draw(){

    
    cam.begin();
    for (int i = 0; i < scene.getMeshes().size(); i++){
        scene.getMeshes()[i]->drawWireframe();
    }
    cam.end();
}
Beispiel #8
0
    void draw() {
        ofBackground(100);
        cam.begin();
        ofSetColor(ofRandom(255), ofRandom(255),ofRandom(255));
        ofDrawBox(0, 0, 0, 200, 200, 200);
        ofTranslate(-128, -128, -128);
        mesh.draw();
        cam.end();

    }
Beispiel #9
0
	void draw() {
		ofBackground(0);
		cam.begin();
		ofSetLineWidth(2);
		ofSetColor(ofColor::red, 16);
		mesh.drawWireframe();
		glPointSize(4);
		ofSetColor(ofColor::white);
		controlPoints.draw();
		cam.end();
	}
Beispiel #10
0
	void draw()
	{
		ofEnableDepthTest();
		
		cam.begin();
		light0.enable();
		light1.enable();

		ofScale(0.3, 0.3, 0.3);
		mesh.draw();
		cam.end();
	}
Beispiel #11
0
//--------------------------------------------------------------
void testApp::draw(){
	ofBackgroundGradient(ofColor(64), ofColor(0));
	
	ofSetColor(255);
	ofDrawBitmapString("rotate: " + ofToString(rotationPosition), 10, 20);
	ofDrawBitmapString("swipe: " + ofToString(swipePosition), 10, 40);
	ofDrawBitmapString("magnify: " + ofToString(magnifyPosition), 10, 60);
	ofDrawBitmapString("scroll: " + ofToString(scrollPosition), 10, 80);
	ofDrawBitmapString("position: " + ofToString(mousePosition), 10, 100);
	cam.begin();
	
	ofPushMatrix();
	ofTranslate(0, -180, 0);
	ofDrawGrid(1000, 40, false, false, true, false);
	ofPopMatrix();
	
	ofSetColor(ofColor::gray);	
	mesh.drawWireframe();
	
	glPointSize(2);
	ofSetColor(ofColor::white);
	mesh.drawVertices();
	cam.end();
	
	int n = mesh.getNumVertices();
	float nearestDistance = 0;
	ofVec2f nearestVertex;
	int nearestIndex;
	ofVec2f mouse(mouseX, mouseY);
	for(int i = 0; i < n; i++) {
		ofVec3f cur = cam.worldToScreen(mesh.getVertex(i));
		float distance = cur.distance(mouse);
		if(i == 0 || distance < nearestDistance) {
			nearestDistance = distance;
			nearestVertex = cur;
			nearestIndex = i;
		}
	}
	
	ofSetColor(ofColor::gray);
	ofLine(nearestVertex, mouse);
	
	ofNoFill();
	ofSetColor(ofColor::yellow);
	ofSetLineWidth(2);
	ofCircle(nearestVertex, 4);
	ofSetLineWidth(1);
	
	ofVec2f offset(10, -10);
	ofDrawBitmapStringHighlight(ofToString(nearestIndex), mouse + offset);
}
Beispiel #12
0
//--------------------------------------------------------------
void testApp::draw(){
    
   
    //draw the fbos directly
    if (drawFbos) {
        //draw fbo1 contents in the top left
        ofPushMatrix();
        ofTranslate(0, 0);
        fbo1.draw(0, 0);
        ofPopMatrix();

        //draw fbo2 contents in the underneath it
        ofPushMatrix();
        ofTranslate(0, ofGetHeight()/2.0);
        //here we pass the size arguments as well, so oF will scale it to fit
        fbo2.draw(0, 0, ofGetWidth()/2.0, ofGetHeight()/2.0);
        ofPopMatrix();

        //draw main fbo
        ofPushMatrix();
        ofTranslate(ofGetWidth()/2.0, 0);
        Mainfbo.draw(0,0);
        ofPopMatrix();
        
        //Pointeur souris
        ofFill();
        ofSetColor(255, 0, 0);
        ofSphere(ofGetMouseX(), ofGetMouseY(), 5);
        
        //draw some borders
        ofSetColor(255);
        ofSetLineWidth(3);
        ofLine(ofGetWidth()/2.0, 0, ofGetWidth()/2.0, ofGetHeight());
        ofLine(0, ofGetHeight()/2.0, ofGetWidth()/2.0, ofGetHeight()/2.0);
    } else {
        
        //or you can use getTextureReference() and bind the fbo contents
        //to use as a texture.
        //you will need texture coordinates set in your mesh for this to work

        ofClear(30);
        cam.begin();
        Mainfbo.getTextureReference().bind();
        mesh1.draw();
        Mainfbo.getTextureReference().unbind();
        cam.end();

    }
}
Beispiel #13
0
//--------------------------------------------------------------
void testApp::draw()
{
	ofEnableBlendMode(OF_BLENDMODE_ADD);
	
	cam.begin();

	ofEnableAlphaBlending();
	sys.draw();

	em.draw();
	
	mod.draw();
	mod2.draw();

	cam.end();
}
Beispiel #14
0
    void draw() {
        ofBackgroundGradient(64, 0);

	if(reflect || sreflect) 
		env.draw(0,0,env.getWidth()/8,env.getHeight()/8);
	if(sreflect) 
		env1.draw(env.getWidth()/8,0,env1.getWidth()/8,env1.getHeight()/8);

	ofEnableDepthTest();
        cam.begin();
        shader.begin();

	if(sreflect){
//        	shader.setUniform3f("CameraPos",cam.getGlobalPosition().x, cam.getGlobalPosition().y, cam.getGlobalPosition().z);
//		shader.setUniformMatrix4f("ModelWorld4x4",cam.getGlobalTransformMatrix());
        	shader.setUniform3f("CameraPos",cam.getPosition().x, cam.getPosition().y, cam.getPosition().z);
		shader.setUniformMatrix4f("ModelWorld4x4",cam.getModelViewMatrix());//getLocalTransformMatrix());
	        shader.setUniformTexture("frontMap",  env,1);
	        shader.setUniformTexture("backMap",  env1,2);
	}

	if(reflect){
        	shader.setUniformTexture("colorMap",env1,1);
	        shader.setUniformTexture("envMap",  env,2);
	}else if(sreflect==false){
        	shader.setUniformTexture("texture", img, 1);
        	shader.setUniform1f("time", ofGetElapsedTimef());
	}

	if(cube)
		ofDrawBox(200);
	else {
		ofTranslate(0,-150,0);
		ofRotateX(-90);
		ofRotateY(-90);
		ofRotateZ(45);
		model.drawFaces();
	}

        shader.end();
        cam.end();
	ofDisableDepthTest();

        ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
    }
Beispiel #15
0
//--------------------------------------------------------------
void testApp::draw()
{
	cam.begin();

	glPointSize(4);
	
	// get meshes and draw
	
	{
		ofMesh mesh;
		abc.get("/Cloner/ClonerShape", mesh);
		
		ofSetColor(255, 0, 0);
		mesh.draw();
	}

	{
        std::vector<glm::vec3> points;
		abc.get("/Emitter/EmitterCloud", points);
		
		ofSetColor(0, 255, 0);
		glBegin(GL_POINTS);
		for (int i = 0; i < points.size(); i++)
			glVertex3fv(&points[i].x);
		glEnd();
	}

	{
		vector<ofPolyline> curves;
		abc.get("/Tracer/TracerSpline", curves);
		
		ofSetColor(0, 0, 255);
		for (int i = 0; i < curves.size(); i++)
			curves[i].draw();
	}
	
	// or simply, abc.draw();

	cam.end();
	
	ofSetColor(255);
	
	ofDrawBitmapString(ofToString(abc.getTime()) + "/" + ofToString(abc.getMaxTime()), 10, 20);
}
Beispiel #16
0
void draw() {
    
    // The camera will modify the view of everything between camera.being()
    // and camera.end().  
    camera.begin();
    
    // Draw the bounding box.
    drawBoundingBox();
    
    // Draw the particles.
    drawParticles();
    
    // Draw lines connecting the particles.
    drawParticleLines();
    
    // End the camera.
    camera.end();
    
}
Beispiel #17
0
//--------------------------------------------------------------
void testApp::draw()
{
	cam.begin();

	glPointSize(4);
	
	{
		ofMesh mesh;
		abc.get("/polymesh")->get(mesh);
		
		ofSetColor(255, 0, 0);
		mesh.draw();
	}

	{
		vector<ofVec3f> points;
		abc.get("/points")->get(points);
		
		ofSetColor(0, 255, 0);
		glBegin(GL_POINTS);
		for (int i = 0; i < points.size(); i++)
			glVertex3fv(points[i].getPtr());
		glEnd();
	}

	{
		vector<ofPolyline> curves;
		abc.get("/curves")->get(curves);
		
		ofSetColor(0, 0, 255);
		for (int i = 0; i < curves.size(); i++)
			curves[i].draw();
	}

	// or simply, abc.draw();
	
	cam.end();
	
	ofSetColor(255);
	
	ofDrawBitmapString(ofToString(abc.getTime()) + "/" + ofToString(abc.getMaxTime()), 10, 20);
}
Beispiel #18
0
//--------------------------------------------------------------
void testApp::draw()
{
    ofEnableLighting();
    // the position of the light must be updated every frame,
    // call enable() so that it can update itself //
    pointLight.enable();
    material.begin();

	cam.begin();

	// get meshes and draw
	{
		ofMesh mesh;
		abc.get("/Aa-CHAN", mesh);
		ofSetColor(0, 0, 255);
		mesh.draw();
	}
	{
		ofMesh mesh;
		abc.get("/KASHIYUKA", mesh);
		ofSetColor(255, 0, 0);
		mesh.draw();
	}
	{
		ofMesh mesh;
		abc.get("/NOCCHi", mesh);
		ofSetColor(255, 255, 255);
		mesh.draw();
	}

	// or simply, abc.draw();

	cam.end();
	material.end();
	// turn off lighting //
    ofDisableLighting();
	
	ofSetColor(255);
	
	ofDrawBitmapString(ofToString(abc.getTime()) + "/" + ofToString(abc.getMaxTime()), 10, 20);
}
Beispiel #19
0
void BufferCont::drawPoint(ofRectangle &view, ofEasyCam & cam, vector <ofVec3f> &data){

	m_vbo.setVertexData(&data[0], data.size(), GL_STATIC_DRAW);
	m_vbo.setNormalData(&m_sizes.front()[0], m_sizes.front().size(), GL_STATIC_DRAW);
	m_vbo.setColorData(&m_indiColor.front()[0], m_indiColor.front().size(), GL_STATIC_DRAW);
	glDepthMask(GL_FALSE);
	//ofEnableBlendMode(OF_BLENDMODE_ADD);
	ofEnablePointSprites();

	m_shader.begin();
	cam.begin(view);
	m_texture.bind();
	m_vbo.draw(GL_POINTS, 0, data.size());
	m_texture.unbind();
	cam.end();
	m_shader.end();

	ofDisablePointSprites();
	//ofDisableBlendMode();
	glDepthMask(GL_TRUE);
}
Beispiel #20
0
		void draw() {
			ofBackground(25);

			fbo.begin();
			ofClear(0,0,0,0);
			ofEnableDepthTest();
			camera.begin();
			    glPushMatrix();

			    glEnable(GL_BLEND);
		        glBlendFunc(GL_SRC_ALPHA, GL_ONE);
		        glEnable(GL_ALPHA_TEST);
		        glAlphaFunc(GL_GREATER, 0);

		        if(dvel) draw_velocity();
		        if(dden){
                        draw_density();
                }

                glDisable(GL_BLEND);
		        glDisable(GL_ALPHA_TEST);

		        glPopMatrix();
                if( drawAxis ){	ofDrawAxis(15); }

			camera.end();
			ofDisableDepthTest();
			fbo.end();

            shader.begin();
            shader.setUniformTexture("tex",fbo.getTextureReference(),0);
            shader.setUniform2f("resolution",dw,dh);
            shader.setUniform1f("timer",ofGetElapsedTimef());

            fbo.draw(0,0);

            shader.end();
			gui.draw();
		}
Beispiel #21
0
//--------------------------------------------------------------
void testApp::draw() {
	ofEnableAlphaBlending();

	cam.begin();
	
	ofDrawAxis(100);

	ofFill();

	// draw all markers set
	ofSetColor(255, 128);
	for (int i = 0; i < max(0, (int)natnet.getNumMarkersSet() - 1); i++) {
		for (int j = 0; j < natnet.getMarkersSetAt(i).size(); j++) {
			ofDrawBox(natnet.getMarkersSetAt(i)[j], 3);
		}
	}
	
	// draw all markers
	ofSetColor(255, 30);
	for (int i = 0; i < natnet.getNumMarker(); i++) {
		ofDrawBox(natnet.getMarker(i), 3);
	}

	ofNoFill();

	// draw filtered markers
	ofSetColor(255);
	for (int i = 0; i < natnet.getNumFilterdMarker(); i++) {
		ofDrawBox(natnet.getFilterdMarker(i), 10);
	}

	// draw rigidbodies
	for (int i = 0; i < natnet.getNumRigidBody(); i++) {
		const ofxNatNet::RigidBody &RB = natnet.getRigidBodyAt(i);

		if (RB.isActive())
			ofSetColor(0, 255, 0);
		else
			ofSetColor(255, 0, 0);

		ofPushMatrix();
		glMultMatrixf(RB.getMatrix().getPtr());
		ofDrawAxis(30);
		ofPopMatrix();

		glBegin(GL_LINE_LOOP);
		for (int n = 0; n < RB.markers.size(); n++) {
			glVertex3fv(RB.markers[n].getPtr());
		}
		glEnd();

		for (int n = 0; n < RB.markers.size(); n++) {
			ofDrawBox(RB.markers[n], 5);
		}
	}
	
	// draw skeletons
	for (int j = 0;  j < natnet.getNumSkeleton(); j++) {
		const ofxNatNet::Skeleton &S = natnet.getSkeletonAt(j);
		ofSetColor(0, 0, 255);
		
		for (int i = 0; i < S.joints.size(); i++) {
			const ofxNatNet::RigidBody &RB = S.joints[i];
			ofPushMatrix();
			glMultMatrixf(RB.getMatrix().getPtr());
			ofDrawBox(5);
			ofPopMatrix();
		}
	}

	cam.end();

	string str;
	str += "frames: " + ofToString(natnet.getFrameNumber()) + "\n";
	str += "data rate: " + ofToString(natnet.getDataRate()) + "\n";
	str += string("connected: ") + (natnet.isConnected() ? "YES" : "NO") + "\n";
	str += "num markers set: " + ofToString(natnet.getNumMarkersSet()) + "\n";
	str += "num marker: " + ofToString(natnet.getNumMarker()) + "\n";
	str += "num filtered (non regidbodies) marker: " +
		   ofToString(natnet.getNumFilterdMarker()) + "\n";
	str += "num rigidbody: " + ofToString(natnet.getNumRigidBody()) + "\n";
	str += "num skeleton: " + ofToString(natnet.getNumSkeleton()) + "\n";

	ofSetColor(255);
	ofDrawBitmapString(str, 10, 20);
}
Beispiel #22
0
//--------------------------------------------------------------
void testApp::draw()
{
	ofFill();

	cam.begin();
	/*
	glPointSize(4);
	
	// get meshes and draw
	
	{
		ofMesh mesh;
		abc.get("/Cloner/ClonerShape", mesh);
		
		ofSetColor(255, 0, 0);
		mesh.draw();
	}

	{
		vector<ofVec3f> points;
		abc.get("/Emitter/EmitterCloud", points);
		
		ofSetColor(0, 255, 0);
		glBegin(GL_POINTS);
		for (int i = 0; i < points.size(); i++)
			glVertex3fv(points[i].getPtr());
		glEnd();
	}

	{
		vector<ofPolyline> curves;
		abc.get("/Tracer/TracerSpline", curves);
		
		ofSetColor(0, 0, 255);
		for (int i = 0; i < curves.size(); i++)
			curves[i].draw();
	}
	
	*/

	// or simply, abc.draw();
	
	//ofMesh mesh;
	//abc.get("/Null/Sphere/SphereShape", mesh);
	//cout << mesh.getNumNormals() << endl;

	//ofLight l;
	//l.setPosition(mesh.getCentroid() + ofVec3f(0,0,0));
	//l.enable();
	//ofSetColor(ofColor::white);
	//ofSetColor(255, 0, 0);
	/*
	ofEnableDepthTest();
	texture.getTextureReference().bind();
//	mesh.draw();
	abc.draw();
	texture.getTextureReference().unbind();
	ofDisableDepthTest();
	*/
	//glCullFace( GL_FRONT );

	//abc.draw();

	ofEnableDepthTest();

	glEnable( GL_CULL_FACE );

	glCullFace( GL_BACK );
	//*

	ofSetColor( 255, 255, 255, 255.0 * 0.5 );

	for( int i=0; i<meshNames.size(); i++ ){
		ofxAlembic::IGeom *geo = abc.get( meshNames[i] );
		if( i == numTextured ){
			geo->drawTextured( &texture );
		}else{
			geo->draw();
		}
	}
	//*/
	glCullFace( GL_FRONT );
	ofSetColor( 255, 255, 255, 255.0 * 0.5 );
	//*
	for( int i=0; i<meshNames.size(); i++ ){
		ofxAlembic::IGeom *geo = abc.get( meshNames[i] );
		if( i == numTextured ){
			geo->drawTextured( &texture );
		}else{
			geo->draw();
		}
	}
	//*/
	glDisable( GL_CULL_FACE );

	cam.end();
	
	ofSetColor(255);
	
	ofDrawBitmapString(ofToString(abc.getTime()) + "/" + ofToString(abc.getMaxTime()), 10, 20);
}