feat: lightning now working
This commit is contained in:
parent
aac95baa7f
commit
047b613e03
|
@ -80,14 +80,14 @@ public class Lighting {
|
|||
h.add(l);
|
||||
h.normalize();
|
||||
|
||||
/* diffuse contribution : A COMPLETER */
|
||||
/* diffuse contribution */
|
||||
double Id = light.params[3];
|
||||
double Id = kd *Id* Math.cos(normal,l);
|
||||
double I_diff = Id * kd * Math.cos(normal.dot(l));
|
||||
|
||||
/* specular contribution : A COMPLETER */
|
||||
double Is = ks * Id * Math.cos(h,normal)^2;
|
||||
/* specular contribution */
|
||||
double I_spec = Id * ks * Math.cos(h.dot(normal));
|
||||
|
||||
I += Id + Is;
|
||||
I += I_diff + I_spec;
|
||||
} catch (InstantiationException ex) {
|
||||
/* should not reach */ } catch (SizeMismatchException ex) {
|
||||
/* should not reach */ }
|
||||
|
|
10
Mesh.java
10
Mesh.java
|
@ -120,9 +120,13 @@ public class Mesh {
|
|||
try {
|
||||
for (int i = 0; i < 3 * getNumFaces(); i += 3) {
|
||||
|
||||
Vector v0 = vertices[i + 0];
|
||||
Vector v1 = vertices[i + 1];
|
||||
Vector v2 = vertices[i + 2];
|
||||
int index_v0 = faces[i + 0];
|
||||
int index_v1 = faces[i + 1];
|
||||
int index_v2 = faces[i + 2];
|
||||
|
||||
Vector3 v0 = new Vector3(vertices[index_v0]);
|
||||
Vector3 v1 = new Vector3(vertices[index_v1]);
|
||||
Vector3 v2 = new Vector3(vertices[index_v2]);
|
||||
|
||||
Vector3 bidule_gauche = new Vector3(v1);
|
||||
bidule_gauche.subtract(v0);
|
||||
|
|
|
@ -156,17 +156,13 @@ public class Renderer {
|
|||
screen.swapBuffers();
|
||||
wait(1);
|
||||
|
||||
wait(10);
|
||||
|
||||
/* solid rendering, with lighting */
|
||||
/*
|
||||
* screen.clearBuffer ();
|
||||
* shader.reset ();
|
||||
* setLightingEnabled (true);
|
||||
* renderSolid ();
|
||||
* screen.swapBuffers ();
|
||||
* wait (3);
|
||||
*/
|
||||
screen.clearBuffer();
|
||||
shader.reset();
|
||||
setLightingEnabled(true);
|
||||
renderSolid();
|
||||
screen.swapBuffers();
|
||||
wait(1);
|
||||
|
||||
/* solid rendering, with texture */
|
||||
/*
|
||||
|
@ -178,9 +174,10 @@ public class Renderer {
|
|||
* setLightingEnabled (true);
|
||||
* renderSolid ();
|
||||
* screen.swapBuffers ();
|
||||
* wait (3);
|
||||
* wait (1);
|
||||
*/
|
||||
|
||||
wait(5);
|
||||
screen.destroy();
|
||||
System.exit(0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue