Ejemplo n.º 1
0
		public static Transform BlendMany(Transform reference, IEnumerable<Influence> t)
		{
			Transform result = reference;
			float w = 0;

			foreach (var i in t)
			{
				if (w == 0)
				{
					result = Transform.Blend(i.First, reference, i.Second);
					w = i.First;
				}
				else
				{
					float factor = i.First / (w + i.First);
					result = Transform.Blend(factor, result, i.Second);
					w += factor;
				}
			}

			return result;
		}
Ejemplo n.º 2
0
		internal CoreBone(XmlElement e, CoreSkeleton skeleton)
		{
			parentId = int.Parse(e.SelectSingleNode("./PARENTID").InnerText);

			name = e.GetAttribute("NAME");
			boneSpace = new Transform(
				Util.ReadQuaternion(e.SelectSingleNode("./LOCALROTATION")),
				Util.ReadVector3(e.SelectSingleNode("./LOCALTRANSLATION")));

			transform = new Transform(
				Util.ReadQuaternion(e.SelectSingleNode("./ROTATION")),
				Util.ReadVector3(e.SelectSingleNode("./TRANSLATION")));

			this.skeleton = skeleton;

			parent = Lazy.New(() => 
			{ 
				var bone = skeleton.GetBone(parentId); 
				if (bone != null)
					bone.AddChild(this);
				return bone;
			});
		}
Ejemplo n.º 3
0
		public Bone(CoreBone coreBone, Skeleton skeleton)
		{
			this.coreBone = coreBone;
			this.skeleton = skeleton;
			this.transform = coreBone.Transform;
		}
Ejemplo n.º 4
0
		public static Transform Blend(float t, Transform a, Transform b)
		{
			return new Transform(
				Quaternion.Blend(t, a.rotation, b.rotation),
				Vector3.Lerp(t, a.translation, b.translation));
		}