Search in sources :

Example 21 with ModelBatch

use of com.badlogic.gdx.graphics.g3d.ModelBatch in project libgdx by libgdx.

the class FogTest method create.

@Override
public void create() {
    modelBatch = new ModelBatch();
    environment = new Environment();
    environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
    environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 1f));
    environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(30f, 10f, 30f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 45f;
    cam.update();
    ModelBuilder modelBuilder = new ModelBuilder();
    model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
    instance = new ModelInstance(model);
    Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) CameraInputController(com.badlogic.gdx.graphics.g3d.utils.CameraInputController) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) DirectionalLight(com.badlogic.gdx.graphics.g3d.environment.DirectionalLight) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Environment(com.badlogic.gdx.graphics.g3d.Environment) Material(com.badlogic.gdx.graphics.g3d.Material) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Example 22 with ModelBatch

use of com.badlogic.gdx.graphics.g3d.ModelBatch in project libgdx by libgdx.

the class MaterialTest method create.

@Override
public void create() {
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
    // Create material attributes. Each material can contain x-number of attributes.
    textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture);
    colorAttribute = new ColorAttribute(ColorAttribute.Diffuse, Color.ORANGE);
    blendingAttribute = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    ModelBuilder builder = new ModelBuilder();
    model = builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
    model.manageDisposable(texture);
    modelInstance = new ModelInstance(model);
    modelInstance.transform.rotate(Vector3.X, 45);
    material = modelInstance.materials.get(0);
    builder.begin();
    MeshPartBuilder mpb = builder.part("back", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates, new Material(textureAttribute));
    mpb.rect(-2, -2, -2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 0, 0, 1);
    backModel = builder.end();
    background = new ModelInstance(backModel);
    modelBatch = new ModelBatch();
    camera = new PerspectiveCamera(45, 4, 4);
    camera.position.set(0, 0, 3);
    camera.direction.set(0, 0, -1);
    camera.update();
    Gdx.input.setInputProcessor(this);
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) BlendingAttribute(com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Material(com.badlogic.gdx.graphics.g3d.Material) MeshPartBuilder(com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute) Texture(com.badlogic.gdx.graphics.Texture) TextureAttribute(com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)

Example 23 with ModelBatch

use of com.badlogic.gdx.graphics.g3d.ModelBatch in project libgdx by libgdx.

the class ModelLoaderTest method create.

@Override
public void create() {
    camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(0, 0, 5);
    camera.near = 1;
    camera.far = 100;
    camera.update();
    assets = new AssetManager();
    assets.load("data/g3d/cube.g3dj", Model.class);
    spriteBatch = new SpriteBatch();
    modelBatch = new ModelBatch();
// assets.getLogger().setLevel(Logger.DEBUG);
}
Also used : AssetManager(com.badlogic.gdx.assets.AssetManager) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 24 with ModelBatch

use of com.badlogic.gdx.graphics.g3d.ModelBatch in project nhglib by VoidZombie.

the class GraphicsSystem method end.

@Override
protected void end() {
    super.end();
    for (int i = 0; i < cameras.size; i++) {
        Camera camera = cameras.get(i);
        ModelBatch modelBatch = modelBatches.get(i);
        ModelCache dynamicCache = dynamicCaches.get(i);
        ModelCache staticCache = staticCaches.get(i);
        dynamicCache.end();
        GLUtils.clearScreen(clearColor);
        modelBatch.begin(camera);
        modelBatch.render(staticCache, environment);
        modelBatch.render(dynamicCache, environment);
        modelBatch.end();
        if (Nhg.debugDrawPhysics && debugDrawer != null) {
            debugDrawer.begin(camera);
            physicsSystem.debugDraw();
            debugDrawer.end();
        }
    }
}
Also used : ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) Camera(com.badlogic.gdx.graphics.Camera) ModelCache(com.badlogic.gdx.graphics.g3d.ModelCache)

Aggregations

ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)24 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)18 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)16 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)14 Environment (com.badlogic.gdx.graphics.g3d.Environment)13 Material (com.badlogic.gdx.graphics.g3d.Material)12 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)11 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)10 CameraInputController (com.badlogic.gdx.graphics.g3d.utils.CameraInputController)8 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)7 Texture (com.badlogic.gdx.graphics.Texture)5 DefaultShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider)5 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)4 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4 ObjLoader (com.badlogic.gdx.graphics.g3d.loader.ObjLoader)4 AssetManager (com.badlogic.gdx.assets.AssetManager)3 Model (com.badlogic.gdx.graphics.g3d.Model)3 TextureAttribute (com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)3 DirectionalShadowLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalShadowLight)3 DepthShaderProvider (com.badlogic.gdx.graphics.g3d.utils.DepthShaderProvider)3