From: Ash Tyndall Date: Fri, 21 Oct 2011 02:55:47 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=ea48dd7a038f3648d49808c3f9444ad6f636ba93;p=atyndall%2Fcits2231.git --- diff --git a/globals.c b/globals.c index 210dee4..374d8b3 100644 --- a/globals.c +++ b/globals.c @@ -82,7 +82,7 @@ GLfloat specular0[]={1.0, 0.0, 0.0, 1.0}; GLfloat emission0[] = {0.0, 0.3, 0.3, 1.0}; GLfloat direction0[] = {0.0, 0.0, 0.0}; -GLfloat light0_pos[] ={10.0, 10.0, 0,0, 0.5}; +GLfloat light0_pos[] ={1.0, 1.0, 0,0, 0.5}; GLfloat shine = 100.0; diff --git a/scene.c b/scene.c index c024bf1..a529c62 100644 --- a/scene.c +++ b/scene.c @@ -262,6 +262,13 @@ void motion(int x, int y) { starty = y; glutPostRedisplay(); } + if (lightMoving) { + lightAngle += (x - lightStartX)/40.0; + lightHeight += (lightStartY - y)/20.0; + lightStartX = x; + lightStartY = y; + glutPostRedisplay(); + } } /** @@ -292,17 +299,27 @@ void display() { glLoadIdentity(); gluLookAt( - 0.0, 0.0, 5.0 + zoomFactor, /* eye is at (x,y,z) */ + 0.0, 0.0, 5.0 + (zoomFactor*0.2), /* 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(75.0, 1.0, 0.0, 0.0); + /* Reposition the light source. */ + lightPosition[0] = 12*cos(lightAngle); + lightPosition[1] = lightHeight; + lightPosition[2] = 12*sin(lightAngle); + lightPosition[3] = 0.0; + + + //glRotatef(angle, 0.0, 1.0, 0.0); + // glRotatef(angle2, 1.0, 0.0, 0.0); + glPushMatrix(); /* Perform scene rotations based on user mouse/keyboard input. */ - glRotatef(rotateFactor, 0.0, 0.0, 1.0); + glRotatef(rotateFactor*0.2, 0.0, 1.0, 0.0); //glTranslatef(camx, camy, camz); //glRotatef(rot, 1.0, 0.0, 0.0);