add json config support for tile definitions using submodels
This commit is contained in:
parent
0482491c2a
commit
d3bacd32a9
|
@ -11,6 +11,7 @@ public class JsonTileDefinition {
|
||||||
public int texture;
|
public int texture;
|
||||||
public ArrayList<String> faces;
|
public ArrayList<String> faces;
|
||||||
public String model;
|
public String model;
|
||||||
|
public ArrayList<JsonTileSubModels> models;
|
||||||
public String collisionModel;
|
public String collisionModel;
|
||||||
public String collisionShape;
|
public String collisionShape;
|
||||||
public ArrayList<String> opaqueSides;
|
public ArrayList<String> opaqueSides;
|
||||||
|
|
12
src/com/blarg/gdx/tilemap3d/tilemesh/JsonTileSubModels.java
Normal file
12
src/com/blarg/gdx/tilemap3d/tilemesh/JsonTileSubModels.java
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package com.blarg.gdx.tilemap3d.tilemesh;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
|
||||||
|
public class JsonTileSubModels {
|
||||||
|
public String submodel;
|
||||||
|
public Color color;
|
||||||
|
public Vector3 scaleToSize;
|
||||||
|
public Vector3 positionOffset;
|
||||||
|
public Vector3 collisionPositionOffset;
|
||||||
|
}
|
|
@ -48,8 +48,8 @@ public final class TileMeshCollectionLoader {
|
||||||
for (int i = 0; i < config.tiles.size(); ++i) {
|
for (int i = 0; i < config.tiles.size(); ++i) {
|
||||||
JsonTileDefinition tileDef = config.tiles.get(i);
|
JsonTileDefinition tileDef = config.tiles.get(i);
|
||||||
|
|
||||||
if (tileDef.cube && tileDef.model != null)
|
if (!tileDef.cube && tileDef.model == null && tileDef.models == null)
|
||||||
throw new RuntimeException("cube and model cannot both be set.");
|
throw new RuntimeException("One of cube, model, or models must be specified for each tile.");
|
||||||
if (tileDef.model != null && materialMapping == null)
|
if (tileDef.model != null && materialMapping == null)
|
||||||
throw new RuntimeException("Missing materials section but using models to define tiles.");
|
throw new RuntimeException("Missing materials section but using models to define tiles.");
|
||||||
if (tileDef.collisionModel != null && tileDef.collisionShape != null)
|
if (tileDef.collisionModel != null && tileDef.collisionShape != null)
|
||||||
|
@ -64,7 +64,7 @@ public final class TileMeshCollectionLoader {
|
||||||
TextureRegion leftTexture = null;
|
TextureRegion leftTexture = null;
|
||||||
TextureRegion rightTexture = null;
|
TextureRegion rightTexture = null;
|
||||||
byte faces = 0;
|
byte faces = 0;
|
||||||
Model model;
|
Model model = null;
|
||||||
Model collisionModel;
|
Model collisionModel;
|
||||||
byte opaqueSides = 0;
|
byte opaqueSides = 0;
|
||||||
byte lightValue;
|
byte lightValue;
|
||||||
|
@ -148,7 +148,7 @@ public final class TileMeshCollectionLoader {
|
||||||
else
|
else
|
||||||
collection.addCube(topTexture, bottomTexture, frontTexture, backTexture, leftTexture, rightTexture, opaqueSides, lightValue, alpha, translucency, color);
|
collection.addCube(topTexture, bottomTexture, frontTexture, backTexture, leftTexture, rightTexture, opaqueSides, lightValue, alpha, translucency, color);
|
||||||
|
|
||||||
} else {
|
} else if (tileDef.model != null) {
|
||||||
model = models.get(tileDef.model);
|
model = models.get(tileDef.model);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
model = loader.loadModel(Gdx.files.internal(tileDef.model));
|
model = loader.loadModel(Gdx.files.internal(tileDef.model));
|
||||||
|
|
Loading…
Reference in a new issue