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