From: Ash Tyndall Date: Sat, 22 Oct 2011 07:38:35 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=98e1aa8665249d427fee1bedceec646bd16c35b6;p=atyndall%2Fcits2231.git --- diff --git a/helper.c b/helper.c index 8135854..cb4278d 100644 --- a/helper.c +++ b/helper.c @@ -224,19 +224,19 @@ void drawFloor() { for ( int z = -floorSize; z < floorSize; z++ ) { glColor3f( 1.0, 1.0, 1.0 ); - glNormal3i( 0, 1, 0 ); + glNormal3i( 1, 1, 0 ); glTexCoord2f( 1.0, 1.0 ); glVertex3f ( (x+1)*squareSize, 0.0, (z+1)*squareSize ); - glNormal3i( 0, 1, 0 ); + glNormal3i( 1, 1, 0 ); glTexCoord2f( 1.0, 0.0 ); glVertex3f ( (x+1)*squareSize, 0.0, z*squareSize ); - glNormal3i( 0, 1, 0 ); + glNormal3i( 1, 1, 0 ); glTexCoord2f( 0.0, 0.0 ); glVertex3f ( x*squareSize, 0.0, z*squareSize ); - glNormal3i( 0, 1, 0 ); + glNormal3i( 1, 1, 0 ); glTexCoord2f( 0.0, 1.0 ); glVertex3f ( x*squareSize, 0.0, (z+1)*squareSize ); } @@ -340,18 +340,18 @@ void updateLights() { glDisable(GL_LIGHTING); for ( int i = 0; i < LIGHTS; i++ ) { - glDisable(GL_LIGHT0 + i); + glDisable( GL_LIGHT0 + i ); - glLightfv(GL_LIGHT0 + i, GL_POSITION, lightObjs[i].position); - glLightfv(GL_LIGHT0 + i, GL_AMBIENT, lightObjs[i].ambient); - glLightfv(GL_LIGHT0 + i, GL_DIFFUSE, lightObjs[i].diffuse); - glLightfv(GL_LIGHT0 + i, GL_SPECULAR, lightObjs[i].specular); - glLightfv(GL_LIGHT0 + i, GL_SPOT_DIRECTION, lightObjs[i].direction); + glLightfv( GL_LIGHT0 + i, GL_POSITION, lightObjs[i].position ); + glLightfv( GL_LIGHT0 + i, GL_AMBIENT, lightObjs[i].ambient ); + glLightfv( GL_LIGHT0 + i, GL_DIFFUSE, lightObjs[i].diffuse ); + glLightfv( GL_LIGHT0 + i, GL_SPECULAR, lightObjs[i].specular ); + glLightfv( GL_LIGHT0 + i, GL_SPOT_DIRECTION, lightObjs[i].direction ); - glLightf(GL_LIGHT0 + i, GL_SPOT_CUTOFF, lightObjs[i].cutoff); - glLighti(GL_LIGHT0 + i, GL_SPOT_EXPONENT, (int)lightObjs[i].exponent ); + glLightf ( GL_LIGHT0 + i, GL_SPOT_CUTOFF, lightObjs[i].cutoff ); + glLighti ( GL_LIGHT0 + i, GL_SPOT_EXPONENT, lightObjs[i].exponent ); - glEnable(GL_LIGHT0 + i); + glEnable ( GL_LIGHT0 + i ); // Draw light ball for light glPushMatrix(); @@ -382,5 +382,6 @@ void initializeState() { lightObjs[1].position[3] = 0.0; /* Initial floor texture */ - currentGroundTexture = 5; + // **NOTE: Commented out while testing lighting + //currentGroundTexture = 5; } \ No newline at end of file diff --git a/scene.c b/scene.c index 450d160..e003003 100644 --- a/scene.c +++ b/scene.c @@ -216,66 +216,6 @@ void mouse(int button, int state, int x, int y) { } } -/** - * Keybord event handler - * w/s increase/decrease the z - * a/d increase/decrease the x - * q/e increase/decrease the y - * z/x increase/decrease the angle - * @param key Key pressed - * @param x x co-ordinate of mouse - * @param y y co-ordinate of mouse - */ -void keyboard(unsigned char key, int x, int y) { - switch(key) { - case 'w': - case 'W': - camz -= factor; - break; - case 'a': - case 'A': - camx -= factor; - break; - case 's': - case 'S': - camz += factor; - break; - case 'd': - case 'D': - camx += factor; - break; - case 'q': - case 'Q': - camy += factor; - break; - case 'e': - case 'E': - camy -= factor; - break; - case 'z': - case 'Z': - keyrot += factor; - break; - case 'x': - case 'X': - keyrot -= factor; - break; - case '=': - case '+': - factor += 0.1; - printf("Factor of change is now %f\n", factor); - break; - case '-': - case '_': - factor -= 0.1; - printf("Factor of change is now %f\n", factor); - break; - - } - printf("Camera is now at (%f, %f, %f), angle %f\n", camx, camy, camz, keyrot); - glutPostRedisplay(); -} - /** * Called when motion event occurs * @param x Mouse x position @@ -503,14 +443,13 @@ int main(int argc, char **argv) { glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // the type glEnable(GL_CULL_FACE); - glLineWidth(2.0); + glLineWidth(1.0); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glutReshapeFunc(windowReshape); glutDisplayFunc(display); glutMouseFunc(mouse); - glutKeyboardFunc(keyboard); glutMotionFunc(motion); makeMenu();