feat: jme casse à la THC bye bye
This commit is contained in:
parent
8fee10f2a5
commit
ea2d88c68b
|
@ -8,7 +8,7 @@ public class Lighting {
|
|||
static final int NONE = 0;
|
||||
static final int AMBIENT = 1;
|
||||
static final int POINT = 2;
|
||||
List lights;
|
||||
List<Light> lights;
|
||||
|
||||
/* Internal Class describing a light source */
|
||||
private class Light {
|
||||
|
@ -22,7 +22,7 @@ public class Lighting {
|
|||
}
|
||||
|
||||
public Lighting() {
|
||||
lights = new LinkedList();
|
||||
lights = new LinkedList<Light>();
|
||||
}
|
||||
|
||||
/* Adds a new ambient light source of intensity @ia to the environment. */
|
||||
|
@ -54,13 +54,14 @@ public class Lighting {
|
|||
double[] litColor = new double[3];
|
||||
/* total light intensity */
|
||||
double I = 0.0;
|
||||
Iterator it = lights.iterator();
|
||||
Iterator<Light> it = lights.iterator();
|
||||
while (it.hasNext()) {
|
||||
Light light = (Light) it.next();
|
||||
switch (light.type) {
|
||||
case AMBIENT:
|
||||
/* Ambient light : A COMPLETER */
|
||||
/* I += ... */
|
||||
/* Ambient light */
|
||||
double Ia = light.params[0];
|
||||
I += Ia * ka;
|
||||
break;
|
||||
case POINT:
|
||||
try {
|
||||
|
@ -68,19 +69,24 @@ public class Lighting {
|
|||
Vector3 e = new Vector3(cameraPosition);
|
||||
e.subtract(position);
|
||||
e.normalize();
|
||||
|
||||
/* vector from point to light */
|
||||
Vector3 l = new Vector3(light.params[0], light.params[1], light.params[2]);
|
||||
l.subtract(position);
|
||||
l.normalize();
|
||||
|
||||
/* half-vector between e and l */
|
||||
Vector3 h = new Vector3(e);
|
||||
h.add(l);
|
||||
h.normalize();
|
||||
|
||||
/* diffuse contribution : A COMPLETER */
|
||||
/* double Id = ... */
|
||||
double Id = kd * ...
|
||||
|
||||
/* specular contribution : A COMPLETER */
|
||||
/* double Is = ... */
|
||||
/* I += Id + Is; */
|
||||
double Is = ks * ...
|
||||
|
||||
I += Id + Is;
|
||||
} catch (InstantiationException ex) {
|
||||
/* should not reach */ } catch (SizeMismatchException ex) {
|
||||
/* should not reach */ }
|
||||
|
|
12
Mesh.java
12
Mesh.java
|
@ -120,9 +120,17 @@ public class Mesh {
|
|||
try {
|
||||
for (int i = 0; i < 3 * getNumFaces(); i += 3) {
|
||||
|
||||
/* A COMPLETER */
|
||||
Vector v0 = vertices[i + 0];
|
||||
Vector v1 = vertices[i + 1];
|
||||
Vector v2 = vertices[i + 2];
|
||||
|
||||
Vector3 n = new Vector3(); // ?
|
||||
Vector3 bidule_gauche = new Vector3(v1);
|
||||
bidule_gauche.subtract(v0);
|
||||
|
||||
Vector3 bidule_droite = new Vector3(v2);
|
||||
bidule_droite.subtract(v0);
|
||||
|
||||
Vector3 n = bidule_gauche.cross(bidule_droite);
|
||||
|
||||
// ajoute la normale calculee a chq sommet de la face
|
||||
for (int j = 0; j < 3; j++) {
|
||||
|
|
Loading…
Reference in a new issue