X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=0a186f84fdeea4566c0720e9e4112cf407305ff1;hp=d6b3e8fe51f3038e982e25f871b5fe4ef871e9f7;hb=e204dbdc0e5925daec44037f7b26c9e5984cfdb3;hpb=168b99f77c5c0defa67c22beb64f44dbe03c7b22 diff --git a/scene.c b/scene.c index d6b3e8f..0a186f8 100644 --- a/scene.c +++ b/scene.c @@ -123,8 +123,8 @@ GLfloat angle = -150; /* in degrees */ GLfloat angle2 = 30; /* in degrees */ /* Near and far parameters */ -GLfloat near = -10; -GLfloat far = 10; +GLfloat near = -100; +GLfloat far = 100; /* Zoom factor for mouse movements */ GLfloat zoomFactor = 1.0; @@ -137,9 +137,11 @@ int floorSize = 100; /* Light 0 parameters */ GLfloat diffuse0[] = {1.0, 1.0, 1.0, 1.0}; -GLfloat ambient0[] = {1.0, 1.0, 1.0, 1.0}; +GLfloat ambient0[] = {0.0, 0.0, 0.0, 1.0}; GLfloat specular0[] = {1.0, 1.0, 1.0, 1.0}; -GLfloat light0_pos[] ={ 1.0, 2.0, 3,0, 1.0}; +GLfloat emission0[] = {0.0, 0.0, 0.0, 0.0}; +GLfloat light0_pos[] ={1.0, 1.0, 0,0, 1.0}; +GLfloat glightmodel[] = {0.2,0.2,0.2,1}; /** @@ -604,7 +606,13 @@ void drawSquare(int recurseLevel, float x1, float z1, float x2, float z2) { * Draw a floor by calling the drawSquare recursion */ void drawFloor() { - drawSquare(0, -floorSize, -floorSize, floorSize, floorSize); + //drawSquare(0, -floorSize, -floorSize, floorSize, floorSize); + glBegin(GL_QUADS); + glVertex3f(-18.0, 0.0, 27.0); + glVertex3f(27.0, 0.0, 27.0); + glVertex3f(27.0, 0.0, -18.0); + glVertex3f(-18.0, 0.0, -18.0); + glEnd(); } /** @@ -637,12 +645,7 @@ void display() { 0.0, 0.0, 0.0, /* center is at (x,y,z) */ 0.0, 1.0, 0.0 /* up is in postivie Y direction */ ); - glEnable(GL_LIGHT0); - glLightfv(GL_LIGHT0, GL_POSITION, light0_pos); - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0); - glLightfv(GL_LIGHT0, GL_SPECULAR, specular0); - glEnable(GL_LIGHTING); + // **NOTE: Currently this rotation function is all that moves the camera off // the flat surface. Need to integrate function into gluLookAt @@ -668,8 +671,9 @@ void display() { // Draw teapot for a test object glPushMatrix(); - glTranslatef(0.0, 1.0, 0.0); // **NOTE: Teapot does not rest on surface - glutWireTeapot(1); + glTranslatef(0.0, 0.5, 0.0); // **NOTE: Teapot does not rest on surface + glColor3f(0.5, 0.5, 0.5); + glutSolidTeapot(1); glPopMatrix(); // Draw a white ball over the light source @@ -698,14 +702,22 @@ void init() { 1.0, /* aspect ratio */ near, /* Z near */ far /* Z far */ - ); + ); - glEnable(GL_LIGHT0); + glLightfv(GL_LIGHT0, GL_POSITION, light0_pos); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0); glLightfv(GL_LIGHT0, GL_SPECULAR, specular0); + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, glightmodel); + glEnable(GL_LIGHT0); glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE ); + glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, specular0); + glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, emission0); + + glMatrixMode(GL_MODELVIEW); glLoadIdentity();