示例#1
0
        public Transform GetWandControllerAttachPoint()
        {
            int iMappedIndex = (int)ControllerName.Wand;
            BaseControllerBehavior behavior = m_ControllerInfos[iMappedIndex].Behavior;

            if (behavior)
            {
                return(behavior.PointerAttachPoint);
            }
            return(null);
        }
示例#2
0
 public WebXRControllerInfo(BaseControllerBehavior behavior, bool isLeftHand) : base(behavior)
 {
     if (isLeftHand)
     {
         controller = GameObject.Find("handL").GetComponent <WebXRController>();
     }
     else
     {
         controller = GameObject.Find("handR").GetComponent <WebXRController>();
     }
 }
示例#3
0
        public Transform GetPinCushionSpawn()
        {
            int iMappedIndex = (int)ControllerName.Brush;
            BaseControllerBehavior behavior = m_ControllerInfos[iMappedIndex].Behavior;

            if (behavior)
            {
                return(behavior.PinCushionSpawn);
            }
            return(null);
        }
示例#4
0
        public void EnablePointAtPanelHint(bool bEnable)
        {
            BaseControllerBehavior behavior =
                InputManager.m_Instance.GetControllerBehavior(InputManager.ControllerName.Brush);
            ControllerBehaviorBrush rBrushScript = behavior as ControllerBehaviorBrush;

            if (rBrushScript)
            {
                rBrushScript.EnablePointAtPanelsHintObject(bEnable);
            }
        }
示例#5
0
        public void EnableQuickLoadTutorial(bool bEnable)
        {
            BaseControllerBehavior behavior =
                InputManager.m_Instance.GetControllerBehavior(InputManager.ControllerName.Wand);
            ControllerBehaviorWand rWandScript = behavior as ControllerBehaviorWand;

            if (rWandScript)
            {
                rWandScript.EnableQuickLoadHintObject(bEnable);
            }
        }
示例#6
0
        public ControllerInfo(BaseControllerBehavior behavior)
        {
            m_Behavior  = behavior;
            m_Transform = behavior.transform;
            m_Tutorial  = behavior.GetComponent <ControllerTutorialScript>();

            m_Position         = m_Transform.position;
            m_Velocity         = Vector3.zero;
            m_Acceleration     = Vector3.zero;
            m_WasTracked       = false;
            m_HapticPulseCount = 0;
        }
示例#7
0
        void UpdateBrushControllerGripState()
        {
            BaseControllerBehavior behavior =
                InputManager.m_Instance.GetControllerBehavior(InputManager.ControllerName.Brush);
            bool  gripReady    = m_BrushInWidgetRange || (m_DesiredVisualState == VisualState.WorldWandGrip);
            float visualAmount = m_DesiredVisualState == VisualState.WidgetBrushGrip ? 1.0f : 0.5f;

            behavior.EnableTransformVisuals(m_BrushInWidgetRange, visualAmount);
            behavior.SetGripState(gripReady ?
                                  BaseControllerBehavior.GripState.ReadyToGrip :
                                  BaseControllerBehavior.GripState.Standard);
        }
示例#8
0
        /// Swaps the behaviors associated with the controller geometries.
        /// The geometries themselves do not move.
        public static void SwapBehaviors(BaseControllerBehavior a, BaseControllerBehavior b)
        {
            // Well, this is a bit roundabout, because the behavior is the parent of the geometry
            // rather than vice versa. The geometries swap positions twice: once when they swap parents,
            // and again when their new parents swap places.
            SwapPoses(a.transform, b.transform);
            // Force instantiation using ControllerGeometry accessor
            var tmp = a.ControllerGeometry;

            a.SetGeometry(b.ControllerGeometry);
            b.SetGeometry(tmp);
        }
示例#9
0
 // Stitches together these things:
 // - Behavior, which encapsulates Wand and Brush
 // - Geometry, which encapsulates phsyical controller appearance (Touch, Knuckles, ...)
 // - Info, which encapsulates VR APIs (OVR, SteamVR, GVR, ...)
 public ControllerInfo CreateControllerInfo(BaseControllerBehavior behavior, bool isLeftHand)
 {
     if (App.Config.m_SdkMode == SdkMode.Oculus)
     {
         return(new OculusControllerInfo(behavior, isLeftHand));
     }
     else if (App.Config.m_SdkMode == SdkMode.WebXR)
     {
         return(new WebXRControllerInfo(behavior, isLeftHand));
     }
     else
     {
         return(new NonVrControllerInfo(behavior));
     }
 }
示例#10
0
        public void AttachToController(BaseControllerBehavior behavior)
        {
            ControllerGeometry geo = behavior.ControllerGeometry;

            transform.parent   = null;
            transform.position = geo.ConsoleAttachPoint.position;
            transform.rotation = geo.ConsoleAttachPoint.rotation;
            transform.parent   = geo.ConsoleAttachPoint.transform;

            m_NotificationAnchor.position = geo.BaseAttachPoint.position;
            m_NotificationAnchor.rotation = geo.BaseAttachPoint.rotation;

            // The logitech pen has a custom activation angle.
            ControllerStyle geoStyle = geo.Style;

            m_ActivateAngle = (geoStyle == ControllerStyle.LogitechPen) ?
                              m_ActivationAngle_LogitechPen : m_ActivationAngle_Default;
        }
示例#11
0
 public GvrControllerInfo(BaseControllerBehavior behavior, bool isLeftHand) : base(behavior)
 {
     m_controllerIndex = sm_numControllers++;
     m_isLeftHand      = isLeftHand;
 }
示例#12
0
 public NonVrControllerInfo(BaseControllerBehavior behavior) : base(behavior)
 {
 }
示例#13
0
  override public void RecordAndSetPosRot(TrTransform inputXf) {
    // Don't manipulate anything if we're eating input.
    if (m_EatInteractingInput) {
      return;
    }

    SnapEnabled = (m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Rotation ||
                   m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Position) &&
                  InputManager.Controllers[(int)m_InteractingController].GetCommand(
                      InputManager.SketchCommands.MenuContextClick);
    inputXf = GetDesiredTransform(inputXf);

    if (m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Position) {
      // Move the base knot.
      if (m_ActiveKnot.control == 0) {
        // If this knot is the tail or the head and we're within snapping distance of the other
        // end, snap to the transform.
        TrTransform snappedXf = inputXf;
        int positionKnot = m_ActiveKnot.positionKnotIndex.Value;
        if (positionKnot == 0 || positionKnot == Path.NumPositionKnots - 1) {
          int otherIndex = positionKnot == 0 ? Path.NumPositionKnots - 1 : 0;
          float distToOther = Vector3.Distance(inputXf.translation,
              Path.PositionKnots[otherIndex].KnotXf.position);
          if (distToOther < m_KnotSnapDistanceToEnd) {
            snappedXf.translation = Path.PositionKnots[otherIndex].KnotXf.position;
            snappedXf.rotation = Path.PositionKnots[otherIndex].KnotXf.rotation;
          }
        }

        SketchMemoryScript.m_Instance.PerformAndRecordCommand(
            new MovePositionKnotCommand(m_Path, m_ActiveKnot, snappedXf));
      } else {
        // Modify the knot tangents.
        CameraPathPositionKnot pk = m_ActiveKnot.knot as CameraPathPositionKnot;
        if (SnapEnabled) {
          Vector3 snappedTranslation = inputXf.translation;
          snappedTranslation.y = pk.transform.position.y;
          inputXf.translation = snappedTranslation;
        }
        float tangentMag = pk.GetTangentMagnitudeFromControlXf(inputXf);
        Vector3 knotFwd = (inputXf.translation - m_ActiveKnot.knot.transform.position).normalized;
        if ((CameraPathPositionKnot.ControlType)m_ActiveKnot.control ==
            CameraPathPositionKnot.ControlType.TangentControlBack) {
          knotFwd *= -1.0f;
        }
        SketchMemoryScript.m_Instance.PerformAndRecordCommand(
            new ModifyPositionKnotCommand(m_Path, m_ActiveKnot, tangentMag, knotFwd));
      }
      return;
    }

    // Constrain rotation and speed knots to the path.
    // Instead of testing the raw value that comes in from the controller position, test our
    // last valid path position plus any translation that's happened the past frame.  This
    // method keeps the test positions near the path, allowing continuous movement when the
    // user has moved beyond the intersection distance to the path.
    Vector3 positionToProject = inputXf.translation;
    if (m_KnotEditingLastInputXf.HasValue) {
      Vector3 translationDiff = inputXf.translation - m_KnotEditingLastInputXf.Value;
      positionToProject = m_ActiveKnot.knot.KnotXf.position + translationDiff;
    }
    m_KnotEditingLastInputXf = inputXf.translation;

    // Project transform on to the path to get t.
    Vector3 error = Vector3.zero;
    if (m_Path.ProjectPositionOnToPath(positionToProject, out PathT pathT, out error)) {
      // Move the base knot.
      if (m_ActiveKnot.control == 0) {
        // Path constrained knots are a little sticky on the ends of the path.  Knots very
        // near the ends *probably* want to be on the ends, and when there are small deltas
        // near the ends, it causes unwanted erratic curves.
        m_ActiveKnot.pathT = m_Path.MaybeSnapPathTToEnd(pathT, m_KnotSnapDistanceToEnd);

        // Rotation knots allow the user to place the preview widget at their position
        // for live preview.
        if (m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Rotation) {
          CheckForPreviewWidgetOverride(pathT);
        }

        SketchMemoryScript.m_Instance.PerformAndRecordCommand(
            new MoveConstrainedKnotCommand(m_Path, m_ActiveKnot, inputXf.rotation));
      } else {
        // Alternate controls.
        BaseControllerBehavior b = InputManager.Controllers[(int)m_InteractingController].Behavior;
        float controllerY = b.PointerAttachPoint.transform.position.y;

        if (m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Speed) {
          CameraPathSpeedKnot sk = m_ActiveKnot.knot as CameraPathSpeedKnot;
          float speed = sk.GetSpeedValueFromY(controllerY - m_GrabControlInitialYDiff);
          SketchMemoryScript.m_Instance.PerformAndRecordCommand(
              new ModifySpeedKnotCommand(sk, speed));
        } else if (m_ActiveKnot.knot.KnotType == CameraPathKnot.Type.Fov) {
          CameraPathFovKnot fk = m_ActiveKnot.knot as CameraPathFovKnot;
          float fov = fk.GetFovValueFromY(controllerY - m_GrabControlInitialYDiff);
          CheckForPreviewWidgetOverride(fk.PathT);
          SketchMemoryScript.m_Instance.PerformAndRecordCommand(
              new ModifyFovKnotCommand(fk, fov));
        }
      }
    }
    m_KnotEditingLastInputXf -= error;
  }
示例#14
0
        void SwitchState()
        {
            InputManager.ControllerName wand          = InputManager.ControllerName.Wand;
            InputManager.ControllerName brush         = InputManager.ControllerName.Brush;
            BaseControllerBehavior      wandBehavior  = InputManager.m_Instance.GetControllerBehavior(wand);
            BaseControllerBehavior      brushBehavior = InputManager.m_Instance.GetControllerBehavior(brush);

            // Short circuit out of certain states if all the pieces don't fit.
            if (m_DesiredVisualState == VisualState.WorldBrushGrip)
            {
                if (!InputManager.Wand.IsTrackedObjectValid)
                {
                    m_DesiredVisualState = VisualState.Off;
                }
            }
            else if (m_DesiredVisualState == VisualState.WorldWandGrip)
            {
                if (!InputManager.Brush.IsTrackedObjectValid)
                {
                    m_DesiredVisualState = VisualState.Off;
                }
            }

            switch (m_DesiredVisualState)
            {
            case VisualState.Off:
                m_LineDrawInTime              = 0.0f;
                m_LineT                       = 0.0f;
                m_LineRenderer.enabled        = false;
                m_LineOutlineRenderer.enabled = false;
                UpdateWandControllerGripState();
                UpdateBrushControllerGripState();
                m_AnimalRulerAnchor.gameObject.SetActive(false);
                SetAnimalRulerScale(0);
                m_AnimalRulerRequestVisible = false;
                break;

            case VisualState.WorldWandGrip:
            case VisualState.WidgetWandGrip:
                m_LineRenderer.material.SetFloat("_Intensity", m_HintIntensity);
                m_Intensity                   = m_HintIntensity;
                m_LineRenderer.enabled        = true;
                m_LineOutlineRenderer.enabled = true;
                wandBehavior.EnableTransformVisuals(true, 0.5f);
                wandBehavior.SetGripState(BaseControllerBehavior.GripState.Gripped);
                UpdateBrushControllerGripState();
                m_AnimalRulerAnchor.gameObject.SetActive(false);
                m_AnimalRulerRequestVisible = false;
                break;

            case VisualState.WorldBrushGrip:
            case VisualState.WidgetBrushGrip:
                m_LineRenderer.material.SetFloat("_Intensity", m_HintIntensity);
                m_Intensity                   = m_HintIntensity;
                m_LineRenderer.enabled        = true;
                m_LineOutlineRenderer.enabled = true;
                brushBehavior.EnableTransformVisuals(true, 0.5f);
                brushBehavior.SetGripState(BaseControllerBehavior.GripState.Gripped);
                UpdateWandControllerGripState();
                m_AnimalRulerAnchor.gameObject.SetActive(false);
                m_AnimalRulerRequestVisible = false;
                break;

            case VisualState.WorldDoubleGrip:
                m_LineT                       = 1.0f;
                m_Intensity                   = 1.0f;
                m_LineRenderer.enabled        = true;
                m_LineOutlineRenderer.enabled = true;
                m_LineRenderer.material.SetFloat("_Intensity", 1.0f);
                wandBehavior.EnableTransformVisuals(true, 1.0f);
                wandBehavior.SetGripState(BaseControllerBehavior.GripState.Gripped);
                brushBehavior.EnableTransformVisuals(true, 1.0f);
                brushBehavior.SetGripState(BaseControllerBehavior.GripState.Gripped);
                m_AnimalRulerAnchor.gameObject.SetActive(true);
                m_AnimalRulerRequestVisible = true;
                break;
            }

            m_CurrentVisualState = m_DesiredVisualState;
        }
示例#15
0
 public OculusControllerInfo(BaseControllerBehavior behavior, bool isLeftHand)
     : base(behavior)
 {
     m_ControllerType = isLeftHand ? OVRInput.Controller.LTouch : OVRInput.Controller.RTouch;
 }
示例#16
0
 public OculusControllerInfo(BaseControllerBehavior behavior, bool isLeftHand)
     : base(behavior)
 {
 }