public void OnEvent(StartInteractionConceptEvent e)
 {
     if (e.newConcept == InteractionConcept.Selection)
     {
         Hint.Display("HowToNavigateHint");
     }
 }
Example #2
0
    public void OnEvent(StartInteractionConceptEvent e)
    {
        if (e.newConcept == InteractionConcept.Idle)
        {
            VRTK_ControllerEvents leftController  = VRTK.VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();
            VRTK_ControllerEvents rightController = VRTK.VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();

            startScaleRotate = new ControllerInteractionEventHandler(StartScaleRotate);
            leftController.TriggerTouchStart += startScaleRotate;


            startSelectNavigate = new ControllerInteractionEventHandler(StartSelectNavigate);
            rightController.TriggerTouchStart += startSelectNavigate;

            Hint.Display("BuildingSelectionTriggerHint");
            Hint.Display("ScaleTranslateTriggerHint");
        }
    }
Example #3
0
    public void OnEvent(StartInteractionConceptEvent e)
    {
        if (e.newConcept == InteractionConcept.ScaleRotate)
        {
            VRTK_ControllerEvents leftController = VRTK.VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();

            showScaleRotateMenu = new ControllerInteractionEventHandler(UpdateScaleRotateMenu);
            leftController.TriggerAxisChanged += showScaleRotateMenu;

            startIdle = new ControllerInteractionEventHandler(StartIdle);
            leftController.TriggerTouchEnd += startIdle;

            // set inital animation progress and show menu
            scaleRotateMenu.SetActive(true);
            scaleRotateMenu.gameObject.GetComponent <ScaleAnimator>().SetAnimationProgress(leftController.GetTriggerAxis());

            Hint.Display("HowToScaleTranslate1Hint");
            Hint.Display("HowToScaleTranslate2Hint");
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Time.time > timeNextSample)
        {
            ray.origin     = transform.position;
            ray.direction  = transform.forward;
            timeNextSample = Time.time + samplingIntervalInSeconds;

            float    nearestDist      = float.MaxValue;
            Building selectedBuilding = null;

            Decoration cube = null;

            foreach (RaycastHit hit in Physics.RaycastAll(ray, 100))
            {
                if (hit.distance > nearestDist)
                {
                    continue;
                }
                nearestDist = hit.distance;
                if (hit.collider.transform.GetComponent <Building>() != null)
                {
                    selectedBuilding             = hit.collider.transform.GetComponent <Building>();
                    lastSelectedBuildingPosition = hit.point;
                }
                if (hit.collider.transform.GetComponent <Floor>() != null)
                {
                    lastSelectedFloorPosition = hit.point;
                    selectionOnFloor          = true;
                }
                else
                {
                    selectionOnFloor = false;
                }
                if (hit.collider.transform.GetComponent <Decoration>() != null)
                {
                    cube = hit.collider.transform.GetComponent <Decoration>();
                }
                else
                {
                    cube = null;
                }
            }

            if (selectionOnFloor)
            {
                if (navigationHint == null)
                {
                    navigationHint = (GameObject)GameObject.Instantiate(navigationHintPrefab);
                }
                navigationHint.transform.position = new Vector3(lastSelectedFloorPosition.x, 0, lastSelectedFloorPosition.z);
                navigationHint.transform.rotation = Quaternion.LookRotation(new Vector3(ray.direction.x, 0, ray.direction.z).normalized, Vector3.up);
            }
            else if (navigationHint != null)
            {
                GameObject.Destroy(navigationHint);
            }

            if (cube != null)
            {
                cube.TractorBeamToPosition(ray.origin);
            }

            if (selectedBuilding != lastSelectedBuilding)
            {
                if (selectedBuilding != null)
                {
                    transform.FindChild("TextHolder/FileNameLabel").GetComponent <TextMesh>().text = selectedBuilding.node.name;
                    transform.FindChild("TextHolder/PathNameLabel").GetComponent <TextMesh>().text = selectedBuilding.node.pathName;
                    AnimateThis anim = transform.FindChild("TextHolder").GetComponent <AnimateThis>();
                    anim.CancelAll();
                    anim.Transformate().Duration(1).FromScale(new Vector3(1, 0, 1)).ToScale(Vector3.one).Ease(AnimateThis.EaseOutElastic).Start();

                    if (currentSelectionObject != null)
                    {
                        Destroy(currentSelectionObject);
                    }
                    currentSelectionObject = (GameObject)GameObject.Instantiate(selectionPrefab);
                    Bounds bounds = selectedBuilding.gameObject.GetComponent <Renderer>().bounds;
                    currentSelectionObject.transform.position   = bounds.center;
                    currentSelectionObject.transform.localScale = selectedBuilding.transform.parent.lossyScale + new Vector3(0.001f, 0.001f, 0.001f);
                    currentSelectionObject.transform.rotation   = GameObject.Find("SoftwareCity").transform.rotation;

                    VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerActions>().TriggerHapticPulse((ushort)(0.1f * 3999));

                    Hint.Display("BuildingSelectionConfirmHint");
                    //VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerActions>().ToggleHighlightTouchpad(true, new Color(0, 0, 1, 0.5f));
                }
                else
                {
                    transform.FindChild("TextHolder/FileNameLabel").GetComponent <TextMesh>().text = "";
                    transform.FindChild("TextHolder/PathNameLabel").GetComponent <TextMesh>().text = "";

                    if (currentSelectionObject != null)
                    {
                        Destroy(currentSelectionObject);
                        currentSelectionObject = null;
                    }

                    Hint.Hide("BuildingSelectionConfirmHint");
                    //VRTK_DeviceFinder.GetControllerRightHand().GetComponent<VRTK_ControllerActions>().ToggleHighlightTouchpad(false);
                }
                lastSelectedBuilding = selectedBuilding;
            }
        }
    }