Exemplo n.º 1
0
        private void HandleControlButtonUp(byte controlId, MLInputControllerButton button)
        {
            //wrong or no control?
            if (Control == null || controlId != Control.Id)
            {
                return;
            }

            switch (button)
            {
            case MLInputControllerButton.Bumper:
                StopCoroutine("BumperHold");
                Bumper = false;
                OnBumperUp?.Invoke();
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the event for button down and cycles the raycast mode.
        /// </summary>
        /// <param name="controllerId">The id of the controller.</param>
        /// <param name="button">The button that is being pressed.</param>
        private void OnButtonDown(byte controllerId, MLInputControllerButton button)
        {
            if (_controllerConnectionHandler.IsControllerValid(controllerId) && button == MLInputControllerButton.Bumper)
            {
                //maybe should clean up
                MeshRenderer gameObjectRenderer = _raycastController.gameObject.GetComponent <MeshRenderer>();
                Material     newMaterial        = new Material(Shader.Find("GreenCursor"));

                newMaterial.color = Color.blue;
                // gameObjectRenderer.material = newMaterial;
                //Thread.Sleep(10000);ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssxxxxxxxxxxxxxxxx

                //_raycastMode = (RaycastMode)((int)(_raycastMode + 1) % _modeCount);
                UpdateRaycastMode();
                UpdateStatusText();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the event for button down. Changes render mode if bumper is pressed or
        /// changes from bounded to boundless and viceversa if home button is pressed.
        /// </summary>
        /// <param name="controllerId">The id of the controller.</param>
        /// <param name="button">The button that is being released.</param>
        private void OnButtonDown(byte controllerId, MLInputControllerButton button)
        {
            if (_controllerConnectionHandler.IsControllerValid(controllerId))
            {
                if (button == MLInputControllerButton.Bumper)
                {
                    _renderMode = (MeshingVisualizer.RenderMode)((int)(_renderMode + 1) % _renderModeCount);
                    _meshingVisualizer.SetRenderers(_renderMode);
                }
                else if (button == MLInputControllerButton.HomeTap)
                {
                    _bounded = !_bounded;

                    _mlSpatialMapper.gameObject.transform.localScale = _bounded ? _boundedExtentsSize : _boundlessExtentsSize;
                }
            }
        }
 private void HandleOnButtonDown(byte controllerId, MLInputControllerButton button)
 {
     if (_controllerConnectionHandler.IsControllerValid(controllerId))
     {
         if (button == MLInputControllerButton.HomeTap)
         {
             for (int i = 0; i < _vignette.Count; i++)
             {
                 _vignette[i].CycleVignetteState();
             }
         }
         else if (button == MLInputControllerButton.HomeTap)
         {
             // _vignette.Reset();
         }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="controllerId"></param>
        /// <param name="button"></param>
        void HandleControllerButtonDown(byte controllerId, MLInputControllerButton button)
        {
            if (!_controller.IsControllerValid(controllerId))
            {
                return;
            }

            if (button == MLInputControllerButton.Bumper)
            {
                Vector3 position = _controller.transform.position + _controller.transform.forward * _distance;
                CreateContent(position, _controller.transform.rotation);
            }
            else if (button == MLInputControllerButton.HomeTap)
            {
                _pcfVisualizer.ToggleDebug();
            }
        }
    void OnButtonDown(byte controller_id, MLInputControllerButton button)
    {
        if ((button == MLInputControllerButton.Bumper))
        {
            _bumper = true;



            _beginAnimation = true;

            GameObject newObject = Instantiate(cloneObject);

            // transform tutorial
            // unity tutorial

            newObject.transform.parent = GameObject.Find("GameObject1").transform;
        }
    }
Exemplo n.º 7
0
    void OnButtonUp(byte controller_id, MLInputControllerButton button)
    {
        if (button == MLInputControllerButton.Bumper)
        {
            _bumperPressed = false;
        }
        else if (button == MLInputControllerButton.HomeTap)
        {
            _homePressed = false;
        }

        if (_curScreen == -1)
        {
            _Settings.SetActive(false);
            _screens[_storedScreen].SetActive(true);
            _curScreen = _storedScreen;
        }
    }
Exemplo n.º 8
0
        /// <summary>
        /// Handles the event for button down. Changes render mode if bumper is pressed or
        /// changes from bounded to boundless and viceversa if home button is pressed.
        /// </summary>
        /// <param name="controller_id">The id of the controller.</param>
        /// <param name="button">The button that is being released.</param>
        private void OnButtonDown(byte controller_id, MLInputControllerButton button)
        {
            if (button == MLInputControllerButton.Bumper)
            {
                _renderMode = (MeshingVisualizer.RenderMode)((int)(_renderMode + 1) % _renderModeCount);
                _meshingVisualizer.SetRenderers(_renderMode);
            }
            if (button == MLInputControllerButton.HomeTap)
            {
                _bounded = !_bounded;

                _visualBounds.SetActive(_bounded);
                _mlSpatialMapper.gameObject.transform.localScale = _bounded ? _boundedExtentsSize : _boundlessExtentsSize;
            }


            UpdateStatusText();
        }
Exemplo n.º 9
0
    void OnButtonUp(byte controller_id, MLInputControllerButton button)
    {
        if ((button == MLInputControllerButton.HomeTap))
        {
            print("HomeTap");
            if (menueIsActive)
            {
                menue.SetActive(false);
                menueIsActive = false;
            }

            else
            {
                menue.SetActive(true);
                menueIsActive = true;
            }
        }
    }
Exemplo n.º 10
0
 /// <summary>
 /// Handles the event for button down.
 /// </summary>
 /// <param name="controllerId">The id of the controller.</param>
 /// <param name="button">The button that is being pressed.</param>
 private void OnButtonDown(byte controllerId, MLInputControllerButton button)
 {
     if (_controllerConnectionHandler.IsControllerValid(controllerId) && MLInputControllerButton.Bumper == button)
     {
         if (_autoCapture)
         {
             _autoCapture = false;
             if (!_isCapturing)
             {
                 GenerateJsonReport();
             }
         }
         else
         {
             _autoCapture = true;
             TriggerAsyncCapture();
         }
     }
 }
        /// <summary>
        /// Handles the event for button down. Changes render mode if bumper is pressed or
        /// changes from bounded to boundless and viceversa if home button is pressed.
        /// </summary>
        /// <param name="controller_id">The id of the controller.</param>
        /// <param name="button">The button that is being released.</param>
        private void OnButtonDown(byte controller_id, MLInputControllerButton button)
        {
            if (button == MLInputControllerButton.Bumper)
            {
                _renderMode = (MeshingVisualizer.RenderMode)((int)(_renderMode + 1) % _renderModeCount);
                _meshingVisualizer.SetRenderers(_renderMode);
            }
            if (button == MLInputControllerButton.HomeTap)
            {
                _bounded = !_bounded;

                // Disable the bounds visual.
                _spatialMapper.ShowBounds(_bounded);
                _spatialMapper.transform.localScale = _bounded ? _boundedExtentsSize : _boundlessExtentsSize;
                _spatialMapper.ClearMesh();
            }

            UpdateStatusText();
        }
 void OnButtonDown(byte contorller_id, MLInputControllerButton button)
 {
     if (button == MLInputControllerButton.Bumper)
     {
         RaycastHit hit;
         if (Physics.Raycast(controller.Position, transform.forward, out hit))
         {
             GameObject test = hit.collider.gameObject;
             test.transform.position = new  Vector3(0, 0, 400);
         }
     }
     if (button == MLInputControllerButton.HomeTap)
     {
         GameObject globe = GameObject.Find("Globe");
         globe.transform.position = new  Vector3(0, 0, 3);
         GameObject barChart = GameObject.Find("Plane");
         barChart.transform.position = new Vector3(-0.5f, 0, 1f);
     }
 }
Exemplo n.º 13
0
 private void HandleControllerButtonUp(byte controllerId, MLInputControllerButton button)
 {
     if (_controllerConnectionHandler.IsControllerValid(controllerId))
     {
         if (_lastButtonHit != null)
         {
             if (_lastButtonHit.OnControllerButtonUp != null)
             {
                 _lastButtonHit.OnControllerButtonUp(button);
             }
             _pointerLight.color = _pointerLightColorHit;
             _isGrabbing         = false;
         }
         else
         {
             _pointerLight.color = _pointerLightColorNoHit;
         }
     }
 }
Exemplo n.º 14
0

        void MLInput_OnButtonUp(byte controller_id, MLInputControllerButton button)
        {
            //Debug.Log("On button up: " + controller_id + " (mine is " + _controller.Id + ")");
            if (controller_id != _controller.Id)
            {
                //Debug.Log("Not mine, return");
                return;
            }

            int buttonId = -1;
            switch (button)
            {
                case MLInputControllerButton.Bumper:
                    buttonId = (int)Control.Bumper;
                    break;

                case MLInputControllerButton.HomeTap:
                    buttonId = (int)Control.Home;
                    break;
            }

            Debug.Log("Button id is " + buttonId);

            if (buttonId != -1)
            {
                buttonFrameState[buttonId] = ButtonFrameState.ClickedUp;
                buttonDownState[buttonId] = false;
#if DEBUG_ML_CONTROLLER
                Debug.Log(Time.frameCount + ": Setting frame state - " + (Control)buttonId + " to up");
#endif

                Debug.Log("Do the callback");
                if (OnMagicLeapControllerButtonStateChange != null)
                {
                    OnMagicLeapControllerButtonStateChange(this, (Control)buttonId, ButtonFrameState.ClickedUp);
                }
            }
            else
            {
                Debug.LogError("Not catching a button: " + buttonId);
            }
        }
    // Home button to spawn soldier
    void OnButtonUp(byte controller_id, MLInputControllerButton button)
    {
        if (button == MLInputControllerButton.HomeTap && canBuildSoldier > 0 && Island != GameObject.Find("GameObject1") &&
            Island != GameObject.Find("GameObject4") && Island != GameObject.Find("GameObject5"))
        {
            GameObject newSoldier = Instantiate(soldierList[soldierCount % 3]) as GameObject;

            soldierCount    = soldierCount + 1;
            canBuildSoldier = canBuildSoldier - 1;

            // at some position of the island

            newSoldier.transform.parent = Island.transform;


            newSoldier.transform.localPosition = new Vector3(-((soldierCount / 5) % 3) - 1, 0, (soldierCount % 5) * (-1) + 2);

            newSoldier.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
        }
    }
Exemplo n.º 16
0
    /// <summary>
    /// Handles the event for trigger down.
    /// </summary>
    /// <param name="controllerId">The id of the controller.</param>
    /// <param name="button">The button that was pressed.</param>
    private void HandleOnButtonDown(byte controllerId, MLInputControllerButton button)
    {
        MLInputController controller = _controllerConnectionHandler.ConnectedController;

        if (controller != null && controller.Id == controllerId)
        {
            if (button == MLInputControllerButton.HomeTap &&
                GameStateManager.instance.currentGamePhase == GameStateManager.Phase.ONBOARDING_P1)
            {
                Bomb.transform.SetParent(transform);
                var rb = Bomb.GetComponent <Rigidbody>();
                rb.AddForce(Vector3.zero);
                rb.useGravity           = false;
                rb.isKinematic          = true;
                rb.constraints          = RigidbodyConstraints.None;
                Bomb.transform.position = Bomb.transform.parent.position;
                GameStateManager.instance.currentGamePhase = GameStateManager.Phase.PLACING_BOMB;
            }
        }
    }
Exemplo n.º 17
0
        /// <summary>
        /// Toggles the placement of the plant model.
        /// </summary>
        /// <param name="controllerId"></param>
        /// <param name="button"></param>
        private void HandleOnButtonDown(byte controllerId, MLInputControllerButton button)
        {
            if (button == MLInputControllerButton.Bumper)
            {
                if (_plantModel.transform.parent == null)
                {
                    _raycastCursor.gameObject.SetActive(true);

                    _plantModel.transform.SetParent(_raycastCursor);
                    _plantModel.transform.localPosition = Vector3.zero;
                    _plantModel.transform.localRotation = Quaternion.Euler(90, 0, 0);
                }
                else if (_plantModel.transform.parent == _raycastCursor)
                {
                    _raycastCursor.gameObject.SetActive(false);

                    _plantModel.transform.SetParent(null);
                }
            }
        }
Exemplo n.º 18
0
        private void HandleOnButtonDown(byte controllerId, MLInputControllerButton button)
        {
            if (_controllerConnectionHandler.IsControllerValid(controllerId))
            {
                if (_canCapture && button == MLInputControllerButton.Bumper)
                {
                    _captureMode = (_captureMode == CaptureMode.Delayed) ? CaptureMode.Inactive : _captureMode + 1;

                    // Stop & Start to clear the previous mode.
                    if (_isCapturing)
                    {
                        StopCapture();
                    }

                    if (_captureMode != CaptureMode.Inactive)
                    {
                        StartCapture();
                    }
                }
            }
        }
Exemplo n.º 19
0
 ///<summary>
 /// Handles the event for button up.
 ///</summary>
 /// <param name="controller_id">The id of the controller.</param>
 /// <param name="button">The button that is being pressed.</param>
 private void OnControllerButtonUp(byte controller_id, MLInputControllerButton button)
 {
     #if !UNITY_EDITOR // Removing calibration step from ML Remote Host builds.
     // Reset to new calibration spot in front of view.
     if (button == MLInputControllerButton.HomeTap)
     {
         if (!_isCalibrated)
         {
             // Calculate the calibration offsets.
             _calibratedPosition    = _calibratedPosition - _controller.Position;
             _calibratedOrientation = _calibratedOrientation * Quaternion.Inverse(_controller.Orientation);
         }
         else
         {
             // If already calibrated then reset to static calibration in front of view.
             ResetTransform();
         }
         _isCalibrated = !_isCalibrated;
     }
     #endif
 }
Exemplo n.º 20
0
        /// <summary>
        /// Handles the event for button up.
        /// </summary>
        /// <param name="controllerId">The id of the controller.</param>
        /// <param name="button">The button that is being released.</param>
        private void HandleOnButtonUp(byte controllerId, MLInputControllerButton button)
        {
            if (_controllerConnectionHandler.IsControllerValid() && _controllerConnectionHandler.ConnectedController.Id == controllerId)
            {
                if (button == MLInputControllerButton.Bumper)
                {
                    // Sets the color of the Bumper to the default color.
                    _bumperButtonMaterial.color = _defaultColor;
                }

                else if (button == MLInputControllerButton.HomeTap)
                {
                    // Note: HomeTap is NOT a button. It's a physical button on the controller.
                    // But in the application side, the tap registers as a ButtonUp event and there is NO
                    // ButtonDown equivalent. We cannot detect holding down the Home (button). The OS will
                    // handle it as either a return to the icon grid or turning off the controller.
                    _homeButtonMaterial.color = _activeColor;
                    StartCoroutine(RestoreHomeColor());
                }
            }
        }
    void OnButtonUp(byte controller_id, MLInputControllerButton button)
    {
        if (button == MLInputControllerButton.HomeTap)
        {
            _enabled = !_enabled;

            if (_enabled)
            {
                exitObj.SetActive(true);
            }
            else
            {
                exitObj.SetActive(false);
                GameObject.FindGameObjectWithTag("ActivitySequenceManager").GetComponent <ActivitySequenceManager>().goToNextActivity();
            }
        }

        if (button == MLInputControllerButton.Bumper)
        {
            _bumper = false;
        }
    }
Exemplo n.º 22
0
        private void HandleControlButtonDown(byte controlId, MLInputControllerButton button)
        {
            //wrong or no control?
            if (Control == null || controlId != Control.Id)
            {
                return;
            }

            switch (button)
            {
            case MLInputControllerButton.Bumper:
                StartCoroutine("BumperHold");
                Bumper = true;
                OnBumperDown?.Invoke();

                //double?
                if (Time.realtimeSinceStartup - _lastBumperTime < _bumperDoubleTapDuration)
                {
                    OnDoubleBumper?.Invoke();
                }

                _lastBumperTime = Time.realtimeSinceStartup;
                break;

            case MLInputControllerButton.HomeTap:
                OnHomeButtonTap?.Invoke();

                //double?
                if (Time.realtimeSinceStartup - _lastHomeTime < _homeDoubleDuration)
                {
                    OnDoubleHome?.Invoke();
                }

                _lastHomeTime = Time.realtimeSinceStartup;
                break;
            }
        }
Exemplo n.º 23
0
    void HandleOnButtonDown(byte controller_id, MLInputControllerButton button)
    {
        // Callback - Button Down
        if (button == MLInputControllerButton.Bumper)
        {
            _bumperIndex++;
            BtnState = ButtonStates.Pressed;

            //Our code
            if (_bumperIndex < 3)
            {
                _audioSource.Play();
                _textController.NextItem();
            }

            if (_bumperIndex == 3)
            {
                _textController.gameObject.SetActive(false);
                FruitTray.SetActive(true);
            }

            if (_bumperIndex == 4)
            {
                Hydroponics_1.SetActive(true);
                FruitTray.SetActive(false);
            }
            if (_bumperIndex == 5)
            {
                Hydroponics_2.SetActive(true);
            }
            if (_bumperIndex == 6)
            {
                Hydroponics_3.SetActive(true);
            }
        }
    }
Exemplo n.º 24
0
        /// <summary>
        /// Handles the event for button down. Changes render mode if bumper is pressed or
        /// changes from bounded to boundless and viceversa if home button is pressed.
        /// </summary>
        /// <param name="controller_id">The id of the controller.</param>
        /// <param name="button">The button that is being released.</param>
        private void OnButtonDown(byte controller_id, MLInputControllerButton button)
        {
            if (button == MLInputControllerButton.Bumper || button == MLInputControllerButton.Move)
            {
                _renderMode = (MeshingVisualizer.RenderMode)((int)(_renderMode + 1) % _renderModeCount);
                _meshingVisualizer.SetRenderers(_renderMode);
            }
            // On MLMA, trigger is represented with the app button.
            if (button == MLInputControllerButton.App)
            {
                OnTriggerDown(0, 1.0f);
            }
            if (button == MLInputControllerButton.HomeTap)
            {
                _bounded = !_bounded;

                // Disable the bounds visual.
                _spatialMapper.ShowBounds(_bounded);
                _spatialMapper.transform.localScale = _bounded ? _boundedExtentsSize : _boundlessExtentsSize;
                _spatialMapper.ClearFragments();
            }

            UpdateStatusText();
        }
Exemplo n.º 25
0
    void OnButtonUp(byte controller_id, MLInputControllerButton button)
    {
        //Debug.Log("On button up!");
        string curState = PickPlaceState.GetComponent <PickAndPlaceState>().GetState();

        if (button == MLInputControllerButton.HomeTap) //Home Button tapped
        {
            if (curState == "CALIBRATE")               //Robot calibration is on. We should switch to stable mode, and turn off the laser
            {
                LaserEnd.transform.parent.transform.parent.transform.parent.gameObject.SetActive(false);
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("STABLE");
            }

            if (curState == "STABLE") //Robot is in stable mode. Should switchg to calibrate mode, and turn on laser
            {
                LaserEnd.transform.parent.transform.parent.transform.parent.gameObject.SetActive(true);
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("CALIBRATE");
            }

            if (curState == "SELECT_ITEM_MESH") //in menu screen and home button, should global reset to stable.
            {
                menu.SetActive(false);
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("STABLE");
            }
            if (curState == "SELECT_ITEM_POSE" || curState == "SELECT_GRASP_POSE" || curState == "SELECT_PICK_POSE" || curState == "SELECT_PLACE_POSE" || curState == "SELECT_PLACE_LOC_POSE")
            {
                Destroy(SetParentGO);
                LaserEnd.transform.parent.transform.parent.transform.parent.gameObject.SetActive(false);
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("STABLE");
            }
        }

        if (button == MLInputControllerButton.Bumper) //bumper tapped
        {
            if (curState == "CALIBRATE")
            {
                robot.transform.position = LaserEnd.transform.position;
            }
            if (curState == "STABLE") //Robot is in stable mode. Should switchg to SelectItemMesh mode, turn on menu
            {
                menu.SetActive(true);
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("SELECT_ITEM_MESH");
            }
            if (curState == "SELECT_ITEM_MESH") //select item mesh is on. Switch to SetItemPose, deactivate menu, get grounded item model, set it to child of Grounded Items, reactive laser.
            {
                menu.SetActive(false);
                SetItemGO   = Instantiate(menu.GetComponent <MenuScriptPickAndPlace>().getSelectedGO());
                SetParentGO = new GameObject(SetItemGO.name);
                SetParentGO.transform.SetParent(GroundedItems.transform);
                SetItemGO.transform.SetParent(SetParentGO.transform);

                SetItemGO.name = "PICK_ITEM";

                SetParentGO.transform.localRotation = Quaternion.identity;
                SetParentGO.transform.localPosition = Vector3.zero;

                SetItemGO.transform.localRotation = Quaternion.identity;
                SetItemGO.transform.localPosition = Vector3.zero;

                SetParentGO.transform.localPosition = new Vector3(0, 0, 0);
                LaserEnd.transform.parent.transform.parent.transform.parent.gameObject.SetActive(true);
                LaserEnd.transform.localPosition = new Vector3(0, 0.1f, 0);
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("SELECT_ITEM_POSE");
            }
            if (curState == "SELECT_ITEM_POSE") //select item pose is on. Switch to End Effector Pose. Add End Effector to scene. Make it child of SetItemGO.
            {
                //Debug.Log("Select grasp pose has changed");
                SetGraspGO = Instantiate(EECopyModel);
                Debug.Log("enter color");
                Material    colormat     = SetItemGO.GetComponent <MeshRenderer>().material;
                Component[] partsToColor = SetGraspGO.GetComponentsInChildren <MeshRenderer>();

                foreach (MeshRenderer colorpart in partsToColor)
                {
                    Debug.Log("COLORING!");
                    colorpart.material = colormat;
                }

                //GameObject wtf = Instantiate(UnityRobotLeftHand, robot.transform.GetChild(0)).gameObject;
                //GameObject wtf = Instantiate(robot).gameObject;
                //GameObject wtff = wtf.Find("left_ee_link");
                //wtf.name = "wtf";
                SetGraspGO.name = "GRASP_POSE_PICK";
                //GameObject wtff = wtf.transform.GetChild(0).GetChild(1).GetChild(2).GetChild(2).GetChild(2).GetChild(5).GetChild(2).GetChild(2).GetChild(2).GetChild(2).GetChild(2).GetChild(2).GetChild(2).GetChild(2).GetChild(2).gameObject;
                //Debug.Log
                //Quaternion globpos = wtff.transform.rotation;
                // Debug.Log("Glob1");
                //Debug.Log(wtff.transform.rotation);
                //Quaternion wtffpos = wtff.transform.localRotation;

                //wtff.transform.SetParent(SetGraspGO.transform, true);
                //Debug.Log("Glob2");
                //wtff.transform.rotation = globpos;
                //Debug.Log(wtff.transform.rotation);

                //wtff.transform.localRotation = wtffpos;


                //SetGraspGO.transform.SetParent(SetItemGO.transform); //REDO THIS LATER
                SetGraspGO.transform.SetParent(SetParentGO.transform);

                SetGraspGO.transform.localRotation = Quaternion.identity;
                SetGraspGO.transform.localPosition = Vector3.zero;

                //SetGraspGO.transform.SetParent(SetParentGO.transform);

                //Debug.Log("Scoop scoop");
                //Debug.Log(ROSRobotLeftHand.getRotation());
                //Debug.Log(ROSRobotLeftHand.getRotation().eulerAngles);
                //SetGraspGO.transform.localRotation = ROSRobotLeftHand.getRotation(); //apply rotation to the temp object
                //Debug.Log("(ERIC) UNITY quaterion to be sent - temp");
                //Debug.Log(SetGraspGO.transform.localRotation);
                //Debug.Log("Rotaiton values of unity hand are below");
                //Debug.Log(UnityRobotLeftHand.transform.rotation);
                //SetGraspGO.transform.GetChild(0).rotation = ROSRobotLeftHand.getRotation();
                //SetGraspGO.transform.GetChild(0).rotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
                //Debug.Log("UnityRobotLeftHandGlobal");
                //Debug.Log(SetGraspGO.transform.GetChild(0).localRotation.eulerAngles);
                //Debug.Log("UnityVirtualLeftHandGlobal");
                //Debug.Log(ROSRobotLeftHand.getRotation());
                //SetGraspGO.transform.GetChild(0).localRotation = Quaternion.Inverse(UnityRobotLeftHand.transform.rotation) * robot.transform.rotation;
                //wtf.transform.rotation = Quaternion.Inverse(UnityRobotLeftHand.transform.rotation)*robot.transform.rotation;


                //Debug.Log("Instantied a grasper!");

                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("SELECT_GRASP_POSE");
            }
            if (curState == "SELECT_GRASP_POSE")                     //select item pose is on. Switch to End Effector Pose. Add End Effector to scene. Make it child of SetItemGO.
            {
                SetItemGO.transform.SetParent(SetGraspGO.transform); //already placed the gripper, make it a child of object
                SetPickGO = Instantiate(SetPoseCopyModel);

                Material    colormat     = SetItemGO.GetComponent <MeshRenderer>().material;
                Component[] partsToColor = SetPickGO.GetComponentsInChildren <MeshRenderer>();

                foreach (MeshRenderer colorpart in partsToColor)
                {
                    Debug.Log("COLORING!");
                    colorpart.material = colormat;
                }

                SetPickGO.name = "PICK_LOC";
                LaserEnd.transform.localPosition = new Vector3(0, 1.5f, 0);
                //Debug.Log("Instantied a go to!");
                SetPickGO.transform.SetParent(SetParentGO.transform);
                SetPickGO.transform.localRotation = Quaternion.identity;
                SetPickGO.transform.localPosition = Vector3.zero;
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("SELECT_PICK_POSE");
            }

            if (curState == "SELECT_PICK_POSE")
            {
                //SetPlaceGO = Instantiate(menu.GetComponent<MenuScriptPickAndPlace>().getSelectedGO());
                //eric you touched this line below last
                //SetPlaceGO = Instantiate(SetGraspGO);
                SetPlaceGO      = Instantiate(EECopyModel);
                SetPlaceGO.name = "GRASP_POSE_PLACE";
                LaserEnd.transform.localPosition = new Vector3(0, 0.1f, 0);
                SetPlaceGO.transform.SetParent(SetParentGO.transform);
                SetPlaceGO.transform.localRotation = Quaternion.identity;
                SetPlaceGO.transform.localPosition = Vector3.zero;
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("SELECT_PLACE_POSE");
            }


            if (curState == "SELECT_PLACE_POSE") //go into mode to place final base
            {
                SetPlaceLocGO = Instantiate(SetPoseCopyModel);

                Material    colormat     = SetItemGO.GetComponent <MeshRenderer>().material;
                Component[] partsToColor = SetPlaceLocGO.GetComponentsInChildren <MeshRenderer>();

                foreach (MeshRenderer colorpart in partsToColor)
                {
                    Debug.Log("COLORING!");
                    colorpart.material = colormat;
                }

                LaserEnd.transform.localPosition = new Vector3(0, 1.5f, 0);

                SetPlaceLocGO.name = "PLACE_LOC";
                Debug.Log("Instantied a go to!");
                SetPlaceLocGO.transform.SetParent(SetParentGO.transform);
                SetPlaceLocGO.transform.localRotation = Quaternion.identity;
                SetPlaceLocGO.transform.localPosition = Vector3.zero;
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("SELECT_PLACE_LOC_POSE");
            }

            if (curState == "SELECT_PLACE_LOC_POSE")
            {
                //Correc the GRASP POSE
                SetGraspGO.transform.SetParent(SetParentGO.transform);
                //SetPlaceGO.transform.GetChild(0).name = "GRASP_POSE_PLACE";
                //SetPlaceGO.transform.GetChild(0).SetParent(SetParentGO.transform);
                LaserEnd.transform.parent.transform.parent.transform.parent.gameObject.SetActive(false);
                PickPlaceState.GetComponent <PickAndPlaceState>().SetState("STABLE");
            }
        }
    }
Exemplo n.º 26
0
 void OnButtonDown(byte controller_id, MLInputControllerButton button)
 {
 }
 /// <summary>
 /// Returns true if given MLInputControllerButton has been released during this frame (just one frame).
 /// </summary>
 public bool IsButtonReleased(MLInputControllerButton button)
 {
     return(buttons[(int)button] == ButtonState.Released);
 }
Exemplo n.º 28
0
 private void OnButtonDown(byte controllerId, MLInputControllerButton button)
 {
 }
 private void HandleOnButtonUp(byte controllerId, MLInputControllerButton button)
 {
 }
Exemplo n.º 30
0
 void OnButtonDown(byte controller_id, MLInputControllerButton button)
 {
     Debug.Log("Button pressed");
     text.text = "Is it changed?";
     //StartCoroutine(SendRequest());
 }