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

How to Fill SkinData

<< < (2/11) > >>

raft:
you cant do that in a single iteration IMHO.*

first iterate over boneRefs to collect vertex-bone relations


--- Code: ---map = Map<Integer, List<Integer>>();
for (b: boneRefs) {
  map.get(b.vertexIndexReference).add(b.boneIndexReference);
}

--- End code ---

then loop over your map to place into jointIndices array. sth like this


--- Code: ---for (e : map.entrySet) {
  count = 0;
  for (index : e.value) {
    jointIndices[e.key][count++] = index;
  }
}

--- End code ---

hope this helps
r a f t

(*) actually you can but will be ugly

AGP:
Same confusion: between


--- Code: --- HashMap<Integer, java.util.List<Integer>> map = new HashMap<Integer, java.util.List<Integer>>();
for (BoneReference b: boneRefs)

--- End code ---
and

--- Code: ---      map.get(b.vertexIndexReference).add((int)b.boneIndexReference);
//then loop over your map to place into jointIndices array. sth like this
for (Map.Entry<Integer, java.util.List<Integer>> e : map.entrySet()) {
     int count = 0;
     for (Integer index : e.getValue())//index : e.value
jointIndices[e.getKey()][count++] = index.shortValue();
}

--- End code ---
how do I fill the HashMap?

raft:
it's written above AGP, in the first iteration


--- Code: ---map = Map<Integer, List<Integer>>();
for (b: boneRefs) {
  map.get(b.vertexIndexReference).add(b.boneIndexReference);
}
--- End code ---

but of course you should first create the list if it's null

AGP:
boneRefs is neither null nor size 0. But map.get(b.vertexIndexReference).add((int)b.boneIndexReference) produces a NullPointerExecption (because get(...) returns a null value).

raft:

--- Quote from: raft on June 17, 2016, 01:50:28 pm ---but of course you should first create the list if it's null

--- End quote ---


--- Code: ---map = Map<Integer, List<Integer>>();
for (b: boneRefs) {
  list = map.get(b.vertexIndexReference);
  if (list == null) {
    list = new ArrayList<Integer>();
    map.put(b.vertexIndexReference, list);
  }
  list.add(b.boneIndexReference);
}
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version