void DrawModel( const PorousModel& model ) { const static FPoint radius( 0.5, 0.5, 0.5 ); static Point<long> pnt; static Point<ulong> sz; static FPoint center, p; GLfloat material[3]; COLORREF color; GLUquadric *q = gluNewQuadric(); sz = model.GetSize(); center.Init( 0.5f*sz.x, 0.5f*sz.y, 0.5f*sz.z ); double volume = double(sz.x)*sz.y*sz.z; int quality; if( volume < 1e6 ) quality = 10; else if ( volume < 1e9 ) quality = 5; else quality = 3; for( pnt.x = 0; pnt.x < long(sz.x); ++pnt.x ) for( pnt.y = 0; pnt.y < long(sz.y); ++pnt.y ) for( pnt.z = 0; pnt.z < long(sz.z); ++pnt.z ) if( model.GetCellColor( pnt, &color ) ) { material[0] = float(GetRValue(color))/0xFF; material[1] = float(GetGValue(color))/0xFF; material[2] = float(GetBValue(color))/0xFF; glMaterialfv( GL_FRONT, GL_DIFFUSE, material ); copy_vector( p, pnt ); p += radius; p -= center; glTranslatef( p.x, -p.z, -p.y ); gluSphere( q, 0.7, quality, quality ); glTranslatef( -p.x, p.z, p.y ); } //material[0] = material[1] = 1.0f; //material[2] = 0.0f; //glMaterialfv( GL_FRONT, GL_DIFFUSE, material ); //glTranslatef( -sz.x/5, sz.z/5, 0 ); //gluSphere( q, 1, 10, 10 ); //glTranslatef( sz.x/5, -sz.z/5, 0 ); //gluDeleteQuadric( q ); }