diff --git a/app/PdeEditor.java b/app/PdeEditor.java index 71b946de2..ab793684f 100644 --- a/app/PdeEditor.java +++ b/app/PdeEditor.java @@ -582,6 +582,7 @@ public class PdeEditor extends JFrame item = new JMenuItem("Auto Format"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + //new AutoFormat(PdeEditor.this).show(); handleBeautify(); } }); diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index b7190c59e..a2da0c72f 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -7,6 +7,42 @@ releases will be super crusty. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +ABOUT REV 0083 - + +- what he hope is the finalized lighting api for beta/1.0 + + + because lights are in object space, they are considered more + like a shape in this release. they are not retained and must + be "drawn" each time you run through draw(). + + + to enable a simple ambient and directional light, place inside draw: + public void lights(); + + + ambientLight(float r, float g, float b) + adds an ambient light based on the current colorMode. + + + directionalLight(r, g, b, vx, vy, vz); + sets up a direction light along vector vx, vy, vz + + + spotLight(r, g, b, x, y, z, vx, vy, vz, angle); + sets up a spotlight at a position, with a direction and an angle + + + lightFalloff(constant, linear, quadratic) + will change the falloff for the last light addressed. default + setting is lightFalloff(1, 0, 0) + + + lightSpecular(r, g, b) + sets the specular color of this light + + + ambient(), emissive(), specular() set the material properties + of shapes. they take the same form as fill() and stroke(). + + + shininess(float shiney) takes a float from 0..1 to specify + the level of shininess for the current material + +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + ABOUT REV 0082 - 6 april 2005 - casey has updated the examples, reference, and keywords. diff --git a/build/windows/launcher/launcher.cpp b/build/windows/launcher/launcher.cpp index 6896f55a1..3706cc85e 100644 --- a/build/windows/launcher/launcher.cpp +++ b/build/windows/launcher/launcher.cpp @@ -10,7 +10,7 @@ //#define JAVA_ARGS "-Xms64m -Xmx64m " #define JAVA_ARGS "-Xms128m -Xmx128m " -#define JAVA_MAIN_CLASS "PdeBase" +#define JAVA_MAIN_CLASS "processing.app.PdeBase" #include #include diff --git a/build/windows/launcher/processing.exe b/build/windows/launcher/processing.exe index 70f317c5b..ce98531b2 100755 Binary files a/build/windows/launcher/processing.exe and b/build/windows/launcher/processing.exe differ diff --git a/build/windows/make.sh b/build/windows/make.sh index 90c6662bc..3f18aa068 100755 --- a/build/windows/make.sh +++ b/build/windows/make.sh @@ -54,7 +54,7 @@ else cd ../../.. mkdir work/lib/build - mkdir work/classes + #mkdir work/classes echo Compiling processing.exe cd launcher @@ -111,7 +111,7 @@ then echo Building PDE for JDK 1.4 -cd app/preprocessor +cd app/preproc # first build the default java goop ../../build/windows/work/java/bin/java \ diff --git a/build/windows/run.sh b/build/windows/run.sh index 0988c1016..bc0c1ff49 100644 --- a/build/windows/run.sh +++ b/build/windows/run.sh @@ -34,5 +34,5 @@ CLASSPATH=\"java\\lib\\rt.jar\;lib\;lib\\build\;lib\\pde.jar\;lib\\core.jar\;lib export CLASSPATH #cd work && ./java/bin/java -Xint PdeBase -cd work && ./java/bin/java PdeBase +cd work && ./java/bin/java processing.app.PdeBase #cd work && /cygdrive/c/jdk-1.3.1_11/bin/java PdeBase diff --git a/core/PApplet.java b/core/PApplet.java index 01dfca12d..a49800752 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -5649,6 +5649,12 @@ v PApplet.this.stop(); } + public void printProjection() { + if (recorder != null) recorder.printProjection(); + g.printProjection(); + } + + public float screenX(float x, float y) { return g.screenX(x, y); } @@ -5689,98 +5695,6 @@ v PApplet.this.stop(); } - public void lights() { - if (recorder != null) recorder.lights(); - g.lights(); - } - - - public void noLights() { - if (recorder != null) recorder.noLights(); - g.noLights(); - } - - - 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); - g.light(num, x, y, z, red, green, blue); - } - - - public void lightEnable(int num) { - if (recorder != null) recorder.lightEnable(num); - g.lightEnable(num); - } - - - public void lightDisable(int num) { - if (recorder != null) recorder.lightDisable(num); - g.lightDisable(num); - } - - - public void lightPosition(int num, float x, float y, float z) { - if (recorder != null) recorder.lightPosition(num, x, y, z); - g.lightPosition(num, x, y, z); - } - - - public void lightAmbient(int num, float x, float y, float z) { - if (recorder != null) recorder.lightAmbient(num, x, y, z); - g.lightAmbient(num, x, y, z); - } - - - public void lightDiffuse(int num, float x, float y, float z) { - if (recorder != null) recorder.lightDiffuse(num, x, y, z); - g.lightDiffuse(num, x, y, z); - } - - - public void lightSpecular(int num, float x, float y, float z) { - if (recorder != null) recorder.lightSpecular(num, x, y, z); - g.lightSpecular(num, x, y, z); - } - - - public void lightDirection(int num, float x, float y, float z) { - if (recorder != null) recorder.lightDirection(num, x, y, z); - g.lightDirection(num, x, y, z); - } - - - public void lightFalloff(int num, float constant, - float linear, float quadratic) { - if (recorder != null) recorder.lightFalloff(num, constant, linear, quadratic); - g.lightFalloff(num, constant, linear, quadratic); - } - - - public void lightSpotAngle(int num, float spotAngle) { - if (recorder != null) recorder.lightSpotAngle(num, spotAngle); - g.lightSpotAngle(num, spotAngle); - } - - - public void lightSpotConcentration(int num, float concentration) { - if (recorder != null) recorder.lightSpotConcentration(num, concentration); - g.lightSpotConcentration(num, concentration); - } - - public void colorMode(int mode) { if (recorder != null) recorder.colorMode(mode); g.colorMode(mode); @@ -5951,63 +5865,49 @@ v PApplet.this.stop(); } - public int createAmbientLight(int rgb) { - return g.createAmbientLight(rgb); + public void lights() { + if (recorder != null) recorder.lights(); + g.lights(); } - public int createAmbientLight(float gray) { - return g.createAmbientLight(gray); + public void ambientLight(float red, float green, float blue) { + if (recorder != null) recorder.ambientLight(red, green, blue); + g.ambientLight(red, green, blue); } - public int createAmbientLight(float lr, float lg, float lb) { - return g.createAmbientLight(lr, lg, lb); + public void directionalLight(float red, float green, float blue, + float nx, float ny, float nz) { + if (recorder != null) recorder.directionalLight(red, green, blue, nx, ny, nz); + g.directionalLight(red, green, blue, nx, ny, nz); } - public int createDirectionalLight(int rgb, float nx, float ny, float nz) { - return g.createDirectionalLight(rgb, nx, ny, nz); + public void pointLight(float red, float green, float blue, + float x, float y, float z) { + if (recorder != null) recorder.pointLight(red, green, blue, x, y, z); + g.pointLight(red, green, blue, x, y, z); } - public int createDirectionalLight(float gray, float nx, float ny, float nz) { - return g.createDirectionalLight(gray, nx, ny, nz); + public void spotLight(float red, float green, float blue, + float x, float y, float z, + float nx, float ny, float nz, float angle) { + if (recorder != null) recorder.spotLight(red, green, blue, x, y, z, nx, ny, nz, angle); + g.spotLight(red, green, blue, x, y, z, nx, ny, nz, angle); } - public int createDirectionalLight(float lr, float lg, float lb, float nx, float ny, float nz) { - return g.createDirectionalLight(lr, lg, lb, nx, ny, nz); + public void lightFalloff(float constant, float linear, float quadratic) { + if (recorder != null) recorder.lightFalloff(constant, linear, quadratic); + g.lightFalloff(constant, linear, quadratic); } - public int createPointLight(int rgb, float x, float y, float z) { - return g.createPointLight(rgb, x, y, z); - } - - - public int createPointLight(float gray, float x, float y, float z) { - return g.createPointLight(gray, x, y, z); - } - - - public int createPointLight(float lr, float lg, float lb, float x, float y, float z) { - return g.createPointLight(lr, lg, lb, x, y, z); - } - - - public int createSpotLight(int rgb, float x, float y, float z, float nx, float ny, float nz, float angle) { - return g.createSpotLight(rgb, x, y, z, nx, ny, nz, angle); - } - - - public int createSpotLight(float gray, float x, float y, float z, float nx, float ny, float nz, float angle) { - return g.createSpotLight(gray, x, y, z, nx, ny, nz, angle); - } - - - public int createSpotLight(float lr, float lg, float lb, float x, float y, float z, float nx, float ny, float nz, float angle) { - return g.createSpotLight(lr, lg, lb, x, y, z, nx, ny, nz, angle); + public void lightSpecular(float x, float y, float z) { + if (recorder != null) recorder.lightSpecular(x, y, z); + g.lightSpecular(x, y, z); } diff --git a/core/PGraphics.java b/core/PGraphics.java index 25d249c93..a3e9d90d4 100644 --- a/core/PGraphics.java +++ b/core/PGraphics.java @@ -1980,95 +1980,32 @@ public class PGraphics extends PImage implements PConstants { public float screenX(float x, float y, float z) { depthErrorXYZ("screenX"); + return 0; } public float screenY(float x, float y, float z) { depthErrorXYZ("screenY"); + return 0; } public float screenZ(float x, float y, float z) { depthErrorXYZ("screenZ"); + return 0; } public float objectX(float x, float y, float z) { depthErrorXYZ("objectX"); + return 0; } public float objectY(float x, float y, float z) { depthErrorXYZ("objectY"); + return 0; } public float objectZ(float x, float y, float z) { depthErrorXYZ("objectZ"); - } - - - - ////////////////////////////////////////////////////////////// - - // LIGHTS - - - public void lights() { - depthError("lights"); - } - - public void noLights() { - depthError("noLights"); - } - - public void clearLights() { - depthError("clearLights"); - } - - public void defaultLights() { - depthError("defaultLights"); - } - - public void light(int num, float x, float y, float z, - float red, float green, float blue) { - depthError("light"); - } - - public void lightEnable(int num) { - depthError("lightEnable"); - } - - public void lightDisable(int num) { - depthError("lightDisable"); - } - - public void lightPosition(int num, float x, float y, float z) { - depthError("lightPosition"); - } - - public void lightAmbient(int num, float x, float y, float z) { - depthError("lightAmbient"); - } - - public void lightDiffuse(int num, float x, float y, float z) { - depthError("lightDiffuse"); - } - - public void lightSpecular(int num, float x, float y, float z) { - depthError("lightSpecular"); - } - - public void lightDirection(int num, float x, float y, float z) { - depthError("lightDirection"); - } - - public void lightFalloff(int num, float constant, - float linear, float quadratic) { - depthError("lightFalloff"); - } - - public void lightSpotAngle(int num, float spotAngle) { - depthError("lightSpotAngle"); - } - - public void lightSpotConcentration(int num, float concentration) { - depthError("lightSpotConcentration"); + return 0; } @@ -2459,56 +2396,44 @@ public class PGraphics extends PImage implements PConstants { } + ////////////////////////////////////////////////////////////// + // LIGHTS - public int createAmbientLight(int rgb) { - depthError("createAmbientLight"); + + public void lights() { + depthError("lights"); } - public int createAmbientLight(float gray) { - depthError("createAmbientLight"); + public void ambientLight(float red, float green, float blue) { + depthError("ambientLight"); } - public int createAmbientLight(float lr, float lg, float lb) { - depthError("createAmbientLight"); + public void directionalLight(float red, float green, float blue, + float nx, float ny, float nz) { + depthError("directionalLight"); } - public int createDirectionalLight(int rgb, float nx, float ny, float nz) { - depthError("createDirectionalLight"); + public void pointLight(float red, float green, float blue, + float x, float y, float z) { + depthError("pointLight"); } - public int createDirectionalLight(float gray, float nx, float ny, float nz) { - depthError("createDirectionalLight"); + public void spotLight(float red, float green, float blue, + float x, float y, float z, + float nx, float ny, float nz, float angle) { + depthError("spotLight"); } - public int createDirectionalLight(float lr, float lg, float lb, float nx, float ny, float nz) { - depthError("createDirectionalLight"); + public void lightFalloff(float constant, float linear, float quadratic) { + depthError("lightFalloff"); } - public int createPointLight(int rgb, float x, float y, float z) { - depthError("createPointLight"); + public void lightSpecular(float x, float y, float z) { + depthError("lightSpecular"); } - public int createPointLight(float gray, float x, float y, float z) { - depthError("createPointLight"); - } - - public int createPointLight(float lr, float lg, float lb, float x, float y, float z) { - depthError("createPointLight"); - } - - public int createSpotLight(int rgb, float x, float y, float z, float nx, float ny, float nz, float angle) { - depthError("createSpotLight"); - } - - public int createSpotLight(float gray, float x, float y, float z, float nx, float ny, float nz, float angle) { - depthError("createSpotLight"); - } - - public int createSpotLight(float lr, float lg, float lb, float x, float y, float z, float nx, float ny, float nz, float angle) { - depthError("createSpotLight"); - } ////////////////////////////////////////////////////////////// diff --git a/core/PGraphics3.java b/core/PGraphics3.java index dde73988b..a423da1d7 100644 --- a/core/PGraphics3.java +++ b/core/PGraphics3.java @@ -61,8 +61,6 @@ public class PGraphics3 extends PGraphics { // ........................................................ - //public int cameraMode; - // perspective setup public float cameraFOV; public float cameraX, cameraY, cameraZ; @@ -100,13 +98,13 @@ public class PGraphics3 extends PGraphics { but is the minimum defined by OpenGL */ protected static final int MAX_LIGHTS = 8; - int lightCount = 0; + public int lightCount = 0; /** True if lights are enabled */ - public boolean lights; + //public boolean lights; /** True if this light is enabled */ - public boolean light[]; + //public boolean light[]; /** Light types */ public int lightType[]; @@ -114,17 +112,19 @@ public class PGraphics3 extends PGraphics { /** Light positions */ public float lightX[], lightY[], lightZ[]; - /** Light direction */ + /** Light direction (normalized vector) */ public float lightNX[], lightNY[], lightNZ[]; /** Light falloff */ - public float lightConstantFalloff[], lightLinearFalloff[], lightQuadraticFalloff[]; + public float lightConstantFalloff[]; + public float lightLinearFalloff[]; + public float lightQuadraticFalloff[]; /** Light spot angle */ public float lightSpotAngle[]; /** Cosine of light spot angle */ - public float lightCosSpotAngle[]; + public float lightSpotAngleCos[]; /** Light spot concentration */ public float lightSpotConcentration[]; @@ -279,8 +279,9 @@ public class PGraphics3 extends PGraphics { cameraFar = cameraZ * 10.0f; cameraAspect = (float)width / (float)height; - // init lights (here instead of allocate b/c needed by opengl) - light = new boolean[MAX_LIGHTS]; + // init lights (in resize() instead of allocate() b/c needed by opengl) + //lights = new PLight[MAX_LIGHTS]; + //light = new boolean[MAX_LIGHTS]; lightX = new float[MAX_LIGHTS]; lightY = new float[MAX_LIGHTS]; lightZ = new float[MAX_LIGHTS]; @@ -298,7 +299,7 @@ public class PGraphics3 extends PGraphics { lightLinearFalloff = new float[MAX_LIGHTS]; lightQuadraticFalloff = new float[MAX_LIGHTS]; lightSpotAngle = new float[MAX_LIGHTS]; - lightCosSpotAngle = new float[MAX_LIGHTS]; + lightSpotAngleCos = new float[MAX_LIGHTS]; lightSpotConcentration = new float[MAX_LIGHTS]; // reset the cameraMode if PERSPECTIVE or ORTHOGRAPHIC @@ -349,6 +350,7 @@ public class PGraphics3 extends PGraphics { } + /* public void clearLights() { lightCount = 0; light[0] = false; @@ -356,13 +358,7 @@ public class PGraphics3 extends PGraphics { light[i] = false; } } - - - public void defaultLights() { - clearLights(); - createAmbientLight(60); - createDirectionalLight(80, 80, 80, 0, 0, -1); - } + */ public void beginFrame() { @@ -371,9 +367,11 @@ public class PGraphics3 extends PGraphics { modelview.set(camera); inverseModelview.set(inverseCamera); - if (lights) { - defaultLights(); - } + // clear out the lights, they'll have to be turned on again + lightCount = 0; + //if (lights) { + //defaultLights(); + //} // reset lines lineCount = 0; @@ -437,7 +435,8 @@ public class PGraphics3 extends PGraphics { textureMode(IMAGE); // better to leave this turned off by default - noLights(); + //noLights(); + //lightCount = 0; //lightEnable(0); //lightAmbient(0, 0, 0, 0); @@ -1415,7 +1414,7 @@ public class PGraphics3 extends PGraphics { // if no lights enabled, then all the values for r, g, b // have been set with calls to vertex() (no need to re-calculate here) - if (lights) { + if (lightCount > 0) { // The assumption here is that we are only using vertex normals // I think face normals may be necessary to offer also. We'll see. //float f[] = vertices[vertex_start]; @@ -1494,7 +1493,7 @@ public class PGraphics3 extends PGraphics { float target[], int toffset) { //System.out.println("calc_lighting normals " + nx + " " + ny + " " + nz); - if (!lights) { + if (lightCount == 0) { target[toffset + 0] = min(1.0f, er+dr); target[toffset + 1] = min(1.0f, eg+dg); target[toffset + 2] = min(1.0f, eb+db); @@ -1530,8 +1529,9 @@ public class PGraphics3 extends PGraphics { float specular_g = 0; float specular_b = 0; - for (int i = 0; i < MAX_LIGHTS; i++) { - if (!light[i]) continue; + //for (int i = 0; i < MAX_LIGHTS; i++) { + //if (!light[i]) continue; + for (int i = 0; i < lightCount; i++) { float denom = lightConstantFalloff[i]; float spotTerm = 1; @@ -1581,7 +1581,7 @@ public class PGraphics3 extends PGraphics { if (lightType[i] == SPOT) { lightDir_dot_li = -(lightNX[i]*lix + lightNY[i]*liy + lightNZ[i]*liz); - if (lightDir_dot_li <= lightCosSpotAngle[i]) { + if (lightDir_dot_li <= lightSpotAngleCos[i]) { continue; } spotTerm = pow(lightDir_dot_li, lightSpotConcentration[i]); @@ -2770,6 +2770,7 @@ public class PGraphics3 extends PGraphics { // LIGHTS + /* public void lights() { lights = true; defaultLights(); @@ -2778,6 +2779,7 @@ public class PGraphics3 extends PGraphics { public void noLights() { lights = false; } + */ /** @@ -2789,6 +2791,7 @@ public class PGraphics3 extends PGraphics { * because otherwise the compiler gets stuck on g.light() inside * the auto-generated section of PApplet) */ + /* public void light(int num, float x, float y, float z, float red, float green, float blue) { lightPosition(num, x, y, z); @@ -2807,7 +2810,6 @@ public class PGraphics3 extends PGraphics { light[num] = false; } - public void lightPosition(int num, float x, float y, float z) { lightX[num] = modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03; lightY[num] = modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13; @@ -2856,12 +2858,14 @@ public class PGraphics3 extends PGraphics { public void lightSpotAngle(int num, float spotAngle) { lightSpotAngle[num] = spotAngle; - lightCosSpotAngle[num] = max(0, cos(spotAngle)); + lightSpotAngleCos[num] = max(0, cos(spotAngle)); } public void lightSpotConcentration(int num, float concentration) { lightSpotConcentration[num] = concentration; } + */ + ////////////////////////////////////////////////////////////// @@ -3077,81 +3081,62 @@ public class PGraphics3 extends PGraphics { ////////////////////////////////////////////////////////////// - public int createAmbientLight(int rgb) { - if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above - return createAmbientLight((float) rgb); - } else { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorFrom(rgb); - return internalCreateAmbientLight(calcR, calcG, calcB); - } + /** + * Sets up an ambient and directional light. + *

+ * The directional light is setup second, so that it can be modified + * via lightSpecular() or lightFalloff() if needed. + */ + public void lights() { + // need to make sure colorMode is RGB 255 here + int colorModeSaved = colorMode; + colorMode = RGB; + + ambientLight(colorModeX * 0.23f, + colorModeY * 0.23f, + colorModeZ * 0.23f); + directionalLight(colorModeX * 0.31f, + colorModeY * 0.31f, + colorModeZ * 0.31f, + 0, 0, -1); + + colorMode = colorModeSaved; } - public int createAmbientLight(float gray) { - if (lightCount >= MAX_LIGHTS) { + + /** + * Add an ambient light based on the current color mode. + */ + public void ambientLight(float r, float g, float b) { + if (lightCount == MAX_LIGHTS) { throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); } - colorCalc(gray); - return internalCreateAmbientLight(calcR, calcG, calcB); - } + colorCalc(r, g, b); + lightDiffuseR[lightCount] = calcR; + lightDiffuseG[lightCount] = calcG; + lightDiffuseB[lightCount] = calcB; - public int createAmbientLight(float lr, float lg, float lb) { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorCalc(lr, lg, lb); - return internalCreateAmbientLight(calcR, calcG, calcB); - } - - protected int internalCreateAmbientLight(float lr, float lg, float lb) { - lightDiffuseR[lightCount] = lr; - lightDiffuseG[lightCount] = lg; - lightDiffuseB[lightCount] = lb; - light[lightCount] = true; lightType[lightCount] = AMBIENT; lightConstantFalloff[lightCount] = 1; lightLinearFalloff[lightCount] = 0; lightQuadraticFalloff[lightCount] = 0; lightPosition(lightCount, 0, 0, 0); lightCount++; - return lightCount-1; + //return lightCount-1; } - public int createDirectionalLight(int rgb, float nx, float ny, float nz) { - if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above - return createDirectionalLight((float) rgb, nx, ny, nz); - } else { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorFrom(rgb); - return internalCreateDirectionalLight(calcR, calcG, calcB, nx, ny, nz); - } - } - public int createDirectionalLight(float gray, float nx, float ny, float nz) { - if (lightCount >= MAX_LIGHTS) { + public void directionalLight(float r, float g, float b, + float nx, float ny, float nz) { + if (lightCount == MAX_LIGHTS) { throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); } - colorCalc(gray); - return internalCreateDirectionalLight(calcR, calcG, calcB, nx, ny, nz); - } + colorCalc(r, g, b); + lightDiffuseR[lightCount] = calcR; + lightDiffuseG[lightCount] = calcG; + lightDiffuseB[lightCount] = calcB; - public int createDirectionalLight(float lr, float lg, float lb, float nx, float ny, float nz) { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorCalc(lr, lg, lb); - return internalCreateDirectionalLight(calcR, calcG, calcB, nx, ny, nz); - } - - protected int internalCreateDirectionalLight(float lr, float lg, float lb, float nx, float ny, float nz) { - lightDiffuseR[lightCount] = lr; - lightDiffuseG[lightCount] = lg; - lightDiffuseB[lightCount] = lb; - light[lightCount] = true; + //light[lightCount] = true; lightType[lightCount] = DIRECTIONAL; lightConstantFalloff[lightCount] = 1; lightLinearFalloff[lightCount] = 0; @@ -3161,42 +3146,21 @@ public class PGraphics3 extends PGraphics { lightSpecularB[lightCount] = 0; lightDirection(lightCount, nx, ny, nz); lightCount++; - return lightCount-1; + //return lightCount-1; } - public int createPointLight(int rgb, float x, float y, float z) { - if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above - return createPointLight((float) rgb, x, y, z); - } else { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorFrom(rgb); - return internalCreatePointLight(calcR, calcG, calcB, x, y, z); - } - } - public int createPointLight(float gray, float x, float y, float z) { - if (lightCount >= MAX_LIGHTS) { + public void pointLight(float r, float g, float b, + float x, float y, float z) { + if (lightCount == MAX_LIGHTS) { throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); } - colorCalc(gray); - return internalCreatePointLight(calcR, calcG, calcB, x, y, z); - } + colorCalc(r, g, b); + lightDiffuseR[lightCount] = calcR; + lightDiffuseG[lightCount] = calcG; + lightDiffuseB[lightCount] = calcB; - public int createPointLight(float lr, float lg, float lb, float x, float y, float z) { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorCalc(lr, lg, lb); - return internalCreatePointLight(calcR, calcG, calcB, x, y, z); - } - - protected int internalCreatePointLight(float lr, float lg, float lb, float x, float y, float z) { - lightDiffuseR[lightCount] = lr; - lightDiffuseG[lightCount] = lg; - lightDiffuseB[lightCount] = lb; - light[lightCount] = true; + //light[lightCount] = true; lightType[lightCount] = POINT; lightConstantFalloff[lightCount] = 1; lightLinearFalloff[lightCount] = 0; @@ -3206,42 +3170,22 @@ public class PGraphics3 extends PGraphics { lightSpecularB[lightCount] = 0; lightPosition(lightCount, x, y, z); lightCount++; - return lightCount-1; + //return lightCount-1; } - public int createSpotLight(int rgb, float x, float y, float z, float nx, float ny, float nz, float angle) { - if (((rgb & 0xff000000) == 0) && (rgb <= colorModeX)) { // see above - return createSpotLight((float) rgb, x, y, z, nx, ny, nz, angle); - } else { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorFrom(rgb); - return internalCreateSpotLight(calcR, calcG, calcB, x, y, z, nx, ny, nz, angle); - } - } - public int createSpotLight(float gray, float x, float y, float z, float nx, float ny, float nz, float angle) { - if (lightCount >= MAX_LIGHTS) { + public void spotLight(float r, float g, float b, + float x, float y, float z, + float nx, float ny, float nz, float angle) { + if (lightCount == MAX_LIGHTS) { throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); } - colorCalc(gray); - return internalCreateSpotLight(calcR, calcG, calcB, x, y, z, nx, ny, nz, angle); - } + colorCalc(r, g, b); + lightDiffuseR[lightCount] = calcR; + lightDiffuseG[lightCount] = calcG; + lightDiffuseB[lightCount] = calcB; - public int createSpotLight(float lr, float lg, float lb, float x, float y, float z, float nx, float ny, float nz, float angle) { - if (lightCount >= MAX_LIGHTS) { - throw new RuntimeException("can only create " + MAX_LIGHTS + " lights"); - } - colorCalc(lr, lg, lb); - return internalCreateSpotLight(calcR, calcG, calcB, x, y, z, nx, ny, nz, angle); - } - - protected int internalCreateSpotLight(float lr, float lg, float lb, float x, float y, float z, float nx, float ny, float nz, float angle) { - lightDiffuseR[lightCount] = lr; - lightDiffuseG[lightCount] = lg; - lightDiffuseB[lightCount] = lb; - light[lightCount] = true; + //light[lightCount] = true; lightType[lightCount] = SPOT; lightConstantFalloff[lightCount] = 1; lightLinearFalloff[lightCount] = 0; @@ -3251,13 +3195,84 @@ public class PGraphics3 extends PGraphics { lightSpecularB[lightCount] = 0; lightPosition(lightCount, x, y, z); lightDirection(lightCount, nx, ny, nz); - lightSpotAngle(lightCount, angle); + lightSpotAngle[lightCount] = angle; + lightSpotAngleCos[lightCount] = max(0, cos(angle)); lightSpotConcentration[lightCount] = 1; lightCount++; - return lightCount-1; + //return lightCount-1; } + /** + * Set the light falloff rates for the last light that was created. + * Default is lightFalloff(1, 0, 0). + */ + public void lightFalloff(float constant, float linear, float quadratic) { + if (lightCount < 1) { + throw new RuntimeException("Must create a light before " + + "calling lightFalloff()"); + } + lightConstantFalloff[lightCount-1] = constant; + lightLinearFalloff[lightCount-1] = linear; + lightQuadraticFalloff[lightCount-1] = quadratic; + } + + + /** + * Set the specular color of the last light created. + */ + public void lightSpecular(float x, float y, float z) { + if (lightCount < 1) { + throw new RuntimeException("Must create a light before " + + "calling lightSpecular()."); + } + colorCalc(x, y, z); + lightSpecularR[lightCount-1] = calcR; + lightSpecularG[lightCount-1] = calcG; + lightSpecularB[lightCount-1] = calcB; + } + + + /** + * internal function to set the light position + * based on the current modelview matrix. + */ + protected void lightPosition(int num, float x, float y, float z) { + lightX[num] = + modelview.m00*x + modelview.m01*y + modelview.m02*z + modelview.m03; + lightY[num] = + modelview.m10*x + modelview.m11*y + modelview.m12*z + modelview.m13; + lightZ[num] = + modelview.m20*x + modelview.m21*y + modelview.m22*z + modelview.m23; + } + + + /** + * internal function to set the light direction + * based on the current modelview matrix. + */ + protected void lightDirection(int num, float x, float y, float z) { + // Multiply by inverse transpose. + lightNX[num] = + inverseModelview.m00*x + inverseModelview.m10*y + + inverseModelview.m20*z + inverseModelview.m30; + lightNY[num] = + inverseModelview.m01*x + inverseModelview.m11*y + + inverseModelview.m21*z + inverseModelview.m31; + lightNZ[num] = + inverseModelview.m02*x + inverseModelview.m12*y + + inverseModelview.m22*z + inverseModelview.m32; + + float norm = mag(lightNX[num], lightNY[num], lightNZ[num]); + if (norm == 0 || norm == 1) return; + + lightNX[num] /= norm; + lightNY[num] /= norm; + lightNZ[num] /= norm; + } + + + ////////////////////////////////////////////////////////////// // MATH (internal use only) diff --git a/core/PMethods.java b/core/PMethods.java index 1399694f5..b95c37c73 100755 --- a/core/PMethods.java +++ b/core/PMethods.java @@ -305,6 +305,17 @@ public interface PMethods { public void lights(); + public PLight createAmbient(); + + public PLight createDiffuse(); + + public PLight createSpecular(); + + public PLight createSpotlight(); + + public void light(myLight); + + public void noLights(); public void light(int num, float x, float y, float z, diff --git a/core/make.sh b/core/make.sh index 36926e3fa..57232ed3b 100755 --- a/core/make.sh +++ b/core/make.sh @@ -1,6 +1,7 @@ #!/bin/sh #C:\jdk-1.4.2_05\bin -/cygdrive/c/jdk-1.4.2_05/bin/javadoc -d doc *.java +#/cygdrive/c/jdk-1.4.2_05/bin/javadoc -d doc *.java #javadoc -public -d doc *.java +./preproc.pl jikes -d . +D *.java diff --git a/core/todo.txt b/core/todo.txt index 79ec5f202..ba9775ee3 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -7,6 +7,7 @@ X remove/rename postSetup() stuff from PGraphics/PApplet X camera(), perspective(), ortho() X matrix set by the camera on each beginFrame X push/pop are now pushMatrix/popMatrix +o get PGraphics.java engine working again lighting stuff X make fill() cover ambient and diffuse @@ -21,7 +22,37 @@ already done X remove PMethods as actual class, use recordFrame(PGraphics) X size(200, 200, "processing.illustrator.PGraphicsAI"); +api questions +o image(String name) and textFont(String name) +o do we change to font(arial, 12) ? +X remove angleMode() ? +X be consistent about getXxx() methods +_ just use the variable names.. don't do overkill on fillR et al +_ or just what functions are actually made public +_ is fillRi needed? it's pretty goofy.. +X how to handle full screen (opengl especially) or no screen (for scripts) +_ expose api to launch files, folders, URLs +X use with/in place of link() +_ call it open() +X what to call firstMouse +_ implement rightMouse? +_ mouseButton = LEFT, CENTER, or RIGHT + +_ should we include a from and to for the directional light? + +_ rename video.Camera to video.Video ? +_ VideoInput VideoOutput, SoundInput, SoundOutput or AudioInput/AudioOutput +_ should nf() handle commas as well? +_ yes, and add nf(int what) so that non-padded version works +_ but don't put commas into the zero-padded version +_ make nf/nfs/nfp not so weird +_ nf(PLUS, ...) nf(PAD, ...) nfc(PLUS, ...) + _ make the 1.4 code in PApplet load via reflection +_ noCursor seems to be broken on the mac? +_ error when running on 1.1... +_ You need to install Java 1.3 or later to view this content. +_ Click here to visit java.com and install. tweaking up simong light code _ what's up with resetLights? @@ -54,6 +85,10 @@ _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs NOT NECESSARY BEFORE BETA +_ bit shifting in opengl, get down to 2 ops by using other image modes +_ i.e. ABGR_EXT might allow for just two shifts instead of 4 +_ allow access to native pixel buffer in opengl and power of 2 +_ so that no need to copy/update everything _ make get/getImpl for PGraphics/PGraphics2 _ make sure there's a loadPixels/updatePixels in PGraphics2 @@ -104,8 +139,6 @@ _ The ref in PSound2 says volume accepts vals from 0...1 _ but values larger than one increase the volume. _ SoundEvent // is sound finished?? Can't access now. -_ get PGraphics.java engine working again - _ don't grab pixels of java2d images unless asked _ this is the difference between a lot of loadPixels() and not _ so important to have it in before beta if that's the change @@ -185,23 +218,6 @@ _ check with the a_Displaying example and tint(255, 0, 0, 100); _ Stroking a rect() leaves the upper right pixel off. -api questions -_ remove angleMode() ? -_ rename video.Camera to video.Video ? -_ what to call firstMouse, implement rightMouse? -_ should nf() handle commas as well? -_ yes, and add nf(int what) so that non-padded version works -_ but don't put commas into the zero-padded version -_ make nf/nfs/nfp not so weird -_ image(String name) and textFont(String name) -_ do we change to font(arial, 12) ? -_ be consistent about getXxx() methods -_ just use the variable names.. don't do overkill on fillR et al -_ or just what functions are actually made public -_ is fillRi needed? it's pretty goofy.. -_ how to handle full screen (opengl especially) or no screen (for scripts) -_ expose api to launch files, folders, URLs -_ use with/in place of link() _ might be able to do a typed expand() public Object growArray(Object array, int size) { Class type = array.getClass().getComponentType(); @@ -369,6 +385,7 @@ _ move SCREEN_SPACE into ScreenFont() class? _ probably not, casey thinks screen space text is prolly more useful _ that way can clear up some of the general confusion in the code _ check into symbol font encoding with create font +_ create font with user-specified charsets text wish list _ look into fixing the texture mapping to not squash fonts diff --git a/opengl/PGraphicsGL.java b/opengl/PGraphicsGL.java index aa6c258e1..b5c296640 100644 --- a/opengl/PGraphicsGL.java +++ b/opengl/PGraphicsGL.java @@ -28,11 +28,19 @@ import processing.core.*; import net.java.games.jogl.*; +/** + * Implementation of the PGraphics API that + * employs OpenGL rendering via JOGL. + *

+ * Lighting and camera implementation by Simon Greenwold. + */ public class PGraphicsGL extends PGraphics3 { public GL gl; public GLU glu; public GLCanvas canvas; + protected float[] projectionFloats; + /** * true if the host system is big endian (mac, irix, sun), * false if little endian (intel). @@ -50,7 +58,7 @@ public class PGraphicsGL extends PGraphics3 { if (applet == null) { throw new RuntimeException("The applet passed to PGraphicsGL " + - "cannot be null."); + "cannot be null"); } //System.out.println("creating PGraphicsGL 2"); @@ -157,6 +165,7 @@ public class PGraphicsGL extends PGraphics3 { /* // this was additional stuff used when the animator // thread was being shut down.. how to handle this.. + // (doesn't seem to be needed?) drawable.setNoAutoRedrawMode(false); try { @@ -177,18 +186,17 @@ public class PGraphicsGL extends PGraphics3 { /** - * Called by resize(), but nothing to allocate for an OpenGL canvas. + * Called by resize(), but nothing to allocate for an OpenGL canvas + * because OpenGL's pixel buffer is all handled internally. */ protected void allocate() { - // nothing to do here just yet - // normally this allocates the pixel buffer, etc. + // nothing to do here } // public void defaults() { } - // this sets up the positions of the two base lights - // not sure if this needs to be enabled in opengl + /* private void syncMatrices() { gl.glMatrixMode(GL.GL_PROJECTION); @@ -203,20 +211,65 @@ public class PGraphicsGL extends PGraphics3 { gl.glLoadIdentity(); gl.glScalef(1, -1, 1); } + */ + /* public void clearLights() { super.clearLights(); for (int i = 0; i < MAX_LIGHTS; i++) { lightDisable(i); } } + */ + public void beginFrame() { super.beginFrame(); - syncMatrices(); + report("top beginFrame()"); + gl.glDisable(GL.GL_LIGHTING); + for (int i = 0; i < MAX_LIGHTS; i++) { + gl.glDisable(GL.GL_LIGHT0 + i); + } + + //syncMatrices(); + gl.glMatrixMode(GL.GL_PROJECTION); + if (projectionFloats == null) { + projectionFloats = new float[] { + projection.m00, projection.m10, projection.m20, projection.m30, + projection.m01, projection.m11, projection.m21, projection.m31, + projection.m02, projection.m12, projection.m22, projection.m32, + projection.m03, projection.m13, projection.m23, projection.m33 + }; + } else { + projectionFloats[0] = projection.m00; + projectionFloats[1] = projection.m10; + projectionFloats[2] = projection.m20; + projectionFloats[3] = projection.m30; + + projectionFloats[4] = projection.m01; + projectionFloats[5] = projection.m11; + projectionFloats[6] = projection.m21; + projectionFloats[7] = projection.m31; + + projectionFloats[8] = projection.m02; + projectionFloats[9] = projection.m12; + projectionFloats[10] = projection.m22; + projectionFloats[11] = projection.m32; + + projectionFloats[12] = projection.m03; + projectionFloats[13] = projection.m13; + projectionFloats[14] = projection.m23; + projectionFloats[15] = projection.m33; + } + gl.glLoadMatrixf(projectionFloats); + + gl.glMatrixMode(GL.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glScalef(1, -1, 1); + // these are necessary for alpha (i.e. fonts) to work gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); @@ -226,10 +279,6 @@ public class PGraphicsGL extends PGraphics3 { // use <= since that's what processing.core does gl.glDepthFunc(GL.GL_LEQUAL); - // I never really got the hang of lighting in OpenGL ... - // I've done something like [the following] which at least - // demonstrates that it works... --tom carden - // because y is flipped gl.glFrontFace(GL.GL_CW); @@ -273,7 +322,9 @@ public class PGraphicsGL extends PGraphics3 { report("bot endFrame()"); } - // For now we do our own lighting (so sum the specular and diffuse light colors...) + + // For now we do our own lighting (so sum the specular + // and diffuse light colors...) protected void handle_lighting() { super.handle_lighting(); for (int i = vertex_start; i < vertex_end; i++) { @@ -282,18 +333,16 @@ public class PGraphicsGL extends PGraphics3 { v[G] = min(ONE, v[G] + v[SPG]); v[B] = min(ONE, v[B] + v[SPB]); } - } + private final float min(float a, float b) { return (a < b) ? a : b; } - protected void render_triangles() { - //public void render_triangles() { - report("into triangles"); - //System.out.println("into triangles error " + PApplet.hex(gl.glGetError())); + protected void render_triangles() { + report("into triangles"); //System.out.println("rendering " + triangleCount + " triangles"); for (int i = 0; i < triangleCount; i ++) { @@ -688,6 +737,7 @@ public class PGraphicsGL extends PGraphics3 { ////////////////////////////////////////////////////////////// + /* public void textMode(int mode) { // TODO get this guy straightened out if (mode != OBJECT) { @@ -696,11 +746,12 @@ public class PGraphicsGL extends PGraphics3 { } super.textMode(mode); } + */ - public void cameraMode(int mode) { - super.cameraMode(mode); - syncMatrices(); - } + //public void cameraMode(int mode) { + //super.cameraMode(mode); + //syncMatrices(); + //} ////////////////////////////////////////////////////////////// @@ -741,50 +792,9 @@ public class PGraphicsGL extends PGraphics3 { } */ + ////////////////////////////////////////////////////////////// - protected int internalCreateAmbientLight(float lr, float lg, float lb) { - int num = super.internalCreateAmbientLight(lr, lg, lb); - lightEnable(num); - glLightAmbient(num); - glLightPosition(num); - glLightFalloff(num); - return num; - } - - protected int internalCreateDirectionalLight(float lr, float lg, float lb, float nx, float ny, float nz) { - int num = super.internalCreateDirectionalLight(lr, lg, lb, nx, ny, nz); - lightEnable(num); - glLightNoAmbient(num); - glLightDirection(num); - glLightDiffuse(num); - glLightSpecular(num); - glLightFalloff(num); - return num; - } - - protected int internalCreatePointLight(float lr, float lg, float lb, float x, float y, float z) { - int num = super.internalCreatePointLight(lr, lg, lb, x, y, z); - glLightNoAmbient(num); - glLightPosition(num); - glLightDiffuse(num); - glLightSpecular(num); - glLightFalloff(num); - return num; - } - - protected int internalCreateSpotLight(float lr, float lg, float lb, float x, float y, float z, float nx, float ny, float nz, float angle) { - int num = super.internalCreateSpotLight(lr, lg, lb, x, y, z, nx, ny, nz, angle); - glLightNoAmbient(num); - glLightPosition(num); - glLightDirection(num); - glLightDiffuse(num); - glLightSpecular(num); - glLightFalloff(num); - glLightSpotAngle(num); - glLightSpotConcentration(num); - return num; - } // We're not actually turning on GL lights right now // because our home-grown ones work better for now. @@ -793,117 +803,186 @@ public class PGraphicsGL extends PGraphics3 { //gl.glEnable(GL.GL_LIGHTING); } - public void noLights() { - super.noLights(); - gl.glDisable(GL.GL_LIGHTING); + //public void noLights() { + //super.noLights(); + //gl.glDisable(GL.GL_LIGHTING); + //} + + + public void ambientLight(float r, float g, float b) { + super.ambientLight(r, g, b); + glLightEnable(lightCount - 1); + glLightAmbient(lightCount - 1); + glLightPosition(lightCount - 1); + glLightFalloff(lightCount - 1); + //return num; } - public void lightEnable(int num) { - super.lightEnable(num); - gl.glEnable(GL.GL_LIGHT0 + num); + public void directionalLight(float r, float g, float b, + float nx, float ny, float nz) { + super.directionalLight(r, g, b, nx, ny, nz); + //int num = super.internalCreateDirectionalLight(lr, lg, lb, nx, ny, nz); + glLightEnable(lightCount - 1); + glLightNoAmbient(lightCount - 1); + glLightDirection(lightCount - 1); + glLightDiffuse(lightCount - 1); + glLightSpecular(lightCount - 1); + glLightFalloff(lightCount - 1); + //return num; } - public void lightDisable(int num) { - super.lightDisable(num); - gl.glDisable(GL.GL_LIGHT0 + num); + public void pointLight(float r, float g, float b, + float x, float y, float z) { + super.pointLight(r, g, b, x, y, z); + //int num = super.internalCreatePointLight(lr, lg, lb, x, y, z); + glLightEnable(lightCount - 1); + glLightNoAmbient(lightCount - 1); + glLightPosition(lightCount - 1); + glLightDiffuse(lightCount - 1); + glLightSpecular(lightCount - 1); + glLightFalloff(lightCount - 1); + //return num; } - public void lightPosition(int num, float x, float y, float z) { + public void spotLight(float r, float g, float b, + float x, float y, float z, + float nx, float ny, float nz, float angle) { + super.spotLight(r, g, b, x, y, z, nx, ny, nz, angle); + //int num = super.internalCreateSpotLight(lr, lg, lb, x, y, z, nx, ny, nz, angle); + glLightNoAmbient(lightCount - 1); + glLightPosition(lightCount - 1); + glLightDirection(lightCount - 1); + glLightDiffuse(lightCount - 1); + glLightSpecular(lightCount - 1); + glLightFalloff(lightCount - 1); + glLightSpotAngle(lightCount - 1); + glLightSpotConcentration(lightCount - 1); + //return num; + } + + + //public void lightDisable(int num) { + //super.lightDisable(num); + //gl.glDisable(GL.GL_LIGHT0 + num); + //} + + + public void lightFalloff(float constant, float linear, float quadratic) { + super.lightFalloff(constant, linear, quadratic); + glLightFalloff(lightCount - 1); + } + + + public void lightSpecular(float x, float y, float z) { + super.lightSpecular(x, y, z); + glLightSpecular(lightCount - 1); + } + + + ////////////////////////////////////////////////////////////// + + // internal helper functions to update position and direction + // (eventually remove the 'num' param here) + + + protected void lightPosition(int num, float x, float y, float z) { super.lightPosition(num, x, y, z); glLightPosition(num); } - public void glLightPosition(int num) { - gl.glLightfv(GL.GL_LIGHT0 + num, - GL.GL_POSITION, new float[] { lightX[num], lightY[num], lightZ[num] }); - } - public void lightDirection(int num, float x, float y, float z) { + protected void lightDirection(int num, float x, float y, float z) { super.lightDirection(num, x, y, z); glLightDirection(num); } - public void glLightDirection(int num) { - if (lightType[num] == DIRECTIONAL) { - gl.glLightfv(GL.GL_LIGHT0 + num, - GL.GL_POSITION, new float[] { lightNX[num], lightNY[num], lightNZ[num], 1 }); - } else { // Spot light - gl.glLightfv(GL.GL_LIGHT0 + num, - GL.GL_SPOT_DIRECTION, new float[] { lightNX[num], lightNY[num], lightNZ[num] }); - } + ////////////////////////////////////////////////////////////// + + // internal functions to update gl state for lighting variables + // (eventually remove the 'num' param here) + + + protected void glLightAmbient(int num) { + gl.glLightfv(GL.GL_LIGHT0 + num, + GL.GL_AMBIENT, new float[] { lightDiffuseR[num], + lightDiffuseG[num], + lightDiffuseB[num] }); } - public void lightAmbient(int num, float x, float y, float z) { - super.lightAmbient(num, x, y, z); - glLightAmbient(num); - } - public void glLightNoAmbient(int num) { + protected void glLightNoAmbient(int num) { gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_AMBIENT, new float[] { 0, 0, 0 }); } - public void glLightAmbient(int num) { - gl.glLightfv(GL.GL_LIGHT0 + num, - GL.GL_AMBIENT, new float[] { lightDiffuseR[num], lightDiffuseG[num], lightDiffuseB[num] }); - } - - public void lightDiffuse(int num, float x, float y, float z) { - super.lightDiffuse(num, x, y, z); - glLightDiffuse(num); - } - - public void glLightDiffuse(int num) { + protected void glLightDiffuse(int num) { gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_DIFFUSE, new float[] { lightDiffuseR[num], lightDiffuseG[num], lightDiffuseB[num] }); } - public void lightSpecular(int num, float x, float y, float z) { - super.lightSpecular(num, x, y, z); - glLightSpecular(num); + + protected void glLightDirection(int num) { + if (lightType[num] == DIRECTIONAL) { + gl.glLightfv(GL.GL_LIGHT0 + num, + GL.GL_POSITION, new float[] { lightNX[num], + lightNY[num], + lightNZ[num], 1 }); + } else { // spotlight + gl.glLightfv(GL.GL_LIGHT0 + num, + GL.GL_SPOT_DIRECTION, + new float[] { lightNX[num], + lightNY[num], + lightNZ[num] }); + } } - public void glLightSpecular(int num) { + + protected void glLightEnable(int num) { + gl.glEnable(GL.GL_LIGHT0 + num); + } + + + protected void glLightFalloff(int num) { + gl.glLightf(GL.GL_LIGHT0 + num, + GL.GL_CONSTANT_ATTENUATION, lightConstantFalloff[num]); + gl.glLightf(GL.GL_LIGHT0 + num, + GL.GL_LINEAR_ATTENUATION, lightLinearFalloff[num]); + gl.glLightf(GL.GL_LIGHT0 + num, + GL.GL_QUADRATIC_ATTENUATION, lightQuadraticFalloff[num]); + } + + + protected void glLightPosition(int num) { + gl.glLightfv(GL.GL_LIGHT0 + num, + GL.GL_POSITION, + new float[] { lightX[num], lightY[num], lightZ[num] }); + } + + + protected void glLightSpecular(int num) { gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_SPECULAR, new float[] { lightSpecularR[num], lightSpecularG[num], lightSpecularB[num] }); } - public void lightFalloff(int num, float constant, float linear, float quadratic) { - super.lightFalloff(num, constant, linear, quadratic); - glLightFalloff(num); - } - - public void glLightFalloff(int num) { - gl.glLightf(GL.GL_LIGHT0 + num, GL.GL_CONSTANT_ATTENUATION, lightConstantFalloff[num]); - gl.glLightf(GL.GL_LIGHT0 + num, GL.GL_LINEAR_ATTENUATION, lightLinearFalloff[num]); - gl.glLightf(GL.GL_LIGHT0 + num, GL.GL_QUADRATIC_ATTENUATION, lightQuadraticFalloff[num]); - } - - public void lightSpotAngle(int num, float spotAngle) { - super.lightSpotAngle(num, spotAngle); - glLightSpotAngle(num); - } public void glLightSpotAngle(int num) { - gl.glLightf(GL.GL_LIGHT0 + num, GL.GL_SPOT_CUTOFF, lightSpotAngle[num]); + gl.glLightf(GL.GL_LIGHT0 + num, + GL.GL_SPOT_CUTOFF, lightSpotAngle[num]); } - public void lightSpotConcentration(int num, float concentration) { - super.lightSpotConcentration(num, concentration); - glLightSpotConcentration(num); - } public void glLightSpotConcentration(int num) { - gl.glLightf(GL.GL_LIGHT0 + num, GL.GL_SPOT_EXPONENT, lightSpotConcentration[num]); + gl.glLightf(GL.GL_LIGHT0 + num, + GL.GL_SPOT_EXPONENT, lightSpotConcentration[num]); } @@ -981,11 +1060,13 @@ public class PGraphicsGL extends PGraphics3 { gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] {calcR, calcG, calcB, calcA}); } + public void ambient(float gray) { super.ambient(gray); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] {calcR, calcG, calcB, calcA}); } + public void ambient(float x, float y, float z) { super.ambient(x, y, z); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, new float[] {calcR, calcG, calcB, calcA}); @@ -1023,23 +1104,31 @@ public class PGraphicsGL extends PGraphics3 { gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, new float[] {calcR, calcG, calcB, calcA}); } + ////////////////////////////////////////////////////////////// + public void emissive(int rgb) { super.emissive(rgb); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, new float[] {calcR, calcG, calcB, calcA}); } + public void emissive(float gray) { super.emissive(gray); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, new float[] {calcR, calcG, calcB, calcA}); } + public void emissive(float x, float y, float z) { super.emissive(x, y, z); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, new float[] {calcR, calcG, calcB, calcA}); } + + ////////////////////////////////////////////////////////////// + + public void shininess(float shine) { super.shininess(shine); gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, shine); diff --git a/todo.txt b/todo.txt index af33dd316..0517e9037 100644 --- a/todo.txt +++ b/todo.txt @@ -8,16 +8,21 @@ X get both versions of size() properly detected on export _ remove PdeXxx prefixes on names, make PdeBase into just "Processing" +_ remove particles from current processing +_ move netscape library out of libs and into build/shared + _ update .exe to use new class package _ update .app to use new package _ update linux shell script for new package -fixed in 82 -X border weirdness in PdeEditor panels on windows +_ get latest sonia from amit _ make a linux version _ need to fix up the make/dist scripts for linux +fixed in 82 +X border weirdness in PdeEditor panels on windows + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . @@ -243,22 +248,27 @@ _ println() for debugging TALK TO CASEY ABOUT... -_ must call depth() for 3D applications +o no transformations before background() is called +o implementation specific, may cause trouble +o must call depth() for 3D applications _ lights cannot be enabled/disabled throughout _ lighting will be based on what's left at endFrame() -_ images should be a power of 2, or call modified() -_ document the use of "die" -_ can override the method to do your own handling -_ sketches no longer require a "data" folder -_ example that uses loop/noLoop, or redraw? +X images should be a power of 2, or call modified() +X document the use of "die" +X can override the method to do your own handling +X sketches no longer require a "data" folder +X example that uses loop/noLoop, or redraw? _ talk to creas about making html files for bugs, readme, revisions. _ or how they should relate to the 'faq'.. readme -> faq? _ make a sketch that shows loading from the web _ make another sketch that shows loading from a file _ make notes about preproc +_ move the readme stuff for each file into the files themselves +_ also put a general rundown of the preproc into Preprocessor.java _ subclasses need to use "public void keyPressed" not "void keyPressed" _ write a threading example -_ or handle this some more intelligent way, super.stop() is needed. +X or handle this some more intelligent way, super.stop() is needed. +X registerDispose() does the trick _ http://processing.org/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1083574943 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Syntax;action=display;num=1067383998 _ write an example that uses Hashtable @@ -266,9 +276,7 @@ _ and another that uses Vector _ beginShape() defaults to beginShape(POLYGON) _ needs to be noted for the reference _ make a note that u/v coordinates clamp at 0 and 1 -_ no transformations before background() is called -_ implementation specific, may cause trouble -_ get an xml library in there +_ get an xml library and example in there _ nanoxml problems with manifest _ appears to use 1.6.8 version since it's just two classes @@ -301,9 +309,9 @@ _ need to ignore comments.. but not those inside quotes.. oog _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1067309918;start=0 _ ignores colons for case statements _ need to tie this to the parser instead -_ do a better job of maintaining cursor during beautify -_ only beautify a particular section of code -_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1087227217 +_ do a better job of maintaining cursor during beautify +_ only beautify a particular section of code +_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1087227217 _ color picker or other things written by folks _ add all .jar files in lib/plugins on startup _ make some kind of internal color picker @@ -371,12 +379,9 @@ PDE / Details 1 _ exception in setup() on external app doesn't kill run button 1 _ also doesn't kill external vm + 1 _ quitting from present mode doesn't kill run button 1 _ package processing.app for PdeBase, PdeEditor.. - 1 _ save caret position when switching tabs - 1 _ ctrl-tab to switch between tabs - 1 _ maintain tab scroll and caret positions - 1 _ add mnemonics for menus (alt-f to open 'file') 1 _ processing.exe: problem if expert version is run, and no java installed @@ -444,6 +449,10 @@ PDE / Find & Replace PDE / Editor Header 1 _ make some fancy extendo things because the tabs get too big + 1 _ either condense or popdown menu thingy + 1 _ save caret position when switching tabs + 1 _ ctrl-tab to switch between tabs + 1 _ maintain tab scroll and caret positions PDE / Sketch & Sketchbook