package ca.blarg.gdx.tilemap3d.tilemesh;

import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.utils.ObjectMap;

public class CollisionShapes {
	static final ModelBuilder modelBuilder = new ModelBuilder();
	static final ObjectMap<String, Model> shapes = new ObjectMap<String, Model>();

	static {
		shapes.put("cube-1x1x1", buildCube1x1x1());
	}

	private static Model buildCube1x1x1() {
		return modelBuilder.createBox(1.0f, 1.0f, 1.0f, null, VertexAttributes.Usage.Position);
	}

	public static Model get(String shapeName) {
		return shapes.get(shapeName);
	}
}

@@ -35,16 +35,55 @@
 emesh;%0A%0A
+import com.badlogic.gdx.graphics.GL10;%0A
 import c
@@ -169,16 +169,76 @@
 .Model;%0A
+import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder;%0A
 import c
@@ -568,215 +568,1723 @@
 %0A%0A%09p
-rivate static Model buildCube1x1x1() %7B%0A%09%09return modelBuilder.createBox(1.0f, 1.0f, 1.0f, null, VertexAttributes.Usage.Position);%0A%09%7D%0A%0A%09public static Model get(String shapeName) %7B%0A%09%09return shapes.get(shapeName
+ublic static Model get(String shapeName) %7B%0A%09%09return shapes.get(shapeName);%0A%09%7D%0A%0A%09private static Model buildCube1x1x1() %7B%0A%09%09modelBuilder.begin();%0A%09%09MeshPartBuilder partBuilder = modelBuilder.part(%22collisionShape%22, GL10.GL_TRIANGLES, VertexAttributes.Usage.Position, null);%0A%09%09addBoxShape(partBuilder, -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);%0A%09%09return modelBuilder.end();%0A%09%7D%0A%0A%09private static void addBoxShape(MeshPartBuilder partBuilder, float ax, float ay, float az, float bx, float by, float bz) %7B%0A%09%09// TODO: for some reason, ModelBuilder's createBox() creates a box model in a way that BaseModelTileMesh%0A%09%09// collects the vertices from it incorrectly. for now, we just manually create a box's vertices/indices ourself%0A%0A%09%09partBuilder.vertex(ax, by, bz);  // 0%0A%09%09partBuilder.vertex(bx, by, bz);  // 1%0A%09%09partBuilder.vertex(ax, by, az);  // 2%0A%09%09partBuilder.vertex(bx, by, az);  // 3%0A%09%09partBuilder.vertex(bx, ay, bz);  // 4%0A%09%09partBuilder.vertex(ax, ay, bz);  // 5%0A%09%09partBuilder.vertex(bx, ay, az);  // 6%0A%09%09partBuilder.vertex(ax, ay, az);  // 7%0A%0A%09%09// top%0A%09%09partBuilder.index((short)0, (short)1, (short)2);%0A%09%09partBuilder.index((short)1, (short)3, (short)2);%0A%0A%09%09// bottom%0A%09%09partBuilder.index((short)4, (short)5, (short)6);%0A%09%09partBuilder.index((short)5, (short)7, (short)6);%0A%0A%09%09// front%0A%09%09partBuilder.index((short)6, (short)7, (short)3);%0A%09%09partBuilder.index((short)7, (short)2, (short)3);%0A%0A%09%09// back%0A%09%09partBuilder.index((short)5, (short)4, (short)0);%0A%09%09partBuilder.index((short)4, (short)1, (short)0);%0A%0A%09%09// left%0A%09%09partBuilder.index((short)7, (short)5, (short)2);%0A%09%09partBuilder.index((short)5, (short)0, (short)2);%0A%0A%09%09// right%0A%09%09partBuilder.index((short)4, (short)6, (short)1);%0A%09%09partBuilder.index((short)6, (short)3, (short)1
 );%0A%09

fix creating box shape vertices