X-Git-Url: https://git.ucc.asn.au/?p=atyndall%2Fcits2231.git;a=blobdiff_plain;f=scene.c;h=fc078e25777cd0bc54371664c20e04b010908090;hp=954d75ce1f1ec1f31daf757659c977469966fc95;hb=b4de9c715f7b22cc0c08fab65cebc566e938a248;hpb=272fb88381b2021bc430384231d0d2fcd64fa1b6 diff --git a/scene.c b/scene.c index 954d75c..fc078e2 100644 --- a/scene.c +++ b/scene.c @@ -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}; /** @@ -497,7 +499,7 @@ void makeMenu() { * @param h New height */ void windowReshape(int w, int h) { - glViewport(0, 0, (GLsizei) w, (GLsizei) h); + /*glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) @@ -507,7 +509,7 @@ void windowReshape(int w, int h) { glOrtho(near*(GLfloat)w/(GLfloat)h, far*(GLfloat)w/(GLfloat)h, near, far, near, far); glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + glLoadIdentity();*/ } /** @@ -607,6 +609,25 @@ void drawFloor() { drawSquare(0, -floorSize, -floorSize, floorSize, floorSize); } +/** + * Draw x, z axis on floor + */ +void drawLine() { + // **NOTE: fix function + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4ub( 0.0, 0.0, 0.0, 0.5 ); + + glBegin(GL_LINES); + glVertex3i( 10.0, 0.1, 10.0); + glVertex3i( -10.0, 0.1, -10.0); + glEnd(); + + glDisable(GL_BLEND); + glEnable(GL_TEXTURE_2D); +} + /** * Display function */ @@ -619,6 +640,7 @@ void display() { 0.0, 1.0, 0.0 /* up is in postivie Y direction */ ); + // **NOTE: Currently this rotation function is all that moves the camera off // the flat surface. Need to integrate function into gluLookAt glRotatef(30.0, 1.0, 0.0, 0.0); @@ -639,10 +661,13 @@ void display() { drawFloor(); + drawLine(); + // 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 @@ -671,14 +696,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();