Search in sources :

Example 1 with AssetJson

use of io.github.voidzombie.nhglib.data.models.serialization.AssetJson in project nhglib by VoidZombie.

the class ModelComponentJson method parse.

@Override
public void parse(JsonValue jsonValue) {
    ModelComponent modelComponent = entities.createComponent(entity, ModelComponent.class);
    String type = jsonValue.getString("graphicsType");
    JsonValue asset = jsonValue.get("asset");
    boolean enabled = jsonValue.getBoolean("enabled", true);
    AssetJson assetJson = new AssetJson();
    assetJson.parse(asset);
    JsonValue materialsJson = jsonValue.get("materials");
    if (materialsJson != null) {
        for (JsonValue mat : materialsJson) {
            PbrMaterialJson pbrMaterialJson = new PbrMaterialJson();
            pbrMaterialJson.parse(mat);
            modelComponent.pbrMaterials.add(pbrMaterialJson.get());
        }
    }
    modelComponent.type = ModelComponent.Type.fromString(type);
    modelComponent.asset = assetJson.get();
    modelComponent.enabled = enabled;
    output = modelComponent;
}
Also used : PbrMaterialJson(io.github.voidzombie.nhglib.data.models.serialization.PbrMaterialJson) ModelComponent(io.github.voidzombie.nhglib.runtime.ecs.components.graphics.ModelComponent) JsonValue(com.badlogic.gdx.utils.JsonValue) AssetJson(io.github.voidzombie.nhglib.data.models.serialization.AssetJson)

Aggregations

JsonValue (com.badlogic.gdx.utils.JsonValue)1 AssetJson (io.github.voidzombie.nhglib.data.models.serialization.AssetJson)1 PbrMaterialJson (io.github.voidzombie.nhglib.data.models.serialization.PbrMaterialJson)1 ModelComponent (io.github.voidzombie.nhglib.runtime.ecs.components.graphics.ModelComponent)1