コード例 #1
0
 public override void PreProcessData <T>(T data)
 {
     if (data is RigComponent)
     {
         var rig = data as RigComponent;
         m_FeatherBlendQuery = CreateFeatherBlendQuery(rig, Blends);
     }
 }
コード例 #2
0
    /// <summary>
    /// From the transform's name, find the path in the rig that will later be converted to
    /// a hash, and then the hash will be used to find an index in the AnimationStream.
    /// </summary>
    public ChannelWeightQuery CreateFeatherBlendQuery(RigComponent rig, List <FeatherBlend> blendMap)
    {
        string status = "";

        List <ChannelWeightMap> channels = new List <ChannelWeightMap>();

        for (var mapIter = 0; mapIter < blendMap.Count; mapIter++)
        {
            bool success = false;

            for (var srcBoneIter = 0; srcBoneIter < rig.Bones.Length; srcBoneIter++)
            {
                if (blendMap[mapIter].Id == rig.Bones[srcBoneIter].name)
                {
                    var srcPath = RigGenerator.ComputeRelativePath(rig.Bones[srcBoneIter], rig.transform);

                    channels.Add(new ChannelWeightMap()
                    {
                        Id = srcPath, Weight = blendMap[mapIter].Weight
                    });
                }

                success = true;
            }

            if (!success)
            {
                status = status + mapIter + " ";
            }
        }

        ChannelWeightQuery featherBlendQuery = new ChannelWeightQuery();

        featherBlendQuery.Channels = new ChannelWeightMap[channels.Count];

        for (var iter = 0; iter < channels.Count; iter++)
        {
            featherBlendQuery.Channels[iter] = channels[iter];
        }

        if (!string.IsNullOrEmpty(status))
        {
            UnityEngine.Debug.LogError("Faulty Entries : " + status);
        }

        return(featherBlendQuery);
    }