	private AnimData blend(AnimData a, AnimData b) {
		int overlap = 50;
		float[] blendWeights = new float[overlap];
		for (int i=overlap; i>0; i--) {
			blendWeights[overlap - i] = ((float)i) / overlap; 
		}
		int numBones = a.getNumBones();
		AnimData blendedData = new AnimData(numBones);
		Vector3f[] boneTrans1 = a.getBoneTransData();
		Vector3f[] boneTrans2 = b.getBoneTransData();
		int numFrames = boneTrans1.length + boneTrans2.length - overlap;
		blendedData.setNumFrames(numFrames);
		Vector3f[] blendedTrans = new Vector3f[numFrames];
		Vector3f end = new Vector3f(boneTrans1[boneTrans1.length-1]);
		Vector3f start = boneTrans2[0];
		end.sub(start);
		Vector3f shift = new Vector3f(end);
		for (int i=0; i<boneTrans1.length; i++) {
			blendedTrans[i] = boneTrans1[i];
		}
		int k = 0;
		for (int i=boneTrans1.length-overlap; i<boneTrans1.length; i++) {
			Vector3f vec1 = boneTrans1[i];
			Vector3f vec2 = new Vector3f(boneTrans2[k]);
			vec2.add(shift);
			Vector3f blend = new Vector3f();
			blend.x = vec1.x * blendWeights[k] + vec2.x * 
				blendWeights[overlap - k - 1];
			blend.y = vec1.y * blendWeights[k] + vec2.y * 
				blendWeights[overlap - k - 1];
			blend.z = vec1.z * blendWeights[k] + vec2.z * 
				blendWeights[overlap - k - 1];
			blendedTrans[i] = blend;
			k++;
		}
		for (int i=k; i<boneTrans2.length; i++) {
			Vector3f curr = new Vector3f(boneTrans2[i]);
			curr.add(shift);
			blendedTrans[i + boneTrans1.length - overlap] = curr;
		}
		blendedData.putBoneTransData(blendedTrans);
		for (int i=0; i<numBones; i++) {
			Quat4f[] boneRot1 = a.getBoneRotData(i);
			Quat4f[] boneRot2 = b.getBoneRotData(i);
			Quat4f[] boneBlend = new Quat4f[numFrames];
			for (int j=0; j<boneRot1.length-overlap; j++) {
				boneBlend[j] = boneRot1[j];
			}
			k=0;
			for (int j=boneRot1.length-overlap; j<boneRot1.length; j++) {
				Quat4f q1 = new Quat4f(boneRot1[j]);
				Quat4f q2 = new Quat4f(boneRot2[k]);
				q1.interpolate(q2, 1-blendWeights[k]);
				boneBlend[j] = q1;
				k++;
			}
			for (int j=k; j<boneRot2.length; j++) {
				Quat4f q = new Quat4f(boneRot2[j]);
				boneBlend[boneRot1.length-overlap + j] = q;
			}
			blendedData.putBoneRotData(i, boneBlend);
		}
		return blendedData;
	}

	private AnimData blend(AnimData a, AnimData b) {
		int overlap = 50;
		float[] blendWeights = new float[overlap];
		for (int i=overlap; i>0; i--) {
			blendWeights[overlap - i] = ((float)i) / overlap; 
		}
		int numBones = a.getNumBones();
		AnimData blendedData = new AnimData(numBones);
		Vector3f[] boneTrans1 = a.getBoneTransData();
		Vector3f[] boneTrans2 = b.getBoneTransData();
		int numFrames = boneTrans1.length + boneTrans2.length - overlap;
		blendedData.setNumFrames(numFrames);
		Vector3f[] blendedTrans = new Vector3f[numFrames];
		Vector3f end = new Vector3f(boneTrans1[boneTrans1.length-overlap-1]);
		Vector3f start = boneTrans2[0];
		end.sub(start);
		Vector3f shift = new Vector3f(end);
		for (int i=0; i<boneTrans1.length; i++) {
			blendedTrans[i] = boneTrans1[i];
		}
		int k = 0;
		for (int i=boneTrans1.length-overlap; i<boneTrans1.length; i++) {
			Vector3f vec1 = boneTrans1[i];
			Vector3f vec2 = new Vector3f(boneTrans2[k]);
			vec2.add(shift);
			Vector3f blend = new Vector3f();
			blend.x = vec1.x * blendWeights[k] + vec2.x * 
				blendWeights[overlap - k - 1];
			blend.y = vec1.y * blendWeights[k] + vec2.y * 
				blendWeights[overlap - k - 1];
			blend.z = vec1.z * blendWeights[k] + vec2.z * 
				blendWeights[overlap - k - 1];
			blendedTrans[i] = blend;
			k++;
		}
		for (int i=k; i<boneTrans2.length; i++) {
			Vector3f curr = new Vector3f(boneTrans2[i]);
			curr.add(shift);
			blendedTrans[i + boneTrans1.length - overlap] = curr;
		}
		blendedData.putBoneTransData(blendedTrans);
		Quat4f qShift = null;
		Quat4f first = new Quat4f(a.getBoneRotData(0)[a.getNumFrames()-overlap-1]);
		Quat4f sec = new Quat4f(b.getBoneRotData(0)[0]);
		qShift = new Quat4f(sec);
		qShift.inverse();
		qShift.mul(first);
		for (int i=0; i<numBones; i++) {
			Quat4f[] boneRot1 = a.getBoneRotData(i);
			Quat4f[] boneRot2 = b.getBoneRotData(i);
			Quat4f[] boneBlend = new Quat4f[numFrames];
			for (int j=0; j<boneRot1.length-overlap; j++) {
				boneBlend[j] = boneRot1[j];
			}
			k=0;
			for (int j=boneRot1.length-overlap; j<boneRot1.length; j++) {
				Quat4f q1 = new Quat4f(boneRot1[j]);
				Quat4f q2 = new Quat4f(boneRot2[k]);
				if (i==0) q2.mul(qShift);
				q1.interpolate(q2, 1-blendWeights[k]);
				boneBlend[j] = q1;
				k++;
			}
			for (int j=k; j<boneRot2.length; j++) {
				Quat4f q = new Quat4f(boneRot2[j]);
				if (i==0) q.mul(qShift);
				boneBlend[boneRot1.length-overlap + j] = q;
			}
			blendedData.putBoneRotData(i, boneBlend);
		}
		return blendedData;
	}
