Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

virtual void Impala::Visualization::Plot::HeightMap::Draw ( Plot plot  )  [inline, virtual]

this function calls all opengl statements to draw the plottable all scaling, translation and raotation should be done before this function is called

Todo:
decide what coordinate system to draw in, for now assume [-1..1] in all dimensions

Implements Impala::Visualization::Plot::Plottable.

Definition at line 31 of file HeightMap.h.

References Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::H(), mData, Impala::Visualization::Plot::Plottable::mMaxX, Impala::Visualization::Plot::Plottable::mMaxZ, Impala::Visualization::Plot::Plottable::mMinX, Impala::Visualization::Plot::Plottable::mMinZ, Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::Val(), Val2Material(), and Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::W().

00032     {
00033         if (mData == 0)
00034             return;
00035 
00036         // adjust rendering settings
00037         glPushAttrib(GL_ALL_ATTRIB_BITS);
00038         glEnable(GL_LIGHTING);
00039         glEnable(GL_LIGHT0);
00040         glEnable(GL_NORMALIZE);
00041         // draw surface sligtly behind lines
00042         glEnable(GL_POLYGON_OFFSET_FILL);
00043         glPolygonOffset(1,1);
00044 
00045         // setup light independent of model view
00046         glMatrixMode (GL_MODELVIEW);
00047         glPushMatrix();
00048         glLoadIdentity();
00049         GLfloat materialSpecular[] = { 1.0, 1.0, 1.0, 1.0 };
00050         GLfloat materialShininess[] = { 10.0 };
00051         GLfloat lightPosition[] = { 0.0, 0.0, 1000.0, 0.0 };
00052         glClearColor (0.0, 0.0, 0.0, 0.0);
00053         glShadeModel (GL_SMOOTH);
00054         glMaterialfv(GL_FRONT, GL_SPECULAR, materialSpecular);
00055         glMaterialfv(GL_FRONT, GL_SHININESS, materialShininess);
00056         glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
00057         glPopMatrix();
00058 
00059 
00060         int h = mData->H()-1;
00061         int w = mData->W()-1;
00062         double x,z;
00063         double dx = ((double)mMaxX-mMinX) / (double)w;
00064         double dz = ((double)mMaxZ-mMinZ) / (double)h;
00065         double v1,v2,v3,v4;
00066         z = mMinZ;
00067         for (int i=0 ; i<h ; i++)
00068         {
00069             x = mMinX;
00070             for (int j=0 ; j<w ; j++)
00071             {
00072                 v1 = mData->Val(j,i);
00073                 v2 = mData->Val(j,i+1);
00074                 v3 = mData->Val(j+1,i+1);
00075                 v4 = mData->Val(j+1,i);
00076 
00077                 // outlines
00078                 glBegin(GL_LINE_LOOP);
00079                 glColor3f(0, 0, 0);
00080                 glMaterialfv(GL_FRONT, GL_AMBIENT, materialSpecular);
00081                 glVertex3d(x,   v1,z);
00082                 glVertex3d(x,   v2,z+dz);
00083                 glVertex3d(x+dx,v3,z+dz);
00084                 glVertex3d(x+dx,v4,z);
00085                 glEnd();
00086 
00087                 // surface
00088                 glBegin(GL_QUADS);
00089                 glNormal3d(-dz*(v4-v1), -dx*(v2-v1), dx*dz);
00090                 Val2Material(v1); glVertex3d(x,   v1,z);
00091                 Val2Material(v2); glVertex3d(x,   v2,z+dz);
00092                 Val2Material(v3); glVertex3d(x+dx,v3,z+dz);
00093                 Val2Material(v4); glVertex3d(x+dx,v4,z);
00094                 glEnd();
00095 
00096                 x += dx;
00097             }
00098             z += dz;
00099         }
00100 
00101         // prevent our render settings from affecting the rest
00102         glPopAttrib();
00103     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:52:39 2010 for ImpalaSrc by  doxygen 1.5.1