Basically whenever I press Run in my java IDE (Eclipse) it outputs:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 36 out of bounds for length 36
at javax.media.j3d.GeometryArrayRetained.setCoordinate(GeometryArrayRetained.java:3634)
at javax.media.j3d.GeometryArray.setCoordinate(GeometryArray.java:1336)
at Main.Shapes.Square.Make(Square.java:38)
at Main.Second.<init>(Second.java:24)
at Main.Main.main(Main.java:7)
the class it points out is called Square this is what it contains:
package Main.Shapes;
import javax.media.j3d.Node;
import javax.media.j3d.QuadArray;
import javax.media.j3d.Shape3D;
import javax.vecmath.Point3f;
public class Square {
Node shape;
public Square() {
}
public Node Make(float Size) {
QuadArray polygon1 = new QuadArray (12, QuadArray.COORDINATES);
//Front
polygon1.setCoordinate(0, new Point3f (0f, 0f, 0f));
polygon1.setCoordinate(1, new Point3f (Size, 0f, 0f));
polygon1.setCoordinate(2, new Point3f (Size, Size, 0f));
polygon1.setCoordinate(3, new Point3f (0f, Size, 0f));
//Back
polygon1.setCoordinate(4, new Point3f (0f, 0f, -Size));
polygon1.setCoordinate(5, new Point3f (Size, 0f, -Size));
polygon1.setCoordinate(6, new Point3f (Size, Size, -Size));
polygon1.setCoordinate(7, new Point3f (0f, Size, -Size));
//Right
polygon1.setCoordinate(8, new Point3f (Size, 0f, 0f));
polygon1.setCoordinate(9, new Point3f (Size, Size, 0f));
polygon1.setCoordinate(10, new Point3f(Size, Size, -Size));
polygon1.setCoordinate(11, new Point3f(Size, 0f, -Size));
//left
polygon1.setCoordinate(11, new Point3f (0f, 0f, 0f));
polygon1.setCoordinate(12, new Point3f (0f, Size, 0f));
polygon1.setCoordinate(13, new Point3f(0f, Size, -Size));
polygon1.setCoordinate(14, new Point3f(0f, 0f, -Size));
shape = new Shape3D(polygon1);
return shape;
}
}
the lines it points out are:
polygon1.setCoordinate(12, new Point3f (0f, Size, 0f));
polygon1.setCoordinate(13, new Point3f(0f, Size, -Size));
polygon1.setCoordinate(14, new Point3f(0f, 0f, -Size));
and when deleted the program runs fine but I cant delete them since they are used to create a face of a cube.
Anybody got any ideas?