예제 #1
0
void DrawNetwork()
{      
    // draw vertices
	glBegin(GL_POINTS);
		
		for ( int i = 0; i < physics->numberOfParticles(); ++i )
		{
			Particle* v = physics->getParticle( i );
			if(i == selected_index)
				glColor3f(0,1,0);
			else
				glColor3f(0.63f, 0.63f, 0.63f);
			glVertex2f(v->position.x, v->position.y);
		}
	glEnd();
    
    // draw springs 
	glBegin(GL_LINES);
		glColor3f(0.5,0.5,0.5);
		for ( int i = 0; i < physics->numberOfSprings(); ++i )
		{
			Spring* e = physics->getSpring( i );
			Particle* a = e->getOneEnd();
			Particle* b = e->getTheOtherEnd();
			glVertex2f(a->position.x, a->position.y);
			glVertex2f(b->position.x, b->position.y);                 
		}
	glEnd();
}
//--------------------------------------------------------------
void testApp::draw(){

	// draw vertices
    glColor3f(0.63f, 0.63f, 0.63f);
    for ( int i = 0; i < physics->numberOfParticles(); ++i )
    {
        Particle* v = physics->getParticle( i );
		ofCircle( v->mPos, NODE_SIZE/2.0f );
    }
    
    // draw springs 
	ofSetColor(ofColor::black );
    for ( int i = 0; i < physics->numberOfSprings(); ++i )
    {
        Spring* e = physics->getSpring( i );
        Particle* a = e->getOneEnd();
        Particle* b = e->getTheOtherEnd();
        ofLine( a->mPos, b->mPos );    
    }

}