todo items from first day in barcelona, addition of PShape

This commit is contained in:
benfry
2006-05-09 12:24:41 +00:00
parent 5385d9ad14
commit ac37ce6632
3 changed files with 378 additions and 7 deletions
+289
View File
@@ -0,0 +1,289 @@
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2006 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.core;
// take a look at the obj loader to see how this fits with things
// PShape.line() PShape.ellipse()?
// PShape s = beginShape()
// line()
// endShape(s)
public class PShape {
int kind;
PMatrix matrix;
int[] opcode;
int opcodeCount;
// need to reorder vertex fields to make a VERTEX_SHORT_COUNT
// that puts all the non-rendering fields into later indices
float[][] data; // second param is the VERTEX_FIELD_COUNT
// should this be called vertices (consistent with PGraphics internals)
// or does that hurt flexibility?
int childCount;
PShape[] children;
// POINTS, LINES, xLINE_STRIP, xLINE_LOOP
// TRIANGLES, TRIANGLE_STRIP, TRIANGLE_FAN
// QUADS, QUAD_STRIP
// xPOLYGON
static final int PATH = 1; // POLYGON, LINE_LOOP, LINE_STRIP
static final int GROUP = 2;
// how to handle rectmode/ellipsemode?
// are they bitshifted into the constant?
// CORNER, CORNERS, CENTER, (CENTER_RADIUS?)
static final int RECT = 3; // could just be QUAD, but would be x1/y1/x2/y2
static final int ELLIPSE = 4;
static final int VERTEX = 7;
static final int CURVE = 5;
static final int BEZIER = 6;
// fill and stroke functions will need a pointer to the parent
// PGraphics object.. may need some kind of createShape() fxn
// or maybe the values are stored until draw() is called?
// attaching images is very tricky.. it's a different type of data
// material parameters will be thrown out,
// except those currently supported (kinds of lights)
// setAxis -> .x and .y to move x and y coords of origin
public float x;
public float y;
// pivot point for transformations
public float px;
public float py;
public PShape() {
}
public PShape(float x, float y) {
this.x = x;
this.y = y;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* Called by the following (the shape() command adds the g)
* PShape s = loadShapes("blah.svg");
* shape(s);
*/
public void draw(PGraphics g) {
boolean flat = g instanceof PGraphics3;
if (matrix != null) {
g.pushMatrix();
if (flat) {
g.applyMatrix(matrix.m00, matrix.m01, matrix.m02,
matrix.m10, matrix.m11, matrix.m12);
} else {
g.applyMatrix(matrix.m00, matrix.m01, matrix.m02, matrix.m03,
matrix.m10, matrix.m11, matrix.m12, matrix.m13,
matrix.m20, matrix.m21, matrix.m22, matrix.m23,
matrix.m30, matrix.m31, matrix.m32, matrix.m33);
}
}
// if g subclasses PGraphics2, ignore all lighting stuff and z coords
// otherwise if PGraphics3, need to call diffuse() etc
// unfortunately, also a problem with no way to encode stroke/fill
// being enabled/disabled.. this quickly gets into just having opcodes
// for the entire api, to deal with things like textures and images
switch (kind) {
case PATH:
for (int i = 0; i < opcodeCount; i++) {
switch (opcode[i]) {
case VERTEX:
break;
}
}
break;
case GROUP:
break;
case RECT:
break;
}
if (matrix != null) {
g.popMatrix();
}
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// can't be 'add' because that suggests additive geometry
public void addChild(PShape who) {
}
public PShape createGroup() {
PShape group = new PShape();
group.kind = GROUP;
addChild(group);
return group;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
// translate, rotate, scale, apply (no push/pop)
// these each call matrix.translate, etc
// if matrix is null when one is called,
// it is created and set to identity
public void translate(float tx, float ty) {
translate(tx, ty, 0);
}
public void translate(float tx, float ty, float tz) {
checkMatrix();
matrix.translate(tx, ty, 0);
}
//
public void rotateX(float angle) {
rotate(angle, 1, 0, 0);
}
public void rotateY(float angle) {
rotate(angle, 0, 1, 0);
}
public void rotateZ(float angle) {
rotate(angle, 0, 0, 1);
}
public void rotate(float angle) {
rotateZ(angle);
}
public void rotate(float angle, float v0, float v1, float v2) {
checkMatrix();
matrix.rotate(angle, v0, v1, v2);
}
//
public void scale(float s) {
scale(s, s, s);
}
public void scale(float sx, float sy) {
scale(sx, sy, 1);
}
public void scale(float x, float y, float z) {
checkMatrix();
matrix.scale(x, y, z);
}
//
public void applyMatrix(float n00, float n01, float n02,
float n10, float n11, float n12) {
checkMatrix();
matrix.apply(n00, n01, n02, 0,
n10, n11, n12, 0,
0, 0, 1, 0,
0, 0, 0, 1);
}
public void applyMatrix(float n00, float n01, float n02, float n03,
float n10, float n11, float n12, float n13,
float n20, float n21, float n22, float n23,
float n30, float n31, float n32, float n33) {
checkMatrix();
matrix.apply(n00, n01, n02, n03,
n10, n11, n12, n13,
n20, n21, n22, n23,
n30, n31, n32, n33);
}
//
protected void checkMatrix() {
if (matrix == null) {
matrix = new PMatrix();
}
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* Center the shape based on its bounding box. Can't assume
* that the bounding box is 0, 0, width, height. Common case will be
* opening a letter size document in Illustrator, and drawing something
* in the middle, then reading it in as an svg file.
* This will also need to flip the y axis (scale(1, -1)) in cases
* like Adobe Illustrator where the coordinates start at the bottom.
*/
public void center() {
}
/**
* Set the pivot point for all transformations.
*/
public void pivot(float x, float y) {
px = x;
py = y;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
}
+61 -6
View File
@@ -1,7 +1,68 @@
0115 core
X remove debug message from loadPixels()
X remove debug message from PGraphics2.save()
X fix error message with dxf when used with opengl
X if file is missing for reader()
X return null and println an error rather than failing
X add arraycopy(from, to, count);
X fix fill/stroke issues in bugs db (bug 339)
_ endRaw() should force depth sorted triangles to flush
_ fix dxf export bug
_ fix erik's problems with export (also in bugs db)
0116 core
_ bring back the old P2D, rename PGraphics2 into PGraphicsJava
_ opengl keeping memory around..
_ could this be in vertices that have an image associated
_ or the image buffer used for textures
_ that never gets cleared fully?
_ make the opengl textmode shape stuff get better and use PShape
_ docs: get/set are faster way to do image, but no tint, no translations
_ textSpace(SCREEN) for opengl and java2d
_ don't use loadPixels for either
_ use font code to set the cached color of the font, then call set()
_ although set() with alpha is a little different..
_ textMode(SHAPE) faster in opengl
_ cache for tyhpe should be per-renderer
_ because opengl needs vectors, but also the image cache for textures
_ createGraphics to not require defaults()
_ how to clear the screen with alpha? background(0, 0, 0, 0)?
_ background(EMPTY) -> background(0x01000000) or something?
_ remove POLYGON, LINE_LOOP, LINE_STRIP
_ beginFrame/endFrame -> beginDraw/endDraw
_ begin/endPixels..
_ on PImage, sets a flag that marks it to be updated on next render
_ for PImage, begin after an end is ignored, no pixels are re-loaded
_ the "changed" bit gets turned off when the PImage is rendered
_ for subclasses of PGraphics, the reload bit needs to be set on endFrame
_ filter() checks to see if inside begin/endPixels, if so doesn't call
o if line() is called inside beginpixels, call updatepixels?
_ introduce calc()
_ tint() sets texture color, fill() is ignored with textures
_ cmyk version of tiff encoder code?
_ when NPE on line with pixels[], suggest user includes beginPixels
_ when turning smoothing on, internal lines of shapes are visible
_ need to turn off smoothing for the interior of shapes
_ http://dev.processing.org/bugs/show_bug.cgi?id=200
_ gl smoothing.. how to disable polygon but keep line enabled
_ or at least make a note of this?
_ leave smooth off, get the gl object, then enable line smooth
_ get()/set() in PGraphicsJava don't bounds check
_ add better error messages for all built-in renderers
_ i.e. "import library -> pdf" when pdf is missing
_ color values on camera input flipped on intel macs
X checked in a change for this recommended on qtjava list
_ http://dev.processing.org/bugs/show_bug.cgi?id=313
@@ -681,12 +742,6 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=150
_ make a note about the anti-aliasing types in the faq
_ polygon vs line etc.. may want to enable lines but disable polys
_ y may be flipped in modelX/Y/Z stuff on opengl
_ when turning smoothing on, internal lines of shapes are visible
_ need to turn off smoothing for the interior of shapes
_ http://dev.processing.org/bugs/show_bug.cgi?id=200
_ gl smoothing.. how to disable polygon but keep line enabled
_ or at least make a note of this?
_ leave smooth off, get the gl object, then enable line smooth
_ ortho() behaving differently in P3D vs OPENGL
_ http://dev.processing.org/bugs/show_bug.cgi?id=100
_ gl points not working again
+28 -1
View File
@@ -1,14 +1,30 @@
0115 pde
o what's the long delay when hitting "save as" on osx?
o the first time, it's very slow.. presumably an awt problem
X renaming a sketch should rebuild the sketch menu
X http://dev.processing.org/bugs/show_bug.cgi?id=332
_ would be nice to have macosx packaged up as a single .app file
_ should recommend that people install libraries into their sketchbook
_ jar files like the bad aiexport plugin will cause serious problems
_ need to ignore processing.core classes showing up in other jar files
_ tougher than it looks, because it all depends on what java wants to use
_ i.e. even if not specified, the stuff will be in the classpath
_ need to make classpath code be less promiscuous
_ the order of adding libraries to classpath should be opposite
_ the important local libraries should be first in cp, user contrib later
_ http://dev.processing.org/bugs/show_bug.cgi?id=321
_ stop button won't kill a video sketch (bug 150 example does this)
_ run/stop button highlight is almost completely broken
_ add "hide stop button" arg for PApplet
board stuff
_ only allow moderators to delete posts
_ set "no smileys" as the default for posting code
_ make the export to the board just copy to clipboard
_ also make it insert &nbsp; for extra spaces
@@ -121,6 +137,17 @@ _ things will also be very ugly on-screen
_ text being nicer in java2d
_ textMode(SCREEN) for P2D and P3D for nice fast text
advanced faq
_ move 'how do i create large images' here
_ move stuff about getting gl object and java2d stuff here
_ explain how to integrate code with swing
_ use a separate environment, call init(), use noLoop(), redraw()
_ how do i add gui to a sketch?
_ don't use awt components
_ advanced reference contains more info about how things work
_ createGraphics with PDF, using dispose() to clear the thing
_ calling nextPage()
board faq
_ someone wrote up an initial version of this
_ how to put [code] around blocks of code
@@ -129,6 +156,7 @@ _ also the reference page on the bb commands
_ i don't answer to instant messages
_ i don't answer email
_ use the bugs db instead of the bugs board
_ use the search box (not the forum search)
_ read the faq, read the faq
_ read the reference.. right-click on a word and choose "find in ref"
_ non-processing posts will be deleted (not a java discussion board)
@@ -774,7 +802,6 @@ _ was missing the error about a package being gone
_ can comment out /System/Library/ as a test
_ Contents/Resources/Java can take jnilib files
_ set file type/creator for .pde files of examples
_ would be nice to have macosx packaged up as a single .app file
_ is there a way to set the color of the Frame growbox?
_ currently it's white instead of dark gray like the ui
_ setBackground(Color) didn't seem to help inside PdeBase.<init>