saveFrame() fix, fov in radians

This commit is contained in:
benfry
2005-04-30 04:25:15 +00:00
parent 19dd95354e
commit 0168dd759b
5 changed files with 179 additions and 181 deletions
+12 -19
View File
@@ -588,7 +588,7 @@ public class PApplet extends Applet
}
public void draw() {
synchronized public void draw() {
// if no draw method, then shut things down
//System.out.println("no draw method, goodbye");
finished = true;
@@ -980,7 +980,7 @@ public class PApplet extends Applet
}
public void display() {
synchronized public void display() {
if (PApplet.THREAD_DEBUG) println(Thread.currentThread().getName() +
" formerly nextFrame()");
if (looping || redraw) {
@@ -1794,8 +1794,8 @@ public class PApplet extends Applet
/**
* This version of save() is an override of PImage.save(),
* rather than calling g.save(). This version properly saves
* the image to the applet folder (whereas save doesn't know
* where to put things)
* the image to the applet folder (whereas PImage.save() and
* the inherited PGraphics.save() don't know where to put things).
*/
public void save(String filename) {
g.save(savePath(filename));
@@ -1831,7 +1831,7 @@ public class PApplet extends Applet
* <PRE>
* i.e. saveFrame("blah-####.tif");
* // saves a numbered tiff image, replacing the
* // # signs with zeros and the frame number </PRE>
* // #### signs with zeros and the frame number </PRE>
*/
public void saveFrame(String what) {
if (online) {
@@ -1849,12 +1849,7 @@ public class PApplet extends Applet
String prefix = what.substring(0, first);
int count = last - first + 1;
String suffix = what.substring(last + 1);
//File file = new File(folder, prefix + nf(frame, count) + suffix);
// in case the user tries to make subdirs with the filename
//new File(file.getParent()).mkdirs();
//save(file.getAbsolutePath());
save(savePath(prefix + nf(frameCount, count) + suffix));
save(prefix + nf(frameCount, count) + suffix);
}
}
@@ -1864,7 +1859,7 @@ public class PApplet extends Applet
// CURSOR
// based on code contributed by amit pitaru and jonathan feinberg
//
int cursor_type = ARROW; // cursor type
@@ -1876,9 +1871,7 @@ public class PApplet extends Applet
* Set the cursor type
*/
public void cursor(int _cursor_type) {
//if (cursor_visible && _cursor_type != cursor_type) {
setCursor(Cursor.getPredefinedCursor(_cursor_type));
//}
cursor_visible = true;
cursor_type = _cursor_type;
}
@@ -1888,9 +1881,11 @@ public class PApplet extends Applet
* Set a custom cursor to an image with a specific hotspot.
* Only works with JDK 1.2 and later.
* Currently seems to be broken on Java 1.4 for Mac OS X
* <P>
* Based on code contributed by Amit Pitaru, plus additional
* code to handle Java versions via reflection by Jonathan Feinberg.
*/
public void cursor(PImage image, int hotspotX, int hotspotY) {
//if (!isOneTwoOrBetter()) {
if (javaVersion < 1.2f) {
System.err.println("Java 1.2 or higher is required to use cursor()");
System.err.println("(You're using version " + javaVersionName + ")");
@@ -1904,7 +1899,6 @@ public class PApplet extends Applet
createImage(new MemoryImageSource(image.width, image.height,
image.pixels, 0, image.width));
//Toolkit tk = Toolkit.getDefaultToolkit();
Point hotspot = new Point(hotspotX, hotspotY);
try {
Method mCustomCursor =
@@ -1921,8 +1915,8 @@ public class PApplet extends Applet
cursor_visible = true;
} catch (NoSuchMethodError e) {
System.err.println("cursor() is not available on " +
nf(javaVersion, 1, 1));
System.err.println("cursor() is not available " +
"when using Java " + javaVersionName);
} catch (IndexOutOfBoundsException e) {
System.err.println("cursor() error: the hotspot " + hotspot +
" is out of bounds for the given image.");
@@ -1956,7 +1950,6 @@ public class PApplet extends Applet
if (!cursor_visible) return; // don't hide if already hidden.
if (invisible_cursor == null) {
//invisible_cursor = new PImage(new int[32*32], 32, 32, RGBA);
invisible_cursor = new PImage(new int[16*16], 16, 16, ARGB);
}
// was formerly 16x16, but the 0x0 was added by jdf as a fix
+14 -12
View File
@@ -1543,9 +1543,21 @@ public class PGraphics extends PImage implements PConstants {
}
public void textMode(int space) {
/**
* Sets the text rendering/placement to be either SCREEN (direct
* to the screen, exact coordinates) or MODEL (the default, where
* text is manipulated by translate() etc). The text size cannot
* be set when using textMode(SCREEN), because it uses the pixels
* directly from the font.
*/
public void textMode(int mode) {
if ((mode != SCREEN) && (mode != MODEL)) {
throw new RuntimeException("Only textMode(SCREEN) or textMode(MODEL) " +
"can be used. Maybe you meant textAlign()?");
}
if (textFont != null) {
textMode = space;
textMode = mode;
// reset the font to its natural size
// (helps with width calculations and all that)
@@ -1605,16 +1617,6 @@ public class PGraphics extends PImage implements PConstants {
public void text(char c, float x, float y) {
text(c, x, y, 0);
/*
if (textFont != null) {
if (textMode == SCREEN) loadPixels();
textFont.text(c, x, y, this);
if (textMode == SCREEN) updatePixels();
} else {
throw new RuntimeException("use textFont() before text()");
}
*/
}
+12 -8
View File
@@ -83,15 +83,19 @@ public class PGraphics3 extends PGraphics {
static final int LIGHT_COLOR_COUNT = 9;
// Used to shuttle lighting calcs around (no need to re-allocate all the time)
// 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];
// ........................................................
// perspective setup
/** Camera field of view (in radians, as of rev 86) */
public float cameraFOV;
/** Position of the camera */
public float cameraX, cameraY, cameraZ;
public float cameraNear, cameraFar;
public float cameraAspect;
@@ -306,10 +310,11 @@ public class PGraphics3 extends PGraphics {
//background(backgroundColor);
// init perspective projection based on new dimensions
cameraFOV = 60; // at least for now
cameraFOV = 60 * DEG_TO_RAD; // at least for now
cameraX = width / 2.0f;
cameraY = height / 2.0f;
cameraZ = cameraY / ((float) tan(PI * cameraFOV / 360f));
//cameraZ = cameraY / ((float) tan(PI * cameraFOV / 360f));
cameraZ = cameraY / ((float) tan(cameraFOV / 2.0f));
cameraNear = cameraZ / 10.0f;
cameraFar = cameraZ * 10.0f;
@@ -2901,10 +2906,9 @@ public class PGraphics3 extends PGraphics {
/**
* Same as gluPerspective(). Implementation based on Mesa's glu.c
*/
public void perspective(float fovy, float aspect, float zNear, float zFar) {
//System.out.println("perspective: " + fovy + " " + aspect + " " +
// zNear + " " + zFar);
float ymax = zNear * tan(fovy * PI / 360.0f);
public void perspective(float fov, float aspect, float zNear, float zFar) {
//float ymax = zNear * tan(fovy * PI / 360.0f);
float ymax = zNear * tan(fov / 2.0f);
float ymin = -ymax;
float xmin = ymin * aspect;
+30 -38
View File
@@ -3,23 +3,41 @@ X java 1.4 getButton() was inside the mouse handler
X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114147314;start=3
X color() doesn't work properly because g might be null?
X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114518309;start=0
X textMode(RIGHT) etc causing trouble.. tell ppl to use textAlign()
X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1114219121;start=4
X saveFrame with a filename still causing trouble:
X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114097641;start=0
X fov should be in radians
_ createGraphics(200, 200) to create same as source
_ createGraphics(200, 200, P2D) to create 2D from 3D
_ also, drawing a PGraphics2 doesn't seem to work
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1113919619;start=5
_ new PGraphics2 objects are set as RGB, but on loadPixels/updatePixels
_ they're drawn as transparent and don't have their high bits set
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1113933055;start=0
_ is mousePressed broken because of event queue? or at least w/ framerate?
_ seem to be problems with updatePixels() on the mac
_ appears to run asynchronously
_ for present mode, need to set a default display
_ currently crashes if only --present is specified w/o --display
_ fov should be in radians
_ polygons perpendicular to axis not drawing
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114158993;start=0
_ createGraphics(200, 200) to create same as source **include for 86**
_ createGraphics(200, 200, P2D) to create 2D from 3D
_ also, drawing a PGraphics2 doesn't seem to work
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1113919619;start=5
_ is camera backwards, or staying fixed and moving the scene?
_ end of lookat might be backwards
_ or endCamera might be swapping camera and cameraInv
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
high priority but not *required* for 86
X typed version of expand() and contract()
_ need to complete for the others:
_ append(), shorten(), splice, slice, subset, concat, reverse
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Suggestions;action=display;num=1114443601;start=0
_ for present mode, need to set a default display
_ currently crashes if only --present is specified w/o --display
_ seem to be problems with updatePixels() on the mac
_ appears to run asynchronously
@@ -46,37 +64,12 @@ As an aside, set() is at least 10x faster, and
perhaps should be used in these examples anyway.
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114204116;start=0
_ textMode(RIGHT) etc causing trouble.. tell ppl to use textAlign()
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1114219121;start=4
_ polygon rendering bug?
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114158993;start=1
_ video wrong device name crashes things
_ is it the run() exception handler that's leaving off the CRLFs?
o draw happening before setup() ?
X typed version of expand() and contract()
_ need to complete for the others:
_ append(), shorten(), splice, slice, subset, concat, reverse
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Suggestions;action=display;num=1114443601;start=0
_ saveFrame with a filename still causing trouble:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114097641;start=0
_ would be cool if could sort w/o the sort class..
_ meaning use reflection to sort objects, just by implementing a few methods
_ make a PException that extends RuntimeException but packages an ex?
_ new PGraphics2 objects are set as RGB, but on loadPixels/updatePixels
_ they're drawn as transparent and don't have their high bits set
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1113933055;start=0
_ set upper bound on framerate so as not to completely hose things?
_ is camera backwards, or staying fixed and moving the scene?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -89,6 +82,7 @@ _ bizarre image loading error with c_Rollover.zip
_ text() with a z coordinate is now using translate, very slow
_ also puts up a weird error message about translate() in 2D mode
_ set upper bound on framerate so as not to completely hose things?
_ fix the flicker in java2d mode
_ not clear what's happening here
_ appears to be much worse (unfinished drawing) on macosx
@@ -105,8 +99,6 @@ _ so that no need to copy/update everything
_ make the 1.4 code in PApplet load via reflection
_ doesn't appear necessary with 1.3 applets
_ noCursor seems to be broken on the mac?
_ make get/getImpl for PGraphics/PGraphics2
_ make sure there's a loadPixels/updatePixels in PGraphics2
_ rewrite getImpl/setImpl inside opengl
+111 -104
View File
@@ -2,35 +2,17 @@
X new versions of java for windows and linux: 1.4.2_07
X update faq on site? what's difference between versions?
X no difference between versions... should it be cvs based?
X linux is missing all libraries except for javascript
_ added again, but check the distribution to make sure they're working
X http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Tools;action=display;num=1114325419;start=1
_ set applet.frame on runner, so ppl can mess with the frame itself
_ make simple tool for casey to rebuild all the examples at once
_ need to rebuild with this release because of 1.3/1.4 issues
_ osx is swallowing exceptions on external apps
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114520230;start=5
_ documentation on tabs: .java files, inner classes, etc
_ "are you trying to f-- with me" on quitting the app is super problem
_ built in functions.. may not always be fastest, we're going for correct
_ most things have other ways of making things much faster
_ we've attempted for less confusion over speed in some cases
_ get(), set() and red() et al are one such example
_ serial will only list ports that are currently not in use
_ i.e. if you're monitoring the port in one app, it won't be listed
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1114561057;start=0
_ additional requests for this (and it's an easy fix)
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Suggestions;action=display;num=1114449442;start=0
1 _ maintain tab scroll and caret positions
1 _ save caret position when switching tabs
_ faq - not supporting windows 95
_ http://www.java.com/en/download/help/win95.xml
_ include platform information when checking for updates
_ send over the int as long hex number?
_ 64 bits hex is gonna be 16 digits.. much cleaner
_ get platform checker into the latest exhibition piece
_ macosx 10.2 needs libiconv to run jikes
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114113204;start=0
@@ -42,63 +24,6 @@ _ gnu page for libiconv
_ http://www.gnu.org/software/libiconv/
_ on 10.2, the version of jikes from 69 (the cvs build) works fine
_ faq - known bugs
_ put the jikes fix for 10.2 on the faq
_ 1 pixel stroke weight in opengl (temporary)
_ make clear that P2D is not working if not clear enough
_ save/yes/no needs cancel
X wontstart wasn't properly linked
_ faq - graphics engines
_ default graphics may be slow
_ opengl only runs with 1.4
_ need to write an error if people try to use it in 1.3 (i.e. on export)
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Contribution_3DOpenGL;action=display;num=1114368123;start=3
_ grabbing sun.cpu.endian throws a security exception with gl applets
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Contribution_3DOpenGL;action=display;num=1114368123;start=3
_ opengl not tested for applets
_ to get to opengl functions, put this after size:
_ GL gl = ((PGraphicsGL)g).gl;
_ and then can make opengl calls. this is not supported,
_ and if things don't work, sorry.
_ faq - not our problem
_ watch out for upper/lowercase changes
_ methods and functions always start lowercase, and have inner caps
_ sun.dc.pr.PRException
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1113990788;start=0
_ faq - changes
X videoEvent and serialEvent pass in the object
_ updatePixels() may be slower.. hopefully JAVA2D mostly temporary
_ is there a way to do xxx?
_ advanced users who are outgrowing the basic reference:
_ be sure to check the "complete" reference
_ faq - java 1.5
_ seems to run things more slowly..
_ if using p5 standard, will be running 1.4
_ but if 1.5 installed, browser will probably use that
_ faq - how things work
_ additional tabs are added to the main code
_ as a result, static variables can't be used
_ though they can go above the class itself or be placed in the parent
_ if you want it separate, use a .java file instead (not parsed)
_ classes in tabs are inner classes, or use .java files
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1114393478;start=0
_ sun.applet.Main is appletviewer
_ settings.path.fallback not being used
_ can't find build dir on operatign systems w/ non-ascii chars
_ info about getting started with building processing
_ also re: what about eclipse? what about antlr?
_ update things for java 1.5 since it's inevitable
_ esc doesn't kill fullscreen mode
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114027594;start=0
@@ -106,6 +31,8 @@ _ preferences - second line of prefs (the file path) is smashing things
_ righthand max isn't being updated for that second line
_ or it's getting written over by the line below it
_ "are you trying to f-- with me" on quitting the app is super problem
_ "save as" not quite working
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1113944897;start=0
Performed a "Save As" that didn't quite take. The save action
@@ -125,15 +52,109 @@ I get it. But i wonder if this will catch others off guard.
Not suggesting a change to the way it works... but thoughts on if this
might screw people in the long run?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DOCUMENTATION
_ documentation on tabs: .java files, inner classes, etc
_ serial will only list ports that are currently not in use
_ i.e. if you're monitoring the port in one app, it won't be listed
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1114561057;start=0
_ built in functions.. may not always be fastest, we're going for correct
_ most things have other ways of making things much faster
_ we've attempted for less confusion over speed in some cases
_ get(), set() and red() et al are one such example
_ faq - not supporting windows 95
_ http://www.java.com/en/download/help/win95.xml
_ faq - known bugs
_ put the jikes fix for 10.2 on the faq
_ 1 pixel stroke weight in opengl (temporary)
_ make clear that P2D is not working if not clear enough
_ save/yes/no needs cancel
X wontstart wasn't properly linked
_ faq - graphics engines
_ default graphics may be slow
_ opengl only runs with 1.4
_ need to write an error if people try to use it in 1.3 (i.e. on export)
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Contribution_3DOpenGL;action=display;num=1114368123;start=3
_ grabbing sun.cpu.endian throws a security exception with gl applets
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Contribution_3DOpenGL;action=display;num=1114368123;start=3
_ opengl not tested for applets
_ to get to opengl functions, put this after size:
_ GL gl = ((PGraphicsGL)g).gl;
_ and then can make opengl calls. this is not supported,
_ and if things don't work, sorry.
_ faq - not our problem
_ watch out for upper/lowercase changes
_ methods and functions always start lowercase, and have inner caps
_ sun.dc.pr.PRException
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1113990788;start=0
_ faq - changes
X videoEvent and serialEvent pass in the object
_ updatePixels() may be slower.. hopefully JAVA2D mostly temporary
_ is there a way to do xxx?
_ advanced users who are outgrowing the basic reference:
_ be sure to check the "complete" reference
_ faq - java 1.5
_ seems to run things more slowly..
_ if using p5 standard, will be running 1.4
_ but if 1.5 installed, browser will probably use that
_ faq - how things work
_ additional tabs are added to the main code
_ as a result, static variables can't be used
_ though they can go above the class itself or be placed in the parent
_ if you want it separate, use a .java file instead (not parsed)
_ classes in tabs are inner classes, or use .java files
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1114393478;start=0
_ not slice() but subset()... get word from casey on how to resolve
_ auto-run the javadoc in dist.sh
_ doctor a copy of the css file to use p5 defaults
_ and re-copy the css in after generating the doc each time
_ include platform information when checking for updates
_ send over the int as long hex number?
_ 64 bits hex is gonna be 16 digits.. much cleaner
_ get platform checker into the latest exhibition piece
_ not slice() but subset()... get word from casey on how to resolve
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
HIGH PRIORITY BUT NOT NECESSITY
_ ability to select monitor via preferences panel
_ this applies to any applet that's run externally currently (verify)
_ make it also work with anything that's run inside of p5 itself
_ check current present code with multiple monitors
_ first pass on full screen
_ exceptions in full screen mode will quit the app completely
_ (can't keep window open because things are hosed)
_ default is that full screen app doesn't cover multiple displays
_ this is fine since opengl can't usually go across both
_ but include an example for how to use full in gl
_ (use toolkit.getscreensize)
_ println() can hose the app for the first 20-30 frames
_ need to figure out threading etc
_ problem with it launching a new thread for every single update!
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
_ set applet.frame on runner, so ppl can mess with the frame itself
_ osx is swallowing exceptions on external apps
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=SoftwareBugs;action=display;num=1114520230;start=5
_ additional requests for this (and it's an easy fix)
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Suggestions;action=display;num=1114449442;start=0
1 _ maintain tab scroll and caret positions
1 _ save caret position when switching tabs
_ sun.applet.Main is appletviewer
_ settings.path.fallback not being used
_ can't find build dir on operating systems w/ non-ascii chars
_ or rather, when user accounts have non-ascii chars in the name
_ try setting up an account where this is the case
_ info about getting started with building processing
_ also re: what about eclipse? what about antlr?
_ update things for java 1.5 since it's inevitable
_ port buffering not working properly
_ may just be a problem with thread starvation
@@ -182,9 +203,6 @@ _ if extends PApplet.. or rather, put PApplet cast into a
_ try/catch block.. if it doesn't work, try applet. if that
_ doesn't work, try using the class' main() to run it
_ println() can hose the app for the first 20-30 frames
_ need to figure out threading etc
_ not confirmed to be a bug
Is it possible that saving with the 'save' button doesn't pay
attention to where you point at the project folder from prefs? Jeez,
@@ -230,26 +248,14 @@ _ this seems too complicated.. just make people restart
_ more javadoc for the stuff inside processing.app
_ ability to select monitor via preferences panel
_ this applies to any applet that's run externally currently (verify)
_ make it also work with anything that's run inside of p5 itself
_ check current present code with multiple monitors
_ first pass on full screen
_ exceptions in full screen mode will quit the app completely
_ (can't keep window open because things are hosed)
_ default is that full screen app doesn't cover multiple displays
_ this is fine since opengl can't usually go across both
_ but include an example for how to use full in gl
_ (use toolkit.getscreensize)
_ runtime exceptions have stopped coming through (on pc only?)
_ that they don't show up in the error bar
_ npe is a runtimeex, so any npe in setup comes up weird
_ maybe the renderer exception is something different? newrendex?
_ why is gl being added on export, no matter what? or is it?
_ sketch folder not really being emptied on export
_ applet folder not really being emptied on export
_ so old libs will just perpetuate themselves
_ external apps don't stop at all when 'stop' is hit
@@ -295,6 +301,7 @@ camera
_ tearing and incomplete updates on camera?
_ http://processing.org/discourse/yabb_beta/YaBB.cgi?board=VideoCamera;action=display;num=1114628335;start=0
_ pause and framerate aren't working
_ video wrong device name crashes things
_ when passing in 'null' as the camera, dialog pops up fine
_ but the applet craps out after a few seconds (pinwheel spin)
_ couldn't get req'd component also happens when the camera isn't ready