@@ -0,0 +1,2782 @@
+package ca.blarg.gdx.graphics.atlas;%0A%0Aimport com.badlogic.gdx.graphics.g2d.TextureRegion;%0Aimport com.badlogic.gdx.math.Vector2;%0Aimport com.badlogic.gdx.utils.ObjectMap;%0A%0Apublic class MaterialTileMapping %7B%0A%09public class TileTexture %7B%0A%09%09public TextureRegion region;%0A%09%09public float materialMinU = 0.0f;%0A%09%09public float materialMaxU = 1.0f;%0A%09%09public float materialMinV = 0.0f;%0A%09%09public float materialMaxV = 1.0f;%0A%09%7D%0A%0A%09final ObjectMap%3CString, TileTexture%3E mappings;%0A%09public final TextureAtlas atlas;%0A%0A%09public MaterialTileMapping(TextureAtlas atlas) %7B%0A%09%09if (atlas == null)%0A%09%09%09throw new IllegalArgumentException(%22atlas cannot be null.%22);%0A%0A%09%09this.mappings = new ObjectMap%3CString, TileTexture%3E();%0A%09%09this.atlas = atlas;%0A%09%7D%0A%0A%09public MaterialTileMapping add(String materialName, TextureRegion region) %7B%0A%09%09if (mappings.containsKey(materialName))%0A%09%09%09throw new UnsupportedOperationException(String.format(%22Material '%25s' already exists.%22, materialName));%0A%0A%09%09TileTexture tileTexture = new TileTexture();%0A%09%09tileTexture.region = region;%0A%09%09mappings.put(materialName, tileTexture);%0A%09%09return this;%0A%09%7D%0A%0A%09public MaterialTileMapping add(String materialName, TextureRegion region, float materialMinU, float materialMaxU, float materialMinV, float materialMaxV) %7B%0A%09%09if (mappings.containsKey(materialName))%0A%09%09%09throw new UnsupportedOperationException(String.format(%22Material '%25s' already exists.%22, materialName));%0A%0A%09%09TileTexture tileTexture = new TileTexture();%0A%09%09tileTexture.region = region;%0A%09%09tileTexture.materialMinU = materialMinU;%0A%09%09tileTexture.materialMaxU = materialMaxU;%0A%09%09tileTexture.materialMinV = materialMinV;%0A%09%09tileTexture.materialMaxV = materialMaxV;%0A%09%09mappings.put(materialName, tileTexture);%0A%09%09return this;%0A%09%7D%0A%0A%09public TileTexture get(String materialName) %7B%0A%09%09return mappings.get(materialName);%0A%09%7D%0A%0A%09public void scaleUV(String materialName, Vector2 srcTexCoord, Vector2 out) %7B%0A%09%09TileTexture tileTexture = mappings.get(materialName);%0A%09%09if (tileTexture == null)%0A%09%09%09throw new IllegalArgumentException(%22No matching material.%22);%0A%0A%09%09out.x = TextureAtlas.scaleTexCoordU(srcTexCoord.x, tileTexture.materialMinU, tileTexture.materialMaxU, tileTexture.region);%0A%09%09out.y = TextureAtlas.scaleTexCoordV(srcTexCoord.y, tileTexture.materialMinV, tileTexture.materialMaxV, tileTexture.region);%0A%09%7D%0A%0A%09public void scaleUV(String materialName, float srcU, float srcV, Vector2 out) %7B%0A%09%09TileTexture tileTexture = mappings.get(materialName);%0A%09%09if (tileTexture == null)%0A%09%09%09throw new IllegalArgumentException(%22No matching material.%22);%0A%0A%09%09out.x = TextureAtlas.scaleTexCoordU(srcU, tileTexture.materialMinU, tileTexture.materialMaxU, tileTexture.region);%0A%09%09out.y = TextureAtlas.scaleTexCoordV(srcV, tileTexture.materialMinV, tileTexture.materialMaxV, tileTexture.region);%0A%09%7D%0A%0A%09public void clear() %7B%0A%09%09mappings.clear();%0A%09%7D%0A%7D%0A

add MaterialTileMapping