Skip to main content

setCoordinates for QuadArray throwing NullPointer

No replies
okelly4408
Offline
Joined: 2012-08-12
Points: 0

When I attempt to set coordinates with my quadarray with a point3f[] array with the following: quad.setCoordinates(0,array); a nullpointerexception is returned. When I add the following arguments quad.setCoordinates(0,array,0,array.length); a nullpointer is still returned and when I change that to array.length-1 it works. Here is the code for the class where .setCoordinates is used, if any more code is required please ask. Thanks for any help!

import javax.media.j3d.Appearance;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.PolygonAttributes;
import javax.media.j3d.QuadArray;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;
import com.sun.j3d.utils.geometry.GeometryInfo;
import com.sun.j3d.utils.geometry.Stripifier;


public class Landscape extends Shape3D {

private  QuadArray plane;
public Landscape( Point3f[] pointarray, Color3f cols){

  
int vert = pointarray.length;
System.out.println(vert+"+");
    plane = new QuadArray(vert, GeometryArray.COORDINATES| GeometryArray.COLOR_3);
    plane.setCoordinates(0,pointarray,0,pointarray.length-1);
//plane.setColors(0,cols);
GeometryInfo geo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
geo.setCoordinates(pointarray);
    Stripifier triangler = new Stripifier();
    triangler.stripify(geo);
    setGeometry(plane);
    appearance();
}
private  void appearance(){
PolygonAttributes pa = new PolygonAttributes();
Appearance app = new Appearance();
pa.setCullFace(PolygonAttributes.CULL_NONE);
pa.setPolygonMode(PolygonAttributes.POLYGON_LINE);
app.setPolygonAttributes(pa);

}

}