void TunnelSegment::Draw( void ) { GLfloat x, y, z, new_z; GLfloat nX, nY; GLfloat S, T, Tnew; int stack, slice; float teta; if ( ! enabled ) return; PrepDraw(); if ( list < 0 ) { glNewList( list = 1, GL_COMPILE ); z = 0; T = 0; for( stack=0 ; stack < NSTACKS ; stack++ ) { Tnew = T + (double) SREP / (double) NSTACKS; glBegin( GL_QUAD_STRIP ); S = 0; new_z = z + length / NSTACKS; for( teta = 0, slice = 0 ; slice <= NSLICES ; slice++ ) { nX = cos( teta ); nY = sin( teta ); x = radius * cos( teta ); y = radius * sin( teta ); glNormal3f( nX, nY, 0.0 ); glTexCoord2f( S, T ); glVertex3f( x, y, z ); glNormal3f( nX, nY, 0.0 ); glTexCoord2f( S, Tnew ); glVertex3f( x, y, new_z ); // 1er segment est -z teta += 2.0 * pi / (double) NSLICES; S += (double) SREP / (double) NSLICES; } glEnd(); z = new_z; T =Tnew; } glEndList(); } else glCallList( list ); FinishDraw(); }
void Disk::Draw( void ) { if ( ! enabled ) return; PrepDraw(); gluDisk( quad, inner_radius, outer_radius, slices, loops ); FinishDraw(); }
void Cylinder::Draw( void ) { if ( ! enabled ) return; PrepDraw(); gluCylinder( quad, top_radius, bottom_radius, height, slices, stacks ); FinishDraw(); }
void Sphere::Draw( void ) { if ( ! enabled ) return; PrepDraw(); gluSphere( quad, radius, slices, stacks ); FinishDraw(); }
void OpenGLObject::Draw( void ) { if ( ! enabled ) return; PrepDraw(); FinishDraw(); }
void Ellipsoid::Draw( void ) { if ( ! enabled ) return; PrepDraw(); glScaled( x_distortion, y_distortion, z_distortion ); gluSphere( quad, max_radius, slices, stacks ); FinishDraw(); }
void Hole::Draw( void ) { double rx, ry, angle, angle_step = Pi / 128.0; if ( ! enabled ) return; PrepDraw(); glBegin( GL_POLYGON ); glVertex2f( width, height ); glVertex2f( width, 0.0 ); for ( angle = - angle_step; angle <= 0.5 * Pi + angle_step; angle += angle_step ) { rx = radius * cos( angle ); ry = radius * sin( angle ); glVertex2f( rx, ry ); } glVertex2f( 0.0, height ); glVertex2f( width, height ); glEnd(); glBegin( GL_POLYGON ); glVertex2f( - width, height ); glVertex2f( 0.0, height ); for ( angle = 0.5 * Pi - angle_step; angle <= Pi + angle_step; angle += angle_step ) { rx = radius * cos( angle ); ry = radius * sin( angle ); glVertex2f( rx, ry ); } glVertex2f( - width, 0.0 ); glVertex2f( - width, height ); glEnd(); glBegin( GL_POLYGON ); glVertex2f( - width, - height ); glVertex2f( - width, 0.0 ); for ( angle = Pi - angle_step; angle <= 1.5 * Pi + angle_step; angle += angle_step ) { rx = radius * cos( angle ); ry = radius * sin( angle ); glVertex2f( rx, ry ); } glVertex2f( 0.0, - height ); glVertex2f( - width, - height ); glEnd(); glBegin( GL_POLYGON ); glVertex2f( width, - height ); glVertex2f( 0.0, - height ); for ( angle = 1.5 * Pi - angle_step; angle <= 2.0 * Pi + angle_step; angle += angle_step ) { rx = radius * cos( angle ); ry = radius * sin( angle ); glVertex2f( rx, ry ); } glVertex2f( width, 0.0 ); glVertex2f( width, - height ); glEnd(); FinishDraw(); }
void IGraphics::Resize(int w, int h) { mWidth = w; mHeight = h; ReleaseMouseCapture(); mControls.Empty(true); DELETE_NULL(mDrawBitmap); DELETE_NULL(mTmpBitmap); PrepDraw(); mPlug->ResizeGraphics(w, h); }
void Patch::Draw( void ) { double x = width / 2.0; double y = length / 2.0; double z = 0.0; if ( ! enabled ) return; PrepDraw(); if ( texture ) { GLfloat u, v; glEnable( GL_TEXTURE_2D ); texture->Use(); glBegin(GL_QUADS); if ( texture->u_length ) u = umag * width / texture->u_length; else u = umag; if ( texture->v_length ) v = vmag * length / texture->v_length; else v = vmag; glNormal3d( 0.0, 0.0, - 1.0 ); glTexCoord2f(0.0f, 0.0f); glVertex3d( - x, - y, z ); glTexCoord2f(0.0f, v); glVertex3d( - x, y, z ); glTexCoord2f( u, v); glVertex3d( x, y, z ); glTexCoord2f( u, 0.0); glVertex3d( x, - y, z ); glEnd(); glDisable( GL_TEXTURE_2D ); } else { glBegin(GL_QUADS); glNormal3d( 0.0, 0.0, - 1.0 ); glVertex3d( - x, - y, z ); glVertex3d( - x, y, z ); glVertex3d( x, y, z ); glVertex3d( x, - y, z ); glEnd(); } FinishDraw(); }
void Assembly::Draw( void ) { if ( ! enabled ) return; PrepDraw(); for ( int i = 0; i < components; i++ ) { component[i]->Draw(); // Restore the color, in case the component changed it. // This does not work in the case where the assembly is supposed to use // the parent color. Need to find a way to push the color on the stack // or to query the color and save it to restore it later. if ( color[3] != USE_PARENT_COLOR ) glColor4fv( color ); } FinishDraw(); }
void Circle::Draw( void ) { double rx, ry, angle, angle_step = Pi / 10.0; if ( ! enabled ) return; PrepDraw(); glBegin( GL_POLYGON ); for ( angle = 0.0; angle < 2.0 * Pi; angle += angle_step ) { rx = radius * cos( angle ); ry = radius * sin( angle ); glVertex2f( rx, ry ); } glEnd(); FinishDraw(); }
void Frustrum::Draw( void ) { if ( ! enabled ) return; PrepDraw(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable( GL_LIGHTING ); draw_polygons(); glDisable( GL_LIGHTING ); glColor4fv( OpenGLColors[ RED ] ); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE ); draw_end(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable( GL_LIGHTING ); FinishDraw(); }
void Extrusion::Draw( void ) { double l2 = length / 2.0; int i, j; Vector3 delta, normal; if ( ! enabled ) return; PrepDraw(); /* Draw the ends first. */ glBegin( GL_POLYGON ); glNormal3d( 0.0, 0.0, - 1.0 ); for ( i = 0; i < vertices; i++ ) glVertex3d( vertex[i][X], vertex[i][Y], l2 ); glEnd(); glBegin( GL_POLYGON ); glNormal3d( 0.0, 0.0, 1.0 ); for ( i = vertices - 1; i >= 0; i-- ) glVertex3d( vertex[i][X], vertex[i][Y], - l2 ); glEnd(); /* Now draw the facets. */ for ( i = 0; i < vertices; i++ ) { j = ( i + 1 ) % vertices; // subtract_vectors( vertex[i], vertex[j], delta ); delta[0] = vertex[i][0] - vertex[j][0]; delta[1] = vertex[i][1] - vertex[j][1]; delta[2] = 0.0; ComputeCrossProduct( normal, delta, kVector ); NormalizeVector( normal ); glBegin( GL_POLYGON ); glNormal3dv( normal ); glVertex3d( vertex[i][X], vertex[i][Y], - l2 ); glVertex3d( vertex[i][X], vertex[i][Y], l2 ); glVertex3d( vertex[j][X], vertex[j][Y], l2 ); glVertex3d( vertex[j][X], vertex[j][Y], - l2 ); glEnd(); } FinishDraw(); }
void WindowFrame::Draw( void ) { double x = width / 2.0; double y = height / 2.0; double z = 0.0; if ( ! enabled ) return; PrepDraw(); glBegin(GL_QUADS); glNormal3d( 0.0, 0.0, - 1.0 ); glVertex3d( - x - thickness, - y - thickness, z ); glVertex3d( - x - thickness, y + thickness, z ); glVertex3d( - x, y, z ); glVertex3d( - x, - y, z ); glVertex3d( x, - y, z ); glVertex3d( x, y, z ); glVertex3d( x + thickness, y + thickness, z ); glVertex3d( x + thickness, - y - thickness, z ); glVertex3d( - x - thickness, - y - thickness, z ); glVertex3d( - x, - y, z ); glVertex3d( x, - y, z ); glVertex3d( x + thickness, - y - thickness, z ); glVertex3d( - x, y, z ); glVertex3d( - x - thickness, y + thickness, z ); glVertex3d( x + thickness, y + thickness, z ); glVertex3d( x, y, z ); glEnd(); FinishDraw(); }
void TunnelJunction::Draw( void ) { GLfloat *T; GLfloat dT; GLfloat Xold[NSLICES+1], Yold[NSLICES+1], Zold[NSLICES+1]; GLfloat x, y, z; GLfloat nXold[NSLICES+1], nYold[NSLICES+1], nZold[NSLICES+1], nX, nY, nZ; GLfloat S, Tnew; int stack, slice; float teta, phi; if ( ! enabled ) return; PrepDraw(); // Initialisation des Xolds (premier cercle de pts, phi=0) for(teta=0, slice=0 ; slice<=NSLICES ; slice++) { nXold[slice] = sin( teta ); nYold[slice] = - cos( teta ); nZold[slice] = 0; Xold[slice] = RSEG * sin( teta ); Yold[slice] = - RSEG * cos( teta ); Zold[slice] = 0; teta += 2.0 * pi / NSLICES; } phi = pi / 2.0 / NSTACKS; for(stack=0 ; stack<NSTACKS ; stack++) { glBegin(GL_QUAD_STRIP); Tnew = *T + dT * pi * RSEG / NSTACKS; S = 0; for( teta=0, slice=0; slice <= NSLICES ; slice++ ) { nX = sin(teta); nY = - cos( teta ) * cos( phi ); nZ = - cos( teta )* sin( phi ); x = RSEG * sin( teta ); y = - RSEG * ( cos( phi ) * ( 1.0 + cos(teta) ) - 1.0); z = - RSEG * sin( phi ) * ( 1.0 + cos( teta ) ); glNormal3f( nXold[slice], nYold[slice], nZold[slice] ); glTexCoord2f(S, *T); glVertex3f( Xold[slice], Yold[slice], Zold[slice] ); glNormal3f( nX, nY, nZ ); glTexCoord2f( S, Tnew ); glVertex3f( x, y, z ); nXold[slice] = nX; nYold[slice] = nY; nZold[slice] = nZ; Xold[slice] = x; Yold[slice] = y; Zold[slice] = z; S += (GLfloat) SREP / NSLICES; teta += 2.0 * pi / NSLICES; } glEnd(); phi += 90.0/NSTACKS; *T = Tnew; } FinishDraw(); }
void Bar::Draw( void ) { double x = width / 2.0; double y = thickness / 2.0; double z = length / 2.0; if ( ! enabled ) return; PrepDraw(); // Consider the position to be the end of the bar, not the middle. glTranslated( 0.0, 0.0, z ); glBegin( GL_POLYGON ); glNormal3d( 0.0, 0.0, - 1.0 ); glVertex3d( - x, y, - z ); glVertex3d( - x, y, z ); glVertex3d( x, y, z ); glVertex3d( x, y, - z ); glEnd(); glBegin( GL_POLYGON ); glNormal3d( 0.0, 0.0, 1.0 ); glVertex3d( - x, - y, - z ); glVertex3d( x, - y, - z ); glVertex3d( x, - y, z ); glVertex3d( - x, - y, z ); glEnd(); if ( capped ) { glBegin( GL_POLYGON ); glNormal3d( 0.0, - 1.0, 0.0 ); glVertex3d( - x, - y, z ); glVertex3d( - x, y, z ); glVertex3d( x, y, z ); glVertex3d( x, - y, z ); glEnd(); glBegin( GL_POLYGON ); glNormal3d( 0.0, 1.0, 0.0 ); glVertex3d( - x, - y, - z ); glVertex3d( x, - y, - z ); glVertex3d( x, y, - z ); glVertex3d( - x, y, - z ); glEnd(); } glBegin( GL_POLYGON ); glNormal3d( - 1.0, 0.0, 0.0 ); glVertex3d( x, - y, - z ); glVertex3d( x, y, - z ); glVertex3d( x, y, z ); glVertex3d( x, - y, z ); glEnd(); glBegin( GL_POLYGON ); glNormal3d( 1.0, 0.0, 0.0 ); glVertex3d( - x, - y, - z ); glVertex3d( - x, - y, z ); glVertex3d( - x, y, z ); glVertex3d( - x, y, - z ); glEnd(); FinishDraw(); }