I have tried adding a quad using the IndexedQuadArray and a triangle using the IndexedTriangleArray. The quad does not display, but the triangle will. Below is my code.
The quad:
public Shape3D getGrid(){
int numIndexes = 4;
int[] indexes = new int[]{0,1,2,3};
// Vector3f[] normals = new Vector3f[]{ new Vector3f(0.0f,0.0f,1.0f),new Vector3f(0.0f,0.0f,1.0f),new Vector3f(0.0f,0.0f,1.0f),new Vector3f(0.0f,0.0f,1.0f)};
IndexedQuadArray a = new IndexedQuadArray(4,IndexedTriangleArray.COORDINATES,numIndexes);
Point3f[] coords = new Point3f[]{ new Point3f(1.0f,1.0f,0.0f), new Point3f(-1.0f,1.0f,0.0f),new Point3f(-1.0f,-1.0f,0.0f),new Point3f(1.0f,-1.0f,0.0f)};
a.setValidIndexCount(4);
a.setCoordinates(0,coords);
//a.setNormals(0,normals);
a.setIndex(indexes);
Appearance app = new Appearance();
Material material = new Material();
material.setAmbientColor(.6f,.6f,.6f);
material.setLightingEnable(true);
app.setColoringAttributes(new ColoringAttributes(new Color3f(1.0f,0.0f,0.0f),ColoringAttributes.FASTEST));
app.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE,PolygonAttributes.CULL_NONE,0f));
// app.setMaterial(material);
Shape3D s = new Shape3D(a,app);
return s;
}
The triangle:
public Shape3D getTriangle(){
int numIndexes = 3;
int[] indexes = new int[]{0,1,2};
// Vector3f[] normals = new Vector3f[]{ new Vector3f(0.0f,0.0f,1.0f),new Vector3f(0.0f,0.0f,1.0f),new Vector3f(0.0f,0.0f,1.0f),new Vector3f(0.0f,0.0f,1.0f)};
IndexedTriangleArray a = new IndexedTriangleArray(3,IndexedTriangleArray.COORDINATES,numIndexes);
Point3f[] coords = new Point3f[]{ new Point3f(1.0f,1.0f,0.0f), new Point3f(-1.0f,1.0f,0.0f),new Point3f(-1.0f,-1.0f,0.0f)};
a.setValidIndexCount(3);
a.setCoordinates(0,coords);
//a.setNormals(0,normals);
a.setIndex(indexes);
Appearance app = new Appearance();
Material material = new Material();
material.setAmbientColor(.6f,.6f,.6f);
material.setLightingEnable(true);
app.setColoringAttributes(new ColoringAttributes(new Color3f(1.0f,0.0f,0.0f),ColoringAttributes.FASTEST));
app.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_LINE,PolygonAttributes.CULL_NONE,0f));
// app.setMaterial(material);
Shape3D s = new Shape3D(a,app);
return s;
}
Any thing I am doing wrong?
Thanks
Zak