public void dumbAnimation(String str) { System.out.println(str + "Animation : " + id); int i = 0, j; for (BoneTransform[] bones : frames) { j = 0; for (BoneTransform frame : bones) { System.out.println(str + " " + i + "/" + j + " : " + frame.toString()); j++; } i++; } }
/** * optimize will attempt to condense the BoneAnimation into as few children as possible. This * allows the proper sharing of keyframe times and calculation of current time and current frame. * If a child animation has no children of its own, and its keyframes are equal to this animation, * the BoneTransforms are assimilated into this animation and the child is deleted. */ public void optimize(boolean removeChildren) { if (children == null) { return; } for (int i = 0; i < children.size(); i++) { // check if the child has children, if so, optimize this child if (children.get(i).hasChildren()) { children.get(i).optimize(removeChildren); } else { // make sure the keyframes are equal, if we don't have keyframes // set it to the first one. if (this.keyframeTime == null) { if (boneTransforms == null) { boneTransforms = new ArrayList<BoneTransform>(); } this.keyframeTime = children.get(i).getKeyFrameTimes(); this.interpolationType = children.get(i).getInterpolationType(); this.startFrame = children.get(i).getStartFrame(); this.endFrame = children.get(i).getEndFrame(); if (children.get(i).getBoneTransforms() != null) { for (int j = 0; j < children.get(i).getBoneTransforms().size(); j++) { BoneTransform bt = children.get(i).getBoneTransforms().get(j); if (bt != null && bt.getRotations() != null && bt.getRotations().length > 0) { boneTransforms.add(children.get(i).getBoneTransforms().get(j)); } } } // we've copied this child's data, get rid of it, and adjust // the count // accordingly. children.remove(i); i--; } else { boolean same = true; if (this.keyframeTime.length == children.get(i).getKeyFrameTimes().length) { for (int j = 0; j < keyframeTime.length; j++) { if (keyframeTime[j] != children.get(i).getKeyFrameTimes()[j]) { same = false; break; } } if (same) { if (children.get(i).getBoneTransforms() != null) { for (int j = 0; j < children.get(i).getBoneTransforms().size(); j++) { BoneTransform bt = children.get(i).getBoneTransforms().get(j); if (bt.getRotations() != null && bt.getRotations().length > 0) { boneTransforms.add(children.get(i).getBoneTransforms().get(j)); } } } // we've copied this child's data, get rid of it, // and adjust the count // accordingly. children.remove(i); i--; } } } } } if (removeChildren) { children.clear(); children = null; } }