FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 1153 : curveVertex; ArrayIndexOutOfBoundsException.
Last modified: 2009-02-20 14:41
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
FIXED -
Pr
i
ority:
P1
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
nestor
Assigned To:
fry
Attachment
Type
Created
Size
Actions
Description
: Opened: 2009-02-07 08:28
OSX 10.5.6 on MacPro.
Removing or Commenting out noFill() in the below code leads to an error.
Thread@
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1233939550;start=0#4
[code]
int largo;
float[] x;
float[] y;
float[] z;
int gap = 33;
float noiseX,noiseY,noiseZ,xoff,yoff,zoff,xwalk,ywalk,zwalk,mx2,my2,mz2;
int ind;
float xBin,yBin,avgX,avgY;
void setup(){
size(640,480,P3D);
noiseX = 0.012;
noiseY = 0.023;
noiseZ = 0.008;
largo = 220;
x=new float[largo];
y=new float[largo];
z=new float[largo];
}
void draw(){
xoff = xoff + noiseX;
yoff = yoff + noiseY;
zoff = zoff + noiseZ;
xwalk = sin(noise(xoff)) * width;
ywalk = sin(noise(yoff)) * height;
zwalk = noise(zoff) * height;
background(0);
// noFill(); //Commented this line to reproduce bug.
strokeWeight(0.5);
for(int i =1;i<largo;i++){
x[i-1] = x[i];
y[i-1] = y[i];
z[i-1] = z[i];
}
x[largo-1]=xwalk;
y[largo-1]=ywalk;
z[largo-1]=zwalk;
make();
}
void make(){
beginShape();
for(int i=0; i<largo; i++) {
stroke(i,12,198,i/3);
float mx = x[i];
float my = y[i];
float mz = z[i];
ind = constrain(i+gap,0,largo-1);
mx2 = x[ind];
my2 = y[ind];
mz2 = z[ind];
curveVertex(mx,my,-mz);
curveVertex(mx2,my2,-mz2);
}
endShape();
camFollow();
}
void camFollow(){
xBin = 0;
yBin = 0;
int largo_ = 55;
int plus = largo - largo_;
for (int i=0;i<largo_;i++){
xBin += x[i+plus];
yBin+= y[i+plus];
}
avgX = xBin/largo_;
avgY = yBin/largo_;
camera(xwalk,ywalk,100,
avgX,avgY,-300,
0.0,1.0,0);
spotLight(255,255,0,
avgX,avgY,300,
0,-0.5,-1,
PI, 2);
}
void saveFrames(float numFrames){
if (frameCount <= numFrames) {
saveFrame("woim-####.tif");
}}
[/code]
"Red Spew":
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at processing.core.PApplet.arrayCopy(PApplet.java:4534)
at processing.core.PGraphics3D.addPolygonTriangles(PGraphics3D.java:1512)
at processing.core.PGraphics3D.endShapeFill(PGraphics3D.java:872)
at processing.core.PGraphics3D.endShape(PGraphics3D.java:612)
at processing.core.PGraphics.endShape(PGraphics.java:1133)
at processing.core.PApplet.endShape(PApplet.java:6868)
at follow_that_woim.make(follow_that_woim.java:78)
at follow_that_woim.draw(follow_that_woim.java:57)
at processing.core.PApplet.handleDraw(PApplet.java:1406)
at processing.core.PApplet.run(PApplet.java:1311)
at java.lang.Thread.run(Thread.java:613)
Additional Comment
#1 From yscik 2009-02-19 02:34
I'm getting the same error (in Windows XP) when trying to use OPENGL
rendering. The exception only occurs when fill is on and I try to add more
than 28 vertices.
This works:
void draw()
{
background(0);
fill(80);
beginShape();
for(int i = 1; i <= 28; i++) curveVertex(i * 20, 200 - noise(i) * 20);
endShape();
}
Throws exception:
void draw()
{
background(0);
fill(80);
beginShape();
for(int i = 1; i <= 29; i++) curveVertex(i * 20, 200 - noise(i) * 20);
endShape();
}
Also works:
void draw()
{
background(0);
noFill();
beginShape();
for(int i = 1; i <= 100; i++) curveVertex(i * 20, 200 - noise(i) * 20);
endShape();
}
Additional Comment
#2 From yscik 2009-02-19 03:00
Toyed around a bit more with this; turns out vertex() dies after 512,
bezierVertex after 25 (+1) vertices, throwing the same exception. (As
above, only with fill() and OpenGL, in every other case everything works fine)
Additional Comment
#3 From fry 2009-02-20 14:41
Found and fixed for 1.0.2. Thanks for the report and especially the examples.