コード例 #1
0
        void Update()
        {
            // This is a proxy for "tutorial mode".
            SketchControlsScript.m_Instance.AssignControllerMaterials(m_ControllerName);

            // Skip the tint and animation update if in intro sketch because
            // - nothing but the default has been assigned
            // - the user is not able to change the tint color
            // - we do not want to animate the buttons/pads
            if (!PanelManager.m_Instance.IntroSketchbookMode)
            {
                // Send a signal to the controller that the materials have been assigned.
                ControllerGeometry.OnMaterialsAssigned(GetTintColor());
            }

            if (ControllerGeometry.XRayVisuals)
            {
                float XRayHeight_ss = (App.Scene.Pose.translation.y
                                       + App.Scene.Pose.scale * SceneSettings.m_Instance.ControllerXRayHeight);
                bool bControllerUnderground = transform.position.y < XRayHeight_ss;
                bool bHMDUnderground        = ViewpointScript.Head.position.y < XRayHeight_ss;
                ControllerGeometry.XRayVisuals.SetActive(bControllerUnderground != bHMDUnderground);
            }

            if (ControllerGeometry.TriggerAnchor != null)
            {
                // This is hooked up for Wmr, Vive.
                // This is not hooked up for the Quest, Rift, Knuckles controller geometry;
                // they work using Animators and AnimateOculusTouchSteam.cs
                Vector2 range = m_ControllerGeometry.TriggerRotation;
                ControllerGeometry.TriggerAnchor.localRotation = Quaternion.AngleAxis(
                    Mathf.Lerp(range.x, range.y, ControllerInfo.GetTriggerRatio()),
                    Vector3.right);
            }

            //
            // If the transform visuals are active and the user is interacting with a widget, add the
            // transform visuals to the highlight queue. Eventually, we may:
            //
            // (a) only have the post process higlight in which case these transform visuals will not need
            //     a renderer/material or
            // (b) modify the highlight queue to a dynamic list that retains state across frames in which
            //     case this logic can be moved into EnableTransformVisuals().
            //
            if (TransformVisuals.activeSelf &&
                SketchControlsScript.m_Instance.IsUserAbleToInteractWithAnyWidget())
            {
                App.Instance.SelectionEffect.RegisterMesh(TransformVisuals.GetComponent <MeshFilter>());

                switch (ControllerGeometry.Style)
                {
                case ControllerStyle.OculusTouch:
                case ControllerStyle.Knuckles:
                    App.Instance.SelectionEffect.RegisterMesh(
                        ControllerGeometry.JoystickPad.GetComponent <MeshFilter>());
                    break;

                case ControllerStyle.Vive:
                    App.Instance.SelectionEffect.RegisterMesh(
                        ControllerGeometry.PadMesh.GetComponent <MeshFilter>());
                    break;

                case ControllerStyle.Wmr:
                    // TODO What should be here?  Joystick or pad?
                    break;
                }
            }

            OnUpdate();
        }