@@ -0,0 +1,1847 @@
+package ca.blarg.gdx.tilemap3d.json.tilemesh;%0A%0Aimport ca.blarg.gdx.graphics.atlas.TextureAtlas;%0Aimport ca.blarg.gdx.loaders.textureatlas.TextureAtlasJsonLoader;%0Aimport ca.blarg.gdx.tilemap3d.tilemesh.MaterialTileMapping;%0Aimport com.badlogic.gdx.Gdx;%0Aimport com.badlogic.gdx.assets.AssetManager;%0Aimport com.badlogic.gdx.files.FileHandle;%0Aimport com.badlogic.gdx.utils.Json;%0A%0Apublic class MaterialTileMappingJsonLoader %7B%0A%09public static JsonMaterialMapping load(FileHandle file) %7B%0A%09%09Json json = new Json();%0A%09%09return json.fromJson(JsonMaterialMapping.class, file);%0A%09%7D%0A%0A%09public static MaterialTileMapping create(JsonMaterialMapping definition) %7B%0A%09%09return create(definition, null);%0A%09%7D%0A%0A%09public static MaterialTileMapping create(JsonMaterialMapping definition, AssetManager assetManager) %7B%0A%09%09if (definition.materials == null %7C%7C definition.materials.size() == 0)%0A%09%09%09throw new RuntimeException(%22No material mappings defined.%22);%0A%0A%09%09TextureAtlas atlas;%0A%09%09if (assetManager != null)%0A%09%09%09atlas = assetManager.get(definition.textureAtlas, TextureAtlas.class);%0A%09%09else%0A%09%09%09atlas = TextureAtlasJsonLoader.loadAndCreate(Gdx.files.internal(definition.textureAtlas));%0A%0A%09%09MaterialTileMapping materialMapping = new MaterialTileMapping();%0A%09%09for (int i = 0; i %3C definition.materials.size(); ++i) %7B%0A%09%09%09JsonMaterialMapping.Material mapping = definition.materials.get(i);%0A%09%09%09materialMapping.add(%0A%09%09%09%09mapping.name, atlas.get(mapping.tile),%0A%09%09%09%09mapping.minU, mapping.maxU, mapping.minV, mapping.maxV%0A%09%09%09);%0A%09%09%7D%0A%0A%09%09return materialMapping;%0A%09%7D%0A%0A%09public static MaterialTileMapping loadAndCreate(FileHandle file) %7B%0A%09%09JsonMaterialMapping definition = load(file);%0A%09%09return create(definition);%0A%09%7D%0A%0A%09public static MaterialTileMapping loadAndCreate(FileHandle file, AssetManager assetManager) %7B%0A%09%09JsonMaterialMapping definition = load(file);%0A%09%09return create(definition, assetManager);%0A%09%7D%0A%7D%0A

add MaterialTileMappingJsonLoader