Example usage for javax.media.j3d Texture2D setEnable

List of usage examples for javax.media.j3d Texture2D setEnable

Introduction

In this page you can find the example usage for javax.media.j3d Texture2D setEnable.

Prototype

public void setEnable(boolean state) 

Source Link

Document

Enables or disables texture mapping for this appearance component object.

Usage

From source file:BooksDemo.java

private Appearance createTexture(String fileName) {
    Image sourceImage = UIHelper.readImage(fileName);
    if (sourceImage == null)
        System.out.println("Image could not be loaded from " + fileName);

    TextureLoader loader = new TextureLoader(sourceImage, this);
    ImageComponent2D image = loader.getImage();

    if (image == null)
        System.out.println("Texture could not be loaded from " + fileName);

    Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image.getWidth(), image.getHeight());
    texture.setImage(0, image);//w w w .  j av  a2 s  .c o  m
    texture.setEnable(true);
    texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
    texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);

    Appearance appearance = new Appearance();
    PolygonAttributes polyAttributes = new PolygonAttributes(PolygonAttributes.POLYGON_FILL,
            PolygonAttributes.CULL_NONE, 0f);
    appearance.setPolygonAttributes(polyAttributes);
    appearance.setTexture(texture);

    TextureAttributes textureAttributes = new TextureAttributes();
    appearance.setTextureAttributes(textureAttributes);

    return appearance;
}

From source file:ExTexture.java

private Texture2D loadTexture(String filename) {
    // Load the texture image file
    if (debug)/*from w w w.  ja v  a  2s  .c  om*/
        System.err.println("Loading texture '" + filename + "'");
    TextureLoader texLoader = new TextureLoader(filename, this);

    // If the image is NULL, something went wrong
    ImageComponent2D ic = texLoader.getImage();
    if (ic == null) {
        System.err.println("Cannot load texture '" + filename + "'");
        return null;
    }

    // Configure a Texture2D with the image
    Texture2D t = (Texture2D) texLoader.getTexture();

    int mode = ((Integer) boundaries[currentBoundary].value).intValue();
    t.setBoundaryModeS(mode);
    t.setBoundaryModeT(mode);

    Color3f color = (Color3f) colors[currentColor].value;
    t.setBoundaryColor(color.x, color.y, color.z, 0.0f);

    int filter = ((Integer) filters[currentFilter].value).intValue();
    t.setMagFilter(filter);
    t.setMinFilter(filter);

    t.setMipMapMode(Texture.BASE_LEVEL);

    // Turn it on and allow future changes
    t.setEnable(true);
    t.setCapability(Texture.ALLOW_ENABLE_WRITE);

    return t;
}