Search in sources :

Example 41 with Material

use of com.badlogic.gdx.graphics.g3d.Material in project bladecoder-adventure-engine by bladecoder.

the class Utils3D method createAxes.

private static void createAxes() {
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    MeshPartBuilder builder = modelBuilder.part("grid", GL20.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);
    }
    builder = modelBuilder.part("axes", GL20.GL_LINES, Usage.Position | Usage.ColorUnpacked, new Material());
    builder.setColor(Color.RED);
    builder.line(0, 0, 0, 10, 0, 0);
    builder.setColor(Color.GREEN);
    builder.line(0, 0, 0, 0, 10, 0);
    builder.setColor(Color.BLUE);
    builder.line(0, 0, 0, 0, 0, 10);
    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 42 with Material

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

the class DungeonScreen method addBlock.

public void addBlock(int level, DungeonTile tile, float tx, float ty, float tz) {
    ModelBuilder builder = new ModelBuilder();
    if (tile == DungeonTile.WALL) {
        Model model = builder.createBox(1, 1, 1, new Material(TextureAttribute.createDiffuse(assets.get("assets/graphics/mortar.png", Texture.class))), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
        ModelInstance instance = new ModelInstance(model, tx, ty, tz);
        // rotate so the texture is aligned right
        instance.transform.setFromEulerAngles(0, 0, 90).trn(tx, ty, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    } else if (tile.getValue() >= 144 && tile.getValue() <= 148) {
        ModelInstance instance = new ModelInstance(fountainModel, tx - .15f, 0, tz + .2f);
        instance.nodes.get(0).scale.set(.010f, .010f, .010f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    } else if (tile.getValue() >= 10 && tile.getValue() <= 48) {
        ModelInstance instance = new ModelInstance(ladderModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.060f, .060f, .060f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        Model manhole = builder.createCylinder(.75f, .02f, .75f, 32, new Material(ColorAttribute.createDiffuse(Color.DARK_GRAY)), Usage.Position | Usage.Normal);
        if (tile == DungeonTile.LADDER_DOWN) {
            instance = new ModelInstance(manhole, tx, 0, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
        } else if (tile == DungeonTile.LADDER_UP) {
            instance = new ModelInstance(manhole, tx, 1, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
        } else if (tile == DungeonTile.LADDER_UP_DOWN) {
            instance = new ModelInstance(manhole, tx, 0, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
            instance = new ModelInstance(manhole, tx, 1, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
        }
    } else if (tile == DungeonTile.CHEST) {
        ModelInstance instance = new ModelInstance(chestModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.010f, .010f, .010f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        in.x = (int) tx;
        in.y = (int) tz;
    } else if (tile == DungeonTile.ORB) {
        ModelInstance instance = new ModelInstance(orbModel, tx, .5f, tz);
        instance.nodes.get(0).scale.set(.0025f, .0025f, .0025f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        in.x = (int) tx;
        in.y = (int) tz;
        modelInstances.add(in);
    } else if (tile == DungeonTile.ALTAR) {
        ModelInstance instance = new ModelInstance(altarModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.0040f, .0040f, .0040f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        in.x = (int) tx;
        in.y = (int) tz;
        modelInstances.add(in);
    } else if (tile.getValue() >= 160 && tile.getValue() <= 163) {
        Color c = Color.GREEN;
        if (tile == DungeonTile.FIELD_ENERGY) {
            c = Color.BLUE;
        }
        if (tile == DungeonTile.FIELD_FIRE) {
            c = Color.RED;
        }
        if (tile == DungeonTile.FIELD_SLEEP) {
            c = Color.PURPLE;
        }
        Model model = builder.createBox(1, 1, 1, new Material(ColorAttribute.createDiffuse(c), ColorAttribute.createSpecular(c), new BlendingAttribute(0.7f)), Usage.Position | Usage.Normal);
        ModelInstance instance = new ModelInstance(model, tx, .5f, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        in.x = (int) tx;
        in.y = (int) tz;
    } else if (tile.getValue() >= 208 && tile.getValue() <= 223) {
        // room indicator
        Model model = builder.createBox(1, 1, 1, new Material(ColorAttribute.createDiffuse(Color.DARK_GRAY), ColorAttribute.createSpecular(Color.DARK_GRAY), new BlendingAttribute(0.6f)), Usage.Position | Usage.Normal);
        ModelInstance instance = new ModelInstance(model, tx, .5f, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    } else if (tile == DungeonTile.DOOR || tile == DungeonTile.SECRET_DOOR) {
        Model model = builder.createBox(1, 1, 1, new Material(TextureAttribute.createDiffuse(assets.get("assets/graphics/mortar.png", Texture.class))), Usage.Position | Usage.TextureCoordinates | Usage.Normal);
        ModelInstance instance = new ModelInstance(model, tx, ty, tz);
        instance.transform.setFromEulerAngles(0, 0, 90).trn(tx, ty, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        Material matDoor = null;
        if (tile == DungeonTile.DOOR) {
            matDoor = new Material(TextureAttribute.createDiffuse(assets.get("assets/graphics/door.png", Texture.class)));
        } else {
            matDoor = new Material(new Material(ColorAttribute.createDiffuse(Color.DARK_GRAY), ColorAttribute.createSpecular(Color.DARK_GRAY), new BlendingAttribute(0.3f)));
        }
        model = builder.createBox(1.04f, .85f, .6f, matDoor, Usage.Position | Usage.TextureCoordinates | Usage.Normal);
        instance = new ModelInstance(model, tx, .4f, tz);
        in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        model = builder.createBox(.6f, .85f, 1.04f, matDoor, Usage.Position | Usage.TextureCoordinates | Usage.Normal);
        instance = new ModelInstance(model, tx, .4f, tz);
        in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    }
}
Also used : DungeonTileModelInstance(util.DungeonTileModelInstance) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) BlendingAttribute(com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute) DungeonTileModelInstance(util.DungeonTileModelInstance) Color(com.badlogic.gdx.graphics.Color) Model(com.badlogic.gdx.graphics.g3d.Model) Material(com.badlogic.gdx.graphics.g3d.Material) Texture(com.badlogic.gdx.graphics.Texture)

Example 43 with Material

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

the class StaticGeneratedDungeonScreen method addBlock.

public void addBlock(int level, DungeonTile tile, float tx, float ty, float tz) {
    ModelBuilder builder = new ModelBuilder();
    if (tile == DungeonTile.WALL) {
        Model model = builder.createBox(1, 1, 1, getMaterial(assets.get("assets/graphics/mortar.png", Texture.class)), Usage.Position | Usage.Normal | Usage.TextureCoordinates);
        ModelInstance instance = new ModelInstance(model, tx, ty, tz);
        // rotate so the texture is aligned right
        instance.transform.setFromEulerAngles(0, 0, 90).trn(tx, ty, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    } else if (tile.getValue() >= 144 && tile.getValue() <= 148) {
        ModelInstance instance = new ModelInstance(fountainModel, tx - .15f, 0, tz + .2f);
        instance.nodes.get(0).scale.set(.010f, .010f, .010f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    } else if (tile == DungeonTile.ROCKS) {
        ModelInstance instance = new ModelInstance(rocksModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.010f, .010f, .010f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    } else if (tile == DungeonTile.MOONGATE) {
        Color c = Color.CYAN;
        Model model = builder.createBox(1, 1, 1, getMaterial(c, .7f), Usage.Position | Usage.Normal);
        ModelInstance instance = new ModelInstance(model, tx, .5f, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        in.x = (int) tx;
        in.y = (int) tz;
    } else if (tile.getValue() >= 10 && tile.getValue() <= 48) {
        ModelInstance instance = new ModelInstance(ladderModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.060f, .060f, .060f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        Model manhole = builder.createCylinder(.75f, .02f, .75f, 32, getMaterial(Color.DARK_GRAY, 1), Usage.Position | Usage.Normal);
        if (tile == DungeonTile.LADDER_DOWN) {
            instance = new ModelInstance(manhole, tx, 0, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
        } else if (tile == DungeonTile.LADDER_UP) {
            instance = new ModelInstance(manhole, tx, 1, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
        } else if (tile == DungeonTile.LADDER_UP_DOWN) {
            instance = new ModelInstance(manhole, tx, 0, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
            instance = new ModelInstance(manhole, tx, 1, tz);
            modelInstances.add(new DungeonTileModelInstance(instance, tile, level));
        }
    } else if (tile == DungeonTile.CHEST) {
        ModelInstance instance = new ModelInstance(chestModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.010f, .010f, .010f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        in.x = (int) tx;
        in.y = (int) tz;
    } else if (tile == DungeonTile.COLUMN) {
        Model sf = builder.createCylinder(.35f, 2.5f, .35f, 32, getMaterial(assets.get("assets/graphics/Stone_Masonry.jpg", Texture.class)), Usage.Position | Usage.TextureCoordinates | Usage.Normal);
        ModelInstance instance = new ModelInstance(sf);
        instance.transform.setToTranslation(tx, 0, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        in.x = (int) tx;
        in.y = (int) tz;
        modelInstances.add(in);
    } else if (tile == DungeonTile.ORB) {
        ModelInstance instance = new ModelInstance(orbModel, tx, .5f, tz);
        instance.nodes.get(0).scale.set(.0025f, .0025f, .0025f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        in.x = (int) tx;
        in.y = (int) tz;
        modelInstances.add(in);
    } else if (tile == DungeonTile.ALTAR) {
        ModelInstance instance = new ModelInstance(altarModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.0040f, .0040f, .0040f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        in.x = (int) tx;
        in.y = (int) tz;
        modelInstances.add(in);
    } else if (tile == DungeonTile.LIGHT) {
    // PointLight pl = new PointLight().set(nll2.x, nll2.y,  nll2.z, tx, .8f, tz, 2f);
    // DirectionalLight pl = new DirectionalLight().set(nll2.x, nll2.y,  nll2.z, tx, .8f, tz);
    // environment[level].add(pl);
    // Model lm = builder.createSphere(.02f, .02f, .02f, 10, 10, getMaterial(new Color(nll2.x, nll2.y,  nll2.z, 1), .7f), Usage.Position);
    // ModelInstance instance = new ModelInstance(lm);
    // instance.transform.setToTranslation(tx, .8f, tz);
    // DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
    // in.x=(int)tx; in.y=(int)tz;
    // modelInstances.add(in);
    } else if (tile == DungeonTile.FIRE) {
        ModelInstance instance = new ModelInstance(campfireModel, tx, 0, tz);
        instance.nodes.get(0).scale.set(.510f, .510f, .510f);
        instance.calculateTransforms();
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    } else if (tile.getValue() >= 160 && tile.getValue() <= 163) {
        Color c = Color.GREEN;
        if (tile == DungeonTile.FIELD_ENERGY) {
            c = Color.BLUE;
        }
        if (tile == DungeonTile.FIELD_FIRE) {
            c = Color.RED;
        }
        if (tile == DungeonTile.FIELD_SLEEP) {
            c = Color.PURPLE;
        }
        Model model = builder.createBox(1, 1, 1, getMaterial(c, .7f), Usage.Position | Usage.Normal);
        ModelInstance instance = new ModelInstance(model, tx, .5f, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        in.x = (int) tx;
        in.y = (int) tz;
    } else if (tile == DungeonTile.DOOR || tile == DungeonTile.SECRET_DOOR || tile == DungeonTile.LOCKED_DOOR) {
        Model model = builder.createBox(1, 1, 1, getMaterial(assets.get("assets/graphics/mortar.png", Texture.class)), Usage.Position | Usage.TextureCoordinates | Usage.Normal);
        ModelInstance instance = new ModelInstance(model, tx, ty, tz);
        instance.transform.setFromEulerAngles(0, 0, 90).trn(tx, ty, tz);
        DungeonTileModelInstance in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        Material matDoor = null;
        if (tile == DungeonTile.DOOR || tile == DungeonTile.LOCKED_DOOR) {
            matDoor = getMaterial(assets.get("assets/graphics/door.png", Texture.class));
        } else {
            matDoor = getMaterial(Color.DARK_GRAY, .3f);
        }
        model = builder.createBox(1.04f, .85f, .6f, matDoor, Usage.Position | Usage.TextureCoordinates | Usage.Normal);
        instance = new ModelInstance(model, tx, .4f, tz);
        in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
        model = builder.createBox(.6f, .85f, 1.04f, matDoor, Usage.Position | Usage.TextureCoordinates | Usage.Normal);
        instance = new ModelInstance(model, tx, .4f, tz);
        in = new DungeonTileModelInstance(instance, tile, level);
        modelInstances.add(in);
    }
}
Also used : DungeonTileModelInstance(util.DungeonTileModelInstance) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) DungeonTileModelInstance(util.DungeonTileModelInstance) Color(com.badlogic.gdx.graphics.Color) Model(com.badlogic.gdx.graphics.g3d.Model) Material(com.badlogic.gdx.graphics.g3d.Material)

Example 44 with Material

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

the class StaticGeneratedDungeonScreen method init.

public void init() {
    assets = new AssetManager();
    assets.load("assets/graphics/dirt.png", Texture.class);
    assets.load("assets/graphics/map.png", Texture.class);
    assets.load("assets/graphics/Stone_Masonry.jpg", Texture.class);
    assets.load("assets/graphics/door.png", Texture.class);
    assets.load("assets/graphics/mortar.png", Texture.class);
    assets.load("assets/graphics/rock.png", Texture.class);
    assets.update(2000);
    assets.get("assets/graphics/rock.png", Texture.class).setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    assets.get("assets/graphics/door.png", Texture.class).setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    assets.get("assets/graphics/mortar.png", Texture.class).setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    assets.get("assets/graphics/dirt.png", Texture.class).setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
    ModelLoader<?> gloader = new G3dModelLoader(new UBJsonReader());
    fountainModel = gloader.loadModel(Gdx.files.internal("assets/graphics/fountain2.g3db"));
    ladderModel = gloader.loadModel(Gdx.files.internal("assets/graphics/ladder.g3db"));
    chestModel = gloader.loadModel(Gdx.files.internal("assets/graphics/chest.g3db"));
    orbModel = gloader.loadModel(Gdx.files.internal("assets/graphics/orb.g3db"));
    altarModel = gloader.loadModel(Gdx.files.internal("assets/graphics/altar.g3db"));
    rocksModel = gloader.loadModel(Gdx.files.internal("assets/graphics/rocks.g3db"));
    campfireModel = gloader.loadModel(Gdx.files.internal("assets/graphics/campfire.g3db"));
    font = new BitmapFont();
    font.setColor(Color.WHITE);
    fixedLight = new PointLight().set(1f, 0.8f, 0.6f, 4f, 4f, 4f, 5f);
    modelBatch = new ModelBatch();
    batch = new SpriteBatch();
    camera = new PerspectiveCamera(67, Ultima4.MAP_WIDTH, Ultima4.MAP_HEIGHT);
    camera.near = 0.1f;
    camera.far = 1000f;
    decalBatch = new DecalBatch(new CameraGroupStrategy(camera));
    // inputController = new CameraInputController(camera);
    // inputController.rotateLeftKey = inputController.rotateRightKey = inputController.forwardKey = inputController.backwardKey = 0;
    // inputController.translateUnits = 30f;
    ModelBuilder builder = new ModelBuilder();
    Model fm = builder.createBox(1, 1, 1, new Material(TextureAttribute.createDiffuse(assets.get("assets/graphics/rock.png", Texture.class))), Usage.Position | Usage.TextureCoordinates | Usage.Normal);
    Model cm = builder.createBox(1, 1, 1, new Material(TextureAttribute.createDiffuse(assets.get("assets/graphics/dirt.png", Texture.class))), Usage.Position | Usage.TextureCoordinates | Usage.Normal);
    try {
        int TILE_SIZE = 16;
        FileHandle f = new FileHandle("assets/tilemaps/tiles-vga-atlas.txt");
        TextureAtlasData a = new TextureAtlasData(f, f.parent(), false);
        mapTileIds = new String[a.getRegions().size + 1];
        for (Region r : a.getRegions()) {
            int x = r.left / r.width;
            int y = r.top / r.height;
            int i = y * TILE_SIZE + x + 1;
            mapTileIds[i] = r.name;
        }
        TiledMap map = new TmxMapLoader().load("assets/tilemaps/delveOfSorrows.tmx");
        Iterator<MapLayer> iter = map.getLayers().iterator();
        int level = 0;
        while (iter.hasNext()) {
            environment[level] = new Environment();
            environment[level].set(new ColorAttribute(ColorAttribute.Ambient, 0.5f, 0.5f, 0.5f, 1f));
            environment[level].add(fixedLight);
            layers[level] = (TiledMapTileLayer) iter.next();
            for (int y = 0; y < DUNGEON_MAP; y++) {
                for (int x = 0; x < DUNGEON_MAP; x++) {
                    String val = mapTileIds[layers[level].getCell(x, DUNGEON_MAP - y - 1).getTile().getId()];
                    DungeonTile tile = DungeonTile.getTileByName(val);
                    if (tile == null) {
                        CreatureType ct = CreatureType.get(val);
                        if (ct != null) {
                            Creature creature = Ultima4.creatures.getInstance(ct, Ultima4.standardAtlas);
                            creature.currentX = x;
                            creature.currentY = y;
                            creature.currentLevel = level;
                            creature.getDecal().setPosition(creature.currentX + .5f, .3f, creature.currentY + .5f);
                            dngMap.getMap().addCreature(creature);
                        } else {
                            System.err.println(val);
                        }
                        dungeonTiles[level][x][y] = DungeonTile.NOTHING;
                    } else if (tile == DungeonTile.WATER) {
                        Model w = builder.createBox(1, 1, 1, getMaterial(Color.BLUE, .9f), Usage.Position | Usage.Normal);
                        ModelInstance wi = new ModelInstance(w, x + .5f, -.5f, y + .5f);
                        DungeonTileModelInstance fin = new DungeonTileModelInstance(wi, DungeonTile.WATER, level);
                        modelInstances.add(fin);
                        dungeonTiles[level][x][y] = DungeonTile.NOTHING;
                    } else {
                        dungeonTiles[level][x][y] = tile;
                        addBlock(level, tile, x + .5f, .5f, y + .5f);
                    }
                    if (tile == null || tile != DungeonTile.WATER) {
                        DungeonTileModelInstance fin = new DungeonTileModelInstance(new ModelInstance(fm, new Vector3(x + .5f, -.5f, y + .5f)), DungeonTile.FLOOR, level);
                        modelInstances.add(fin);
                    }
                    DungeonTileModelInstance cin = new DungeonTileModelInstance(new ModelInstance(cm, new Vector3(x + .5f, 1.5f, y + .5f)), DungeonTile.FLOOR, level);
                    modelInstances.add(cin);
                }
            }
            level++;
        }
        setStartPosition();
        camera.position.set(currentPos);
        camera.lookAt(currentPos.x + 1, currentPos.y, currentPos.z);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DecalBatch(com.badlogic.gdx.graphics.g3d.decals.DecalBatch) Creature(objects.Creature) FileHandle(com.badlogic.gdx.files.FileHandle) MapLayer(com.badlogic.gdx.maps.MapLayer) CameraGroupStrategy(com.badlogic.gdx.graphics.g3d.decals.CameraGroupStrategy) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) ModelBuilder(com.badlogic.gdx.graphics.g3d.utils.ModelBuilder) TextureAtlasData(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) UBJsonReader(com.badlogic.gdx.utils.UBJsonReader) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) TmxMapLoader(com.badlogic.gdx.maps.tiled.TmxMapLoader) AssetManager(com.badlogic.gdx.assets.AssetManager) DungeonTileModelInstance(util.DungeonTileModelInstance) Material(com.badlogic.gdx.graphics.g3d.Material) Vector3(com.badlogic.gdx.math.Vector3) PartyDeathException(util.PartyDeathException) DungeonTileModelInstance(util.DungeonTileModelInstance) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) G3dModelLoader(com.badlogic.gdx.graphics.g3d.loader.G3dModelLoader) Model(com.badlogic.gdx.graphics.g3d.Model) Region(com.badlogic.gdx.graphics.g2d.TextureAtlas.TextureAtlasData.Region) Environment(com.badlogic.gdx.graphics.g3d.Environment) PointLight(com.badlogic.gdx.graphics.g3d.environment.PointLight) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) ColorAttribute(com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)

Example 45 with Material

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

the class CodexScreen method nextPiece.

private void nextPiece() {
    switch(codexQuestionCount) {
        case 1:
            // modelInstances.add(createLine(3.75f, 6.5f, 5.5f, 3.5f, 0.204f, Color.WHITE));
            modelInstances.add(createPolygonBox(Virtue.HONESTY.getColor(), .02f, .02f, 3.5f, -30f, 4.65f, 0.204f, 5.0f));
            break;
        case 2:
            // modelInstances.add(createLine(5.5f, 3.5f, 7.25f, 6.5f, 0.204f, Color.WHITE));
            modelInstances.add(createPolygonBox(Virtue.COMPASSION.getColor(), .02f, .02f, 3.5f, 30f, 6.35f, 0.204f, 5.0f));
            break;
        case 3:
            // modelInstances.add(createLine(7.25f, 6.5f, 3.75f, 6.5f, 0.204f, Color.WHITE));
            modelInstances.add(createPolygonBox(Virtue.VALOR.getColor(), .02f, .02f, 3.5f, 90f, 5.5f, 0.204f, 6.5f));
            break;
        case 4:
            // modelInstances.add(createLine(3.5f, 4.75f, 7.5f, 4.75f, 0.204f, Color.WHITE));
            modelInstances.add(createPolygonBox(Virtue.JUSTICE.getColor(), .02f, .02f, 3.7f, 90f, 5.5f, 0.204f, 4.75f));
            break;
        case 5:
            // modelInstances.add(createLine(7.25f, 4.25f, 5.25f, 7.5f, 0.204f, Color.WHITE));
            modelInstances.add(createPolygonBox(Virtue.SACRIFICE.getColor(), .02f, .02f, 3.7f, -30f, 6.2f, 0.204f, 5.9f));
            break;
        case 6:
            // modelInstances.add(createLine(5.75f, 7.5f, 3.75f, 4.25f, 0.204f, Color.WHITE));
            modelInstances.add(createPolygonBox(Virtue.HONOR.getColor(), .02f, .02f, 3.7f, 30f, 4.8f, 0.204f, 5.9f));
            break;
        case 7:
            ModelBuilder builder = new ModelBuilder();
            Model sp = builder.createSphere(.08f, .08f, .08f, 32, 32, new Material(ColorAttribute.createDiffuse(Virtue.SPIRITUALITY.getColor())), Usage.Position | Usage.Normal);
            ModelInstance modelInstance = new ModelInstance(sp);
            modelInstance.transform.setTranslation(5.5f, 0.204f, 5.5f);
            modelInstances.add(modelInstance);
            // modelInstances.add(fillCircle(.05f, center, 0.204f, Virtue.SPIRITUALITY.getColor()));
            break;
        case 8:
            // modelInstances.add(fillCircle(2.5f,center, 0.202f, Virtue.HUMILITY.getColor()));
            modelInstances.add(createCylinder(4.0f, .1f, 5.5f, 0.1f, 5.5f, Virtue.HUMILITY.getColor()));
            break;
        case 9:
            // modelInstances.add(createCircle(.9f, .03f, new Vector3(5.05f, 0, 5.25f), 0.204f, Color.BLUE));
            modelInstances.add(createCylinder(.9f, .1f, 5.05f, 0.204f, 5.25f, Color.BLUE));
            break;
        case 10:
            // modelInstances.add(createCircle(.9f, .03f,new Vector3(5.95f, 0, 5.25f), 0.204f, Color.YELLOW));
            modelInstances.add(createCylinder(.9f, .1f, 5.95f, 0.204f, 5.25f, Color.YELLOW));
            break;
        case 11:
            // modelInstances.add(createCircle(.9f, .03f,new Vector3(5.5f, 0, 6.025f), 0.204f, Color.RED));
            modelInstances.add(createCylinder(.9f, .1f, 5.5f, 0.204f, 6.025f, Color.RED));
            break;
        default:
            break;
    }
}
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)

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