Example #1
0
 private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
 {
     //入力ソースの種類を取得
     InteractionSourceKind kind = obj.state.source.kind;
     //検出時の入力ソースのID(消失するまで同じID)
     var id = obj.state.source.id;
 }
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
    {
        // Check to see that the source is a hand.
        if (args.state.source.kind != InteractionSourceKind.Hand)
        {
            return;
        }

        trackedHands.Add(args.state.source.id);

        //Check which hand to activate
        Vector3 headDir = args.state.headPose.forward;

        Vector3 handPos = new Vector3();
        Vector3 handDir = new Vector3();

        if (args.state.sourcePose.TryGetPosition(out handPos))
        {
            handDir = Vector3.Normalize(handPos - args.state.headPose.position);
        }

        //Activate the correct hand hand and assign it an id
        if (Vector3.Dot(Vector3.Cross(headDir, handDir), Vector3.up) < 0 && !leftHand.activeSelf)
        {
            leftHand.SetActive(true);
            leftHand.GetComponent <Hand>().id = args.state.source.id;
        }
        else if (Vector3.Dot(Vector3.Cross(headDir, handDir), Vector3.up) > 0 && !rightHand.activeSelf)
        {
            rightHand.SetActive(true);
            rightHand.GetComponent <Hand>().id = args.state.source.id;
        }
    }
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
    {
        uint id = args.state.source.id;

        // Check to see that the source is a hand.
        if (args.state.source.kind != InteractionSourceKind.Hand)
        {
            return;
        }

        trackedHands.Add(id);
        activeId = id;

        var obj = Instantiate(TrackingObject) as GameObject;

        obj.transform.localRotation = this.transform.GetChild(0).rotation;


        Vector3 pos;

        if (args.state.sourcePose.TryGetPosition(out pos))
        {
            obj.transform.localPosition = pos;
        }


        trackingObject.Add(id, obj);
    }
Example #4
0
 private void SourceManager_OnInteractionSourceDetected(InteractionSourceDetectedEventArgs args)
 {
     if (args.state.source.kind == InteractionSourceKind.Hand)
     {
         HandsVisible = true;
     }
 }
Example #5
0
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
    {
        uint id = obj.state.source.id;

        if (obj.state.source.kind != InteractionSourceKind.Controller)
        {
            return;
        }

        if (!trackingObject.ContainsKey(id))
        {
            GameObject objPrefab = null;
            if (obj.state.source.handedness == InteractionSourceHandedness.Left)
            {
                objPrefab = Instantiate(LeftPrefab);
            }
            else if (obj.state.source.handedness == InteractionSourceHandedness.Right)
            {
                objPrefab = Instantiate(RightPrefab);
            }
            if (objPrefab)
            {
                objPrefab.transform.SetParent(cameraRig);
                trackingObject.Add(id, objPrefab);
            }
        }
    }
Example #6
0
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
    {
        if (!is_holding_object)
        {
            return;
        }
        uint id = args.state.source.id;

        // Check to see that the source is a hand.
        if (args.state.source.kind != InteractionSourceKind.Hand)
        {
            return;
        }

        trackedHands.Add(id);
        activeId = id;

        var     obj = Instantiate(curObject) as GameObject;
        Vector3 pos;

        if (args.state.sourcePose.TryGetPosition(out pos))
        {
            //obj.transform.position = pos + (m_MainCamera.transform.forward) * 0.5f;
            obj.transform.localPosition = pos; // - m_MainCamera.transform.right * 2.5f; // left
            //+ (m_MainCamera.transform.forward) * 0.1f
        }

        trackingObject.Add(id, obj);
    }
Example #7
0
    private void SourceDetected(InteractionSourceDetectedEventArgs args)
    {
        if (args.state.source.kind != InteractionSourceKind.Hand)
        {
            return;
        }

        if (hand == null)
        {
            hand = new GameObject("hololens_hand");
            TransformPublisher tf = hand.AddComponent <TransformPublisher>();
            tf.frame_id         = "marker";
            tf.child_frame_id   = "hololens_hand";
            tf.parentGameObject = GameObject.FindGameObjectWithTag("world_anchor");
        }

        //GameObject hand = new GameObject("hololens_hand_" + args.state.source.id);
        //TransformPublisher tf = hand.AddComponent<TransformPublisher>();
        //tf.frame_id = "marker";
        //tf.child_frame_id = "hololens_hand_" + args.state.source.id;
        //tf.parentGameObject = GameObject.FindGameObjectWithTag("world_anchor");

        Vector3 position;

        if (args.state.sourcePose.TryGetPosition(out position))
        {
            hand.transform.position = position;
        }

        //hands.Add(args.state.source.id, hand);
    }
Example #8
0
    private void SourceFound(InteractionSourceDetectedEventArgs obj)
    {
        if (obj.state.source.kind.ToString() != "Hand")
        {
            return;
        }

        InteractionSource source = obj.state.source;

        //Rob: I am destroying the mesh renderers for the hands spheres.
        if (handOne.obj == null)
        {
            handOne.obj = Instantiate(HandPrefab);
            handOne.obj.GetComponent <HandObject.Hand>().handDetection = this;
            handOne.obj.transform.localScale = scale;
            handOne.ID = obj.state.source.id;

            if (obj.state.sourcePose.TryGetPosition(out handOne.pos))
            {
                handOne.obj.transform.position = handOne.pos;
            }
        }
        else if (handTwo.obj == null)
        {
            handTwo.obj = Instantiate(HandPrefab);
            handTwo.obj.GetComponent <HandObject.Hand>().handDetection = this;
            handTwo.obj.transform.localScale = scale;
            handTwo.ID = obj.state.source.id;

            if (obj.state.sourcePose.TryGetPosition(out handTwo.pos))
            {
                handTwo.obj.transform.position = handTwo.pos;
            }
        }
    }
Example #9
0
 private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
 {
     if (InteractionSourceDetected != null)
     {
         InteractionSourceDetected(obj);
     }
 }
Example #10
0
    /* ############################################
     * STARTING FROM HERE IS THE HAND TRACKING CODE
     * ############################################
     */
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
    {
        uint id = args.state.source.id;

        // make sure that the source is a hand
        if (args.state.source.kind != InteractionSourceKind.Hand)
        {
            return;
        }
        // add hand to trackedHands if not already added
        if (!trackedHands.Contains(id))
        {
            trackedHands.Add(id);
        }
        //activeId = id;

        var     obj = Instantiate(handBox) as HandBoxController;
        Vector3 pos;

        if (args.state.sourcePose.TryGetPosition(out pos))
        {
            obj.transform.position = pos;
            obj.changeInstructions(instruction.colorChoice, instruction.layerChoice);
        }

        // add object to trackedObjects if not already added
        if (!trackedObjects.ContainsKey(id))
        {
            trackedObjects.Add(id, obj);
        }
    }
Example #11
0
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            if (args.state.source.kind == InteractionSourceKind.Controller)
            {
                string productId = MakeProductIdHash(args.state.source);
                if (!cachedModels.ContainsKey(productId) && !loadingModels.Contains(productId))
                {
                    loadingModels.Add(productId);
                    IntPtr controllerModel = new IntPtr();
                    uint   outputSize      = 0;
                    if (TryGetMotionControllerModel(args.state.source.id, out outputSize, out controllerModel))
                    {
                        byte[] fileBytes;
                        fileBytes = new byte[Convert.ToInt32(outputSize)];
                        Marshal.Copy(controllerModel, fileBytes, 0, Convert.ToInt32(outputSize));
                        AddController(args.state.source.id, productId, fileBytes);
                    }
                    else
                    {
#if TRACING_VERBOSE
                        Debug.LogError("Failed to load design-time controller model. This is not expected");
#endif
                        loadingModels.Remove(productId);
                    }
                }
            }
        }
Example #12
0
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            // NOTE: We update the source state data, in case an app wants to query it on source detected.
            UpdateSourceData(args.state, GetOrAddSourceData(args.state.source));

            InputManager.Instance.RaiseSourceDetected(this, args.state.source.id);
        }
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            uint id = args.state.source.id;

            // Check to see that the source is a hand.
            if (args.state.source.kind != InteractionSourceKind.Hand)
            {
                //StatusText.text = "Tracking failed..";
                return;
            }
            //StatusText.text = "Tracking..";
            trackedHands.Add(id);
            activeId = id;

            //GameObject obj = Instantiate(TrackingObject);
            TrackingObject.SetActive(true);
            Vector3 pos;

            if (args.state.sourcePose.TryGetPosition(out pos))
            {
                //obj.transform.position = pos;
                TrackingObject.transform.position = pos;
                //StatusText.text = "SetPos";
            }

            trackingObject.Add(id, TrackingObject);
        }
 private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
 {
     // 手の認識時のコールバック
     if (state == RingCommandState.INACTIVE)
     {
         StartFadeIn();
     }
 }
Example #15
0
 /// <summary>
 /// 入力ソースが検出されたときの処理
 /// </summary>
 /// <param name="obj">入力情報</param>
 private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
 {
     // モーションコントローラーを認識してID取得
     if (obj.state.source.handedness == hand)
     {
         id = obj.state.source.id;
     }
 }
 private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
 {
     // We only want to attempt loading a model if this source is actually a controller.
     if (obj.state.source.kind == InteractionSourceKind.Controller && !controllerDictionary.ContainsKey(obj.state.source.id))
     {
         StartCoroutine(LoadControllerModel(obj.state.source));
     }
 }
    private void Foo(InteractionSourceDetectedEventArgs obj)
    {
        Vector3 position;

        if (obj.state.sourcePose.TryGetPosition(out position))
        {
        }
    }
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs eventArgs)
    {
        uint id = eventArgs.state.source.id;

        if (eventArgs.state.source.supportsPointing)
        {
            this.AddDevice(id);
        }
    }
Example #19
0
 private void InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
 {
     if (obj.state.source.kind == InteractionSourceKind.Controller &&
         !_controllers.ContainsKey(obj.state.source.id))
         _controllers.Add(obj.state.source.id, new MotionControllerState
         {
             Handedness =
                 obj.state.source.handedness
         });
 }
        protected virtual void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            InteractionSourceState state  = args.state;
            InteractionSource      source = state.source;

            if (source.kind == InteractionSourceKind.Controller && source.handedness == handedness)
            {
                SetupController(source);
            }
        }
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            // Check to see that the source is a hand.
            if (args.state.source.kind != InteractionSourceKind.Hand)
            {
                return;
            }

            trackedHands.Add(args.state.source.id);
        }
        /// <summary>
        /// SDK Interaction Source Detected Event handler
        /// </summary>
        /// <param name="args">SDK source detected event arguments</param>
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            var controller = GetOrAddController(args.state);

            if (controller != null)
            {
                InputSystem?.RaiseSourceDetected(controller.InputSource, controller);
            }

            controller?.UpdateController(args.state);
        }
//	void InteractionManager_InteractionSourcePressed (InteractionSourcePressedEventArgs evt)
//	{
//		if(evt.state.source.kind == InteractionSourceKind.Controller && evt.pressType == InteractionSourcePressType.Select)
//		{
//			inputAction = MultiARInterop.InputAction.Click;
//			inputNavCoordinates = Vector3.zero;
//			startMousePos = handPosition;
//			startTimestamp = inputTimestamp = lastFrameTimestamp;
//
//			isHandGripping = true;  // evt.state.anyPressed;
//			GetHandPosAndDir(evt.state.sourcePose, evt.state.source.kind == InteractionSourceKind.Controller);
//		}
//	}

//	void InteractionManager_InteractionSourceReleased (InteractionSourceReleasedEventArgs evt)
//	{
//		if(evt.state.source.kind == InteractionSourceKind.Controller && inputAction == MultiARInterop.InputAction.Grip)
//		{
//			inputAction = MultiARInterop.InputAction.Release;
//			inputTimestamp = lastFrameTimestamp;
//
//			isHandGripping = false;  // evt.state.anyPressed;
//			GetHandPosAndDir(evt.state.sourcePose, evt.state.source.kind == InteractionSourceKind.Controller);
//		}
//	}

//	void InteractionManager_InteractionSourceUpdated (InteractionSourceUpdatedEventArgs obj)
//	{
//		if(obj.state.thumbstickPressed)
//		{
//			inputAction = MultiARInterop.InputAction.Grip;
//			inputNavCoordinates = obj.state.thumbstickPosition;
//			inputTimestamp = lastFrameTimestamp;
//		}
//	}

    void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs evt)
    {
        if (evt.state.source.kind == InteractionSourceKind.Hand ||
            (evt.state.source.kind == InteractionSourceKind.Controller && evt.state.source.handedness == controllerHandedness))
        {
            handDetected = true;

            isHandGripping = evt.state.anyPressed;
            GetHandPosAndDir(evt.state.sourcePose, evt.state.source.kind == InteractionSourceKind.Controller);
        }
    }
    private void InteractionManager_SourceDetected(InteractionSourceDetectedEventArgs args)
#endif
    {
        var state = args.state;

        TraceHelper.Log("Source Detected:" + state.source.id);
        if (state.source.supportsPointing)
        {
            this.AddDevice(state.source);
        }
    }
Example #25
0
    private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
    {
        //Debug.LogFormat("{0} {1} Detected", obj.state.source.handedness, obj.state.source.kind);

        if (obj.state.source.kind == InteractionSourceKind.Controller && !controllers.ContainsKey(obj.state.source.id))
        {
            controllers.Add(obj.state.source.id, new ControllerState {
                Handedness = obj.state.source.handedness
            });
        }
    }
Example #26
0
 private void InteractionManager_SourceDetected(InteractionSourceDetectedEventArgs obj)
 {
     if (state != State.NoDrawing)
     {
         if (obj.state.source.kind == InteractionSourceKind.Hand)
         {
             offset = Camera.main.transform.forward / 2;
             oldPos = gameObject.transform.position;
             //state = State.FirstClick;
         }
     }
 }
Example #27
0
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            if (args.state.source.kind == InteractionSourceKind.Controller)
            {
                AddInputSource(args.state.source.id, InputSourceKind.MotionController);
            }
#if DEBUG
            else
            {
                Debug.Log("Ignoring source: " + args.state.source.kind);
            }
#endif
        }
        /// <summary>
        /// SDK Interaction Source Detected Event handler
        /// </summary>
        /// <param name="args">SDK source detected event arguments</param>
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
        {
            bool raiseSourceDetected = !activeControllers.ContainsKey(args.state.source.id);

            var controller = GetController(args.state.source);

            if (controller != null && raiseSourceDetected)
            {
                MixedRealityToolkit.InputSystem?.RaiseSourceDetected(controller.InputSource, controller);
            }

            controller?.UpdateController(args.state);
        }
Example #29
0
        void SourceDetected(InteractionSourceDetectedEventArgs state)
        {
            Vector3 v;

            if (state.state.sourcePose.TryGetPosition(out v) == true)
            {
                HandPointList.Add(new HandPointClass(state.state.source.id, v));
                if (onDetected != null)
                {
                    onDetected(HandPointList[HandPointList.Count - 1]);
                }
            }
        }
Example #30
0
        private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs obj)
        {
            if ((obj.state.source.handedness == InteractionSourceHandedness.Left) == Hand.IsLeft)
            {
                if (loading)
                {
                    return;
                }

                loading = true;
                StartCoroutine(LoadSourceControllerModel(obj.state.source));
            }
        }