Example usage for javax.media.j3d ImageComponent2D getHeight

List of usage examples for javax.media.j3d ImageComponent2D getHeight

Introduction

In this page you can find the example usage for javax.media.j3d ImageComponent2D getHeight.

Prototype

public int getHeight() 

Source Link

Document

Retrieves the height of this image component object.

Usage

From source file:SimpleTexture.java

/**
 * This defines the appearance with a texture. The texture is loaded from an
 * external file./*from  www  . j  av a 2  s .  c  o m*/
 * 
 * @return Appearance that uses the texture.
 */
protected Appearance DefineAppearance() {
    //Load the texture from the external image file
    TextureLoader textLoad = new TextureLoader("housebrick.jpg", this);
    //Access the image from the loaded texture
    ImageComponent2D textImage = textLoad.getImage();
    //Create a two dimensional texture
    Texture2D texture = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB, textImage.getWidth(),
            textImage.getHeight());
    //Set the texture from the image loaded
    texture.setImage(0, textImage);
    //Create the appearance that will use the texture
    Appearance app = new Appearance();
    app.setTexture(texture);
    //Define how the texture will be mapped onto the surface
    //by creating the appropriate texture attributes
    TextureAttributes textAttr = new TextureAttributes();
    textAttr.setTextureMode(TextureAttributes.REPLACE);
    app.setTextureAttributes(textAttr);
    app.setMaterial(new Material());
    return app;
}

From source file:SimpleTextureGen.java

/**
 * This defines the appearance for the shape using a texture. It uses a
 * TextureLoader to load the texture image from an external file and a
 * TexCoordGeneration to define the texture coordinates.
 * /*from  ww  w. j a  v  a2s .  c om*/
 * @return Appearance that uses a texture.
 */
protected Appearance DefineAppearance() {
    //This is used to automatically define the texture coordinates.
    //The coordinates are generated in object coordinates, but by
    //commented out the line with 'OBJECT_LINEAR' and uncommenting
    //the line 'EYE_LINEAR' the program will use eye coordinates.
    TexCoordGeneration textCoorder = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR,
            //TexCoordGeneration.EYE_LINEAR,
            TexCoordGeneration.TEXTURE_COORDINATE_2);
    //Load the texture from the external image file
    TextureLoader textLoad = new TextureLoader("housebrick.jpg", this);
    //Access the image from the loaded texture
    ImageComponent2D textImage = textLoad.getImage();
    //Create a two dimensional texture
    Texture2D texture = new Texture2D(Texture2D.BASE_LEVEL, Texture.RGB, textImage.getWidth(),
            textImage.getHeight());
    //Set the texture from the image loaded
    texture.setImage(0, textImage);
    //Create the appearance that will use the texture
    Appearance app = new Appearance();
    app.setTexture(texture);
    //Pass the coordinate generator to the appearance
    app.setTexCoordGeneration(textCoorder);
    //Define how the texture will be mapped onto the surface
    //by creating the appropriate texture attributes
    TextureAttributes textAttr = new TextureAttributes();
    textAttr.setTextureMode(TextureAttributes.REPLACE);
    app.setTextureAttributes(textAttr);
    app.setMaterial(new Material());
    return app;
}

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);// ww  w .j  a v a2s .  c om
    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:AppearanceTest.java

protected NodeComponent createComponent() {
    TextureLoader texLoader = new TextureLoader("texture00.jpg", m_Component);
    ImageComponent2D image = texLoader.getImage();
    Texture2D tex2D = new Texture2D(Texture.MULTI_LEVEL_MIPMAP, Texture.RGBA, image.getWidth(),
            image.getHeight());

    for (int n = 0; n <= 6; n++) {
        texLoader = new TextureLoader("texture0" + n + ".jpg", m_Component);
        tex2D.setImage(n, texLoader.getImage());
    }/*from  w  w  w .  ja  va  2  s.  c  o  m*/

    return (NodeComponent) tex2D;
}