Example usage for com.badlogic.gdx.graphics.g3d.materials Material Material

List of usage examples for com.badlogic.gdx.graphics.g3d.materials Material Material

Introduction

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

Prototype

public Material(String name, MaterialAttribute... attributes) 

Source Link

Usage

From source file:com.badlogic.gdx.graphics.g3d.test.KeyframedModelViewer.java

License:Apache License

@Override
public void create() {
    model = ModelLoaderRegistry.loadKeyframedModel(Gdx.files.internal(fileName));
    if (textureFileName != null)
        texture = new Texture(Gdx.files.internal(textureFileName), Format.RGB565, true);
    model.setMaterial(new Material("default", new TextureAttribute(texture, 0, "skin")));
    hasNormals = hasNormals();//from w ww.  ja v  a2s  .  c om
    anim = (KeyframedAnimation) model.getAnimations()[0];

    model.getBoundingBox(bounds);
    float len = bounds.getDimensions().len();
    System.out.println("bounds: " + bounds);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(bounds.getCenter().cpy().add(len, len, len));
    cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z);
    cam.near = 1f;
    cam.far = 1000;

    renderer = new ImmediateModeRenderer10();
    batch = new SpriteBatch();
    font = new BitmapFont();
}

From source file:com.badlogic.gdx.graphics.g3d.test.QbobViewer.java

License:Apache License

@Override
public void create() {
    animModel = G3dtLoader.loadKeyframedModel(Gdx.files.internal("data/boy.g3dt"), true);
    anim = animModel.getAnimations()[0];
    Material material = new Material("default",
            new TextureAttribute(new Texture(Gdx.files.internal("data/boy.png")), 0, "tex0"));
    animModel.setMaterial(material);// w  w w  .  ja v  a2s. c  o m

    model[0] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_01.dae.g3d"));
    lightMaps[0] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_01.jpg"), Format.RGB565, true);
    model[1] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_02.dae.g3d"));
    lightMaps[1] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_02.jpg"), Format.RGB565, true);
    model[2] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_03.dae.g3d"));
    lightMaps[2] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_03.jpg"), Format.RGB565, true);
    model[3] = G3dLoader.loadStillModel(Gdx.files.internal("data/qbob/test_section_04.dae.g3d"));
    lightMaps[3] = new Texture(Gdx.files.internal("data/qbob/world_blobbie_lm_04.jpg"), Format.RGB565, true);

    diffuse = new Texture(Gdx.files.internal("data/qbob/world_blobbie_blocks.png"), Format.RGB565, true);

    cam = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(30, 10, 85f);
    cam.direction.set(0, 0, -1);
    cam.up.set(0, 1, 0);
    cam.near = 10f;
    cam.far = 1000;

    controller = new PerspectiveCamController(cam);
    Gdx.input.setInputProcessor(controller);

    batch = new SpriteBatch();
    font = new BitmapFont();
}

From source file:com.badlogic.gdx.graphics.g3d.test.SkeletonModelViewer.java

License:Apache License

@Override
public void create() {
    if (fileName.endsWith(".xml")) {
        model = new OgreXmlLoader().load(Gdx.files.internal(fileName),
                Gdx.files.internal(fileName.replace("mesh.xml", "skeleton.xml")));
    } else/*from w w w. j  av  a2s.c o  m*/
        throw new GdxRuntimeException("Unknown file format '" + fileName + "'");
    if (textureFileName != null)
        texture = new Texture(Gdx.files.internal(textureFileName));
    hasNormals = hasNormals();
    Material material = new Material("material", new TextureAttribute(texture, 0, "s_tex"));
    model.setMaterial(material);
    anim = (SkeletonAnimation) model.getAnimations()[0];

    model.getBoundingBox(bounds);
    float len = bounds.getDimensions().len();
    System.out.println("bounds: " + bounds);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(bounds.getCenter().cpy().add(len, len, len));
    cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z);
    cam.near = 1f;
    cam.far = 1000;

    renderer = new ImmediateModeRenderer10();
    batch = new SpriteBatch();
    font = new BitmapFont();
}