if (pairsMap == null) {
throw new ColladaException("Unable to locate pair map for geometry.", geometry);
}
// Check for a remapping, if we optimized geometry
final VertMap vertMap = _dataCache.getMeshVertMap().get(sourceMesh);
// Use pairs map and vertWeightMap to build our weights and joint indices.
{
// count number of weights used
int maxWeightsPerVert = 0;
int weightCount;
for (final int originalIndex : pairsMap.getIndices()) {
weightCount = 0;
// get weights and joints at original index and add weights up to get divisor sum
// we'll assume 0's for vertices with no matching weight.
if (vertWeightMap.length > originalIndex) {
final int[] data = vertWeightMap[originalIndex];
for (int i = 0; i < data.length; i += maxOffset + 1) {
final float weight = jointWeights.get(data[i + weightOff]);
if (weight != 0) {
weightCount++;
}
}
if (weightCount > maxWeightsPerVert) {
maxWeightsPerVert = weightCount;
}
}
}
final int verts = skMesh.getMeshData().getVertexCount();
final FloatBuffer weightBuffer = BufferUtils.createFloatBuffer(verts * maxWeightsPerVert);
final ShortBuffer jointIndexBuffer = BufferUtils.createShortBuffer(verts * maxWeightsPerVert);
int j;
float sum = 0;
final float[] weights = new float[maxWeightsPerVert];
final short[] indices = new short[maxWeightsPerVert];
int originalIndex;
for (int x = 0; x < verts; x++) {
if (vertMap != null) {
originalIndex = pairsMap.getIndices()[vertMap.getFirstOldIndex(x)];
} else {
originalIndex = pairsMap.getIndices()[x];
}
j = 0;