}
box.setVertices(vertices);
return box;
}
case mesh: {
MeshAttachment mesh = attachmentLoader.newMeshAttachment(skin, name, path);
if (mesh == null) return null;
mesh.setPath(path);
float[] vertices = map.require("vertices").asFloatArray();
if (scale != 1) {
for (int i = 0, n = vertices.length; i < n; i++)
vertices[i] *= scale;
}
mesh.setVertices(vertices);
mesh.setTriangles(map.require("triangles").asShortArray());
mesh.setRegionUVs(map.require("uvs").asFloatArray());
mesh.updateUVs();
String color = map.getString("color", null);
if (color != null) mesh.getColor().set(Color.valueOf(color));
if (map.has("hull")) mesh.setHullLength(map.require("hull").asInt() * 2);
if (map.has("edges")) mesh.setEdges(map.require("edges").asIntArray());
mesh.setWidth(map.getFloat("width", 0) * scale);
mesh.setHeight(map.getFloat("height", 0) * scale);
return mesh;
}
case skinnedmesh: {
SkinnedMeshAttachment mesh = attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
if (mesh == null) return null;
mesh.setPath(path);
float[] uvs = map.require("uvs").asFloatArray();
float[] vertices = map.require("vertices").asFloatArray();
FloatArray weights = new FloatArray(uvs.length * 3 * 3);
IntArray bones = new IntArray(uvs.length * 3);
for (int i = 0, n = vertices.length; i < n;) {
int boneCount = (int)vertices[i++];
bones.add(boneCount);
for (int nn = i + boneCount * 4; i < nn;) {
bones.add((int)vertices[i]);
weights.add(vertices[i + 1] * scale);
weights.add(vertices[i + 2] * scale);
weights.add(vertices[i + 3]);
i += 4;
}
}
mesh.setBones(bones.toArray());
mesh.setWeights(weights.toArray());
mesh.setTriangles(map.require("triangles").asShortArray());
mesh.setRegionUVs(uvs);
mesh.updateUVs();
String color = map.getString("color", null);
if (color != null) mesh.getColor().set(Color.valueOf(color));
if (map.has("hull")) mesh.setHullLength(map.require("hull").asInt() * 2);
if (map.has("edges")) mesh.setEdges(map.require("edges").asIntArray());
mesh.setWidth(map.getFloat("width", 0) * scale);
mesh.setHeight(map.getFloat("height", 0) * scale);
return mesh;
}
}
// RegionSequenceAttachment regionSequenceAttachment = (RegionSequenceAttachment)attachment;