94

Building 3D shapes
Building a TriangleStripArray

  • Create lists of 3D coordinates and lighting normals for the vertices
    Point3f[] myCoords = {
        new Point3f(  0.0f, 0.0f, 0.0f ),
        . . .
    }
    Vector3f[] myNormals = {
        new Vector3f(  0.0f, 1.0f, 0.0f ),
        . . .
    }
  • Create a list of vertex strip lengths
    int[] stripLengths = { 6, 5 };
  • Create a TriangleStripArray and set vertex coordinates and lighting normals
    TriangleStripArray myTris = new TriangleStripArray(
        myCoords.length,
        GeometryArray.COORDINATES |
        GeometryArray.NORMALS,
        stripLengths );
    myTris.setCoordinates( 0, myCoords );
    myTris.setNormals( 0, myNormals );
  • Assemble the shape
    Shape3D myShape = new Shape3D( myTris, myAppear );