219

Using texture coordinates
Texture coordinates example code

  • Create lists of 3D coordinates, lighting normals, and texture coordinates for the vertices
    Point3f[] myCoords = {
        new Point3f( 0.0f, 0.0f, 0.0f ),
        . . .
    }
    Vector3f[] myNormals = {
        new Vector3f( 0.0f, 1.0f, 0.0f ),
        . . .
    }
    Point2f[] myTexCoords = {
        new Point2f( 0.0f, 0.0f ),
        . . .
    }
  • Create a QuadArray and set the vertex coordinates, lighting normals, and texture coordinates
    QuadArray myQuads = new QuadArray(
        myCoords.length,
        GeometryArray.COORDINATES |
        GeometryArray.NORMALS |
        GeometryArray.TEXTURE_COORDINATE_2 );
    myQuads.setCoordinates( 0, myCoords );
    myQuads.setNormals( 0, myNormals );
    myQuads.setTextureCoordinates( 0, myTexCoords );

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