Example #1
0
        //Manage hands and feet
        void OnPair(Pairable p)
        {
            switch (p.type)
            {
            case HAND:
                if (rightHand == null)
                {
                    rightHand = p;
                }
                else if (leftHand == null)
                {
                    leftHand = p;
                }
                break;

            case FOOT:
                if (rightFoot == null)
                {
                    rightFoot = p;
                }
                else if (leftFoot == null)
                {
                    leftFoot = p;
                }
                break;
            }
        }
Example #2
0
 void Awake()
 {
     if (!Holojam.Utility.IsMasterPC())
     {
         Destroy(this);
     }
     p = GetComponent <Holojam.Tools.Pairable> ();
 }
Example #3
0
 public void Process(float headLength, Transform torso, Vector3 head, Transform neck,
                     Transform groundPlane, Pairable leftHand, Pairable rightHand, Vector3 headForward)
 {
     this.leftHand    = leftHand;
     this.rightHand   = rightHand;
     this.headForward = headForward;
     base.Process(headLength, torso, head, neck, groundPlane);
 }
Example #4
0
 public void Process(float headLength, Transform torso, Vector3 head, Transform neck,
                     Transform groundPlane, Transform partialTorso, Pairable leftFoot, Pairable rightFoot)
 {
     this.partialTorso = partialTorso;
     this.leftFoot     = leftFoot;
     this.rightFoot    = rightFoot;
     base.Process(headLength, torso, head, neck, groundPlane);
 }
Example #5
0
        void OnTriggerExit(Collider c)
        {
            Pairable p = c.GetComponent <Pairable>();

            if (p != null)
            {
                buffer.Remove(p);
                p.DeregisterTarget(this);
            }
        }
Example #6
0
        void OnTriggerEnter(Collider c)
        {
            Pairable p = c.GetComponent <Pairable>();

            if (p != null)
            {
                buffer.Add(p, Time.time);
                p.RegisterTarget(this);
            }
        }
Example #7
0
        public bool ValidatePair(Pairable p)
        {
            bool valid = Array.Exists(mask, s => s == p.type) == (maskType == MaskType.WHITELIST) &&
                         (p.pairedTo == this || UnderCap(p.type)) && //Cap, but not if unpairing
                         p.CanTarget(this);

            //Reset timer if invalid
            if (!valid)
            {
                buffer[p] = Time.time;
            }
            return(valid);
        }
Example #8
0
            public void Process(float headLength, Vector3 hip, Pairable foot,
                                Transform upperRenderLeg, Transform lowerRenderLeg, Transform renderKnee)
            {
                this.headLength     = headLength;
                this.hip            = hip;
                this.foot           = foot;
                this.lowerRenderLeg = lowerRenderLeg;
                this.upperRenderLeg = upperRenderLeg;
                this.renderKnee     = renderKnee;

                Calculate();
                Render();
            }
Example #9
0
 void OnUnpair(Pairable p)
 {
     if (p == leftHand)
     {
         leftHand = null;
     }
     else if (p == rightHand)
     {
         rightHand = null;
     }
     else if (p == leftFoot)
     {
         leftFoot = null;
     }
     else if (p == rightFoot)
     {
         rightFoot = null;
     }
 }
Example #10
0
            protected override void Calculate()
            {
                lowestFoot = Vector3.Distance(leftFoot.center, head) <
                             Vector3.Distance(rightFoot.center, head)?rightFoot:leftFoot;
                //Median point between feet, at lowest foot height
                Vector3 foundation = (leftFoot.center + rightFoot.center) * 0.5f;

                foundation = Vector3.Project(lowestFoot.center - head, foundation - head) + head;

                Vector3 planedLeftFoot  = ProjectToGround(leftFoot.transform.forward).normalized;
                Vector3 planedRightFoot = ProjectToGround(rightFoot.transform.forward).normalized;

                //Calculate facing direction
                rawForward = ((planedRightFoot + planedLeftFoot) * 0.5f).normalized;

                up = (head - foundation).normalized;
                //Calculate leaning direction
                leanedForward = Vector3.Cross(
                    Vector3.Cross(groundPlane.up, rawForward), up
                    ).normalized;
            }
Example #11
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(type, new GUIContent("Pairable Type"));
            EditorGUILayout.PropertyField(trackingTag);
            EditorGUILayout.PropertyField(localSpace);
            EditorGUILayout.PropertyField(centerOffset, new GUIContent("Center Offset"));

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(pairTime);
            EditorGUILayout.PropertyField(unpairTime);
            EditorGUILayout.PropertyField(cooldown);

            if (!serializedObject.isEditingMultipleObjects)
            {
                EditorGUILayout.Space();

                Pairable p     = (Pairable)serializedObject.targetObject;
                GUIStyle style = new GUIStyle(EditorStyles.boldLabel);
                EditorGUIUtility.labelWidth = 72;

                if (p.paired && !p.unpairing)
                {
                    style.normal.textColor = new Color(0.5f, 1, 1);
                }

                EditorGUILayout.LabelField("Status",
                                           (p.paired && !p.unpairing)?"Paired with \"" + p.pairedTo.pivot.gameObject.name + "\"":
                                           (!p.paired && !p.pairing)?"Unpaired":
                                           p.pairing?"Pairing...":"Unpairing...",
                                           style
                                           );
            }

            EditorUtility.SetDirty(serializedObject.targetObject);
            serializedObject.ApplyModifiedProperties();
        }
Example #12
0
 void OnUnpair(Pairable p)
 {
     buffer[p] = Time.time;
     paired.Remove(p);
 }
Example #13
0
 //Update paired list and reset timers
 void OnPair(Pairable p)
 {
     buffer[p] = Time.time;
     paired.Add(p);
 }
Example #14
0
 //How long has the pairable been in the pairing zone?
 float Lifetime(Pairable p)
 {
     return(Time.time - buffer[p]);
 }
Example #15
0
 void Awake()
 {
     pairable = GetComponent <Holojam.Tools.Pairable>();
 }