X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=2f45633317dc6526b725347353fe82d3aedc8e50;hp=ca81321404a2bbfb0f0d073b6c1b3aaea30d51b0;hb=65f3d838461588453f40f54c884a48bc0a44e8fc;hpb=3affec0660cc9e92f4dc1c23af711b09a9d72866 diff --git a/scene.c b/scene.c index ca81321..2f45633 100644 --- a/scene.c +++ b/scene.c @@ -206,16 +206,6 @@ void mouse(int button, int state, int x, int y) { moving = 0; } } - if (button == GLUT_MIDDLE_BUTTON) { - if (state == GLUT_DOWN) { - lightMoving = 1; - lightStartX = x; - lightStartY = y; - } - if (state == GLUT_UP) { - lightMoving = 0; - } - } } /** @@ -266,8 +256,8 @@ void keyboard(unsigned char key, int x, int y) { */ void motion(int x, int y) { if (moving) { - angle = angle + (x - startx); - angle2 = angle2 + (y - starty); + zoomFactor += (y - starty); + rotateFactor += (x - startx); startx = x; starty = y; glutPostRedisplay(); @@ -308,13 +298,19 @@ void display() { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + GLfloat zcoord = 5.0 + (zoomFactor*0.2); + if ( zcoord < 0.0 ) { + zcoord = 0.0; + zoomFactor = 0.0; + } + gluLookAt( - 0.0, 0.0, 5.0, /* eye is at (x,y,z) */ + 0.0, 0.0, zcoord, /* 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); + glRotatef(50.0, 1.0, 0.0, 0.0); /* Reposition the light source. */ lightPosition[0] = 12*cos(lightAngle); @@ -322,13 +318,16 @@ void display() { 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(angle, 0.0, 1.0, 0.0); - glRotatef(angle2, 1.0, 0.0, 0.0); - glTranslatef(camx, camy, camz); - glRotatef(rot, 1.0, 0.0, 0.0); + glRotatef(rotateFactor*0.5, 0.0, 1.0, 0.0); + //glTranslatef(camx, camy, camz); + //glRotatef(rot, 1.0, 0.0, 0.0); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); @@ -341,7 +340,7 @@ void display() { glTranslatef(0.0, 0.5, 0.0); // **NOTE: Teapot currently does not rest on surface glColor3f(0.0, 0.0, 0.0); glFrontFace(GL_CW); - glutSolidTeapot(1); + glutSolidTeapot(1); glFrontFace(GL_CCW); glPopMatrix();