203

Introducing texture mapping
Texture2D example code

  • Load a texture image (discussed later)
    TextureLoader myLoader = new TextureLoader( "brick.jpg", this );
    ImageComponent2D myImage = myLoader.getImage( );

  • Create a Texture2D using the image, and turn it on
    Texture2D myTex = new Texture2D( );
    myTex.setImage( 0, myImage );
    myTex.setEnable( true );

  • Create an Appearance and set the texture in it
    Appearance myAppear = new Appearance( );
    myAppear.setTexture( myTex );

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