Bones - Skeletal and Pose Animations for jPCT/jPCT-AE > Bones

How to Fill SkinData

(1/11) > >>

I've exported into a JSON-serialized format of my creation all the weights of all the joints in each vertex. How, now, do I fill the 2-dimensional arrays that are weights and jointIndices? Thanks in advance.


jointIndices is a [mesh size][MAX_JOINTS_PER_VERTEX] short array, describing which joints in skeleton is affecting each vertex.

weights is a [mesh size][MAX_JOINTS_PER_VERTEX] float array, describing how much each vertex is affected by corresponding joint in skeleton. if weight is zero, no calculation is done and corresponding jointIndex is irrelevant.

I have filled arrays with the Bone and BoneReference classes below. How would you fill your arrays given this data? The following was my first, unsuccessful attempt (I don't understand how the data is arranged in your arrays, and I assumed that mesh_size is maxTriangles).

--- Code: --- float[][] weights = new float[maxTriangles][Skeleton.MAX_JOINTS_PER_VERTEX];//Skeleton.MAX_JOINTS_PER_VERTEX IS 4
short[][] jointIndices = new short[maxTriangles][Skeleton.MAX_JOINTS_PER_VERTEX];
for (int y = 0; y < weights[0].length; y++) {
     for (int x = 0; x < weights.length; x++) {
weights[x][y] = boneRefs.get(x).vertexWeight;
jointIndices[x][y] = boneRefs.get(x).vertexIndexReference;
class Bone {
     protected String name;
     protected SimpleVector position;
     protected Matrix transform;
     protected int index, parentIndex;
     public Bone(String name, SimpleVector position, Matrix transform, int index, int parentIndex) { = name;
this.position = position;
this.transform = transform;
this.index = index;
this.parentIndex = parentIndex;
class BoneReference {
     public short vertexIndexReference;
     public short boneIndexReference;
     public float vertexWeight;
     public BoneReference(short vertexIndexReference, short boneIndexReference, float vertexWeight) {
          this.vertexIndexReference = vertexIndexReference;
          this.boneIndexReference = boneIndexReference;
          this.vertexWeight = vertexWeight;

--- End code ---


--- Code: ---weights[x][y] = boneRefs.get(x).vertexWeight;
jointIndices[x][y] = boneRefs.get(x).vertexIndexReference;

--- End code ---

if I understand your stucture correct, these should be just the opposite.

--- Code: ---jointIndices[x][y]
--- End code ---
says vertex x is influenced by joint y, NOT joint x influences vertex y. similar for weights.

looks like you shoud loop over boneRefs and fill in jointIndices and weights accordingly. not the other way around

OK, but if I do

--- Code: ---for (int i = 0; i < boneRefs.size(); i++)
--- End code ---

then, what's y in

--- Code: ---jointIndices[i][y] = boneRefs.get(i).vertexIndexReference
--- End code ---
? I can't seem to visualize the 2d array as you designed it.


[0] Message Index

[#] Next page

Go to full version