public void Validate(MxMAnimData a_parentAnimData)
        {
            if (a_parentAnimData != null)
            {
                if (a_parentAnimData.MatchBones.Length != JointPositionWeights.Length)
                {
                    float[] newJointPosWeights = new float[a_parentAnimData.MatchBones.Length];
                    float[] newJointVelWeights = new float[a_parentAnimData.MatchBones.Length];

                    for (int i = 0; i < newJointPosWeights.Length; ++i)
                    {
                        if (i < JointPositionWeights.Length)
                        {
                            newJointPosWeights[i] = JointPositionWeights[i];
                            newJointVelWeights[i] = JointVelocityWeights[i];
                        }
                        else
                        {
                            newJointPosWeights[i] = 3;
                            newJointVelWeights[i] = 1;
                        }
                    }

                    JointPositionWeights = newJointPosWeights;
                    JointVelocityWeights = newJointVelWeights;
                }
            }
            else
            {
                Debug.LogError("Error: Trying to construct calibration data with null MxMAnimData");
            }
        }
Exemplo n.º 2
0
        //============================================================================================

        /**
         *  @brief Generates a pose mask asset based on the used pose data analytics
         *
         *********************************************************************************************/
        public void GeneratePoseMask()
        {
            if (m_usedPoses == null)
            {
                Debug.LogError("Trying to generate a pose mask but m_usedPoses Dictionary is null. Operation aborted");
                return;
            }

            MxMAnimData curAnimData = m_targetAnimator.CurrentAnimData;

            if (curAnimData == null)
            {
                Debug.LogError("Trying to generate a pose mask but the current MxMAnimData is null. Operation aborted");
                return;
            }

            PoseMask poseMask = ScriptableObject.CreateInstance <PoseMask>();

            poseMask.name = "PoseMask_" + curAnimData.name;
            poseMask.Initialize(curAnimData);
            poseMask.SetMask(m_usedPoses);

            curAnimData.StripPoseMask();
            curAnimData.BindPoseMask(poseMask);
            EditorUtility.SetDirty(curAnimData);
        }
Exemplo n.º 3
0
        //============================================================================================

        /**
         *  @brief
         *
         *********************************************************************************************/
        public void Initialize(MxMAnimData a_targetAnim)
        {
            if (a_targetAnim != null)
            {
                TargetAnimData  = a_targetAnim;
                PoseUtilisation = new int[TargetAnimData.Poses.Length];
            }
        }
Exemplo n.º 4
0
        //============================================================================================

        /**
         *  @brief Begins an event that is masked by a passed avatar mask (e.g. upper body event).
         *
         *  Note that masked events cannot use animation warping and other dynamic features that normal
         *  events use.
         *
         *  @param [MxMEventDefinition] a_eventDefinition - the event definition to use
         *  @param [AvatarMask] a_eventMask - the mask to use for the event
         *
         *********************************************************************************************/
        public void BeginEvent(MxMEventDefinition a_eventDefinition, AvatarMask a_eventMask, float a_blendRate,
                               float a_playbackRate = 1f)
        {
            if (a_eventDefinition == null)
            {
                Debug.LogError("Trying to play a layered event but the passed event definision is null.");
                return;
            }

            MxMAnimData currentAnimData = m_mxmAnimator.CurrentAnimData;

            float         bestCost         = float.MaxValue;
            int           bestWindupPoseId = 0;
            ref EventData bestEvent        = ref currentAnimData.Events[0];
        public void Initialize(string a_name, MxMAnimData a_animData)
        {
            CalibrationName = a_name;

            if (a_animData != null)
            {
                JointPositionWeights = new float[a_animData.MatchBones.Length];
                JointVelocityWeights = new float[a_animData.MatchBones.Length];

                for (int i = 0; i < JointPositionWeights.Length; ++i)
                {
                    JointPositionWeights[i] = 3f;
                }

                for (int i = 0; i < JointVelocityWeights.Length; ++i)
                {
                    JointVelocityWeights[i] = 1f;
                }
            }
            else
            {
                Debug.LogError("Error: Trying to construct calibration data with null MxMAnimData");
            }
        }
Exemplo n.º 6
0
        //============================================================================================

        /**
         *  @brief Prints all used pose analytics data to the console
         *
         *********************************************************************************************/
        public void DumpUsedPoseAnalytics()
        {
            if (m_usedPoses != null)
            {
                AnimationClip currentClip = null;

                int maxUseCount = 0;

                foreach (KeyValuePair <int, int> kvp in m_usedPoses)
                {
                    if (kvp.Value > maxUseCount)
                    {
                        maxUseCount = kvp.Value;
                    }
                }

                StringBuilder clipStats = new StringBuilder();

                int uniqueUsedPoses    = 0;
                int clipTotalUsedPoses = 0;

                MxMAnimData curAnimData = m_targetAnimator.CurrentAnimData;

                for (int index = 0; index < curAnimData.Poses.Length; index++)
                {
                    PoseData animDataPose = curAnimData.Poses[index];

                    int clipId = 0;
                    switch (animDataPose.AnimType)
                    {
                    case EMxMAnimtype.Composite: { clipId = curAnimData.Composites[animDataPose.AnimId].ClipIdA; } break;

                    case EMxMAnimtype.BlendSpace: { clipId = curAnimData.BlendSpaces[animDataPose.AnimId].ClipIds[0]; } break;

                    case EMxMAnimtype.Clip: { clipId = curAnimData.ClipsData[animDataPose.AnimId].ClipId; } break;
                    }

                    var newClip = curAnimData.Clips[clipId] != currentClip;

                    if (newClip)
                    {
                        if (currentClip)
                        {
                            clipStats.Append(clipTotalUsedPoses.ToString());

                            Debug.Log(clipStats.ToString(), currentClip);

                            clipTotalUsedPoses = 0;

                            clipStats.Clear();
                        }

                        currentClip = curAnimData.Clips[clipId];

                        clipStats.Append(currentClip.name);
                    }

                    int usedCount;

                    if (m_usedPoses.TryGetValue(index, out usedCount))
                    {
                        uniqueUsedPoses++;
                        clipTotalUsedPoses++;

                        int usedDigit = usedCount * 9 / maxUseCount;

                        clipStats.Append(usedDigit);
                    }
                    else
                    {
                        clipStats.Append('_');
                    }
                }

                if (currentClip)
                {
                    clipStats.Append(clipTotalUsedPoses.ToString());

                    Debug.Log(clipStats.ToString(), currentClip);

                    clipTotalUsedPoses = 0;

                    clipStats.Clear();
                }

                Debug.Log(string.Format("used {0}/{1} poses ", uniqueUsedPoses, curAnimData.Poses.Length));
            }
        }