Commit 9afa128bcdebeeef2f52f34c0e2d3f6c902a32fa
Merge branch 'JACK' into 'master'
add moving light sources See merge request !11
Showing
1 changed file
with
7 additions
and
17 deletions
Show diff stats
main.cu
@@ -132,16 +132,14 @@ void glut_render(void) { | @@ -132,16 +132,14 @@ void glut_render(void) { | ||
132 | 132 | ||
133 | // light | 133 | // light |
134 | stim::vec3<float> eye = cam.getPosition(); //get the camera position (eye point) | 134 | stim::vec3<float> eye = cam.getPosition(); //get the camera position (eye point) |
135 | - if (l1[0] + l1[1] + l1[2] + l2[0] + l2[1] + l2[2] == 0) { | ||
136 | - stim::vec3<float> s = bb.size(); | 135 | + stim::vec3<float> s = bb.size(); |
137 | 136 | ||
138 | - l1[0] = eye[0] + s[0] / 2; | ||
139 | - l1[1] = eye[1] + s[1] / 2; | ||
140 | - l1[2] = eye[2] + s[2] / 2; | ||
141 | - l2[0] = eye[0] - s[0] / 2; | ||
142 | - l2[1] = eye[1] - s[1] / 2; | ||
143 | - l2[2] = eye[2] - s[2] / 2; | ||
144 | - } | 137 | + l1[0] = eye[0] + s[0] / 2; |
138 | + l1[1] = eye[1] + s[1] / 2; | ||
139 | + l1[2] = eye[2] + s[2] / 2; | ||
140 | + l2[0] = eye[0] - s[0] / 2; | ||
141 | + l2[1] = eye[1] - s[1] / 2; | ||
142 | + l2[2] = eye[2] - s[2] / 2; | ||
145 | 143 | ||
146 | GLfloat global_ambient[] = { 0.3, 0.3, 0.3, 1.0 }; | 144 | GLfloat global_ambient[] = { 0.3, 0.3, 0.3, 1.0 }; |
147 | GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; | 145 | GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; |
@@ -150,7 +148,6 @@ void glut_render(void) { | @@ -150,7 +148,6 @@ void glut_render(void) { | ||
150 | GLfloat specular[] = { 0.6, 0.6, 0.6, 1.0 }; | 148 | GLfloat specular[] = { 0.6, 0.6, 0.6, 1.0 }; |
151 | GLfloat position1[] = { l1[0], l1[1], 50, 0.0 }; // upper right light source | 149 | GLfloat position1[] = { l1[0], l1[1], 50, 0.0 }; // upper right light source |
152 | GLfloat position2[] = { l2[0], l2[1], 0, 0.0 }; // lower left light source | 150 | GLfloat position2[] = { l2[0], l2[1], 0, 0.0 }; // lower left light source |
153 | - GLfloat position[] = { eye[0], eye[1], 50, 1.0 }; | ||
154 | 151 | ||
155 | glClearColor(0.0, 0.0, 0.0, 1.0); | 152 | glClearColor(0.0, 0.0, 0.0, 1.0); |
156 | glShadeModel(GL_SMOOTH); | 153 | glShadeModel(GL_SMOOTH); |
@@ -166,11 +163,6 @@ void glut_render(void) { | @@ -166,11 +163,6 @@ void glut_render(void) { | ||
166 | glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse2); | 163 | glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse2); |
167 | glLightfv(GL_LIGHT1, GL_SPECULAR, specular); | 164 | glLightfv(GL_LIGHT1, GL_SPECULAR, specular); |
168 | glLightfv(GL_LIGHT1, GL_POSITION, position2); | 165 | glLightfv(GL_LIGHT1, GL_POSITION, position2); |
169 | - | ||
170 | - glLightfv(GL_LIGHT2, GL_AMBIENT, ambient); | ||
171 | - glLightfv(GL_LIGHT2, GL_DIFFUSE, diffuse1); | ||
172 | - glLightfv(GL_LIGHT2, GL_SPECULAR, specular); | ||
173 | - glLightfv(GL_LIGHT2, GL_POSITION, position); | ||
174 | 166 | ||
175 | glEnable(GL_COLOR_MATERIAL); | 167 | glEnable(GL_COLOR_MATERIAL); |
176 | 168 | ||
@@ -460,14 +452,12 @@ void glut_keyboard(unsigned char key, int x, int y){ | @@ -460,14 +452,12 @@ void glut_keyboard(unsigned char key, int x, int y){ | ||
460 | glEnable(GL_LIGHTING); | 452 | glEnable(GL_LIGHTING); |
461 | glEnable(GL_LIGHT0); | 453 | glEnable(GL_LIGHT0); |
462 | glEnable(GL_LIGHT1); | 454 | glEnable(GL_LIGHT1); |
463 | - glEnable(GL_LIGHT2); | ||
464 | } | 455 | } |
465 | else if (light_fac && !adjoint_fac) { | 456 | else if (light_fac && !adjoint_fac) { |
466 | light_fac = 0; | 457 | light_fac = 0; |
467 | glDisable(GL_LIGHTING); | 458 | glDisable(GL_LIGHTING); |
468 | glDisable(GL_LIGHT0); | 459 | glDisable(GL_LIGHT0); |
469 | glDisable(GL_LIGHT1); | 460 | glDisable(GL_LIGHT1); |
470 | - glDisable(GL_LIGHT2); | ||
471 | } | 461 | } |
472 | break; | 462 | break; |
473 | 463 |