Example usage for com.badlogic.gdx.graphics.g3d.attributes TextureAttribute TextureAttribute

List of usage examples for com.badlogic.gdx.graphics.g3d.attributes TextureAttribute TextureAttribute

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.attributes TextureAttribute TextureAttribute.

Prototype

public TextureAttribute(final long type, final TextureRegion region) 

Source Link

Usage

From source file:com.github.fauu.helix.core.MapRegion.java

License:Open Source License

public void create(Vector2 size, Tile[] tiles, Array<Object> objects, TextureAtlas textureAtlas,
        GeometrySet geometrySet) {/* ww w  .  j a  v a  2  s . c om*/
    this.size = size;
    this.textureAtlas = textureAtlas;
    this.geometrySet = geometrySet;
    this.objects = objects;

    if (tiles != null) {
        this.tiles = tiles;
    } else {
        final int tilesLength = (int) (size.x * size.y);

        tiles = new Tile[tilesLength];
        for (int i = 0; i < tilesLength; i++) {
            final Tile.Builder tileBuilder = new Tile.Builder();
            final int tileX = i % (int) size.x;
            final int tileY = (int) Math.floor(i / (tilesLength / size.y));

            tiles[i] = tileBuilder.setNo(i).setPosition(new Vector2(tileX, tileY)).setElevation(0)
                    .setTextureId(0).setGeometryId(0).setFacing(Direction.SOUTH).build();
        }
    }

    this.tiles = tiles;

    mesh = new MapRegionMesh(tiles, geometrySet, textureAtlas);

    renderable = new Renderable();
    renderable.mesh = mesh;
    renderable.material = new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE),
            new TextureAttribute(TextureAttribute.Diffuse, textureAtlas.getTextures().first()));
    renderable.meshPartOffset = 0;
    renderable.meshPartSize = mesh.getNumVertices();
    renderable.primitiveType = GL20.GL_TRIANGLES;
    renderable.worldTransform.idt();
}

From source file:com.mbrlabs.mundus.commons.assets.MaterialAsset.java

License:Apache License

/**
 * Applies this material asset to the libGDX material.
 *
 * @param material//from w ww. ja va  2 s . com
 * @return
 */
public Material applyToMaterial(Material material) {
    if (diffuseColor != null) {
        material.set(new ColorAttribute(ColorAttribute.Diffuse, diffuseColor));
    }
    if (diffuseTexture != null) {
        material.set(new TextureAttribute(TextureAttribute.Diffuse, diffuseTexture.getTexture()));
    } else {
        material.remove(TextureAttribute.Diffuse);
    }
    material.set(new FloatAttribute(FloatAttribute.Shininess, shininess));

    return material;
}

From source file:com.mygdx.game.utilities.ModelFactory.java

License:Apache License

public static Model buildBillboardModel(Texture texture, float width, float height) {
    TextureRegion textureRegion = new TextureRegion(texture, texture.getWidth(), texture.getHeight());
    Material material = new Material();
    material.set(new TextureAttribute(TextureAttribute.Diffuse, textureRegion));
    material.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));
    material.set(new BlendingAttribute());
    return ModelFactory.buildPlaneModel(width, height, material, 0, 0, 1, 1);
}