Search in sources :

Example 46 with Material

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

the class CodexScreen method createAxes.

private void createAxes() {
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    // grid
    MeshPartBuilder builder = modelBuilder.part("grid", GL30.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material());
    builder.setColor(Color.LIGHT_GRAY);
    for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
        builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
        builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
    }
    // axes
    builder = modelBuilder.part("axes", GL30.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material());
    builder.setColor(Color.RED);
    builder.line(0, 0, 0, 500, 0, 0);
    builder.setColor(Color.GREEN);
    builder.line(0, 0, 0, 0, 500, 0);
    builder.setColor(Color.BLUE);
    builder.line(0, 0, 0, 0, 0, 500);
    axesModel = modelBuilder.end();
    axesInstance = new ModelInstance(axesModel);
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) Material(com.badlogic.gdx.graphics.g3d.Material) MeshPartBuilder(com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)

Example 47 with Material

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

the class CodexScreen method createLine.

private ModelInstance createLine(float sx, float sy, float ex, float ey, float z, Color color) {
    Model model = null;
    ModelBuilder mb = new ModelBuilder();
    mb.begin();
    MeshPartBuilder builder = mb.part("line", GL30.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material());
    builder.setColor(color);
    builder.line(sx, 0, sy, ex, 0, ey);
    model = mb.end();
    ModelInstance modelInstance = new ModelInstance(model);
    modelInstance.transform.setToTranslation(0, z, 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) MeshPartBuilder(com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)

Example 48 with Material

use of com.badlogic.gdx.graphics.g3d.Material in project ProjektGG by eskalon.

the class GameLoadingScreen method onFinishedLoading.

@Override
protected void onFinishedLoading() {
    GameSession session = ((ProjektGGApplication) application).getClient().getSession();
    World world = session.getWorld();
    // Create the ModelInstances
    for (BuildingSlot s : world.getBuildingSlots()) {
        if (s.isBuiltOn()) {
            s.getBuilding().setRenderData(new SelectableRenderData(application.getAssetManager().get(s.getBuilding().getType().getModelPath(), Model.class)));
            // FIXME siehe AuthoritativeSession#init(...)
            s.getBuilding().getRenderData().transform.translate(s.getPosX(), 0, s.getPosZ());
            s.getBuilding().getRenderData().transform.rotate(Y_AXIS, s.getRotationToStreet());
        // TODO Use _one_ scene for all models?
        // new SelectableRenderData(scene,
        // building1.getType().getNodeName(), true);
        }
    }
    Model skyboxModel = application.getAssetManager().get(session.getSessionSetup().getMap().getSkyboxPath(), Model.class);
    for (Material m : skyboxModel.materials) {
        // fixes a bug related to changes in gdx 1.9.9, see
        // https://github.com/libgdx/libgdx/issues/5529
        m.remove(ColorAttribute.Emissive);
    }
    world.setSkybox(new ModelInstance(skyboxModel));
    Log.info("Client", "Game assets loaded");
    if (((ProjektGGApplication) application).isHost()) {
        ((ProjektGGApplication) application).getServer().startMatch();
        Log.info("Server", "Game started!");
    }
    application.getScreenManager().pushScreen("round_end", "simple_zoom", 1);
}
Also used : GameSession(de.gg.game.session.GameSession) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) Model(com.badlogic.gdx.graphics.g3d.Model) Material(com.badlogic.gdx.graphics.g3d.Material) ProjektGGApplication(de.gg.game.core.ProjektGGApplication) World(de.gg.game.model.World) SelectableRenderData(de.gg.game.ui.rendering.SelectableRenderData) BuildingSlot(de.gg.game.model.entities.BuildingSlot)

Aggregations

Material (com.badlogic.gdx.graphics.g3d.Material)48 ModelBuilder (com.badlogic.gdx.graphics.g3d.utils.ModelBuilder)32 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)30 Model (com.badlogic.gdx.graphics.g3d.Model)28 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)19 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)14 Environment (com.badlogic.gdx.graphics.g3d.Environment)14 ModelBatch (com.badlogic.gdx.graphics.g3d.ModelBatch)14 Texture (com.badlogic.gdx.graphics.Texture)13 MeshPartBuilder (com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder)13 DirectionalLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalLight)10 Vector3 (com.badlogic.gdx.math.Vector3)9 Renderable (com.badlogic.gdx.graphics.g3d.Renderable)8 CameraInputController (com.badlogic.gdx.graphics.g3d.utils.CameraInputController)7 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)6 BlendingAttribute (com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute)6 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)5 AssetManager (com.badlogic.gdx.assets.AssetManager)4 TextureAttribute (com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute)4 DirectionalShadowLight (com.badlogic.gdx.graphics.g3d.environment.DirectionalShadowLight)4