X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=a74a6df231cb8a11b06be9b8b81854841baa84df;hp=2b2de6d81bcf49f55cd5ee7342c69412f13e43bd;hb=4b12fdcf72bcba1edd1b30a8c5aa66def470aec5;hpb=f1eb98d3231c2cbcde17e49bb4bc9fdc2db65097 diff --git a/scene.c b/scene.c index 2b2de6d..a74a6df 100644 --- a/scene.c +++ b/scene.c @@ -125,7 +125,7 @@ int lightMoving = 0, lightStartX, lightStartY; /* Time varying or user-controled variables. */ static float jump = 0.0; -static float lightAngle = 0.0, lightHeight = 20; +static float lightAngle = 0.0, lightHeight = 40; GLfloat angle = -150; /* in degrees */ GLfloat angle2 = 30; /* in degrees */ @@ -484,8 +484,8 @@ void makeMenu() { * @param h New height */ void windowReshape(int w, int h) { - GLdouble near = -1000.0; - GLdouble far = 1000.0; + GLdouble near = -100.0; + GLdouble far = 100.0; glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -509,7 +509,7 @@ void windowReshape(int w, int h) { */ /*void mouse(int btn, int state, int x, int y) { -}*//* +}*/ static void mouse(int button, int state, int x, int y) { @@ -552,13 +552,13 @@ motion(int x, int y) lightStartY = y; glutPostRedisplay(); } -}*/ +} void idle() { angle = (int)(angle + 10) % 360; //angle2 = (int)(angle2 + 10) % 360; printf("Angle 1: %f, Angle 2: %f\n", angle, angle2); - sleep(0.5); + sleep(1); glutPostRedisplay(); } @@ -593,30 +593,13 @@ void drawSquare(int recurseLevel, float x1, float y1, float x2, float y2) { * Draw a floor. */ void drawFloor() { - glDisable(GL_LIGHTING); - - //if (useTexture) { - // glEnable(GL_TEXTURE_2D); - //} - - /*glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); - glVertex3fv(floorVertices[0]); - glTexCoord2f(0.0, 16.0); - glVertex3fv(floorVertices[1]); - glTexCoord2f(16.0, 16.0); - glVertex3fv(floorVertices[2]); - glTexCoord2f(16.0, 0.0); - glVertex3fv(floorVertices[3]); - glEnd();*/ - + drawSquare(0, -1000.0, -1000.0, 1000.0, 1000.0); /*if (useTexture) { glDisable(GL_TEXTURE_2D); }*/ - glEnable(GL_LIGHTING); } /*void drawSquare(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { @@ -630,11 +613,13 @@ void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt( - 0.0, 0.0, 60.0, /* eye is at (x,y,z) */ + 0.0, 0.0, 80.0, /* eye is at (x,y,z) */ 0.0, 0.0, 0.0, /* center is at (x,y,z) */ 0.0, 1.0, 0.0 /* up is in postivie Y direction */ ); + glRotatef(30.0, 1.0, 0.0, 0.0); + /* Reposition the light source. */ lightPosition[0] = 12*cos(lightAngle); lightPosition[1] = lightHeight; @@ -643,7 +628,7 @@ void display() { glPushMatrix(); /* Perform scene rotations based on user mouse input. */ - glRotatef(angle2, 1.0, 0.0, 0.0); + glRotatef(angle, 0.0, 1.0, 0.0); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); @@ -656,7 +641,7 @@ void display() { glPushMatrix(); //glTranslatef(0.0, 0.0, 0.0); - glutWireTeapot(30); // Draw teapot for test + glutWireTeapot(1); // Draw teapot for test glPopMatrix(); glPushMatrix(); @@ -738,9 +723,9 @@ int main(int argc, char **argv) { glutReshapeFunc(windowReshape); glutDisplayFunc(display); - //glutMouseFunc(mouse); - //glutMotionFunc(motion); - glutIdleFunc(idle); + glutMouseFunc(mouse); + glutMotionFunc(motion); + //glutIdleFunc(idle); makeMenu();