X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=f544aae31b44e48429ed9b49ac039f02a95c709b;hp=c024bf159a1a47b9b8913d3db753d1e9c57b4e92;hb=6f9b6e0830f4b8e12dbbbdbbdd2c0678bc2bf6a2;hpb=89e90cbd07402f824253fc0a4b2f1cd7e81b31e4 diff --git a/scene.c b/scene.c index c024bf1..f544aae 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.5, 0.0, 1.0, 0.0); //glTranslatef(camx, camy, camz); //glRotatef(rot, 1.0, 0.0, 0.0);