Beispiel #1
0
 public void RenderModelVisible(bool visible)
 {
     if (RenderModel)
     {
         if (alwaysHideController)
         {
             RenderModel.SetMeshRendererState(false);
         }
         else
         {
             RenderModel.SetMeshRendererState(visible);
         }
     }
 }
Beispiel #2
0
 public void RenderModelVisible(bool visible)
 {
     if (RenderModel)
     {
         RenderModel.SetMeshRendererState(visible);
     }
 }
Beispiel #3
0
        private IEnumerator MigrateModel(SteamVR_RenderModel model, IVRAvatarHand hand)
        {
            var controllerVisual = hand.Transform.GetComponentInChildren <VRAvatarController>(includeInactive: true);

            yield return(new WaitUntil(() => model.transform.childCount != 1));

            if (controllerVisual == null)
            {
                model.SetMeshRendererState(false);
                yield break;
            }

            model.transform.SetParent(controllerVisual.transform);
            model.transform.localPosition = Vector3.zero;
            model.transform.localRotation = Quaternion.identity;

            switch (XRDeviceUtils.GetDeviceModelType())
            {
            case EDeviceModelType.HtcVive:
            case EDeviceModelType.HtcViveCosmos:
            case EDeviceModelType.HtcVivePro:

                hand.Anchor.transform.localPosition += new Vector3(0, 0, -0.1f);
                model.transform.localPosition        = new Vector3(0, 0, 0.1f);

                break;
            }

            var pointerVisual = controllerVisual.GetComponentInChildren <LaserPointerVisual>(includeInactive: true);

            pointerVisual.Bind(hand.InputDevice.Pointer);
            hand.InputDevice.Pointer.Transform = pointerVisual.transform;
        }
Beispiel #4
0
 // Update is called once per frame
 void Update()
 {
     if (dimension == GameController._instance.CurrentDimension)
     {
         ray = new Ray(transform.position, Camera.main.transform.position - transform.position);
         int  mask = 511;
         bool cast = Physics.Raycast(transform.position, Camera.main.transform.position - transform.position, out hit, (Camera.main.transform.position - transform.position).magnitude, ~mask);
         if (cast && hit.collider.gameObject.GetComponent <Portal>() != null)
         {
             if (rendering)
             {
                 SteamVRRenderer.SetMeshRendererState(false);
                 rendering = false;
             }
         }
         else
         {
             if (!rendering)
             {
                 SteamVRRenderer.SetMeshRendererState(true);
                 rendering = true;
             }
         }
     }
     else
     {
         ray = new Ray(transform.position, Camera.main.transform.position - transform.position);
         int  mask = 511;
         bool cast = Physics.Raycast(transform.position, Camera.main.transform.position - transform.position, out hit, (Camera.main.transform.position - transform.position).magnitude, ~mask);
         if (cast && hit.collider.gameObject.GetComponent <Portal>() != null)
         {
             if (!rendering)
             {
                 SteamVRRenderer.SetMeshRendererState(true);
                 rendering = true;
             }
         }
         else
         {
             if (rendering)
             {
                 SteamVRRenderer.SetMeshRendererState(false);
                 rendering = false;
             }
         }
     }
 }
Beispiel #5
0
    public override void StateChanged(StateManager.State newState)
    {
        switch (newState)
        {
        case StateManager.State.init:
            break;

        case StateManager.State.positioned:
            InfoText.text = "Great!\nNow look straight forward and press your right grip button to calibrate your height.";
            RightGripMarker.SetActive(true);
            break;

        case StateManager.State.calibrated:
            InfoText.text    = "Place your hands inside the marked areas and press your left grip button to Arm / Disarm. When disarmed, move the Nao with the left Touchpad as shown above.";
            StatusText.text  = "Calibrated";
            StatusText.color = Color.green;

            ChangeLayerRecursive(Nao, 0);
            LeftModel.SetMeshRendererState(false);
            RightModel.SetMeshRendererState(false);

            ImageCanvas.SetActive(true);
            RightGripMarker.SetActive(false);
            //LeftGripMarker.SetActive(true);
            RightHandMarker.SetActive(true);
            LeftHandMarker.SetActive(true);
            FloorMarker.SetActive(false);
            break;

        case StateManager.State.disarmed:
            StatusText.text     = "Disarmed";
            StatusText.color    = new Color(1, 0.5f, 0.2f);
            publisher.DoPublish = false;

            RightGripMarker.SetActive(false);
            //LeftGripMarker.SetActive(true);
            RightHandMarker.SetActive(true);
            LeftHandMarker.SetActive(true);
            break;

        case StateManager.State.armed:
            InfoCanvas.SetActive(false);
            StatusText.text     = "Armed";
            StatusText.color    = Color.red;
            publisher.DoPublish = true;

            ImageCanvas.SetActive(false);
            ChangeLayerRecursive(NaoMirror, 0);
            LeftDisplay.SetActive(true);
            RightDisplay.SetActive(true);
            LeftGripMarker.SetActive(false);
            RightHandMarker.SetActive(false);
            LeftHandMarker.SetActive(false);
            break;
        }
    }
        private IEnumerator DoInitialize(SteamVR_RenderModel renderModel)
        {
            while (renderModel.initializedAttachPoints == false)
            {
                yield return(null);
            }

            textHintParent = new GameObject("Text Hints").transform;
            textHintParent.SetParent(this.transform);
            textHintParent.localPosition = Vector3.zero;
            textHintParent.localRotation = Quaternion.identity;
            textHintParent.localScale    = Vector3.one;

            //Get the button mask for each component of the render model

            var renderModels = OpenVR.RenderModels;

            if (renderModels != null)
            {
                var renderModelDebug = "Components for render model " + renderModel.index;
                for (var childIndex = 0; childIndex < renderModel.transform.childCount; childIndex++)
                {
                    var child = renderModel.transform.GetChild(childIndex);

                    componentTransformMap.Add(child.name, child);

                    renderModelDebug += "\n\t" + child.name + ".";
                }

                //Uncomment to show the button mask for each component of the render model
                HintDebugLog(renderModelDebug);
            }

            actionHintInfos = new Dictionary <SteamVR_Action_In, ActionHintInfo>();

            for (var actionIndex = 0; actionIndex < SteamVR_Input.actionsNonPoseNonSkeletonIn.Length; actionIndex++)
            {
                var action = (SteamVR_Action_In)SteamVR_Input.actionsNonPoseNonSkeletonIn[actionIndex];

                if (action.GetActive(inputSource))
                {
                    CreateAndAddButtonInfo(action, inputSource);
                }
            }

            ComputeTextEndTransforms();

            initialized = true;

            //Set the controller hints render model to not active
            renderModel.SetMeshRendererState(true);
            renderModel.gameObject.SetActive(false);
        }
        //-------------------------------------------------
        void OnRenderModelLoaded(SteamVR_RenderModel renderModel, bool succeess)
        {
            //Only initialize when the render model for the controller hints has been loaded
            if (renderModel == this.renderModel)
            {
                //Debug.Log("<b>[SteamVR Interaction]</b> OnRenderModelLoaded: " + this.renderModel.renderModelName);
                if (initialized)
                {
                    Destroy(textHintParent.gameObject);
                    componentTransformMap.Clear();
                    flashingRenderers.Clear();
                }

                renderModel.SetMeshRendererState(false);

                StartCoroutine(DoInitialize(renderModel));
            }
        }