/** * Computes the maximum frame and time for the animation. Different tracks * can have different lengths so here the maximum one is being found. * * @param animation * the animation * @return maximum frame and time of the animation */ private float[] computeAnimationTimeBoundaries(Animation animation) { int maxFrame = Integer.MIN_VALUE; float maxTime = -Float.MAX_VALUE; for (Track track : animation.getTracks()) { if (track instanceof BoneTrack) { maxFrame = Math.max(maxFrame, ((BoneTrack) track).getTranslations().length); maxTime = Math.max(maxTime, ((BoneTrack) track).getTimes()[((BoneTrack) track).getTimes().length - 1]); } else if (track instanceof SpatialTrack) { maxFrame = Math.max(maxFrame, ((SpatialTrack) track).getTranslations().length); maxTime = Math.max(maxTime, ((SpatialTrack) track).getTimes()[((SpatialTrack) track).getTimes().length - 1]); } else { throw new IllegalStateException("Unsupported track type for simuation: " + track); } } return new float[] { maxFrame, maxTime }; }
if (boneTrack.getTranslations() != null) { for (int i = 0; i < boneTrack.getTranslations().length; i++) { Vector3f oldTrans = boneTrack.getTranslations()[i]; Vector3f newTrans = new Vector3f(); newTrans.set(bone.getBindPosition()).addLocal(oldTrans);
/** * This method creates a clone of the current object. * @return a clone of the current object */ @Override public BoneTrack clone() { int tablesLength = times.length; float[] times = this.times.clone(); Vector3f[] sourceTranslations = this.getTranslations(); Quaternion[] sourceRotations = this.getRotations(); Vector3f[] sourceScales = this.getScales(); Vector3f[] translations = new Vector3f[tablesLength]; Quaternion[] rotations = new Quaternion[tablesLength]; Vector3f[] scales = new Vector3f[tablesLength]; for (int i = 0; i < tablesLength; ++i) { translations[i] = sourceTranslations[i].clone(); rotations[i] = sourceRotations[i].clone(); scales[i] = sourceScales != null ? sourceScales[i].clone() : new Vector3f(1.0f, 1.0f, 1.0f); } // Need to use the constructor here because of the final fields used in this class return new BoneTrack(targetBoneIndex, times, translations, rotations, scales); }