mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
making a complete mess of the graphics engine
This commit is contained in:
@@ -209,46 +209,19 @@ public class PApplet extends Applet
|
||||
Component.class.getMethod("setFocusTraversalKeysEnabled",
|
||||
new Class[] { Boolean.TYPE });
|
||||
defocus.invoke(this, new Object[] { Boolean.FALSE });
|
||||
//} else {
|
||||
//System.out.println(jdkVersion);
|
||||
}
|
||||
} catch (Exception e) { } // oh well
|
||||
|
||||
millisOffset = System.currentTimeMillis();
|
||||
|
||||
finished = false; // just for clarity
|
||||
//drawn = false;
|
||||
//firstFrame = true;
|
||||
|
||||
// this will be cleared by loop() if it is not overridden
|
||||
//drawMethod = true;
|
||||
//loopMethod = true;
|
||||
looping = true;
|
||||
redraw = true; // draw this guy once
|
||||
firstMouse = true;
|
||||
|
||||
/*
|
||||
// call setup for changed params
|
||||
try {
|
||||
setup();
|
||||
} catch (NullPointerException e) {
|
||||
//e.printStackTrace();
|
||||
// this is probably because someone didn't call size() first
|
||||
size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
setup();
|
||||
}
|
||||
|
||||
// do actual setup calls
|
||||
if (g == null) {
|
||||
// if programmer hasn't added a special graphics
|
||||
// object, then setup a standard one
|
||||
size(DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
||||
}
|
||||
*/
|
||||
|
||||
// these need to be inited before setup
|
||||
//libraries = new PLibrary[10];
|
||||
//libraryCalls = new boolean[10][PLibrary.CALL_COUNT];
|
||||
sizeMethods = new RegisteredMethods();
|
||||
preMethods = new RegisteredMethods();
|
||||
drawMethods = new RegisteredMethods();
|
||||
@@ -257,16 +230,6 @@ public class PApplet extends Applet
|
||||
keyEventMethods = new RegisteredMethods();
|
||||
disposeMethods = new RegisteredMethods();
|
||||
|
||||
/*
|
||||
// call the applet's setup method
|
||||
setup();
|
||||
|
||||
// these are the same things as get run inside a call to size()
|
||||
this.pixels = g.pixels;
|
||||
this.width = g.width;
|
||||
this.height = g.height;
|
||||
*/
|
||||
|
||||
try {
|
||||
getAppletContext();
|
||||
online = true;
|
||||
@@ -294,6 +257,10 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
public void depth() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via the first call to PApplet.paint(),
|
||||
* because PAppletGL needs to have a usable screen
|
||||
@@ -314,29 +281,9 @@ public class PApplet extends Applet
|
||||
|
||||
// don't run stop and disposers twice
|
||||
if (thread == null) return;
|
||||
|
||||
//if (thread != null) {
|
||||
thread = null;
|
||||
//}
|
||||
|
||||
disposeMethods.handle();
|
||||
/*
|
||||
for (int i = 0; i < libraryCount; i++) {
|
||||
if (libraryCalls[i][PLibrary.DISPOSE]) {
|
||||
libraries[i].dispose(); // endNet/endSerial etc
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < stopCount; i++) {
|
||||
try {
|
||||
System.err.println("stopping " + i);
|
||||
stopMethods[i].invoke(stopObjects[i], new Object[] { });
|
||||
} catch (Exception e) {
|
||||
System.err.println("Couldn't stop " + stopObjects[i]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -362,57 +309,6 @@ public class PApplet extends Applet
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
/*
|
||||
public void attach(PLibrary library) {
|
||||
if (libraryCount == libraries.length) {
|
||||
PLibrary temp[] = new PLibrary[libraryCount << 1];
|
||||
System.arraycopy(libraries, 0, temp, 0, libraryCount);
|
||||
libraries = temp;
|
||||
boolean ctemp[][] = new boolean[libraryCount << 1][];
|
||||
System.arraycopy(libraryCalls, 0, ctemp, 0, libraryCount);
|
||||
libraryCalls = ctemp;
|
||||
}
|
||||
libraries[libraryCount] = library;
|
||||
libraryCalls[libraryCount] = new boolean[PLibrary.CALL_COUNT];
|
||||
libraryCount++;
|
||||
|
||||
library.setup(this);
|
||||
}
|
||||
|
||||
|
||||
public void attach(String libraryName) {
|
||||
try {
|
||||
Class c = Class.forName(libraryName);
|
||||
PLibrary library = (PLibrary) c.newInstance();
|
||||
library.setup(this);
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("Could not find library \"" + libraryName + "\"");
|
||||
System.err.println("Make sure it's in the libraries folder, ");
|
||||
System.err.println("or exported somewhere inside the sketchbook,");
|
||||
System.err.println("or inside the \"code\" folder of this sketch.");
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
System.err.println("Could not load library \"" + libraryName + "\"");
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (InstantiationException e) {
|
||||
System.err.println("Could not load library \"" + libraryName + "\"");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void registerCall(PLibrary library, int call) {
|
||||
for (int i = 0; i < libraryCount; i++) {
|
||||
if (libraries[i] == library) {
|
||||
//println("registering call # " + call + " to " + library);
|
||||
libraryCalls[i][call] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public class RegisteredMethods {
|
||||
int count;
|
||||
@@ -456,10 +352,6 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
//public void registerSetup(Object o) {
|
||||
//System.err.println("registerSetup not yet implemented");
|
||||
//}
|
||||
|
||||
public void registerSize(Object o) {
|
||||
Class methodArgs[] = new Class[] { Integer.TYPE, Integer.TYPE };
|
||||
registerWithArgs(preMethods, "size", o, methodArgs);
|
||||
@@ -519,60 +411,6 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Class c = o.getClass();
|
||||
try {
|
||||
Method method = c.getMethod("mouseEvent",
|
||||
|
||||
mouseEventMethods.add(o, method);
|
||||
|
||||
} catch (Exception e) {
|
||||
die("Could not register mouseEvent() for " + o, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerSize(Object o) {
|
||||
Class c = o.getClass();
|
||||
try {
|
||||
Method method = c.getMethod("size",
|
||||
new Class[] { Integer.TYPE, Integer.TYPE });
|
||||
sizeMethods.add(o, method);
|
||||
|
||||
} catch (Exception e) {
|
||||
die("Could not register size() for " + o, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void registerKeyEvent(Object o) {
|
||||
Class c = o.getClass();
|
||||
try {
|
||||
Method method = c.getMethod("keyEvent",
|
||||
new Class[] { KeyEvent.class });
|
||||
keyEventMethods.add(o, method);
|
||||
|
||||
} catch (Exception e) {
|
||||
die("Could not register mouseEvent() for " + o, e);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
protected void handleDispose() {
|
||||
for (int i = 0; i < disposeMethods.count; i++) {
|
||||
try {
|
||||
//System.err.println("stopping " + i);
|
||||
disposeMethods[i].handle(new Object[] { });
|
||||
//diposeMethods[i].invoke(stopObjects[i], new Object[] { });
|
||||
} catch (Exception e) {
|
||||
System.err.println("Couldn't stop " + stopObjects[i]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -581,9 +419,7 @@ public class PApplet extends Applet
|
||||
|
||||
|
||||
public void draw() {
|
||||
//drawMethod = false;
|
||||
finished = true; // if no draw method, then...
|
||||
//println("all done");
|
||||
}
|
||||
|
||||
|
||||
@@ -596,21 +432,17 @@ public class PApplet extends Applet
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void loop() {
|
||||
//println("loop 1");
|
||||
if (!looping) {
|
||||
//println("loop 2");
|
||||
looping = true;
|
||||
if (thread != null) {
|
||||
//println("loop 3");
|
||||
//println(Thread.currentThread().getName());
|
||||
//println("loop wakeup");
|
||||
thread.interrupt(); // wake from sleep
|
||||
//println("loop 4");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void noLoop() {
|
||||
if (looping) {
|
||||
looping = false;
|
||||
@@ -640,13 +472,6 @@ public class PApplet extends Applet
|
||||
Object methodArgs[] =
|
||||
new Object[] { new Integer(width), new Integer(height) };
|
||||
sizeMethods.handle(methodArgs);
|
||||
/*
|
||||
for (int i = 0; i < libraryCount; i++) {
|
||||
if (libraryCalls[i][PLibrary.SIZE]) {
|
||||
libraries[i].size(width, height); // endNet/endSerial etc
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (frame != null) {
|
||||
Insets insets = frame.getInsets();
|
||||
@@ -664,28 +489,9 @@ public class PApplet extends Applet
|
||||
} else {
|
||||
setBounds(0, 0, width, height);
|
||||
}
|
||||
|
||||
// set this here, and if not inside browser, getDocumentBase()
|
||||
// will fail with a NullPointerException, and cause applet to
|
||||
// be set to null. might be a better way to deal with that, but..
|
||||
//g.applet = this;
|
||||
}
|
||||
|
||||
|
||||
//boolean updated = false;
|
||||
|
||||
/*
|
||||
public void update() {
|
||||
if (firstFrame) firstFrame = false;
|
||||
|
||||
if (THREAD_DEBUG) println(" 3a update() internal " + firstFrame);
|
||||
repaint();
|
||||
if (THREAD_DEBUG) println(" 3b update() internal " + firstFrame);
|
||||
getToolkit().sync(); // force repaint now (proper method)
|
||||
if (THREAD_DEBUG) println(" 3c update() internal " + firstFrame);
|
||||
}
|
||||
*/
|
||||
|
||||
public void update(Graphics screen) {
|
||||
//System.out.println("PApplet.update()");
|
||||
if (THREAD_DEBUG) println(Thread.currentThread().getName() +
|
||||
@@ -4904,11 +4710,6 @@ v PApplet.this.stop();
|
||||
}
|
||||
|
||||
|
||||
public void render_lines() {
|
||||
g.render_lines();
|
||||
}
|
||||
|
||||
|
||||
public void point(float x, float y) {
|
||||
g.point(x, y);
|
||||
}
|
||||
|
||||
+219
-1925
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,421 @@
|
||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
PGraphics2 - graphics engine implemented via java2d
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2005 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;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
public class PGraphics2 extends PGraphics {
|
||||
|
||||
protected Graphics2D graphics;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// INTERNAL
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the PGraphics2 object.
|
||||
* This prototype only exists because of annoying
|
||||
* java compilers, and should not be used.
|
||||
*/
|
||||
public PGraphics2() { }
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the PGraphics object. Use this to ensure that
|
||||
* the defaults get set properly. In a subclass, use this(w, h)
|
||||
* as the first line of a subclass' constructor to properly set
|
||||
* the internal fields and defaults.
|
||||
*
|
||||
* @param iwidth viewport width
|
||||
* @param iheight viewport height
|
||||
*/
|
||||
public PGraphics2(int iwidth, int iheight) {
|
||||
resize(iwidth, iheight);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called in repsonse to a resize event, handles setting the
|
||||
* new width and height internally, as well as re-allocating
|
||||
* the pixel buffer for the new size.
|
||||
*
|
||||
* Note that this will nuke any cameraMode() settings.
|
||||
*/
|
||||
public void resize(int iwidth, int iheight) { // ignore
|
||||
//System.out.println("resize " + iwidth + " " + iheight);
|
||||
|
||||
width = iwidth;
|
||||
height = iheight;
|
||||
width1 = width - 1;
|
||||
height1 = height - 1;
|
||||
|
||||
allocate();
|
||||
|
||||
// clear the screen with the old background color
|
||||
background(backgroundColor);
|
||||
}
|
||||
|
||||
|
||||
// broken out because of subclassing for opengl
|
||||
protected void allocate() {
|
||||
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
Graphics2D graphics = (Graphics2D) image.getGraphics();
|
||||
|
||||
line = new PLine(this);
|
||||
triangle = new PTriangle(this);
|
||||
}
|
||||
|
||||
|
||||
//public void defaults() {
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// FRAME
|
||||
|
||||
|
||||
//public void beginFrame()
|
||||
|
||||
// turn off mis.newPixels
|
||||
public void endFrame() {
|
||||
// moving this back here (post-68) because of macosx thread problem
|
||||
//mis.newPixels(pixels, cm, 0, width);
|
||||
}
|
||||
|
||||
|
||||
public void endShape() {
|
||||
vertex_end = vertex_count;
|
||||
|
||||
// don't try to draw if there are no vertices
|
||||
// (fixes a bug in LINE_LOOP that re-adds a nonexistent vertex)
|
||||
if (vertex_count == 0) {
|
||||
shape = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// CREATE LINES
|
||||
|
||||
int increment = 1;
|
||||
int stop = 0;
|
||||
int counter = 0;
|
||||
|
||||
if (stroke) {
|
||||
switch (shape) {
|
||||
|
||||
case POINTS:
|
||||
{
|
||||
stop = vertex_end;
|
||||
for (int i = vertex_start; i < stop; i++) {
|
||||
add_path(); // total overkill for points
|
||||
add_line(i, i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LINES:
|
||||
case LINE_STRIP:
|
||||
case LINE_LOOP:
|
||||
{
|
||||
// store index of first vertex
|
||||
int first = lineCount;
|
||||
stop = vertex_end - 1;
|
||||
increment = (shape == LINES) ? 2 : 1;
|
||||
|
||||
// for LINE_STRIP and LINE_LOOP, make this all one path
|
||||
if (shape != LINES) add_path();
|
||||
|
||||
for (int i = vertex_start; i < stop; i+=increment) {
|
||||
// for LINES, make a new path for each segment
|
||||
if (shape == LINES) add_path();
|
||||
add_line(i, i+1);
|
||||
}
|
||||
|
||||
// for LINE_LOOP, close the loop with a final segment
|
||||
if (shape == LINE_LOOP) {
|
||||
add_line(stop, lines[first][VERTEX1]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIANGLES:
|
||||
{
|
||||
for (int i = vertex_start; i < vertex_end; i += 3) {
|
||||
add_path();
|
||||
counter = i - vertex_start;
|
||||
add_line(i+0, i+1);
|
||||
add_line(i+1, i+2);
|
||||
add_line(i+2, i+0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIANGLE_STRIP:
|
||||
{
|
||||
// first draw all vertices as a line strip
|
||||
stop = vertex_end-1;
|
||||
|
||||
add_path();
|
||||
for (int i = vertex_start; i < stop; i++) {
|
||||
counter = i - vertex_start;
|
||||
add_line(i,i+1);
|
||||
}
|
||||
|
||||
// then draw from vertex (n) to (n+2)
|
||||
stop = vertex_end-2;
|
||||
for (int i = vertex_start; i < stop; i++) {
|
||||
add_path();
|
||||
add_line(i,i+2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIANGLE_FAN:
|
||||
{
|
||||
// this just draws a series of line segments
|
||||
// from the center to each exterior point
|
||||
for (int i = vertex_start + 1; i < vertex_end; i++) {
|
||||
add_path();
|
||||
add_line(vertex_start, i);
|
||||
}
|
||||
|
||||
// then a single line loop around the outside.
|
||||
add_path();
|
||||
for (int i = vertex_start + 1; i < vertex_end-1; i++) {
|
||||
add_line(i, i+1);
|
||||
}
|
||||
// closing the loop
|
||||
add_line(vertex_end-1, vertex_start + 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case QUADS:
|
||||
{
|
||||
for (int i = vertex_start; i < vertex_end; i += 4) {
|
||||
add_path();
|
||||
counter = i - vertex_start;
|
||||
add_line(i+0, i+1);
|
||||
add_line(i+1, i+2);
|
||||
add_line(i+2, i+3);
|
||||
add_line(i+3, i+0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case QUAD_STRIP:
|
||||
{
|
||||
// first draw all vertices as a line strip
|
||||
stop = vertex_end - 1;
|
||||
|
||||
add_path();
|
||||
for (int i = vertex_start; i < stop; i++) {
|
||||
counter = i - vertex_start;
|
||||
add_line(i, i+1);
|
||||
}
|
||||
|
||||
// then draw from vertex (n) to (n+3)
|
||||
stop = vertex_end-2;
|
||||
increment = 2;
|
||||
|
||||
add_path();
|
||||
for (int i = vertex_start; i < stop; i += increment) {
|
||||
add_line(i, i+3);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POLYGON:
|
||||
case CONCAVE_POLYGON:
|
||||
case CONVEX_POLYGON:
|
||||
{
|
||||
// store index of first vertex
|
||||
int first = lineCount;
|
||||
stop = vertex_end - 1;
|
||||
|
||||
add_path();
|
||||
for (int i = vertex_start; i < stop; i++) {
|
||||
add_line(i, i+1);
|
||||
}
|
||||
// draw the last line connecting back to the first point in poly
|
||||
add_line(stop, lines[first][VERTEX1]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// CREATE TRIANGLES
|
||||
|
||||
if (fill) {
|
||||
switch (shape) {
|
||||
case TRIANGLES:
|
||||
case TRIANGLE_STRIP:
|
||||
{
|
||||
stop = vertex_end - 2;
|
||||
increment = (shape == TRIANGLES) ? 3 : 1;
|
||||
for (int i = vertex_start; i < stop; i += increment) {
|
||||
add_triangle(i, i+1, i+2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case QUADS:
|
||||
case QUAD_STRIP:
|
||||
{
|
||||
stop = vertex_count-3;
|
||||
increment = (shape == QUADS) ? 4 : 2;
|
||||
|
||||
for (int i = vertex_start; i < stop; i += increment) {
|
||||
// first triangle
|
||||
add_triangle(i, i+1, i+2);
|
||||
// second triangle
|
||||
add_triangle(i, i+2, i+3);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POLYGON:
|
||||
case CONCAVE_POLYGON:
|
||||
case CONVEX_POLYGON:
|
||||
{
|
||||
triangulate_polygon();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// 2D or 3D POINTS FROM MODEL (MX, MY, MZ) TO VIEW SPACE (X, Y, Z)
|
||||
|
||||
if (depth) {
|
||||
for (int i = vertex_start; i < vertex_end; i++) {
|
||||
float vertex[] = vertices[i];
|
||||
|
||||
vertex[VX] = m00*vertex[MX] + m01*vertex[MY] + m02*vertex[MZ] + m03;
|
||||
vertex[VY] = m10*vertex[MX] + m11*vertex[MY] + m12*vertex[MZ] + m13;
|
||||
vertex[VZ] = m20*vertex[MX] + m21*vertex[MY] + m22*vertex[MZ] + m23;
|
||||
vertex[VW] = m30*vertex[MX] + m31*vertex[MY] + m32*vertex[MZ] + m33;
|
||||
}
|
||||
} else {
|
||||
// if no depth in use, then the points can be transformed simpler
|
||||
for (int i = vertex_start; i < vertex_end; i++) {
|
||||
vertices[i][X] = m00*vertices[i][MX] + m01*vertices[i][MY] + m03;
|
||||
vertices[i][Y] = m10*vertices[i][MX] + m11*vertices[i][MY] + m13;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// TRANSFORM / LIGHT / CLIP
|
||||
|
||||
light_and_transform();
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// RENDER SHAPES FILLS HERE WHEN NOT DEPTH SORTING
|
||||
|
||||
// if true, the shapes will be rendered on endFrame
|
||||
if (hints[DEPTH_SORT]) {
|
||||
shape = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// set smoothing mode
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
smooth ?
|
||||
RenderingHints.VALUE_ANTIALIAS_ON :
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
|
||||
if (fill) render_triangles();
|
||||
if (stroke) render_lines();
|
||||
|
||||
shape = 0;
|
||||
}
|
||||
|
||||
|
||||
protected void render_triangles() {
|
||||
for (int i = 0; i < triangleCount; i ++) {
|
||||
float a[] = vertices[triangles[i][VERTEX1]];
|
||||
float b[] = vertices[triangles[i][VERTEX2]];
|
||||
float c[] = vertices[triangles[i][VERTEX3]];
|
||||
int tex = triangles[i][TEXTURE_INDEX];
|
||||
int index = triangles[i][INDEX];
|
||||
|
||||
//System.out.println("A " + a[X] + " " + a[Y] + " " + a[Z]);
|
||||
//System.out.println("B " + b[X] + " " + b[Y] + " " + b[Z]);
|
||||
//System.out.println("C " + c[X] + " " + c[Y] + " " + c[Z]);
|
||||
|
||||
triangle.reset();
|
||||
|
||||
if (tex > -1 && textures[tex] != null) {
|
||||
triangle.setTexture(textures[tex]);
|
||||
triangle.setUV(a[U], a[V], b[U], b[V], c[U], c[V]);
|
||||
}
|
||||
|
||||
triangle.setIntensities(a[R], a[G], a[B], a[A],
|
||||
b[R], b[G], b[B], b[A],
|
||||
c[R], c[G], c[B], c[A]);
|
||||
|
||||
triangle.setVertices(a[X], a[Y], a[Z],
|
||||
b[X], b[Y], b[Z],
|
||||
c[X], c[Y], c[Z]);
|
||||
|
||||
triangle.setIndex(index);
|
||||
triangle.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void render_lines() {
|
||||
for (int i = 0; i < lineCount; i ++) {
|
||||
float a[] = vertices[lines[i][VERTEX1]];
|
||||
float b[] = vertices[lines[i][VERTEX2]];
|
||||
int index = lines[i][INDEX];
|
||||
|
||||
line.reset();
|
||||
|
||||
line.setIntensities(a[SR], a[SG], a[SB], a[SA],
|
||||
b[SR], b[SG], b[SB], b[SA]);
|
||||
|
||||
line.setVertices(a[X], a[Y], a[Z],
|
||||
b[X], b[Y], b[Z]);
|
||||
|
||||
line.setIndex(index);
|
||||
line.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Executable
+382
@@ -0,0 +1,382 @@
|
||||
package processing.core;
|
||||
|
||||
|
||||
|
||||
// this file is auto-generated. no touchy-touchy.
|
||||
|
||||
public interface PMethods {
|
||||
|
||||
public void modified();
|
||||
|
||||
public void alpha(int alpha[]);
|
||||
|
||||
public void alpha(PImage alpha);
|
||||
|
||||
public void filter(int kind);
|
||||
|
||||
public void filter(int kind, float param);
|
||||
|
||||
public int get(int x, int y);
|
||||
|
||||
public PImage get(int x, int y, int w, int h);
|
||||
|
||||
public void set(int x, int y, int c);
|
||||
|
||||
public void copy(PImage src, int dx, int dy);
|
||||
|
||||
public void copy(int sx1, int sy1, int sx2, int sy2,
|
||||
int dx1, int dy1, int dx2, int dy2);
|
||||
|
||||
public void copy(PImage src, int sx1, int sy1, int sx2, int sy2,
|
||||
int dx1, int dy1, int dx2, int dy2);
|
||||
|
||||
public void blend(PImage src, int sx, int sy, int dx, int dy, int mode);
|
||||
|
||||
public void blend(int sx, int sy, int dx, int dy, int mode);
|
||||
|
||||
public void blend(int sx1, int sy1, int sx2, int sy2,
|
||||
int dx1, int dy1, int dx2, int dy2, int mode);
|
||||
|
||||
public void blend(PImage src, int sx1, int sy1, int sx2, int sy2,
|
||||
int dx1, int dy1, int dx2, int dy2, int mode);
|
||||
|
||||
public PImage get();
|
||||
|
||||
public void save(String filename);
|
||||
|
||||
public void smooth();
|
||||
|
||||
public void noSmooth();
|
||||
|
||||
public void imageMode(int mode);
|
||||
|
||||
public void defaults();
|
||||
|
||||
public void beginFrame();
|
||||
|
||||
public void endFrame();
|
||||
|
||||
public void beginShape();
|
||||
|
||||
public void beginShape(int kind);
|
||||
|
||||
public void normal(float nx, float ny, float nz);
|
||||
|
||||
public void textureMode(int mode);
|
||||
|
||||
public void texture(PImage image);
|
||||
|
||||
public void vertex(float x, float y);
|
||||
|
||||
public void vertex(float x, float y, float u, float v);
|
||||
|
||||
public void vertex(float x, float y, float z);
|
||||
|
||||
public void vertex(float x, float y, float z,
|
||||
float u, float v);
|
||||
|
||||
public void bezierVertex(float x, float y);
|
||||
|
||||
public void bezierVertex(float x, float y, float z);
|
||||
|
||||
public void curveVertex(float x, float y);
|
||||
|
||||
public void curveVertex(float x, float y, float z);
|
||||
|
||||
public void endShape();
|
||||
|
||||
public void point(float x, float y);
|
||||
|
||||
public void point(float x, float y, float z);
|
||||
|
||||
public void line(float x1, float y1, float x2, float y2);
|
||||
|
||||
public void line(float x1, float y1, float z1,
|
||||
float x2, float y2, float z2);
|
||||
|
||||
public void triangle(float x1, float y1, float x2, float y2,
|
||||
float x3, float y3);
|
||||
|
||||
public void rectMode(int mode);
|
||||
|
||||
public void rect(float x1, float y1, float x2, float y2);
|
||||
|
||||
public void quad(float x1, float y1, float x2, float y2,
|
||||
float x3, float y3, float x4, float y4);
|
||||
|
||||
public void image(PImage image, float x1, float y1);
|
||||
|
||||
public void image(PImage image,
|
||||
float x1, float y1, float x2, float y2);
|
||||
|
||||
public void image(PImage image,
|
||||
float x1, float y1, float x2, float y2,
|
||||
float u1, float v1, float u2, float v2);
|
||||
|
||||
public void cache(PImage image);
|
||||
|
||||
public void cache(PImage images[]);
|
||||
|
||||
public void arcMode(int mode);
|
||||
|
||||
public void arc(float start, float stop,
|
||||
float x, float y, float radius);
|
||||
|
||||
public void arc(float start, float stop,
|
||||
float x, float y, float hr, float vr);
|
||||
|
||||
public void ellipseMode(int mode);
|
||||
|
||||
public void ellipse(float x, float y, float hradius, float vradius);
|
||||
|
||||
public void circle(float x, float y, float radius);
|
||||
|
||||
public float bezierPoint(float a, float b, float c, float d,
|
||||
float t);
|
||||
|
||||
public float bezierTangent(float a, float b, float c, float d,
|
||||
float t);
|
||||
|
||||
public void bezier(float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4);
|
||||
|
||||
public void bezier(float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4);
|
||||
|
||||
public void bezierDetail(int detail);
|
||||
|
||||
public void curveDetail(int detail);
|
||||
|
||||
public void curveTightness(float tightness);
|
||||
|
||||
public float curvePoint(float a, float b, float c, float d,
|
||||
float t);
|
||||
|
||||
public float curveTangent(float a, float b, float c, float d,
|
||||
float t);
|
||||
|
||||
public void curve(float x1, float y1,
|
||||
float x2, float y2,
|
||||
float x3, float y3,
|
||||
float x4, float y4);
|
||||
|
||||
public void curve(float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float x3, float y3, float z3,
|
||||
float x4, float y4, float z4);
|
||||
|
||||
public void box(float size);
|
||||
|
||||
public void box(float w, float h, float d);
|
||||
|
||||
public void sphereDetail(int res);
|
||||
|
||||
public void sphere(float r);
|
||||
|
||||
public void sphere(float x, float y, float z, float r);
|
||||
|
||||
public void textFont(PFont which);
|
||||
|
||||
public void textSize(float size);
|
||||
|
||||
public void textFont(PFont which, float size);
|
||||
|
||||
public void textLeading(float leading);
|
||||
|
||||
public void textMode(int mode);
|
||||
|
||||
public void textSpace(int space);
|
||||
|
||||
public void text(char c, float x, float y);
|
||||
|
||||
public void text(char c, float x, float y, float z);
|
||||
|
||||
public void text(String s, float x, float y);
|
||||
|
||||
public void text(String s, float x, float y, float z);
|
||||
|
||||
public void text(String s, float x, float y, float w, float h);
|
||||
|
||||
public void text(String s, float x1, float y1, float z, float x2, float y2);
|
||||
|
||||
public void text(int num, float x, float y);
|
||||
|
||||
public void text(int num, float x, float y, float z);
|
||||
|
||||
public void text(float num, float x, float y);
|
||||
|
||||
public void text(float num, float x, float y, float z);
|
||||
|
||||
public void angleMode(int mode);
|
||||
|
||||
public void translate(float tx, float ty);
|
||||
|
||||
public void translate(float tx, float ty, float tz);
|
||||
|
||||
public void rotateX(float angle);
|
||||
|
||||
public void rotateY(float angle);
|
||||
|
||||
public void rotate(float angle);
|
||||
|
||||
public void rotateZ(float angle);
|
||||
|
||||
public void rotate(float angle, float v0, float v1, float v2);
|
||||
|
||||
public void scale(float s);
|
||||
|
||||
public void scale(float sx, float sy);
|
||||
|
||||
public void scale(float x, float y, float z);
|
||||
|
||||
public void transform(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);
|
||||
|
||||
public void push();
|
||||
|
||||
public void pop();
|
||||
|
||||
public void resetMatrix();
|
||||
|
||||
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);
|
||||
|
||||
public void applyMatrix(float n00, float n01, float n02,
|
||||
float n10, float n11, float n12);
|
||||
|
||||
public void printMatrix();
|
||||
|
||||
public void cameraMode(int mode);
|
||||
|
||||
public void beginCamera();
|
||||
|
||||
public void endCamera();
|
||||
|
||||
public void ortho(float left, float right,
|
||||
float bottom, float top,
|
||||
float near, float far);
|
||||
|
||||
public void perspective(float fovy, float aspect, float zNear, float zFar);
|
||||
|
||||
public void frustum(float left, float right, float bottom,
|
||||
float top, float znear, float zfar);
|
||||
|
||||
public void lookat(float eyeX, float eyeY, float eyeZ,
|
||||
float centerX, float centerY, float centerZ,
|
||||
float upX, float upY, float upZ);
|
||||
|
||||
public void printCamera();
|
||||
|
||||
public float screenX(float x, float y);
|
||||
|
||||
public float screenY(float x, float y);
|
||||
|
||||
public float screenX(float x, float y, float z);
|
||||
|
||||
public float screenY(float x, float y, float z);
|
||||
|
||||
public float screenZ(float x, float y, float z);
|
||||
|
||||
public float objectX(float x, float y, float z);
|
||||
|
||||
public float objectY(float x, float y, float z);
|
||||
|
||||
public float objectZ(float x, float y, float z);
|
||||
|
||||
public void colorMode(int mode);
|
||||
|
||||
public void colorMode(int mode, float max);
|
||||
|
||||
public void colorMode(int mode,
|
||||
float maxX, float maxY, float maxZ);
|
||||
|
||||
public void colorMode(int mode,
|
||||
float maxX, float maxY, float maxZ, float maxA);
|
||||
|
||||
public void noTint();
|
||||
|
||||
public void tint(int rgb);
|
||||
|
||||
public void tint(float gray);
|
||||
|
||||
public void tint(float gray, float alpha);
|
||||
|
||||
public void tint(float x, float y, float z);
|
||||
|
||||
public void tint(float x, float y, float z, float a);
|
||||
|
||||
public void noFill();
|
||||
|
||||
public void fill(int rgb);
|
||||
|
||||
public void fill(float gray);
|
||||
|
||||
public void fill(float gray, float alpha);
|
||||
|
||||
public void fill(float x, float y, float z);
|
||||
|
||||
public void fill(float x, float y, float z, float a);
|
||||
|
||||
public void strokeWeight(float weight);
|
||||
|
||||
public void strokeJoin(int join);
|
||||
|
||||
public void strokeCap(int cap);
|
||||
|
||||
public void noStroke();
|
||||
|
||||
public void stroke(int rgb);
|
||||
|
||||
public void stroke(float gray);
|
||||
|
||||
public void stroke(float gray, float alpha);
|
||||
|
||||
public void stroke(float x, float y, float z);
|
||||
|
||||
public void stroke(float x, float y, float z, float a);
|
||||
|
||||
public void background(int rgb);
|
||||
|
||||
public void background(float gray);
|
||||
|
||||
public void background(float x, float y, float z);
|
||||
|
||||
public void background(PImage image);
|
||||
|
||||
public void clear();
|
||||
|
||||
public void depth();
|
||||
|
||||
public void noDepth();
|
||||
|
||||
public void lights();
|
||||
|
||||
public void noLights();
|
||||
|
||||
public void light(int num, float x, float y, float z,
|
||||
float red, float green, float blue);
|
||||
|
||||
public void lightEnable(int num);
|
||||
|
||||
public void lightDisable(int num);
|
||||
|
||||
public void lightPosition(int num, float x, float y, float z);
|
||||
|
||||
public void lightAmbient(int num, float x, float y, float z);
|
||||
|
||||
public void lightDiffuse(int num, float x, float y, float z);
|
||||
|
||||
public void lightSpecular(int num, float x, float y, float z);
|
||||
|
||||
public void hint(int which);
|
||||
|
||||
public void unhint(int which);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ open(F, "PImage.java") || die $!;
|
||||
close(F);
|
||||
|
||||
# next slurp methods from PGraphics
|
||||
open(F, "PGraphics.java") || die $!;
|
||||
open(F, "PGraphics3.java") || die $!;
|
||||
#@contents = <F>;
|
||||
foreach $line (<F>) {
|
||||
# can't remember perl right now.. there must be a better way
|
||||
@@ -29,10 +29,10 @@ foreach $line (@applet) {
|
||||
last if ($line =~ /$insert/);
|
||||
}
|
||||
|
||||
#open(INTF, ">PMethods.java") || die $!;
|
||||
#print INTF "package processing.core;\n\n\n\n";
|
||||
#print INTF "// this file is auto-generated. no touchy-touchy.\n\n";
|
||||
#print INTF "public interface PMethods {\n";
|
||||
open(INTF, ">PMethods.java") || die $!;
|
||||
print INTF "package processing.core;\n\n\n\n";
|
||||
print INTF "// this file is auto-generated. no touchy-touchy.\n\n";
|
||||
print INTF "public interface PMethods {\n";
|
||||
|
||||
$comments = 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ while ($line = shift(@contents)) {
|
||||
if ($got_interface == 1) {
|
||||
$iline = $line;
|
||||
$iline =~ s/ \{/\;/;
|
||||
# print INTF "\n$iline";
|
||||
print INTF "\n$iline";
|
||||
}
|
||||
|
||||
$decl .= $line;
|
||||
@@ -88,8 +88,7 @@ while ($line = shift(@contents)) {
|
||||
if ($got_interface == 1) {
|
||||
$iline = $line;
|
||||
$iline =~ s/ \{/\;/;
|
||||
#$iline =~ s/\) \{/\)\;/;
|
||||
# print INTF $iline;
|
||||
print INTF $iline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,10 +121,10 @@ while ($line = shift(@contents)) {
|
||||
}
|
||||
}
|
||||
print OUT "}\n";
|
||||
#print INTF "}\n";
|
||||
print INTF "}\n";
|
||||
|
||||
close(OUT);
|
||||
#close(INTF);
|
||||
close(INTF);
|
||||
|
||||
$oldguy = join(' ', @applet);
|
||||
|
||||
|
||||
@@ -30,7 +30,15 @@ o or is just a message to save the next frame (problem for anim)
|
||||
X vertices max out at 512.. make it grow
|
||||
X add gzipInput and gzipOutput
|
||||
|
||||
_ PFont.list() to return string list of all the available fonts
|
||||
_ textFont with a named font can use the renderer/os font
|
||||
_ for postscript, can grab the real font
|
||||
_ -> altho problem here is that really the fonts just need a name
|
||||
_ since needs to render to screen as well
|
||||
|
||||
_ get regular graphics engine working again
|
||||
_ smooth is no longer working
|
||||
_ ellipses aren't handled
|
||||
|
||||
_ look for size() method to determine default size of applet
|
||||
_ (same as applet exporter function)
|
||||
@@ -41,6 +49,11 @@ _ default to single byte input from serial port
|
||||
_ and add serial.setBuffer() for message length as alternative
|
||||
_ or serial.setDelimiter() to fire message on delim
|
||||
|
||||
_ move textMode and textSpace back out of PFont
|
||||
_ use die() to fail in font situations
|
||||
|
||||
_ die() may need to throw a RuntimeException
|
||||
|
||||
_ light(x, y, z, c1, c2, c3, TYPE)
|
||||
_ also BLight with same constructor, and on() and off() fxn
|
||||
|
||||
|
||||
Reference in New Issue
Block a user