char dataDir[200]; // Stores the directory name for the meshes and textures.
-GLfloat lightColor[] = {1.0, 1.0, 1.0, 1.0}; // White light
-GLfloat lightPosition[4];
-
int moving, startx, starty;
-int lightMoving = 0, lightStartX, lightStartY;
/* Time varying or user-controled variables. */
float jump = 0.0;
-float lightAngle = 0.0, lightHeight = 5;
-GLfloat angle = -150; /* in degrees */
-GLfloat angle2 = 30; /* in degrees */
/* Near and far parameters - calculates scene size */
GLfloat near = -30;
GLfloat diffuse0[]={1.0, 0.0, 0.0, 1.0};
GLfloat ambient0[]={1.0, 0.0, 0.0, 1.0};
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 shine = 100.0;
+GLfloat lightColor0[] = {1.0, 1.0, 1.0, 1.0}; // White light
+GLfloat lightPosition0[4];
-GLfloat glightmodel[] = {0.2,0.2,0.2,1};
+float lightAngle0 = 0.0, lightHeight0 = 5;
+int lightMoving0 = 0, lightStartX0, lightStartY0;
+
+/* Light 1 parameters */
+GLfloat diffuse1[]={1.0, 0.0, 0.0, 1.0};
+GLfloat ambient1[]={1.0, 0.0, 0.0, 1.0};
+GLfloat specular1[]={1.0, 0.0, 0.0, 1.0};
+GLfloat direction1[] = {0.0, 0.0, 0.0};
+
+GLfloat lightColor1[] = {1.0, 1.0, 1.0, 1.0}; // White light
+GLfloat lightPosition1[4];
+
+float lightAngle1 = 180.0, lightHeight1 = 5;
+int lightMoving1 = 0, lightStartX1, lightStartY1;
/* Material types */
GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0};
GLfloat diffuse[] = {1.0, 0.8, 0.0, 1.0};
GLfloat specular[] = {1.0, 1.0, 1.0, 1.0};
+GLfloat shine = 100.0;
+GLfloat glightmodel[] = {0.2,0.2,0.2,1};
+GLfloat emission[] = {0.0, 0.3, 0.3, 1.0};
/* Zoom and rotate tracking */
GLfloat zoom = 0.0, rotate = 0.0;
// Stores the directory name for the meshes and textures.
extern char dataDir[];
-// Lighting
-extern GLfloat lightColor[];
-extern GLfloat lightPosition[];
-
extern int moving, startx, starty;
-extern int lightMoving, lightStartX, lightStartY;
/* Time varying or user-controled variables. */
extern float jump;
extern GLfloat diffuse0[];
extern GLfloat ambient0[];
extern GLfloat specular0[];
-extern GLfloat emission0[];
-
extern GLfloat direction0[];
-extern GLfloat light0_pos[];
-extern GLfloat shine;
+extern GLfloat lightColor0[];
+extern GLfloat lightPosition0[];
-extern GLfloat glightmodel[];
+extern float lightAngle0, lightHeight0;
+extern int lightMoving0, lightStartX0, lightStartY0;
+
+/* Light 1 parameters */
+extern GLfloat diffuse1[];
+extern GLfloat ambient1[];
+extern GLfloat specular1[];
+extern GLfloat direction1[];
+
+extern GLfloat lightColor1[];
+extern GLfloat lightPosition1[];
+
+extern float lightAngle1, lightHeight1;
+extern int lightMoving1, lightStartX1, lightStartY1;
/* Material types */
extern GLfloat ambient[];
extern GLfloat diffuse[];
extern GLfloat specular[];
+extern GLfloat shine;
+extern GLfloat glightmodel[];
+extern GLfloat emission[];
/* Beginning width, height */
extern int width, height;
starty = y;\r
glutPostRedisplay();\r
}\r
- if (lightMoving) {\r
- lightAngle += (x - lightStartX)/40.0;\r
- lightHeight += (lightStartY - y)/20.0;\r
- lightStartX = x;\r
- lightStartY = y;\r
+ if (lightMoving0) {\r
+ lightAngle0 += (x - lightStartX0)/40.0;\r
+ lightHeight0 += (lightStartY0 - y)/20.0;\r
+ lightStartX0 = x;\r
+ lightStartY0 = y;\r
+ glutPostRedisplay();\r
+ }\r
+ if (lightMoving1) {\r
+ lightAngle1 += (x - lightStartX1)/40.0;\r
+ lightHeight1 += (lightStartY1 - y)/20.0;\r
+ lightStartX1 = x;\r
+ lightStartY1 = y;\r
glutPostRedisplay();\r
}\r
}\r
\r
glRotatef(40.0, 1.0, 0.0, 0.0);\r
\r
- /* Reposition the light source. */\r
- lightPosition[0] = 12*cos(lightAngle);\r
- lightPosition[1] = lightHeight;\r
- lightPosition[2] = 12*sin(lightAngle);\r
- lightPosition[3] = 0.0;\r
+ /* Reposition the light source 0. */\r
+ lightPosition0[0] = 12*cos(lightAngle0);\r
+ lightPosition0[1] = lightHeight0;\r
+ lightPosition0[2] = 12*sin(lightAngle0);\r
+ lightPosition0[3] = 0.0;\r
+\r
+ /* Reposition the light source 1. */\r
+ lightPosition1[0] = 12*cos(lightAngle1);\r
+ lightPosition1[1] = lightHeight1;\r
+ lightPosition1[2] = 12*sin(lightAngle1);\r
+ lightPosition1[3] = 0.0;\r
\r
glPushMatrix();\r
\r
glTranslatef(camx, camy, camz);\r
glRotatef(keyrot, 1.0, 0.0, 0.0);\r
\r
- glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);\r
+ glLightfv(GL_LIGHT0, GL_POSITION, lightPosition0);\r
+ glLightfv(GL_LIGHT1, GL_POSITION, lightPosition1);\r
\r
drawFloor();\r
\r
glPushMatrix();\r
glDisable(GL_LIGHTING);\r
glColor3f(1.0, 1.0, 0.0);\r
- glTranslatef(lightPosition[0], lightPosition[1], lightPosition[2]);\r
+ glTranslatef(lightPosition0[0], lightPosition0[1], lightPosition0[2]);\r
+ glutSolidSphere(1.0, 50, 50);\r
+ glEnable(GL_LIGHTING);\r
+ glPopMatrix();\r
+\r
+ // Draw a white ball over the light source\r
+ glPushMatrix();\r
+ glDisable(GL_LIGHTING);\r
+ glColor3f(1.0, 1.0, 0.0);\r
+ glTranslatef(lightPosition1[0], lightPosition1[1], lightPosition1[2]);\r
glutSolidSphere(1.0, 50, 50);\r
glEnable(GL_LIGHTING);\r
glPopMatrix();\r
\r
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90.0);\r
\r
+ glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1);\r
+ glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1);\r
+ glLightfv(GL_LIGHT1, GL_SPECULAR, specular1);\r
+ glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, direction1);\r
+\r
+ glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 90.0);\r
+\r
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, glightmodel);\r
\r
glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);\r
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);\r
glMaterialfv(GL_FRONT, GL_SPECULAR, specular);\r
- glMaterialfv(GL_FRONT, GL_EMISSION, emission0);\r
+ glMaterialfv(GL_FRONT, GL_EMISSION, emission);\r
glMaterialf(GL_FRONT, GL_SHININESS, shine);\r
\r
glEnable(GL_LIGHT0);\r
+ glEnable(GL_LIGHT1);\r
glEnable(GL_LIGHTING);\r
}\r
\r