Search in sources :

Example 16 with ModelInstance

use of com.badlogic.gdx.graphics.g3d.ModelInstance in project ultimate-java by pantinor.

the class CodexScreen method fillCircle.

private ModelInstance fillCircle(float radius, Vector3 c, float cz, Color color) {
    Model model = null;
    ModelBuilder mb = new ModelBuilder();
    mb.begin();
    MeshPartBuilder part = mb.part("circle", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(color)));
    part.circle(radius, 32, c, new Vector3(0, 1, 0));
    model = mb.end();
    ModelInstance modelInstance = new ModelInstance(model);
    modelInstance.transform.setToTranslation(0, cz, 0);
    return modelInstance;
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) Model(com.badlogic.gdx.graphics.g3d.Model) Material(com.badlogic.gdx.graphics.g3d.Material) Vector3(com.badlogic.gdx.math.Vector3) MeshPartBuilder(com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)

Example 17 with ModelInstance

use of com.badlogic.gdx.graphics.g3d.ModelInstance in project ultimate-java by pantinor.

the class CodexScreen method render.

@Override
public void render(float delta) {
    camera.update();
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
    lightFactor += Gdx.graphics.getDeltaTime();
    float lightSize = 7.75f + 0.25f * (float) Math.sin(lightFactor) + .2f * MathUtils.random();
    fixedLight.set(nll2.x, nll2.y, nll2.z, 5.5f, 2, 5.5f, lightSize);
    modelBatch.begin(camera);
    for (ModelInstance i : floor) {
        modelBatch.render(i, environment);
    }
    for (ModelInstance i : modelInstances) {
        modelBatch.render(i, environment);
    }
    modelBatch.end();
    stage.act();
    stage.draw();
    // modelBatch.render(axesInstance);
    batch.begin();
    logs.render(batch);
    batch.end();
    nextPiece();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance)

Example 18 with ModelInstance

use of com.badlogic.gdx.graphics.g3d.ModelInstance in project ultimate-java by pantinor.

the class CodexScreen method dispose.

@Override
public void dispose() {
    modelBatch.dispose();
    batch.dispose();
    stage.dispose();
    for (ModelInstance mi : floor) {
        mi.model.dispose();
    }
    for (ModelInstance mi : modelInstances) {
        mi.model.dispose();
    }
    font.dispose();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance)

Example 19 with ModelInstance

use of com.badlogic.gdx.graphics.g3d.ModelInstance in project ultimate-java by pantinor.

the class CodexScreen method getFigure.

private ModelInstance getFigure(float x, float y, float z, float rotation) {
    ModelInstance instance = new ModelInstance(avatarModel, x, y, z);
    instance.nodes.get(0).scale.set(.01f, .01f, .01f);
    instance.transform.rotate(new Vector3(0, 1, 0), rotation);
    instance.calculateTransforms();
    return instance;
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) Vector3(com.badlogic.gdx.math.Vector3)

Example 20 with ModelInstance

use of com.badlogic.gdx.graphics.g3d.ModelInstance in project ultimate-java by pantinor.

the class CodexScreen method createCircle.

private ModelInstance createCircle(float radius, float thickness, Vector3 c, float cz, Color color) {
    Model model = null;
    ModelBuilder mb = new ModelBuilder();
    mb.begin();
    MeshPartBuilder part = mb.part("circle", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, new Material(ColorAttribute.createDiffuse(color)));
    part.ellipse(radius, radius, radius - thickness, radius - thickness, 32, c, new Vector3(0, 1, 0));
    model = mb.end();
    ModelInstance modelInstance = new ModelInstance(model);
    modelInstance.transform.setToTranslation(0, cz, 0);
    return modelInstance;
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) Model(com.badlogic.gdx.graphics.g3d.Model) Material(com.badlogic.gdx.graphics.g3d.Material) Vector3(com.badlogic.gdx.math.Vector3) MeshPartBuilder(com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)

Aggregations

ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)55 Material (com.badlogic.gdx.graphics.g3d.Material)29 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)26 Model (com.badlogic.gdx.graphics.g3d.Model)22 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)17 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)16 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)15 MeshPartBuilder (com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)11 Texture (com.badlogic.gdx.graphics.Texture)10 Environment (com.badlogic.gdx.graphics.g3d.Environment)10 Vector3 (com.badlogic.gdx.math.Vector3)10 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)9 AnimationController (com.badlogic.gdx.graphics.g3d.utils.AnimationController)9 DungeonTileModelInstance (util.DungeonTileModelInstance)8 BlendingAttribute (com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute)7 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)7 CameraInputController (com.badlogic.gdx.graphics.g3d.utils.CameraInputController)6 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)5 AssetManager (com.badlogic.gdx.assets.AssetManager)4 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)4