We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Mesh Library Problems (ArrayIndexOutOfBounds..)
Page Index Toggle Pages: 1
Mesh Library Problems (ArrayIndexOutOfBounds..) (Read 741 times)
Mesh Library Problems (ArrayIndexOutOfBounds..)
Aug 29th, 2009, 12:30pm
 
First of all, this is Mesh:

http://leebyron.com/else/mesh

Now, my problem when I try to put anything into a "Voronoi" type variable. I get:

ArrayIndexOutOfBoundsException: 0.

From what I was told in another post, that means my "Voronoi" array is size 0 and I'm trying to put something into it, which of course... doesnt fit.

But I can't manage to give it a size :S

I've tried:

In the header.
float [][] centroid = new float [20][2];
Voronoi myVoronoi = new Voronoi(centroid);


In the "setup" function:
Header --> Voronoi myVoronoi;
                float [][] centroid = new float [20][2];
Setup ---> myVoronoi = new Voronoi (centroid);


In the "draw" function itself:
Header --> Voronoi myVoronoi;
                float [][] centroid = new float [20][2];
Draw ----> myVoronoi = new Voronoi( centroid );


With every method I get the same error :S Array size = 0...
Does anyone know why this might be happening?
Thanks for your help. Once again.... Smiley

PD: Actually the whole error is this, in case it helps:

ArrayIndexOutOfBoundsException : 0

Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 0
     at megamu.mesh.IntArray.add(IntArray.java:22)
     at megamu.mesh.Voronoi.<init>(Voronoi.java:127)
     at sketch_aug29a.draw(sketch_aug29a.java:163)
     at processing.core.PApplet.handleDraw(PApplet.java:1406)
     at processing.core.PApplet.run(PApplet.java:1311)
     at java.lang.Thread.run(Unknown Source)
Re: Mesh Library Problems (ArrayIndexOutOfBounds..)
Reply #1 - Aug 29th, 2009, 2:53pm
 
have you tried assigning values to each index of the centroid array before passing it as a parameter for the new Voronoi object?

as far as i can see what may be causing some problems is that you are passing an empty centroid array to your new Voronoi object. apparently you should pass an array with several x,y coordinates for it to work properly.

hope this helps
Re: Mesh Library Problems (ArrayIndexOutOfBounds..)
Reply #2 - Aug 29th, 2009, 3:24pm
 
My program already assigns those values, but still I tried to do that manually too :S I tried asigning values just to the first 2 values of the array. Like this:

centroid[0][0] = 40;
centroid[0][1] = 40;
centroid[1][0] = 200;
centroid[1][1] = 200;

And I still got the same error :S I dont understand why the array size remains as 0 :S
Page Index Toggle Pages: 1