Lights() now sets up default lighting, which is a slight ambient light and a medium directional light pointing down the Z axis.

This commit is contained in:
juniperoserra
2005-04-06 21:29:28 +00:00
parent e4c50aa331
commit e2a4589f8d
4 changed files with 35 additions and 12 deletions

View File

@@ -5683,6 +5683,18 @@ v PApplet.this.stop();
}
public void clearLights() {
if (recorder != null) recorder.clearLights();
g.clearLights();
}
public void defaultLights() {
if (recorder != null) recorder.defaultLights();
g.defaultLights();
}
public void light(int num, float x, float y, float z,
float red, float green, float blue) {
if (recorder != null) recorder.light(num, x, y, z, red, green, blue);

View File

@@ -2072,6 +2072,14 @@ public class PGraphics extends PImage implements PConstants {
throw new RuntimeException("noLights() can only be used with depth()");
}
public void clearLights() {
throw new RuntimeException("clearLights() can only be used with depth()");
}
public void defaultLights() {
throw new RuntimeException("defaultLights() can only be used with depth()");
}
public void light(int num, float x, float y, float z,
float red, float green, float blue) {
throw new RuntimeException("light() can only be used with depth()");

View File

@@ -326,24 +326,26 @@ public class PGraphics3 extends PGraphics {
triangle = new PTriangle(this);
}
protected void resetLights() {
// reset lights
// This looks like a funny reset, but it's to make the most common
// case the easiest to attain even if the user chooses to do everything
// by hand.
public void clearLights() {
lightCount = 0;
light[0] = false;
lightType[0] = AMBIENT;
for (int i = 1; i < MAX_LIGHTS; i++) {
for (int i = 0; i < MAX_LIGHTS; i++) {
light[i] = false;
lightType[i] = POINT;
}
}
public void defaultLights() {
clearLights();
createAmbientLight(60);
createDirectionalLight(80, 80, 80, 0, 0, -1);
}
public void beginFrame() {
super.beginFrame();
resetLights();
if (lights) {
defaultLights();
}
// reset lines
lineCount = 0;
@@ -2678,6 +2680,7 @@ public class PGraphics3 extends PGraphics {
public void lights() {
lights = true;
defaultLights();
}
public void noLights() {

View File

@@ -136,7 +136,7 @@ public class PGraphicsGL extends PGraphics3 {
canvas.setNoAutoRedrawMode(true);
// maybe this will help?
canvas.requestFocus();
//canvas.requestFocus();
// done with this business
displayed = true;
@@ -204,8 +204,8 @@ public class PGraphicsGL extends PGraphics3 {
}
protected void resetLights() {
super.resetLights();
public void clearLights() {
super.clearLights();
for (int i = 0; i < MAX_LIGHTS; i++) {
lightDisable(i);
}