Esempio n. 1
0
        public void UpdateHandPosePreview()
        {
            if (handPoseType == HandPoseType.HandPose)
            {
                Transform leftHandPreview  = transform.Find("LeftHandModelsEditorPreview");
                Transform rightHandPreview = transform.Find("RightHandModelsEditorPreview");

                if (leftHandPreview)
                {
                    HandPoser hp = leftHandPreview.GetComponentInChildren <HandPoser>();
                    if (hp != null)
                    {
                        hp.CurrentPose = SelectedHandPose;
                    }
                }

                if (rightHandPreview)
                {
                    HandPoser hp = rightHandPreview.GetComponentInChildren <HandPoser>();
                    if (hp != null)
                    {
                        hp.CurrentPose = SelectedHandPose;
                    }
                }
            }
        }
Esempio n. 2
0
 void Start()
 {
     if (InspectedPose == null)
     {
         InspectedPose = GetComponent <HandPoser>();
     }
 }
        public void SaveHandPoseAs(HandPoser poser)
        {
            // Open Window
            HandPoseSaveAs window = (HandPoseSaveAs)EditorWindow.GetWindow(typeof(HandPoseSaveAs));

            window.ShowWindow(poser);
        }
Esempio n. 4
0
 public bool GetPinkyHit(HandPoser poser)
 {
     if (PinkyFingerCollider != null)
     {
         return(LoopThroughJoints(poser.PinkyJoints, ClosedHandPose.Joints.PinkyJoints, PinkyFingerCollider.transform.position, PinkyFingerCollider.Radius));
     }
     else
     {
         return(LoopThroughJoints(poser.PinkyJoints, ClosedHandPose.Joints.PinkyJoints, HandPoser.GetFingerTipPositionWithOffset(poser.PinkyJoints, FingerTipRadius), FingerTipRadius));
     }
 }
Esempio n. 5
0
 public bool GetMiddleHit(HandPoser poser)
 {
     if (MiddleFingerCollider != null)
     {
         return(LoopThroughJoints(poser.MiddleJoints, ClosedHandPose.Joints.MiddleJoints, MiddleFingerCollider.transform.position, MiddleFingerCollider.Radius));
     }
     else
     {
         return(LoopThroughJoints(poser.MiddleJoints, ClosedHandPose.Joints.MiddleJoints, HandPoser.GetFingerTipPositionWithOffset(poser.MiddleJoints, FingerTipRadius), FingerTipRadius));
     }
 }
Esempio n. 6
0
 public bool GetThumbHit(HandPoser poser)
 {
     if (ThumbCollider != null)
     {
         return(LoopThroughJoints(poser.ThumbJoints, ClosedHandPose.Joints.ThumbJoints, ThumbCollider.transform.position, ThumbCollider.Radius));
     }
     else
     {
         return(LoopThroughJoints(poser.ThumbJoints, ClosedHandPose.Joints.ThumbJoints, HandPoser.GetFingerTipPositionWithOffset(poser.ThumbJoints, FingerTipRadius), FingerTipRadius));
     }
 }
Esempio n. 7
0
        public virtual void UpdateHandPoser()
        {
            if (DoUpdateHandPoser == false)
            {
                return;
            }

            // HandPoser may have changed - check for new component
            if (handPoser == null || !handPoser.isActiveAndEnabled)
            {
                handPoser = GetComponentInChildren <HandPoser>();
            }

            // Bail early if missing any info
            if (handPoser == null || grabber == null || grabber.HeldGrabbable == null || grabber.HeldGrabbable.handPoseType != HandPoseType.HandPose)
            {
                return;
            }
        }
Esempio n. 8
0
        void OnDrawGizmos()
        {
            // Don't draw gizmos if this component has been disabled
            if (!this.isActiveAndEnabled)
            {
                return;
            }

            if (InspectedPose == null)
            {
                InspectedPose = GetComponent <HandPoser>();
            }

            if (ShowGizmos && InspectedPose != null)
            {
                Gizmos.color = GizmoColor;
                DrawJointGizmo(ThumbCollider, HandPoser.GetFingerTipPositionWithOffset(InspectedPose.ThumbJoints, FingerTipRadius), FingerTipRadius, GizmoType);
                DrawJointGizmo(IndexFingerCollider, HandPoser.GetFingerTipPositionWithOffset(InspectedPose.IndexJoints, FingerTipRadius), FingerTipRadius, GizmoType);
                DrawJointGizmo(MiddleFingerCollider, HandPoser.GetFingerTipPositionWithOffset(InspectedPose.MiddleJoints, FingerTipRadius), FingerTipRadius, GizmoType);
                DrawJointGizmo(RingFingerCollider, HandPoser.GetFingerTipPositionWithOffset(InspectedPose.RingJoints, FingerTipRadius), FingerTipRadius, GizmoType);
                DrawJointGizmo(PinkyFingerCollider, HandPoser.GetFingerTipPositionWithOffset(InspectedPose.PinkyJoints, FingerTipRadius), FingerTipRadius, GizmoType);
            }
        }
        // [MenuItem("VRIF/HandPose Save As...")]
        public void ShowWindow(HandPoser poser)
        {
            EditorWindow.GetWindow(typeof(HandPoseSaveAs));

            inspectedPoser = poser;

            if (inspectedPoser != null && inspectedPoser.CurrentPose != null)
            {
                PoseName = inspectedPoser.CurrentPose.name;
            }
            else
            {
                PoseName = "Default";
            }

            const int width  = 480;
            const int height = 220;

            var x = (Screen.currentResolution.width - width) / 2;
            var y = (Screen.currentResolution.height - height) / 2;

            GetWindow <HandPoseSaveAs>("Save HandPose As...").position = new Rect(x, y, width, height);
        }
Esempio n. 10
0
        public void EditHandPose()
        {
            // Select the Hand Object
            if (grabPoint.RightHandIsValid)
            {
                if (!showingRightHand)
                {
                    CreateRightHandPreview();
                }

                RightHandPreview.gameObject.hideFlags = HideFlags.DontSave;
                HandPoser hp = RightHandPreview.gameObject.GetComponentInChildren <HandPoser>();
                if (hp != null)
                {
                    Selection.activeGameObject = hp.gameObject;
                }
            }
            else if (grabPoint.LeftHandIsValid)
            {
                if (!showingLeftHand)
                {
                    CreateLeftHandPreview();
                }

                LeftHandPreview.gameObject.hideFlags = HideFlags.DontSave;
                HandPoser hp = LeftHandPreview.gameObject.GetComponentInChildren <HandPoser>();
                if (hp != null)
                {
                    Selection.activeGameObject = hp.gameObject;
                }
            }
            else
            {
                Debug.Log("No HandPoser component was found on hand preview prefab. You may need to add one to 'Resources/RightHandModelsEditorPreview'.");
            }
        }
        public override void OnInspectorGUI()
        {
            poser = (HandPoser)target;

            serializedObject.Update();

            GUILayout.Label("Hand Pose", EditorStyles.boldLabel);

            EditorGUILayout.PropertyField(currentPose);

            // Show option to auto assign if nothing has been set yet
            bool notYetSpecified = (poser.ThumbJoints == null || poser.ThumbJoints != null && poser.ThumbJoints.Count == 0) &&
                                   (poser.IndexJoints == null || poser.IndexJoints != null && poser.IndexJoints.Count == 0) &&
                                   (poser.MiddleJoints == null || poser.MiddleJoints != null && poser.MiddleJoints.Count == 0) &&
                                   (poser.RingJoints == null || poser.RingJoints != null && poser.RingJoints.Count == 0) &&
                                   (poser.PinkyJoints == null || poser.PinkyJoints != null && poser.PinkyJoints.Count == 0) &&
                                   (poser.OtherJoints == null || poser.OtherJoints != null && poser.OtherJoints.Count == 0);

            if (notYetSpecified)
            {
                EditorGUILayout.HelpBox("No Bone Transforms have been assigned, would you like to auto assign them now?", MessageType.Warning);
                if (GUILayout.Button("Auto Assign"))
                {
                    AutoAssignBones();
                    // Toggle props
                    showTransformProps = true;
                }
            }

            // Show Transform Properties
            showTransformProps = EditorGUILayout.Foldout(showTransformProps, "Transform Definitions");
            if (showTransformProps)
            {
                EditorGUILayout.Separator();

                EditorGUI.indentLevel++;

                if (GUILayout.Button("Auto Assign"))
                {
                    AutoAssignBones();
                }

                EditorGUI.indentLevel++;

                EditorGUILayout.PropertyField(ThumbJoints);

                EditorGUILayout.PropertyField(IndexJoints);

                EditorGUILayout.PropertyField(MiddleJoints);

                EditorGUILayout.PropertyField(RingJoints);

                EditorGUILayout.PropertyField(PinkyJoints);

                EditorGUILayout.PropertyField(OtherJoints);

                EditorGUILayout.PropertyField(WristJoint);

                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(animationSpeed);

            GUILayout.BeginHorizontal();

            var initialColor = GUI.backgroundColor;

            //GUI.backgroundColor = Color.green;

            if (GUILayout.Button("Save Pose..."))
            {
                SaveHandPoseAs(poser);
            }

            // Reset color
            GUI.backgroundColor = initialColor;

            GUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            // Gizmos
            serializedObject.ApplyModifiedProperties();
        }