From: Tim R. <ti...@us...> - 2004-07-17 20:50:48
|
Update of /cvsroot/csdopenglnet/csdOpenGL/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23988 Modified Files: gears.cs Log Message: cant' find error i suppose it in the "draw outward faces of teeth" section Index: gears.cs =================================================================== RCS file: /cvsroot/csdopenglnet/csdOpenGL/samples/gears.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gears.cs 17 Jul 2004 19:34:35 -0000 1.2 --- gears.cs 17 Jul 2004 20:50:39 -0000 1.3 *************** *** 2,8 **** using System; ! public class Lesson01GLUT : csdGL { ! protected float angle = 0.0f; protected uint gear1; protected uint gear2; --- 2,8 ---- using System; ! public class Gears : csdGL { ! protected double rotAng = 0.0f; protected uint gear1; protected uint gear2; *************** *** 12,16 **** protected const double view_rotz = 0.0; ! public Lesson01GLUT() { glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutInitWindowSize( 640, 480 ); --- 12,16 ---- protected const double view_rotz = 0.0; ! public Gears() { glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutInitWindowSize( 640, 480 ); *************** *** 35,39 **** protected void redraw() { ! angle += 2.0f; glutPostRedisplay(); } --- 35,39 ---- protected void redraw() { ! rotAng += 0.5f; glutPostRedisplay(); } *************** *** 44,55 **** float[] green = { 0.0f, 0.8f, 0.2f, 1.0f }; float[] blue = { 0.2f, 0.2f, 1.0f, 1.0f }; ! /* glShadeModel( GL_SMOOTH ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClearDepth( 1.0f ); - glEnable( GL_DEPTH_TEST ); - glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); ! */ glLightfv( GL_LIGHT0, GL_POSITION, pos ); glEnable( GL_CULL_FACE ); --- 44,53 ---- float[] green = { 0.0f, 0.8f, 0.2f, 1.0f }; float[] blue = { 0.2f, 0.2f, 1.0f, 1.0f }; ! glShadeModel( GL_SMOOTH ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClearDepth( 1.0f ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); ! glLightfv( GL_LIGHT0, GL_POSITION, pos ); glEnable( GL_CULL_FACE ); *************** *** 78,83 **** glEnable( GL_NORMALIZE ); - - // glEnd(); } --- 76,79 ---- *************** *** 86,96 **** float h = ((float)height) / ((float)width); ! glViewport (0, 0, width, height); ! glMatrixMode (GL_PROJECTION); ! glLoadIdentity (); ! glFrustum (-1.0, 1.0, -h, h, 5.0, 60.0 ); ! glMatrixMode (GL_MODELVIEW); ! glLoadIdentity (); glTranslatef( 0.0f, 0.0f, -40.0f ); } --- 82,92 ---- float h = ((float)height) / ((float)width); ! glViewport( 0, 0, width, height ); ! glMatrixMode( GL_PROJECTION ); ! glLoadIdentity(); ! glFrustum( -1.0, 1.0, -h, h, 5.0, 60.0 ); ! glMatrixMode( GL_MODELVIEW ); ! glLoadIdentity(); glTranslatef( 0.0f, 0.0f, -40.0f ); } *************** *** 106,110 **** glPushMatrix(); glTranslated( -3.0, -2.0, 0.0 ); ! glRotated( angle, 0.0, 0.0, 1.0 ); glCallList( gear1 ); glPopMatrix(); --- 102,106 ---- glPushMatrix(); glTranslated( -3.0, -2.0, 0.0 ); ! glRotated( rotAng, 0.0, 0.0, 1.0 ); glCallList( gear1 ); glPopMatrix(); *************** *** 112,116 **** glPushMatrix(); glTranslated( 3.1, -2.0, 0.0 ); ! glRotated( -2.0 * angle - 9.0, 0.0, 0.0, 1.0 ); glCallList( gear2 ); glPopMatrix(); --- 108,112 ---- glPushMatrix(); glTranslated( 3.1, -2.0, 0.0 ); ! glRotated( -2.0 * rotAng - 9.0, 0.0, 0.0, 1.0 ); glCallList( gear2 ); glPopMatrix(); *************** *** 118,122 **** glPushMatrix(); glTranslated( -3.1, 4.2, 0.0 ); ! glRotated( -2.0 * angle - 25.0, 0.0, 0.0, 1.0 ); glCallList( gear3 ); glPopMatrix(); --- 114,118 ---- glPushMatrix(); glTranslated( -3.1, 4.2, 0.0 ); ! glRotated( -2.0 * rotAng - 25.0, 0.0, 0.0, 1.0 ); glCallList( gear3 ); glPopMatrix(); *************** *** 134,142 **** glShadeModel( GL_FLAT ); /* front face */ glBegin( GL_QUAD_STRIP ); for ( i=0; i<=teeth; i++ ) { ! ang = i * 2.0f * System.Math.PI; glVertex3d( r0 * System.Math.Cos( ang ), r0 * System.Math.Sin( ang ), width * 0.5 ); glVertex3d( r1 * System.Math.Cos( ang ), r1 * System.Math.Sin( ang ), width * 0.5 ); --- 130,139 ---- glShadeModel( GL_FLAT ); + glNormal3d( 0.0, 0.0, 1.0 ); /* front face */ glBegin( GL_QUAD_STRIP ); for ( i=0; i<=teeth; i++ ) { ! ang = i * 2.0f * System.Math.PI / teeth; glVertex3d( r0 * System.Math.Cos( ang ), r0 * System.Math.Sin( ang ), width * 0.5 ); glVertex3d( r1 * System.Math.Cos( ang ), r1 * System.Math.Sin( ang ), width * 0.5 ); *************** *** 197,202 **** v = r2 * System.Math.Sin( ang + da ) - r1 * System.Math.Sin( ang ); len = System.Math.Sqrt( u * u + v * v ); ! u /= len; ! v /= len; glNormal3d( v, -u, 0.0 ); --- 194,199 ---- v = r2 * System.Math.Sin( ang + da ) - r1 * System.Math.Sin( ang ); len = System.Math.Sqrt( u * u + v * v ); ! u = u / len; ! v = v / len; glNormal3d( v, -u, 0.0 ); *************** *** 211,216 **** glNormal3d( v, -u, 0.0 ); ! glVertex3d( r1 * System.Math.Cos( ang + 3 * da ), r1 + System.Math.Sin( ang + 3 * da ), width * 0.5 ); ! glVertex3d( r1 * System.Math.Cos( ang + 3 * da ), r1 + System.Math.Sin( ang + 3 * da ), -width * 0.5 ); glNormal3d( System.Math.Cos( ang ), System.Math.Sin( ang ), 0.0 ); --- 208,213 ---- glNormal3d( v, -u, 0.0 ); ! glVertex3d( r1 * System.Math.Cos( ang + 3 * da ), r1 * System.Math.Sin( ang + 3 * da ), width * 0.5 ); ! glVertex3d( r1 * System.Math.Cos( ang + 3 * da ), r1 * System.Math.Sin( ang + 3 * da ), -width * 0.5 ); glNormal3d( System.Math.Cos( ang ), System.Math.Sin( ang ), 0.0 ); *************** *** 218,223 **** glVertex3d( r1 * System.Math.Cos( 0 ), r1 * System.Math.Sin( 0 ), width * 0.5 ); glVertex3d( r1 * System.Math.Cos( 0 ), r1 * System.Math.Sin( 0 ), -width * 0.5 ); ! glEnd(); ! glShadeModel( GL_SMOOTH ); --- 215,220 ---- glVertex3d( r1 * System.Math.Cos( 0 ), r1 * System.Math.Sin( 0 ), width * 0.5 ); glVertex3d( r1 * System.Math.Cos( 0 ), r1 * System.Math.Sin( 0 ), -width * 0.5 ); ! glEnd(); ! glShadeModel( GL_SMOOTH ); *************** *** 238,242 **** public static void Main( string[] args) { ! new Lesson01GLUT(); } --- 235,239 ---- public static void Main( string[] args) { ! new Gears(); } |