예제 #1
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.
 }
        void FacingHandler(object sender, LMWidgets.EventArg<bool> e)
        {
            if (BoolValue && (e.CurrentValue == true)) {

            HandPumpToggle.BoolValue = false;
              }
        }
예제 #3
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;
                        }
        }
예제 #4
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;
						}
				}
예제 #5
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;
        }
예제 #6
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);
                 }
 }
예제 #7
0
 void OnSelect(object sender, LMWidgets.EventArg<bool> arg)
 {
     if (arg.CurrentValue)
     {
         Application.LoadLevel(0);
     }
 }
예제 #8
0
 private void OnSimpleButtonAction(object sender, LMWidgets.EventArg<bool> arg)
 {
     Debug.Log (this.transform.name + " pressed.");
     foreach (string item in m_TwitterChannel.m_SearchTerms)
     {
         m_TwitterChannel.StartSimpleSearch (item, true);
     }
 }
예제 #9
0
 private void onHandEvent(object sender, LMWidgets.EventArg<WidgetShowcase.HandData> e)
 {
     if ( !e.CurrentValue.HasHand ) {
       m_isAboveHorizon = false;
       return;
     }
     m_isAboveHorizon = HorizonCheck(e.CurrentValue.HandModel);
 }
예제 #10
0
 void HandlePumpEvent(object sender, LMWidgets.EventArg<bool> e)
 {
     if (e.CurrentValue)
                         ++fistPumpedTrue;
                 else
                         ++fistPumpedFalse;
                 FistPumpFeedback.text = string.Format ("Fist Pumped: {0} ({1} true, {2} false)",
                     e.CurrentValue ? "T" : "F", fistPumpedTrue, fistPumpedFalse);
 }
예제 #11
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.
 }
예제 #12
0
        void HandlePointEvent(object sender, LMWidgets.EventArg<PointData> e)
        {
            if (Time.time < 1)
                                return;
                        if (e.CurrentValue.HasData) {
                                //Debug.Log ("Cursor moved to " + e.CurrentValue.Point);
                                Cursor.transform.position = e.CurrentValue.Point;

                        }
        }
예제 #13
0
 void OnScramble(object sender, LMWidgets.EventArg<bool> arg)
 {
     GetComponent<AudioSource>().Play();
     PalmRotator.moveCount = 0;
     PalmRotator.textRef.text = "Moves: " + PalmRotator.moveCount;
     if (arg.CurrentValue && (SwipeCube.checkSwipe || !PalmRotator.canRotate) && !busy)
     {
         busy = true;
         StartCoroutine(ScrambleCube());
     }
 }
예제 #14
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;
						}
				}
예제 #15
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);
						}
				}
예제 #16
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;
        }
예제 #17
0
 void OnSelect(object sender, LMWidgets.EventArg<bool> arg)
 {
     if (arg.CurrentValue)
       {
       if (hard)
       {
           PlayerPrefs.SetInt("Difficulty", 1);
           Application.LoadLevel(1);
       }
       else
       {
           PlayerPrefs.SetInt("Difficulty", 0);
                         Application.LoadLevel(1);
       }
       }
 }
예제 #18
0
    private void onHandEvent(object sender, LMWidgets.EventArg<HandData> e)
    {
        if ( !e.CurrentValue.HasHand ) {
          if ( m_activeObject != null) { m_activeObject.GetComponent<Renderer>().enabled = false; }
          return;
        }
        else {
          if ( m_activeObject != null) { m_activeObject.GetComponent<Renderer>().enabled = true; }
        }

        HandModel hand = e.CurrentValue.HandModel;

        transform.rotation = hand.GetPalmRotation();
        transform.position = hand.GetPalmPosition() + (transform.up * IconOffsetDistance);

        // Transition logic below here.
        if ( ModalityManager.Instance.HasActiveItem() ) {
          if ( ModalityManager.Instance.ActiveItemName == "ARMHUD" && m_activeObject != null || ModalityManager.Instance.ActiveItemName == "Joyball" && m_activeObject != null) {
        m_activeObject = null;
        //Debug.Log("Go None");
        StopAllCoroutines();
        StartCoroutine(transitionOut(switchToNone));
          }
          return;
        }

        bool aboveHorizon = !m_raycastEmitter.RayCheck(hand.GetPalmPosition());

        if ( aboveHorizon && !m_wasAboveHorizon || (aboveHorizon && m_activeObject == null) ) {
          if ( m_activeObject == null ) { m_activeObject = m_constellationIcon; }
          StopAllCoroutines();
          StartCoroutine(transitionOut(switchToConstellation));
        }
        //    else if (!aboveHorizon && m_wasAboveHorizon || (!aboveHorizon && m_activeObject == null) ) {
        else if (!aboveHorizon && m_wasAboveHorizon )  {

          if ( m_activeObject == null ) { m_activeObject = null; }
          StopAllCoroutines();
          // DECISION: Joyball icon is NOT needed due to the affordance presented by the JoyBall itself
        //      StartCoroutine(transitionOut(switchToJoyball));
          		StartCoroutine(transitionOut(switchToNone));
        //      StartCoroutine(transitionOut(switchToGrabCycle));

        }

        m_wasAboveHorizon = aboveHorizon;
    }
예제 #19
0
        void HandleHandEvent(object sender, LMWidgets.EventArg<HandData> e)
        {
            if (IsCurrentHand (e.CurrentValue)) {
                                //Vector3 palmPos = e.CurrentValue.HandModel.GetPalmPosition ();
                                Vector3 fingerTipPosition = e.CurrentValue.HandModel.fingers [1].GetTipPosition ();
                                if (!cursorSet) {
                                        HandFirstPosition = fingerTipPosition;
                                        CursorFirstPosition = Cursor.transform.position;
                                } else {
            // the cursor is moved, indirectly, by the position filter, which takes the desired input as a prompt
                                        //	Debug.Log ("Pushing cursor to be relative to " + e.CurrentValue.LeapHand.Id);
                                        Vector3 toPos = CursorFirstPosition + (fingerTipPosition - CursorFirstPosition);
                                        CursorPositionFilter.PointValue = new PointData (toPos);
                                }

                        }
        }
예제 #20
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));
				}
예제 #21
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;
 }
예제 #22
0
    private void onHandEvent(object sender, LMWidgets.EventArg<WidgetShowcase.HandData> e)
    {
        if ( WidgetShowcase.ModalityManager.Instance.HasActiveItem() ) {
          if ( WidgetShowcase.ModalityManager.Instance.ActiveItemName == "ARMHUD" ) {
        Active = false;
          }
          return;
        }

        if ( e.CurrentValue.HasHand && raycastEmitter != null) {
          if ( raycastEmitter.RayCheck(e.CurrentValue.HandModel.GetPalmPosition()) ) {
        Active = true;
          }
          else {
        Active = false;
          }
        }
        else {
          Active = false;
        }
    }
예제 #23
0
        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 ();
                        }
        }
예제 #24
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;
                        }
        }
예제 #25
0
 private void OnSliderToggleButtonPressed(object sender, LMWidgets.EventArg<bool> args)
 {
     //Debug.Log("ButtonPressed: " + args.CurrentValue);
     //			ToggleSlider(sender as ButtonDemoToggle);
 }
예제 #26
0
 private void OnPanelButtonPressed(object sender, LMWidgets.EventArg<bool> args)
 {
     ChangeActivePanel(sender as ButtonDemoToggle);
 }
예제 #27
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);
                        }
        }
예제 #28
0
				void HandleHandEvent (object sender, LMWidgets.EventArg<HandData> e)
				{
						if (e.CurrentValue.HasHand)
								data = e.CurrentValue;
				}
예제 #29
0
 private void OnSimpleButtonAction(object sender, LMWidgets.EventArg<bool> arg)
 {
     Debug.Log ("Firing the ButtonDemo Example Button");
 }
예제 #30
0
 protected void updateRadial(object sender, LMWidgets.EventArg<float> e)
 {
     if (rotaryImage != null && showRadial)
         rotaryImage.fillAmount = e.CurrentValue;
 }