meshes[i] = new Mesh(frames[i].name);
mData = meshes[i].getMeshData();
mData.setIndexLengths(counts);
mData.setIndexModes(modes);
final FloatBufferData verts = new FloatBufferData(vertexCount * 3, 3);
final FloatBufferData norms = new FloatBufferData(vertexCount * 3, 3);
final FloatBufferData texs = new FloatBufferData(vertexCount * 3, 2);
mData.setVertexCoords(verts);
mData.setNormalCoords(norms);
mData.setTextureCoords(texs, 0);
// go through the triangle strips/fans and add them in
// first the strips
if (stripIndices.size() != 0) {
for (int maxJ = stripIndices.size(), j = 0; j < maxJ; j++) {
cmd = commands[stripIndices.get(j)];
if (cmd.vertIndices.length < 3) {
continue;
}
addVert(cmd, frame, 0, verts);
norms.getBuffer().put(0).put(0).put(0);
texs.getBuffer().put(0).put(0);
// add strip verts / normals
for (int k = 0; k < cmd.vertIndices.length; k++) {
addVert(cmd, frame, k, verts);
addNormal(cmd, frame, k, norms);
}
// add strip tex coords
texs.getBuffer().put(cmd.texCoords);
// if we're not the last strip, add a vert or two for degenerate triangle connector
if (j != maxJ - 1) {
addVert(cmd, frame, cmd.vertIndices.length - 1, verts);
norms.getBuffer().put(0).put(0).put(0);
texs.getBuffer().put(0).put(0);
if (cmd.vertIndices.length % 2 == 1) {
// extra vert to maintain wind order
addVert(cmd, frame, cmd.vertIndices.length - 1, verts);
norms.getBuffer().put(0).put(0).put(0);
texs.getBuffer().put(0).put(0);
}
}
}
}
// Now the fans
// XXX: could add these to the strip instead
for (final int j : fanIndices) {
cmd = commands[j];
texs.getBuffer().put(cmd.texCoords[0]).put(cmd.texCoords[1]);
addNormal(cmd, frame, 0, norms);
addVert(cmd, frame, 0, verts);
for (int k = cmd.vertIndices.length; --k >= 1;) {
texs.getBuffer().put(cmd.texCoords[k * 2]).put(cmd.texCoords[k * 2 + 1]);
addNormal(cmd, frame, k, norms);
addVert(cmd, frame, k, verts);
}
}
}