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; }
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; }); }
public Bone(CoreBone coreBone, Skeleton skeleton) { this.coreBone = coreBone; this.skeleton = skeleton; this.transform = coreBone.Transform; }
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)); }