private void generateArmatureSegments() { childSegments.clear(); // pinnedDescendants.clear(); if (segmentRoot.parent != null && segmentRoot.parent.isPinned()) this.basePinned = true; else this.basePinned = false; AbstractBone tempSegmentTip = this.segmentRoot; this.chainLength = -1; while (true) { this.chainLength++; ArrayList<AbstractBone> childrenWithPinnedDescendants = tempSegmentTip.returnChildrenWithPinnedDescendants(); if (childrenWithPinnedDescendants.size() > 1 || (tempSegmentTip.isPinned())) { if (tempSegmentTip.isPinned()) tipPinned = true; else tipPinned = false; this.segmentTip = tempSegmentTip; for (AbstractBone childBone : childrenWithPinnedDescendants) { this.childSegments.add(new SegmentedArmature(this, childBone)); } break; } else if (childrenWithPinnedDescendants.size() == 1) { tempSegmentTip = childrenWithPinnedDescendants.get(0); } else { this.segmentTip = tempSegmentTip; break; } } updatePinnedDescendants(); generateStrandMaps(); }
public void generateStrandMaps() { originalOrientations.clear(); boneRotationMap.clear(); strandMap.clear(); strandsBoneList.clear(); for (SegmentedArmature sa : pinnedDescendants) { ArrayList<AbstractBone> strandBoneList = getStrandFromTip(sa.segmentTip); strandMap.put(sa, strandBoneList); for (AbstractBone ab : strandBoneList) { AbstractAxes ax = originalOrientations.get(ab); if (ax == null) { originalOrientations.put(ab, ab.localAxes().attachedCopy(false)); boneRotationMap.put(ab, new ArrayList<Rot>()); } } } strandsBoneList.addAll(boneRotationMap.keySet()); }
public ArrayList<AbstractBone> getStrandFromTip(AbstractBone pinnedBone) { ArrayList<AbstractBone> result = new ArrayList<AbstractBone>(); if (pinnedBone.isPinned()) { result.add(pinnedBone); AbstractBone currBone = pinnedBone.parent; while (currBone != null && currBone.parent != null) { result.add(currBone); if (currBone.parent.isPinned()) { break; } currBone = currBone.parent; } } return result; }