87

Building 3D shapes
TriangleArray example code

  • Create lists of 3D coordinates and 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 TriangleArray and set the vertex coordinates and normals
    TriangleArray myTris = new TriangleArray(
        myCoords.length,
        GeometryArray.COORDINATES |
        GeometryArray.NORMALS );
    myTris.setCoordinates( 0, myCoords );
    myTris.setNormals( 0, myNormals );

  • Assemble the shape
    Shape3D myShape = new Shape3D( myTris, myAppear );