コード例 #1
0
    /// <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);
            }
        }
    }
コード例 #2
0
 public ShadowTransform[] NewTransformArray()
 {
     ShadowTransform[] buffer = new ShadowTransform[this.boneKeys.Count];
     for (int i = 0; i < buffer.Length; i++)
         buffer[i] = new ShadowTransform();
     return buffer;
 }
コード例 #3
0
 public ShadowTransform[] NewTransformArray()
 {
     ShadowTransform[] buffer = new ShadowTransform[this.boneKeys.Count];
     for (int i = 0; i < buffer.Length; i++)
     {
         buffer[i] = new ShadowTransform();
     }
     return(buffer);
 }
コード例 #4
0
ファイル: Coordinator.cs プロジェクト: alerdenisov/ADAPT
 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));
 }
コード例 #5
0
    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));
    }
コード例 #6
0
    /// <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);
        }
    }
コード例 #7
0
    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);
    }
コード例 #8
0
ファイル: BlendSystem.cs プロジェクト: BibleUs/Personality
    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;
    }
コード例 #9
0
 public ShadowTransform[] Encode(ShadowTransform[] buffer)
 {
     return this.shadow.Encode(buffer);
 }
コード例 #10
0
 public void Decode(
     ShadowTransform[] data,
     FilterList<string> nameFilter)
 {
     this.shadow.Decode(data, nameFilter);
 }
コード例 #11
0
 public void Decode(ShadowTransform[] data)
 {
     this.shadow.Decode(data);
 }
コード例 #12
0
ファイル: Shadow.cs プロジェクト: alerdenisov/ADAPT
 /// <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;
 }
コード例 #13
0
ファイル: Shadow.cs プロジェクト: BibleUs/Personality
 /// <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;
 }
コード例 #14
0
ファイル: Coordinator.cs プロジェクト: alerdenisov/ADAPT
 private ShadowTransform[] BlendReach(ShadowTransform[] input)
 {
     return BlendController(
         this.reach,
         input,
         this.rWeight,
         new Blacklist<string>(this.reachArm.name));
 }
コード例 #15
0
 public void ClearTransformArray(ShadowTransform[] array)
 {
     for (int i = 0; i < array.Length; i++)
         array[i].valid = false;
 }
コード例 #16
0
ファイル: ShadowTransform.cs プロジェクト: alerdenisov/ADAPT
 public static bool IsValid(ShadowTransform t)
 {
     return (t != null && t.valid == true);
 }
コード例 #17
0
ファイル: Shadow.cs プロジェクト: BibleUs/Personality
    /// <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);
    }
コード例 #18
0
ファイル: Shadow.cs プロジェクト: BibleUs/Personality
 /// <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);
 }
コード例 #19
0
ファイル: Coordinator.cs プロジェクト: alerdenisov/ADAPT
 private ShadowTransform[] BlendHeadLook(ShadowTransform[] input)
 {
     return BlendController(
         this.headLook,
         input,
         this.hWeight);
 }
コード例 #20
0
 public ShadowTransform[] Encode(
     ShadowTransform[] buffer,
     FilterList<string> nameFilter)
 {
     return this.shadow.Encode(buffer, nameFilter);
 }
コード例 #21
0
ファイル: Shadow.cs プロジェクト: alerdenisov/ADAPT
 /// <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);
 }
コード例 #22
0
ファイル: Shadow.cs プロジェクト: BibleUs/Personality
 /// <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);
 }
コード例 #23
0
ファイル: Coordinator.cs プロジェクト: alerdenisov/ADAPT
    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));
    }
コード例 #24
0
ファイル: Shadow.cs プロジェクト: BibleUs/Personality
    /// <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);
    }
コード例 #25
0
ファイル: Shadow.cs プロジェクト: BibleUs/Personality
 /// <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);
 }
コード例 #26
0
ファイル: BlendSystem.cs プロジェクト: BibleUs/Personality
 public BlendPair(ShadowTransform[] shadow, float weight)
 {
     this.shadow = shadow;
     this.weight = weight;
 }
コード例 #27
0
ファイル: Shadow.cs プロジェクト: BibleUs/Personality
 /// <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);
 }
コード例 #28
0
 public static bool IsValid(ShadowTransform t)
 {
     return(t != null && t.valid == true);
 }
コード例 #29
0
ファイル: Shadow.cs プロジェクト: alerdenisov/ADAPT
 /// <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);
 }