コード例 #1
0
        void SetToTPose()
        {
            Dictionary <HumanBodyBones, Transform> includeJoints = jointFieldMap.Keys.
                                                                   Where(k => GetTransformFromField(k) != null).
                                                                   ToDictionary(k => k.ToUnityBones(), v => GetTransformFromField(v));

            Object[] bones = includeJoints.Values.ToArray();
            Undo.RegisterCompleteObjectUndo(bones, "Set T-Pose");

            NuitrackAvatar avatar = target as NuitrackAvatar;

            SkeletonUtils.SetToTPose(avatar.transform, includeJoints);
        }
コード例 #2
0
        protected virtual void OnEnable()
        {
            NuitrackAvatar avatar = target as NuitrackAvatar;

            List <JointType> jointMask = jointFieldMap.Keys.ToList();

            skeletonMapper             = new SkeletonMapperGUI <Transform>(jointMask, optionalJoints);
            skeletonMapper.OnDrop     += SkeletonMapper_onDrop;
            skeletonMapper.OnSelected += SkeletonMapper_onSelected;

            skeletonJointListUI             = new SkeletonMapperListGUI <Transform>(jointMask, optionalJoints);
            skeletonJointListUI.OnDrop     += SkeletonMapper_onDrop;
            skeletonJointListUI.OnSelected += SkeletonMapper_onSelected;

            skeletonBonesView = new SkeletonBonesView(avatar.transform, ViewMode);
            skeletonBonesView.OnBoneSelected += SkeletonBonesView_OnBoneSelected;
            skeletonBonesView.OnRemoveBone   += SkeletonBonesView_OnRemoveBone;
        }
コード例 #3
0
        void DrawSkeletonMap()
        {
            IEnumerable <JointType> activeJoints = jointFieldMap.Keys.Where(k => GetTransformFromField(k) != null);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Avatar map", EditorStyles.boldLabel);

            if (skeletonMapper != null)
            {
                skeletonMapper.Draw(activeJoints.ToList());
            }

            GUIContent toObjectGUIContent = EditorGUIUtility.IconContent("SceneViewCamera");

            toObjectGUIContent.text = "Centered in view";

            if (GUILayout.Button(toObjectGUIContent))
            {
                NuitrackAvatar avatar = target as NuitrackAvatar;
                SkeletonUtils.CenteredInView(avatar.transform);
            }

            if (skeletonBonesView != null)
            {
                skeletonBonesView.DrawInspectorGUI();
            }

            EditorGUILayout.Space();

            if (skeletonJointListUI != null)
            {
                Dictionary <JointType, Transform> jointDict = activeJoints.ToDictionary(k => k, v => GetTransformFromField(v));
                skeletonJointListUI.Draw(jointDict);
            }

            EditorGUILayout.Space();
            DrawAutomapTools(activeJoints);
        }
コード例 #4
0
        void AutoMapping()
        {
            NuitrackAvatar avatar = target as NuitrackAvatar;

            Dictionary <HumanBodyBones, Transform> skeletonBonesMap = SkeletonUtils.GetBonesMap(avatar.transform);

            if (skeletonBonesMap == null || skeletonBonesMap.Count == 0)
            {
                Debug.LogError("It is not possible to automatically fill in the skeleton map. Check the correctness of your model.");
                return;
            }

            List <HumanBodyBones> failFoundBones = new List <HumanBodyBones>();

            foreach (JointType jointType in jointFieldMap.Keys)
            {
                HumanBodyBones humanBodyBones = jointType.ToUnityBones();

                if (GetTransformFromField(jointType) == null)
                {
                    if (excludeAutoFillJoints.Contains(jointType) || !skeletonBonesMap.ContainsKey(humanBodyBones))
                    {
                        failFoundBones.Add(humanBodyBones);
                    }
                    else
                    {
                        EditJoint(jointType, skeletonBonesMap[humanBodyBones]);
                    }
                }
            }

            if (failFoundBones.Count > 0)
            {
                Debug.Log(string.Format("For bones: <color=orange><b>{0}</b></color>, could not be found object Transforms", string.Join(", ", failFoundBones)));
            }
        }