/// <summary> /// Recursively applies an encoded skeleton, or part of it, to the shadow /// </summary> /// <param name="data">The encoded skeleton data</param> /// <param name="t">The current transform to apply to</param> /// <param name="nameFilter">The filter for names</param> /// <param name="bypass">Used for whitelists to take children of /// whitelisted transforms</param> public static void ReadShadowData( ShadowTransform[] data, Transform t, ShadowCoordinator coordinator, FilterList <string> nameFilter, bool bypass = false) { bool allowed = (bypass == true || nameFilter.Allowed(t.name) == true); bool whitelist = (nameFilter.IsWhitelist() == true); bypass = (allowed == true && whitelist == true); // If this is a valid bone, and is allowed, read it to the skeleton int key = coordinator.GetBoneKey(t.name); if (allowed == true && ShadowTransform.IsValid(data[key]) == true) { data[key].WriteTo(t); } // See if we need to keep searching if (whitelist == true || allowed == true) { foreach (Transform child in t) { ReadShadowData(data, child, coordinator, nameFilter, bypass); } } }
public ShadowTransform[] NewTransformArray() { ShadowTransform[] buffer = new ShadowTransform[this.boneKeys.Count]; for (int i = 0; i < buffer.Length; i++) buffer[i] = new ShadowTransform(); return buffer; }
public ShadowTransform[] NewTransformArray() { ShadowTransform[] buffer = new ShadowTransform[this.boneKeys.Count]; for (int i = 0; i < buffer.Length; i++) { buffer[i] = new ShadowTransform(); } return(buffer); }
private ShadowTransform[] BlendAnimations(ShadowTransform[] input) { return BlendController( this.anim, input, this.aWeight, // We want to filter out the upper body from the sitting // and locomotion blend when we're doing the animation on top new Blacklist<string>(this.midSpine.name)); }
private ShadowTransform[] BlendRagdoll(ShadowTransform[] input) { if (this.dWeight.IsMin == true) this.ragdoll.Decode( input, new Blacklist<string>("LeftUpLeg", "RightUpLeg")); this.ragdoll.ControlledUpdate(); ShadowTransform[] result = this.ragdoll.Encode(this.ragdollPose); return BlendSystem.Blend( this.NewTransformArray(), new BlendPair(input, this.dWeight.Inverse), new BlendPair(result, this.dWeight.Value)); }
/// <summary> /// Recursively applies an encoded skeleton, or part of it, to the shadow /// </summary> /// <param name="data">The encoded skeleton data</param> /// <param name="t">The current transform to apply to</param> public static void ReadShadowData( ShadowTransform[] data, Transform t, ShadowCoordinator coordinator) { int key = coordinator.GetBoneKey(t.name); if (ShadowTransform.IsValid(data[key]) == true) { data[key].WriteTo(t); } foreach (Transform child in t) { ReadShadowData(data, child, coordinator); } }
public static ShadowTransform[] Blend( ShadowTransform[] buffer, params BlendPair[] shadows) { int boneCount = shadows[0].shadow.Length; // Bones per shadow int shadowCount = shadows.Length; // Total number of shadows for (int i = 0; i < boneCount; i++) { List <float> weights = new List <float>(); List <Vector3> positions = new List <Vector3>(); List <Quaternion> rotations = new List <Quaternion>(); for (int j = 0; j < shadowCount; j++) { // Extract the features from the bone ShadowTransform bone = shadows[j].shadow[i]; if (ShadowTransform.IsValid(bone) == true) { weights.Add(shadows[j].weight); positions.Add(bone.Position); rotations.Add(bone.Rotation); } } // If we just have one weight for this bone if (weights.Count == 1) { buffer[i].ReadFrom(positions[0], rotations[0]); } // If we have anything to blend for this bone else if (weights.Count > 1) { float[] weightsArray = weights.ToArray(); NormalizeWeights(weightsArray); buffer[i].ReadFrom( BlendVector3(positions, weightsArray), BlendQuaternion(rotations, weightsArray)); } } return(buffer); }
public static ShadowTransform[] Blend( ShadowTransform[] buffer, params BlendPair[] shadows) { int boneCount = shadows[0].shadow.Length; // Bones per shadow int shadowCount = shadows.Length; // Total number of shadows for (int i = 0; i < boneCount; i++) { List<float> weights = new List<float>(); List<Vector3> positions = new List<Vector3>(); List<Quaternion> rotations = new List<Quaternion>(); for (int j = 0; j < shadowCount; j++) { // Extract the features from the bone ShadowTransform bone = shadows[j].shadow[i]; if (ShadowTransform.IsValid(bone) == true) { weights.Add(shadows[j].weight); positions.Add(bone.Position); rotations.Add(bone.Rotation); } } // If we just have one weight for this bone if (weights.Count == 1) { buffer[i].ReadFrom(positions[0], rotations[0]); } // If we have anything to blend for this bone else if (weights.Count > 1) { float[] weightsArray = weights.ToArray(); NormalizeWeights(weightsArray); buffer[i].ReadFrom( BlendVector3(positions, weightsArray), BlendQuaternion(rotations, weightsArray)); } } return buffer; }
public ShadowTransform[] Encode(ShadowTransform[] buffer) { return this.shadow.Encode(buffer); }
public void Decode( ShadowTransform[] data, FilterList<string> nameFilter) { this.shadow.Decode(data, nameFilter); }
public void Decode(ShadowTransform[] data) { this.shadow.Decode(data); }
/// <summary> /// Creates an encoded skeleton array from this shadow hierarchy /// </summary> /// <returns>A potentially sparse array describing this shadow</returns> public ShadowTransform[] Encode(ShadowTransform[] buffer) { ShadowCoordinator coordinator = this.controller.Coordinator; Shadow.WriteShadowData( buffer, this._rootHips, coordinator); return buffer; }
/// <summary> /// <summary> /// Creates an encoded skeleton array from this shadow hierarchy /// </summary> /// <param name="listType">Whitelist or blacklist</param> /// <param name="list">The list of transforms to prune or include</param> /// <returns>A potentially sparse array describing this shadow</returns> public ShadowTransform[] Encode( ShadowTransform[] buffer, FilterList<string> nameFilter) { ShadowCoordinator coordinator = this.controller.Coordinator; Shadow.WriteShadowData( buffer, this._rootObject.transform.GetChild(0), coordinator, nameFilter); return buffer; }
private ShadowTransform[] BlendReach(ShadowTransform[] input) { return BlendController( this.reach, input, this.rWeight, new Blacklist<string>(this.reachArm.name)); }
public void ClearTransformArray(ShadowTransform[] array) { for (int i = 0; i < array.Length; i++) array[i].valid = false; }
public static bool IsValid(ShadowTransform t) { return (t != null && t.valid == true); }
/// <summary> /// Recursively applies an encoded skeleton, or part of it, to the shadow /// </summary> /// <param name="data">The encoded skeleton data</param> /// <param name="t">The current transform to apply to</param> /// <param name="nameFilter">The filter for names</param> /// <param name="bypass">Used for whitelists to take children of /// whitelisted transforms</param> public static void ReadShadowData( ShadowTransform[] data, Transform t, ShadowCoordinator coordinator, FilterList<string> nameFilter, bool bypass = false) { bool allowed = (bypass == true || nameFilter.Allowed(t.name) == true); bool whitelist = (nameFilter.IsWhitelist() == true); bypass = (allowed == true && whitelist == true); // If this is a valid bone, and is allowed, read it to the skeleton int key = coordinator.GetBoneKey(t.name); if (allowed == true && ShadowTransform.IsValid(data[key]) == true) data[key].WriteTo(t); // See if we need to keep searching if (whitelist == true || allowed == true) foreach (Transform child in t) ReadShadowData(data, child, coordinator, nameFilter, bypass); }
/// <summary> /// Recursively applies an encoded skeleton, or part of it, to the shadow /// </summary> /// <param name="data">The encoded skeleton data</param> /// <param name="t">The current transform to apply to</param> public static void ReadShadowData( ShadowTransform[] data, Transform t, ShadowCoordinator coordinator) { int key = coordinator.GetBoneKey(t.name); if (ShadowTransform.IsValid(data[key]) == true) data[key].WriteTo(t); foreach (Transform child in t) ReadShadowData(data, child, coordinator); }
private ShadowTransform[] BlendHeadLook(ShadowTransform[] input) { return BlendController( this.headLook, input, this.hWeight); }
public ShadowTransform[] Encode( ShadowTransform[] buffer, FilterList<string> nameFilter) { return this.shadow.Encode(buffer, nameFilter); }
/// <summary> /// Applies an encoded skeleton (or part of one) to this shadow /// </summary> /// <param name="data">The encoded shadow skeleton</param> /// <param name="listType">Whitelist or blacklist</param> /// <param name="list">The list of transforms to prune or include</param> public void Decode( ShadowTransform[] data, FilterList<string> nameFilter) { Shadow.ReadShadowData( data, this._rootHips, this.controller.Coordinator, nameFilter); }
/// <summary> /// Recursively populates a transform data array from this shadow /// </summary> /// <param name="data">The array to populate</param> /// <param name="t">The current subtree root</param> /// <param name="coordinator">The coordinator</param> public static void WriteShadowData( ShadowTransform[] buffer, Transform t, ShadowCoordinator coordinator) { int key = coordinator.GetBoneKey(t.name); buffer[key].ReadFrom(t); foreach (Transform child in t) WriteShadowData(buffer, child, coordinator); }
private ShadowTransform[] BlendController( ShadowController controller, ShadowTransform[] input, Slider weight, FilterList<string> filter = null) { if (weight.IsMin == true) return input; // Update the target controller from that blend if (filter == null) controller.Decode(input); else controller.Decode(input, filter); controller.ControlledUpdate(); ShadowTransform[] result = controller.Encode(this.NewTransformArray()); return BlendSystem.Blend( this.NewTransformArray(), new BlendPair(input, weight.Inverse), new BlendPair(result, weight.Value)); }
/// <summary> /// Recursively populates a transform data array from this shadow, with /// a potential whitelist or blacklist /// </summary> /// <param name="data">The array to populate</param> /// <param name="t">The current subtree root</param> /// <param name="coordinator">The coordinator</param> /// <param name="nameFilter">The filter for names</param> /// <param name="bypass">Used for whitelists to take children of /// whitelisted transforms</param> public static void WriteShadowData( ShadowTransform[] data, Transform t, ShadowCoordinator coordinator, FilterList<string> nameFilter, bool bypass = false) { bool allowed = (bypass == true || nameFilter.Allowed(t.name) == true); bool whitelist = (nameFilter.IsWhitelist() == true); bypass = (allowed == true && whitelist == true); // If we're permitting this bone through the filter if (allowed == true) data[coordinator.GetBoneKey(t.name)].ReadFrom(t); // See if we need to keep searching if (whitelist == true || allowed == true) foreach (Transform child in t) WriteShadowData(data, child, coordinator, nameFilter, bypass); }
/// <summary> /// Applies an encoded skeleton (or part of one) to this shadow /// </summary> /// <param name="data">The encoded shadow skeleton</param> public void Decode(ShadowTransform[] data) { Shadow.ReadShadowData( data, this._rootObject.transform.GetChild(0), this.controller.Coordinator); }
public BlendPair(ShadowTransform[] shadow, float weight) { this.shadow = shadow; this.weight = weight; }
/// <summary> /// Applies an encoded skeleton (or part of one) to this shadow /// </summary> /// <param name="data">The encoded shadow skeleton</param> /// <param name="listType">Whitelist or blacklist</param> /// <param name="list">The list of transforms to prune or include</param> public void Decode( ShadowTransform[] data, FilterList<string> nameFilter) { Shadow.ReadShadowData( data, this._rootObject.transform.GetChild(0), this.controller.Coordinator, nameFilter); }
public static bool IsValid(ShadowTransform t) { return(t != null && t.valid == true); }
/// <summary> /// Applies an encoded skeleton (or part of one) to this shadow /// </summary> /// <param name="data">The encoded shadow skeleton</param> public void Decode(ShadowTransform[] data) { Shadow.ReadShadowData( data, this._rootHips, this.controller.Coordinator); }