void Handler(object sender, LMWidgets.EventArg <bool> e)
        {
            if (DontEmitUnchangedValue && (LastValue == e.CurrentValue))
            {
                return;
            }
            switch (CopyWhen)
            {
            case BoolWhen.IfFalse:
                if (!e.CurrentValue)
                {
                    BoolValue = e.CurrentValue;
                }
                break;

            case BoolWhen.IfTrue:
                if (e.CurrentValue)
                {
                    BoolValue = e.CurrentValue;
                }
                break;

            case BoolWhen.Always:
                BoolValue = e.CurrentValue;
                break;

            default:
                throw new System.ArgumentOutOfRangeException();
            }
        }
示例#2
0
 void HandleHandEvent(object sender, LMWidgets.EventArg <HandData> e)
 {
     if (e.CurrentValue.HasHand)
     {
         data = e.CurrentValue;
     }
 }
 void HandlePointEvent(object sender, LMWidgets.EventArg <PointData> e)
 {
     if (e.CurrentValue.HasData)
     {
         BoolValue = RayCheck(e.CurrentValue.Point);
     }
 }
示例#4
0
        void HandleBoolEvent(object sender, LMWidgets.EventArg <bool> e)
        {
            switch (ActivationMode)
            {
            case ToggleOn.OnAny:
// always continue
                break;

            case ToggleOn.OnFalse:
                if (e.CurrentValue)
                {
                    return;
                }
                break;

            case ToggleOn.OnTrue:
                if (!e.CurrentValue)
                {
                    return;
                }
                break;
            }

            BoolValue = !BoolValue;
// Debug.Log (string.Format ("... Toggle set to {0}", BoolValue));
        }
示例#5
0
        void HandleFrameEvent(object sender, LMWidgets.EventArg <FrameData> e)
        {
            HandModel oldFound = null;

// attempt to reconnect to the last good id
            HandModel[] handList = ReturnPhysicsHand ? e.CurrentValue.PhysicsModels : e.CurrentValue.HandModels;

            foreach (HandModel handInScene in handList)
            {
                if (handInScene.GetLeapHand().Id == lastHandId)
                {
                    oldFound = handInScene;
                }
            }

// on failure attempt to find a new good left hand
            if (!oldFound)
            {
                CurrentHand = FirstRightHand(handList);
                if (CurrentHand)
                {
                    lastHandId = CurrentHand.GetLeapHand().Id;
                }
            }
            else
            {
                CurrentHand = oldFound;
            }
        }
示例#6
0
 void FacingHandler(object sender, LMWidgets.EventArg <bool> e)
 {
     if (BoolValue && (e.CurrentValue == true))
     {
         HandPumpToggle.BoolValue = false;
     }
 }
示例#7
0
        void HandlePumpToggle(object sender, LMWidgets.EventArg <bool> e)
        {
//      Debug.Log (string.Format ("_____ HAND PUMP TOGGLEL {0} _____", ++c));

            //    Debug.Log (string.Format ("HandPumpToggle Listener: IsOver = {0}, AwayFromUser = {1}, PumpFastEnough: {2}, Pumptoggle: {3}",
            //                            IsOverEarth (),
            //                          IsPointedAwayFromUser (),
            //                        IsPumpingFastEnough (),
            //                      e.CurrentValue));

            if (IsOverEarth() && IsInTheZone() && IsPointedAwayFromUser() && Value != true)
            {
                Activate();
            }
            else
            {
                if (!IsOverEarth())
                {
                    //Debug.Log ("NOT OVER EARTH");
                }
                if (!IsPointedAwayFromUser())
                {
                    //Debug.Log ("NOT POINTED IN THE RIGHT DIRECTION");
                }
                if (!IsPumpingFastEnough())
                {
                    //Debug.Log ("PUMPING TOO SLOW");
                }
                if (!IsInTheZone())
                {
                    //Debug.Log ("Not in the Zone");
                }
                Deactivate();
            }
        }
示例#8
0
 void HandleBoolEvent(object sender, LMWidgets.EventArg <bool> e)
 {
     if (handling)
     {
         return;
     }
     handling = true;
     if (System.Math.Abs(LastTime - -1) < 0.01f)
     {
         IntValue = FirstEventResult;
         //Debug.Log (string.Format ("TimeFilter Default value at start: {0}", FirstEventResult));
     }
     else
     {
         float delta = (Time.time - LastTime);
         if (delta < MinSpeed)
         {
             IntValue = SQ_TOO_SLOW;
         }
         else if (delta > MaxSpeed)
         {
             IntValue = SQ_TOO_FAST;
         }
         else
         {
             IntValue = SQ_GOOD;
         }
         //	Debug.Log (string.Format ("Setting TimeGate value to {0} based on delta of {1} (desired {2}..{3})", IntValue, delta, MinSpeed, MaxSpeed));
     }
     LastTime = Time.time;
     handling = false;
 }
示例#9
0
        void OnBoolChanged(object sender, LMWidgets.EventArg <bool> e)
        {
            if (targets != null)
            {
//								Debug.Log (string.Format ("Setting {0} active to {1}", target.name, e.CurrentValue));
                ChangeVisibility(e.CurrentValue);
            }
        }
示例#10
0
 void HandleHandEvent(object sender, LMWidgets.EventArg <HandData> e)
 {
     if (e.CurrentValue.HasHand)
     {
         //	Debug.Log (string.Format ("Grip Strength = {0}", e.CurrentValue.LeapHand.GrabStrength));
         FloatValue = e.CurrentValue.LeapHand.GrabStrength;
     }
 }
示例#11
0
 void HandleActivationFromInput(object sender, LMWidgets.EventArg <HandData> e)
 {
     if (e.CurrentValue.HasHand)
     {
         //lastSightedHand = Time.time;
         UpdateJoystickPosition(e.CurrentValue.HandModel);
     }
 }
示例#12
0
 void HandleFloatEvent(object sender, LMWidgets.EventArg <float> e)
 {
     if (Target && Target.GetComponent <Renderer>() && Target.GetComponent <Renderer>().material)
     {
         Color c = Target.GetComponent <Renderer>().material.color;
         c.a = Mathf.Clamp01(e.CurrentValue);
         Target.GetComponent <Renderer>().material.color = c;
     }
 }
示例#13
0
        void HandleIntEvent(object sender, LMWidgets.EventArg <int> e)
        {
            handId = e.CurrentValue;
//						Debug.Log ("GetHandById looking for hand of id " + handId);
            if (handId >= 0)
            {
                FoundState.Change(FOUND_STATE_FOUND);
            }
// making the optimistic assumption that there is a hand of that ID In the scene and some other process found it.
        }
示例#14
0
 void HandleHandEvent(object sender, LMWidgets.EventArg <HandData> e)
 {
     if (e.CurrentValue.HasHand)
     {
         if (target)
         {
             target.transform.position = e.CurrentValue.HandModel.GetPalmPosition();
             target.transform.rotation = e.CurrentValue.HandModel.GetPalmRotation();
         }
     }                                     // note - not handling noo-hand case - other script should do that.
 }
示例#15
0
 void FrameEventHandler(object sender, LMWidgets.EventArg <FrameData> e)
 {
     if (e.CurrentValue.CurrentFrame.Hands.Count > 0)
     {
         handCountState.Change(JAX_HANDS);
     }
     else
     {
         handCountState.Change(JAX_NO_HANDS);
     }
 }
示例#16
0
 void HandleHandEvent(object sender, LMWidgets.EventArg <HandData> e)
 {
     if (e.CurrentValue.HasHand)
     {
         PointValue = new PointData(e.CurrentValue.HandModel.GetPalmPosition());
     }
     else
     {
         pointValue = new PointData(false);
     }
 }
示例#17
0
 void HandleFloatEvent(object sender, LMWidgets.EventArg <float> e)
 {
     if (e.CurrentValue > OnValue)
     {
         currentRegion.Change(Top);
     }
     else if (e.CurrentValue < OffValue)
     {
         currentRegion.Change(Bottom);
     }
     else
     {
         currentRegion.Change(Middle);
     }
 }
示例#18
0
 void HandleHandEvent(object sender, LMWidgets.EventArg <HandData> e)
 {
     if (e.CurrentValue.HasHand)
     {
         HandModel hand   = e.CurrentValue.HandModel;
         Vector3   pivot  = hand.GetPalmPosition();
         Vector3   normal = pivot + hand.GetPalmNormal();
         Vector3   axis   = upTarget.transform.position;
         FloatValue = Vector3.Dot((normal - pivot).normalized, (axis - pivot).normalized);
     }
     else
     {
         FloatValue = -1;
     }
 }
示例#19
0
 void ActivationHandler(object sender, LMWidgets.EventArg <bool> e)
 {
     if (e.CurrentValue)
     {
         ReferenceCenter.SetActive(true);
         if (data.HasHand)
         {
             ReferenceCenter.transform.position = data.HandModel.GetPalmPosition();
         }
         ;
         ReferenceCenter.transform.rotation = data.HandModel.GetPalmRotation();
     }
     else
     {
         ReferenceCenter.transform.localPosition    = new Vector3(0f, 0f, 0f);
         ReferenceCenter.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
         ReferenceCenter.SetActive(false);
     }
 }
示例#20
0
/**
 * note - we are polling the current state of all inputs, so the value of the changed one
 * is not (specifically) used.
 */
        void Handler(object sender, LMWidgets.EventArg <bool> e)
        {
            switch (LogicType)
            {
            case LogicGateType.And:
                PollAnd();
                break;

            case LogicGateType.Or:
                PollOr();
                break;

            case LogicGateType.Merge:
                BoolValue = e.CurrentValue;
                break;

            default:
                throw new System.ArgumentOutOfRangeException();
            }
        }
示例#21
0
        void JoystickListener(object sender, LMWidgets.EventArg <JoystickEvent> e)
        {
            if (TextType)
            {
                TextType.text = e.CurrentValue.Type.ToString();
            }
            if (TextX)
            {
                TextX.text = e.CurrentValue.Direction.x.ToString();
            }
            if (TextY)
            {
                TextY.text = e.CurrentValue.Direction.y.ToString();
            }
            if (TextZ)
            {
                TextZ.text = e.CurrentValue.Direction.z.ToString();
            }

            lastUpdateTime = Time.time;
        }
示例#22
0
        void HandleBoolEvent(object sender, LMWidgets.EventArg <bool> e)
        {
            history.Add(e.CurrentValue);
            while (history.Count > HistoryLength)
            {
                history.RemoveAt(0);
            }

            if (WaitForFullHistory && (history.Count < MinValues))
            {
                return;
            }

            if (Mode == mode.Optimist)
            {
                foreach (bool b in history)
                {
                    if (b)
                    {
                        BoolValue = true;
                        return;
                    }
                }
                BoolValue = false;
            }
            else
            {
                foreach (bool b in history)
                {
                    if (!b)
                    {
                        BoolValue = false;
                        return;
                    }
                }
                BoolValue = true;
            }
        }
示例#23
0
        void HandleIntEvent(object sender, LMWidgets.EventArg <int> e)
        {
            history.Add(e.CurrentValue == 0);
            while (history.Count > HistoryLength)
            {
                history.RemoveAt(0);
            }

            if (WaitForFullHistory && (history.Count < MinValues))
            {
                return;
            }

            string log        = "";
            bool   boolResult = false;

            if (Mode == mode.Optimist)
            {
                foreach (bool b in history)
                {
                    boolResult = boolResult || b;
                    log       += ", " + (b ? "T" : "F");
                }
            }
            else
            {
                boolResult = true;
                foreach (bool b in history)
                {
                    boolResult = boolResult && b;
                    log       += ", " + (b ? "T" : "F");
                }
            }

            //	Debug.Log (string.Format ("TimeBWfilter: result = {0}, mode = {1} (history {2})", boolResult, Mode, log));
            BoolValue = boolResult;
        }
示例#24
0
        void HandleHandEvent(object sender, LMWidgets.EventArg <HandData> e)
        {
            SetEmission(e.CurrentValue.HasHand);

            if (!e.CurrentValue.HasHand)
            {
                return;
            }

            AddHandPoints(e.CurrentValue.HandModel);

            // Set the current emmission rate based on hand speed.
            //Vector3 velocity = e.CurrentValue.HandModel.GetLeapHand ().PalmVelocity.ToUnityScaled ();
            float   smoothingFactor  = Mathf.Clamp01(0.1f);
            Vector3 position         = transform.localPosition;
            Vector3 noYPosition      = new Vector3(position.x, 0.0f, position.z);
            float   velocity         = (lastNoYPosition - noYPosition).magnitude * Time.deltaTime;
            float   velocitySmoothed = (lastVelocity * (1 - smoothingFactor)) + (velocity * smoothingFactor);

            lastVelocity    = velocitySmoothed;
            lastNoYPosition = noYPosition;

            float normSpeed = Mathf.Clamp01((velocitySmoothed - m_minHandSpeedForEmmission) / (m_handSpeedForMaxEmmission - m_minHandSpeedForEmmission));

//      Debug.Log("velocitySmoothed: " + (velocitySmoothed * 100));
            //Debug.Log("normSpeed: " + normSpeed);

            if (normSpeed > 0)
            {
                setEmmissionRateFromPercentage(Mathf.Clamp01(normSpeed));
            }
            else
            {
                SetEmission(false);
            }
        }
示例#25
0
        void HandleEnterEcho(object sender, LMWidgets.EventArg <HandTouchData> e)
        {
//						Debug.Log ("Hand has entered: " + e.ToString ());
        }
示例#26
0
 void HandleBoolEvent(object sender, LMWidgets.EventArg <bool> e)
 {
     activeness.Change(e.CurrentValue ? Activeness_Active : Activeness_Inactive);
 }
示例#27
0
 void HandleLeaveEcho(object sender, LMWidgets.EventArg <HandTouchData> e)
 {
     //	Debug.Log ("Hand has left: " + e.ToString ());
 }