diff --git a/core/PApplet.java b/core/PApplet.java index 6d2da3a00..e1992db36 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -5687,7 +5687,7 @@ v PApplet.this.stop(); static public boolean saveHeaderTIFF(OutputStream output, - int width, int height) { + int width, int height) { return PGraphics.saveHeaderTIFF(output, width, height); } @@ -5698,12 +5698,6 @@ v PApplet.this.stop(); } - static public boolean saveHeaderTGA(OutputStream output, - int width, int height) { - return PGraphics.saveHeaderTGA(output, width, height); - } - - static public boolean saveTGA(OutputStream output, int pixels[], int width, int height) { return PGraphics.saveTGA(output, pixels, width, height); @@ -5914,6 +5908,12 @@ v PApplet.this.stop(); } + public void bezierDetail(int detail) { + if (recorder != null) recorder.bezierDetail(detail); + g.bezierDetail(detail); + } + + public void bezier(float x1, float y1, float x2, float y2, float x3, float y3, @@ -5932,9 +5932,14 @@ v PApplet.this.stop(); } - public void bezierDetail(int detail) { - if (recorder != null) recorder.bezierDetail(detail); - g.bezierDetail(detail); + public float curvePoint(float a, float b, float c, float d, float t) { + return g.curvePoint(a, b, c, d, t); + } + + + public float curveTangent(float a, float b, float c, float d, + float t) { + return g.curveTangent(a, b, c, d, t); } @@ -5950,17 +5955,6 @@ v PApplet.this.stop(); } - public float curvePoint(float a, float b, float c, float d, float t) { - return g.curvePoint(a, b, c, d, t); - } - - - public float curveTangent(float a, float b, float c, float d, - float t) { - return g.curveTangent(a, b, c, d, t); - } - - public void curve(float x1, float y1, float x2, float y2, float x3, float y3, @@ -6000,42 +5994,12 @@ v PApplet.this.stop(); } - public void textFont(PFont which, float size) { - if (recorder != null) recorder.textFont(which, size); - g.textFont(which, size); - } - - - public void textFont(PFont which) { - if (recorder != null) recorder.textFont(which); - g.textFont(which); - } - - - public void textSize(float size) { - if (recorder != null) recorder.textSize(size); - g.textSize(size); - } - - - public void textLeading(float leading) { - if (recorder != null) recorder.textLeading(leading); - g.textLeading(leading); - } - - public void textAlign(int align) { if (recorder != null) recorder.textAlign(align); g.textAlign(align); } - public void textMode(int mode) { - if (recorder != null) recorder.textMode(mode); - g.textMode(mode); - } - - public float textAscent() { return g.textAscent(); } @@ -6046,6 +6010,36 @@ v PApplet.this.stop(); } + public void textFont(PFont which) { + if (recorder != null) recorder.textFont(which); + g.textFont(which); + } + + + public void textFont(PFont which, float size) { + if (recorder != null) recorder.textFont(which, size); + g.textFont(which, size); + } + + + public void textLeading(float leading) { + if (recorder != null) recorder.textLeading(leading); + g.textLeading(leading); + } + + + public void textMode(int mode) { + if (recorder != null) recorder.textMode(mode); + g.textMode(mode); + } + + + public void textSize(float size) { + if (recorder != null) recorder.textSize(size); + g.textSize(size); + } + + public float textWidth(char c) { return g.textWidth(c); } @@ -6210,15 +6204,15 @@ v PApplet.this.stop(); } - public void printMatrix() { - if (recorder != null) recorder.printMatrix(); - g.printMatrix(); + public void loadMatrix() { + if (recorder != null) recorder.loadMatrix(); + g.loadMatrix(); } - public void cameraMode(int mode) { - if (recorder != null) recorder.cameraMode(mode); - g.cameraMode(mode); + public void printMatrix() { + if (recorder != null) recorder.printMatrix(); + g.printMatrix(); } @@ -6248,6 +6242,12 @@ v PApplet.this.stop(); } + public void printCamera() { + if (recorder != null) recorder.printCamera(); + g.printCamera(); + } + + public void ortho() { if (recorder != null) recorder.ortho(); g.ortho(); @@ -6281,12 +6281,6 @@ v PApplet.this.stop(); } - public void printCamera() { - if (recorder != null) recorder.printCamera(); - g.printCamera(); - } - - public void printProjection() { if (recorder != null) recorder.printProjection(); g.printProjection(); @@ -6359,6 +6353,60 @@ v PApplet.this.stop(); } + public void strokeWeight(float weight) { + if (recorder != null) recorder.strokeWeight(weight); + g.strokeWeight(weight); + } + + + public void strokeJoin(int join) { + if (recorder != null) recorder.strokeJoin(join); + g.strokeJoin(join); + } + + + public void strokeCap(int cap) { + if (recorder != null) recorder.strokeCap(cap); + g.strokeCap(cap); + } + + + public void noStroke() { + if (recorder != null) recorder.noStroke(); + g.noStroke(); + } + + + public void stroke(int rgb) { + if (recorder != null) recorder.stroke(rgb); + g.stroke(rgb); + } + + + public void stroke(float gray) { + if (recorder != null) recorder.stroke(gray); + g.stroke(gray); + } + + + public void stroke(float gray, float alpha) { + if (recorder != null) recorder.stroke(gray, alpha); + g.stroke(gray, alpha); + } + + + public void stroke(float x, float y, float z) { + if (recorder != null) recorder.stroke(x, y, z); + g.stroke(x, y, z); + } + + + public void stroke(float x, float y, float z, float a) { + if (recorder != null) recorder.stroke(x, y, z, a); + g.stroke(x, y, z, a); + } + + public void noTint() { if (recorder != null) recorder.noTint(); g.noTint(); @@ -6515,7 +6563,8 @@ v PApplet.this.stop(); } - public void ambientLight(float red, float green, float blue, float x, float y, float z) { + public void ambientLight(float red, float green, float blue, + float x, float y, float z) { if (recorder != null) recorder.ambientLight(red, green, blue, x, y, z); g.ambientLight(red, green, blue, x, y, z); } @@ -6556,60 +6605,6 @@ v PApplet.this.stop(); } - public void strokeWeight(float weight) { - if (recorder != null) recorder.strokeWeight(weight); - g.strokeWeight(weight); - } - - - public void strokeJoin(int join) { - if (recorder != null) recorder.strokeJoin(join); - g.strokeJoin(join); - } - - - public void strokeCap(int cap) { - if (recorder != null) recorder.strokeCap(cap); - g.strokeCap(cap); - } - - - public void noStroke() { - if (recorder != null) recorder.noStroke(); - g.noStroke(); - } - - - public void stroke(int rgb) { - if (recorder != null) recorder.stroke(rgb); - g.stroke(rgb); - } - - - public void stroke(float gray) { - if (recorder != null) recorder.stroke(gray); - g.stroke(gray); - } - - - public void stroke(float gray, float alpha) { - if (recorder != null) recorder.stroke(gray, alpha); - g.stroke(gray, alpha); - } - - - public void stroke(float x, float y, float z) { - if (recorder != null) recorder.stroke(x, y, z); - g.stroke(x, y, z); - } - - - public void stroke(float x, float y, float z, float a) { - if (recorder != null) recorder.stroke(x, y, z, a); - g.stroke(x, y, z, a); - } - - public void background(int rgb) { if (recorder != null) recorder.background(rgb); g.background(rgb); diff --git a/core/PGraphics.java b/core/PGraphics.java index e09419134..b05af5a12 100644 --- a/core/PGraphics.java +++ b/core/PGraphics.java @@ -302,21 +302,10 @@ public class PGraphics extends PImage implements PConstants { // Material properties public float ambientR, ambientG, ambientB; - public int ambientRi, ambientGi, ambientBi; - public float specularR, specularG, specularB, specularA; - public int specularRi, specularGi, specularBi, specularAi; - public float emissiveR, emissiveG, emissiveB; - public int emissiveRi, emissiveGi, emissiveBi; - public float shininess; - // Used to shuttle lighting calcs around - // (no need to re-allocate all the time) - public float[] tempLightingContribution = new float[LIGHT_COLOR_COUNT]; - public float[] worldNormal = new float[4]; - // ........................................................ /** Camera field of view (in radians, as of rev 86) */ @@ -343,7 +332,7 @@ public class PGraphics extends PImage implements PConstants { /** Maximum lights by default is 8, which is arbitrary, but is the minimum defined by OpenGL */ - protected static final int MAX_LIGHTS = 8; + public static final int MAX_LIGHTS = 8; public int lightCount = 0; @@ -379,60 +368,18 @@ public class PGraphics extends PImage implements PConstants { Internally these are stored as numbers between 0 and 1. */ public float lightsSpecularR[], lightsSpecularG[], lightsSpecularB[]; + /** Current specular color for lighting */ public float lightSpecularR; public float lightSpecularG; public float lightSpecularB; + + /** Current light falloff */ public float lightFalloffConstant; public float lightFalloffLinear; public float lightFalloffQuadratic; // ........................................................ - // pos of first vertex of current shape in vertices array - protected int vertex_start; - - // i think vertex_end is actually the last vertex in the current shape - // and is separate from vertexCount for occasions where drawing happens - // on endFrame with all the triangles being depth sorted - protected int vertex_end; - - // vertices may be added during clipping against the near plane. - protected int vertex_end_including_clip_verts; - - // used for sorting points when triangulating a polygon - // warning - maximum number of vertices for a polygon is DEFAULT_VERTICES - int vertex_order[] = new int[DEFAULT_VERTICES]; - - // ........................................................ - - public int pathCount; - public int pathOffset[] = new int[64]; - public int pathLength[] = new int[64]; - - // ........................................................ - - // lines - static final int DEFAULT_LINES = 512; - PLine line; // used for drawing - public int lines[][] = new int[DEFAULT_LINES][LINE_FIELD_COUNT]; - public int lineCount; - - // ........................................................ - - // triangles - static final int DEFAULT_TRIANGLES = 256; - PTriangle triangle; - public int triangles[][] = - new int[DEFAULT_TRIANGLES][TRIANGLE_FIELD_COUNT]; - public float triangleColors[][][] = - new float[DEFAULT_TRIANGLES][3][TRIANGLE_COLOR_COUNT]; - public int triangleCount; // total number of triangles - - // cheap picking someday - int shape_index; - - // ........................................................ - /** * Sets whether texture coordinates passed to * vertex() calls will be based on coordinates that are @@ -449,12 +396,9 @@ public class PGraphics extends PImage implements PConstants { /** Current vertical coordinate for texture, see above. */ public float textureV; + /** Current image being used as a texture */ public PImage textureImage; - static final int DEFAULT_TEXTURES = 3; - protected PImage textures[] = new PImage[DEFAULT_TEXTURES]; - int texture_index; - // ........................................................ /** @@ -469,7 +413,6 @@ public class PGraphics extends PImage implements PConstants { // [toxi031031] new & faster sphere code w/ support flexibile resolutions // will be set by sphereDetail() or 1st call to sphere() public int sphereDetail = 0; - float sphereX[], sphereY[], sphereZ[]; diff --git a/core/PGraphics2.java b/core/PGraphics2.java index 48b6a7220..55c75a8a4 100644 --- a/core/PGraphics2.java +++ b/core/PGraphics2.java @@ -739,19 +739,19 @@ public class PGraphics2 extends PGraphics { ////////////////////////////////////////////////////////////// - protected void colorTint() { - super.colorTint(); + protected void tintFromCalc() { + super.tintFromCalc(); // TODO actually implement tinted images tintColorObject = new Color(tintColor, true); } - protected void colorFill() { - super.colorFill(); + protected void fillFromCalc() { + super.fillFromCalc(); fillColorObject = new Color(fillColor, true); } - protected void colorStroke() { - super.colorStroke(); + protected void strokeFromCalc() { + super.strokeFromCalc(); strokeColorObject = new Color(strokeColor, true); } diff --git a/core/PGraphics3.java b/core/PGraphics3.java index 54a7cce12..566d09fc1 100644 --- a/core/PGraphics3.java +++ b/core/PGraphics3.java @@ -34,39 +34,39 @@ import java.awt.image.*; public class PGraphics3 extends PGraphics { /** The modelview matrix. */ - public PMatrix modelview; + //public PMatrix modelview; /** Inverse modelview matrix, used for lighting. */ - public PMatrix modelviewInv; + //public PMatrix modelviewInv; /** * The camera matrix, the modelview * will be set to this on beginFrame. */ - public PMatrix camera; + //public PMatrix camera; /** Inverse camera matrix */ - public PMatrix cameraInv; + //public PMatrix cameraInv; // ........................................................ // Lighting-related variables // store the facing direction to speed rendering - protected boolean useBackfaceCulling = false; // is this in use? + //protected boolean useBackfaceCulling = false; // is this in use? // Material properties - public float ambientR, ambientG, ambientB; + //public float ambientR, ambientG, ambientB; //public int ambientRi, ambientGi, ambientBi; - public float specularR, specularG, specularB, specularA; + //public float specularR, specularG, specularB, specularA; //public int specularRi, specularGi, specularBi, specularAi; - public float emissiveR, emissiveG, emissiveB; + //public float emissiveR, emissiveG, emissiveB; //public int emissiveRi, emissiveGi, emissiveBi; - public float shininess; + //public float shininess; // Whether or not we have to worry about vertex position for lighting calcs private boolean lightingDependsOnVertexPosition; @@ -91,85 +91,85 @@ public class PGraphics3 extends PGraphics { // ........................................................ /** Camera field of view (in radians, as of rev 86) */ - public float cameraFOV; + //public float cameraFOV; /** Position of the camera */ - public float cameraX, cameraY, cameraZ; + //public float cameraX, cameraY, cameraZ; - public float cameraNear, cameraFar; - public float cameraAspect; + //public float cameraNear, cameraFar; + //public float cameraAspect; /** * This is turned on at beginCamera, and off at endCamera * Currently we don't support nested begin/end cameras. * If we wanted to, this variable would have to become a stack. */ - public boolean manipulatingCamera; + protected boolean manipulatingCamera; // projection matrix - public PMatrix projection; // = new PMatrix(); + //public PMatrix projection; // = new PMatrix(); // These two matrices always point to either the modelview // or the modelviewInv, but they are swapped during // when in camera maniuplation mode. That way camera transforms // are automatically accumulated in inverse on the modelview matrix. - public PMatrix forwardTransform; - public PMatrix reverseTransform; + protected PMatrix forwardTransform; + protected PMatrix reverseTransform; // ........................................................ /// the stencil buffer - public int stencil[]; + //public int stencil[]; /// depth buffer - public float zbuffer[]; + //public float zbuffer[]; // ........................................................ /** Maximum lights by default is 8, which is arbitrary, but is the minimum defined by OpenGL */ - protected static final int MAX_LIGHTS = 8; + //public static final int MAX_LIGHTS = 8; - public int lightCount = 0; + //public int lightCount = 0; /** Light types */ - public int lights[]; + //public int lights[]; /** Light positions */ - public float lightsX[], lightsY[], lightsZ[]; + //public float lightsX[], lightsY[], lightsZ[]; /** Light direction (normalized vector) */ - public float lightsNX[], lightsNY[], lightsNZ[]; + //public float lightsNX[], lightsNY[], lightsNZ[]; /** Light falloff */ - public float lightsFalloffConstant[]; - public float lightsFalloffLinear[]; - public float lightsFalloffQuadratic[]; + //public float lightsFalloffConstant[]; + //public float lightsFalloffLinear[]; + //public float lightsFalloffQuadratic[]; /** Light spot angle */ - public float lightsSpotAngle[]; + //public float lightsSpotAngle[]; /** Cosine of light spot angle */ - public float lightsSpotAngleCos[]; + //public float lightsSpotAngleCos[]; /** Light spot concentration */ - public float lightsSpotConcentration[]; + //public float lightsSpotConcentration[]; /** Diffuse colors for lights. * For an ambient light, this will hold the ambient color. * Internally these are stored as numbers between 0 and 1. */ - public float lightsDiffuseR[], lightsDiffuseG[], lightsDiffuseB[]; + //public float lightsDiffuseR[], lightsDiffuseG[], lightsDiffuseB[]; /** Specular colors for lights. Internally these are stored as numbers between 0 and 1. */ - public float lightsSpecularR[], lightsSpecularG[], lightsSpecularB[]; + //public float lightsSpecularR[], lightsSpecularG[], lightsSpecularB[]; - public float lightSpecularR; - public float lightSpecularG; - public float lightSpecularB; - public float lightFalloffConstant; - public float lightFalloffLinear; - public float lightFalloffQuadratic; + //public float lightSpecularR; + //public float lightSpecularG; + //public float lightSpecularB; + //public float lightFalloffConstant; + //public float lightFalloffLinear; + //public float lightFalloffQuadratic; // ........................................................ @@ -186,35 +186,35 @@ public class PGraphics3 extends PGraphics { // used for sorting points when triangulating a polygon // warning - maximum number of vertices for a polygon is DEFAULT_VERTICES - int vertex_order[] = new int[DEFAULT_VERTICES]; + protected int vertex_order[] = new int[DEFAULT_VERTICES]; // ........................................................ - public int pathCount; - public int pathOffset[] = new int[64]; - public int pathLength[] = new int[64]; + protected int pathCount; + protected int pathOffset[] = new int[64]; + protected int pathLength[] = new int[64]; // ........................................................ // lines static final int DEFAULT_LINES = 512; - PLine line; // used for drawing - public int lines[][] = new int[DEFAULT_LINES][LINE_FIELD_COUNT]; - public int lineCount; + public PLine line; // used for drawing + protected int lines[][] = new int[DEFAULT_LINES][LINE_FIELD_COUNT]; + protected int lineCount; // ........................................................ // triangles static final int DEFAULT_TRIANGLES = 256; - PTriangle triangle; - public int triangles[][] = + public PTriangle triangle; + protected int triangles[][] = new int[DEFAULT_TRIANGLES][TRIANGLE_FIELD_COUNT]; - public float triangleColors[][][] = + protected float triangleColors[][][] = new float[DEFAULT_TRIANGLES][3][TRIANGLE_COLOR_COUNT]; - public int triangleCount; // total number of triangles + protected int triangleCount; // total number of triangles // cheap picking someday - int shape_index; + public int shape_index; // ........................................................ @@ -223,18 +223,18 @@ public class PGraphics3 extends PGraphics { * vertex() calls will be based on coordinates that are * based on the IMAGE or NORMALIZED. */ - public int textureMode; + //public int textureMode; /** * Current horizontal coordinate for texture, will always * be between 0 and 1, even if using textureMode(IMAGE). */ - public float textureU; + //public float textureU; /** Current vertical coordinate for texture, see above. */ - public float textureV; + //public float textureV; - public PImage textureImage; + //public PImage textureImage; static final int DEFAULT_TEXTURES = 3; protected PImage textures[] = new PImage[DEFAULT_TEXTURES]; @@ -245,16 +245,16 @@ public class PGraphics3 extends PGraphics { /** * Normals */ - public float normalX, normalY, normalZ; - public int normalMode; - public int normalCount; + //public float normalX, normalY, normalZ; + //public int normalMode; + //public int normalCount; // ........................................................ // [toxi031031] new & faster sphere code w/ support flexibile resolutions // will be set by sphereDetail() or 1st call to sphere() - public int sphereDetail = 0; float sphereX[], sphereY[], sphereZ[]; + //public int sphereDetail = 0; // ........................................................ @@ -3341,9 +3341,9 @@ public class PGraphics3 extends PGraphics { ambientR = calcR; ambientG = calcG; ambientB = calcB; - ambientRi = calcRi; - ambientGi = calcGi; - ambientBi = calcBi; + //ambientRi = calcRi; + //ambientGi = calcGi; + //ambientBi = calcBi; } @@ -3390,10 +3390,10 @@ public class PGraphics3 extends PGraphics { specularG = calcG; specularB = calcB; specularA = calcA; - specularRi = calcRi; - specularGi = calcGi; - specularBi = calcBi; - specularAi = calcAi; + //specularRi = calcRi; + //specularGi = calcGi; + //specularBi = calcBi; + //specularAi = calcAi; } @@ -3432,9 +3432,9 @@ public class PGraphics3 extends PGraphics { emissiveR = calcR; emissiveG = calcG; emissiveB = calcB; - emissiveRi = calcRi; - emissiveGi = calcGi; - emissiveBi = calcBi; + //emissiveRi = calcRi; + //emissiveGi = calcGi; + //emissiveBi = calcBi; } diff --git a/core/PImage.java b/core/PImage.java index a8923a163..fff1d0391 100644 --- a/core/PImage.java +++ b/core/PImage.java @@ -1559,10 +1559,11 @@ public class PImage implements PConstants, Cloneable { public void save(String filename) { // ignore + boolean success = false; + try { OutputStream os = null; - boolean success = false; if (filename.toLowerCase().endsWith(".tga")) { os = new BufferedOutputStream(new FileOutputStream(filename), 32768); success = saveTGA(os, pixels, width, height); diff --git a/core/todo.txt b/core/todo.txt index cc3b91112..1d0e10670 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -6,15 +6,16 @@ _ find the post on the board and make a note of this X proper api for access to Graphics2D object in PGraphics2 _ just add the current "g2" thing to the faq _ and make a note of it on the suggestions board +X vars like cameraX etc need to be in PGraphics +X otherwise g.xxxx won't work +X how far should this go? vertices etc? +X vertices not included because switching to triangleImpl and lineImpl -_ change PGraphics to PGraphics2 +_ change PGraphics to PGraphics2 +_ or not, because PGraphics has all the base stuff for 3D _ change PGraphics2 to PGraphicsJava or PGraphicsJava2D _ maybe wait until the new shape stuff is done? -_ vars like cameraX etc need to be in PGraphics -_ otherwise g.xxxx won't work -_ how far should this go? vertices etc? - _ how to deal with triangles/lines and triangleCount and lineCount _ maybe just need a triangleImpl and lineImpl _ because it's too messy to retain the triangle objects and info