Example usage for javax.media.j3d Texture getImage

List of usage examples for javax.media.j3d Texture getImage

Introduction

In this page you can find the example usage for javax.media.j3d Texture getImage.

Prototype

public ImageComponent getImage(int level) 

Source Link

Document

Retrieves the image for a specified mipmap level.

Usage

From source file:KeyNavigateTest.java

public Group createMap(Group g) {
    System.out.println("Creating map items");

    Group mapGroup = new Group();
    g.addChild(mapGroup);/*  w w w.jav  a  2 s  .  c om*/

    Texture tex = new TextureLoader(m_szMapName, this).getTexture();
    m_MapImage = ((ImageComponent2D) tex.getImage(0)).getImage();

    float imageWidth = m_MapImage.getWidth();
    float imageHeight = m_MapImage.getHeight();

    FLOOR_WIDTH = imageWidth * 8;
    FLOOR_LENGTH = imageHeight * 8;

    for (int nPixelX = 1; nPixelX < imageWidth - 1; nPixelX++) {
        for (int nPixelY = 1; nPixelY < imageWidth - 1; nPixelY++)
            createMapItem(mapGroup, nPixelX, nPixelY);

        float percentDone = 100 * (float) nPixelX / (float) (imageWidth - 2);
        System.out.println("   " + (int) (percentDone) + "%");
    }

    createExternalWall(mapGroup);

    return mapGroup;
}

From source file:SplineInterpolatorTest.java

public Group createBuildings(Group g) {
    m_BuildingAppearance = new Appearance();
    BranchGroup bg = new BranchGroup();

    Texture tex = new TextureLoader("boston.gif", this).getTexture();
    BufferedImage image = ((ImageComponent2D) tex.getImage(0)).getImage();

    final int nMaxBuildings = 120;

    for (int n = 0; n < nMaxBuildings; n++) {
        Cuboid building = new Cuboid(this, bg, ComplexObject.GEOMETRY | ComplexObject.TEXTURE);

        float posX = (int) Utils.getRandomNumber(0, LAND_WIDTH);
        float posZ = (int) Utils.getRandomNumber(0, LAND_LENGTH);

        if (isLocationWater(image, posX, posZ) == false) {
            building.createObject(m_BuildingAppearance, new Vector3d(posX, 0, posZ),
                    new Vector3d(Utils.getRandomNumber(3, 2), Utils.getRandomNumber(8, 7),
                            Utils.getRandomNumber(3, 2)),
                    "house.gif", null, null);
        }//from w  w w .  j a va 2 s.c o m
    }

    g.addChild(bg);
    return bg;
}