コード例 #1
0
        /// <summary>
        /// <para>The current position of the requested VRNode.</para>
        /// </summary>
        /// <param name="node">Node index.</param>
        /// <returns>
        /// <para>Position of node local to its tracking space.</para>
        /// </returns>
        public static Vector3 GetLocalPosition(VRNode node)
        {
            Vector3 vector;

            INTERNAL_CALL_GetLocalPosition(node, out vector);
            return(vector);
        }
コード例 #2
0
ファイル: OVRCameraRig.cs プロジェクト: Smoothstep/VRChat
    // Token: 0x060037B7 RID: 14263 RVA: 0x0011C1F4 File Offset: 0x0011A5F4
    private Transform ConfigureEyeAnchor(Transform root, VRNode eye)
    {
        string    str       = (eye != VRNode.CenterEye) ? ((eye != VRNode.LeftEye) ? "Right" : "Left") : "Center";
        string    text      = str + this.eyeAnchorName;
        Transform transform = base.transform.Find(root.name + "/" + text);

        if (transform == null)
        {
            transform = base.transform.Find(text);
        }
        if (transform == null)
        {
            string name = this.legacyEyeAnchorName + eye.ToString();
            transform = base.transform.Find(name);
        }
        if (transform == null)
        {
            transform = new GameObject(text).transform;
        }
        transform.name          = text;
        transform.parent        = root;
        transform.localScale    = Vector3.one;
        transform.localPosition = Vector3.zero;
        transform.localRotation = Quaternion.identity;
        return(transform);
    }
コード例 #3
0
        /// <summary>
        /// <para>The current rotation of the requested VRNode.</para>
        /// </summary>
        /// <param name="node">Node index.</param>
        /// <returns>
        /// <para>Rotation of node local to its tracking space.</para>
        /// </returns>
        public static Quaternion GetLocalRotation(VRNode node)
        {
            Quaternion quaternion;

            INTERNAL_CALL_GetLocalRotation(node, out quaternion);
            return(quaternion);
        }
コード例 #4
0
        public static Vector3 GetLocalPosition(VRNode node)
        {
            Vector3 result;

            InputTracking.INTERNAL_CALL_GetLocalPosition(node, out result);
            return(result);
        }
コード例 #5
0
        /// <summary>
        ///   <para>The current position of the requested VRNode.</para>
        /// </summary>
        /// <param name="node">Node index.</param>
        /// <returns>
        ///   <para>Position of node local to its tracking space.</para>
        /// </returns>
        public static Vector3 GetLocalPosition(VRNode node)
        {
            Vector3 vector3;

            InputTracking.INTERNAL_CALL_GetLocalPosition(node, out vector3);
            return(vector3);
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        public virtual void SetAnchor(VRNode node, Transform value, bool canAdd)
        {
            int i = 0, imax = m_Anchors.Length;

            for (; i < imax; ++i)
            {
                if (m_Anchors[i].key == node)
                {
                    m_Anchors[i].value = value;
                    return;
                }
            }
            //
            if (canAdd)
            {
                NodeTransformPair[] newAnchors = new NodeTransformPair[imax + 1];
                i = imax;
                while (i-- > 0)
                {
                    newAnchors[i] = m_Anchors[i];
                }
                newAnchors[imax] = new NodeTransformPair {
                    key = node, value = value
                };
                m_Anchors = newAnchors;
            }
        }
コード例 #7
0
        public static Quaternion GetLocalRotation(VRNode node)
        {
            Quaternion result;

            InputTracking.INTERNAL_CALL_GetLocalRotation(node, out result);
            return(result);
        }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 public static void SetAnchor(VRNode node, Transform value)
 {
     if (main == null)
     {
         return;
     }
     main.SetAnchor(node, value, true);
 }
コード例 #9
0
    // Token: 0x060038ED RID: 14573 RVA: 0x001223FC File Offset: 0x001207FC
    public void OverrideOverlayTextureInfo(Texture srcTexture, IntPtr nativePtr, VRNode node)
    {
        int num = (node != VRNode.RightEye) ? 0 : 1;

        this.textures[num]       = srcTexture;
        this.cachedTextures[num] = srcTexture;
        this.texNativePtrs[num]  = nativePtr;
    }
コード例 #10
0
 public static Quaternion GetLocalRotation(VRNode node)
 {
     if (node != VRNode.Head)
     {
         Debug.LogError("GetLocalRotation for other than head");
     }
     return(instance.transform.localRotation);
 }
コード例 #11
0
 /// <summary>
 ///
 /// </summary>
 public static Transform GetAnchor(VRNode node)
 {
     if (main == null)
     {
         return(null);
     }
     return(main.GetAnchor(node, null));
 }
コード例 #12
0
        private void ConfigureCamera(GameObject node, VRNode eye, HMD_Config hmdConfig)
        {
            // adjust camera X-positions based on IPD
            float xDir = 0;

            if (eye == VRNode.LeftEye)
            {
                xDir = -1;
            }
            else if (eye == VRNode.RightEye)
            {
                xDir = +1;
            }

            // shift camera sideways considering any offset orientation
            node.transform.localPosition = (node.transform.localRotation * Vector3.right) * ((hmdConfig.IPD / 2) * xDir);

            foreach (Camera cam in node.GetComponents <Camera>())
            {
                // Setup perspective projection, with aspect ratio matches viewport
                float top    = (float)Mathf.Tan(Mathf.Deg2Rad * hmdConfig.FieldOfView / 2) * cam.nearClipPlane;
                float bottom = -top;
                float left   = cam.aspect * bottom / 2;
                float right  = -left;

                // apply centre offset and adapt viewport
                float offX = hmdConfig.xOffset * (left - right) / 2;
                if (eye == VRNode.LeftEye)
                {
                    cam.rect = new Rect(0.0f, 0, 0.5f, 1);
                }
                else if (eye == VRNode.RightEye)
                {
                    cam.rect = new Rect(0.5f, 0, 0.5f, 1); offX = -offX;
                }
                else
                {
                    cam.rect = new Rect(0.0f, 0, 1.0f, 1); offX = 0;
                }

                // calculate off-centre projection matrix
                Matrix4x4 projectionMatrix = cam.projectionMatrix;
                CalculateProjectionMatrix(ref projectionMatrix, left + offX, right + offX, top, bottom, cam.nearClipPlane, cam.farClipPlane);
                cam.projectionMatrix = projectionMatrix;

                // add distortion filter
                LensDistortion distortion = cam.GetComponent <LensDistortion>();
                if (distortion == null)
                {
                    distortion = cam.gameObject.AddComponent <LensDistortion>();
                    distortion.DistortionShader = Shader.Find("VR/LensDistortion");
                }
                distortion.ApplyConfig(hmdConfig);
                distortion.ScaleIn  = 1.1f;                 // TODO: Hardcoded values > calculate automatically
                distortion.ScaleOut = 0.82f;                // TODO: Hardcoded values > calculate automatically
            }
        }
コード例 #13
0
 /// <summary>
 ///
 /// </summary>
 public virtual Transform GetAnchor(VRNode node, Transform defaultValue)
 {
     for (int i = 0, imax = m_Anchors.Length; i < imax; ++i)
     {
         if (m_Anchors[i].key == node)
         {
             return(m_Anchors[i].value);
         }
     }
     return(defaultValue);
 }
コード例 #14
0
ファイル: OVROverlay.cs プロジェクト: K07H/The-Forest
    public void OverrideOverlayTextureInfo(Texture srcTexture, IntPtr nativePtr, VRNode node)
    {
        int num = (node != VRNode.RightEye) ? 0 : 1;

        if (this.textures.Length <= num)
        {
            return;
        }
        this.textures[num]     = srcTexture;
        this.texturePtrs[num]  = nativePtr;
        this.isOverridePending = true;
    }
コード例 #15
0
    protected virtual void Start()
    {
        //
        if (checkParent)
        {
            Transform p = VRContext.GetAnchor(VRNode.TrackingSpace);
            if (p != null)
            {
                target.SetParent(p, true);
            }
        }
        //
        m_ControllerInput = ControllerInputManager.instance.GetControllerInput(source);
        VRNode node = VRNode.None;

        switch (source)
        {
        case ControllerType.LeftController:
            node = VRNode.LeftHand;
            break;

        case ControllerType.RightController:
            node = VRNode.RightHand;
            break;
        }
        if (node != VRNode.None)
        {
            VRContext.SetAnchor(node, target);
        }
        //
        if (m_ControllerInput != null && canRecenter)
        {
            // Like SteamVR,hmd and controllers don't need to reset yaw angle.
            canRecenter = !m_ControllerInput.isAbsRotation;
        }
        //
        if (canRecenter)
        {
            // Invoke Recenter() on VRContext recenter event.
            VRContext ctx = VRContext.main;
            if (ctx != null)
            {
                ctx.onRecenter += Recenter;
            }
        }
        //
        return;

        // TODO:
        enabled = false;
        UpdatePoses.instance.onUpdatePoses += Update;
    }
コード例 #16
0
ファイル: OVRDisplay.cs プロジェクト: Smoothstep/VRChat
 // Token: 0x060037EB RID: 14315 RVA: 0x0011D018 File Offset: 0x0011B418
 private void ConfigureEyeDesc(VRNode eye)
 {
     if (!OVRManager.isHmdPresent)
     {
         return;
     }
     OVRPlugin.Sizei    eyeTextureSize = OVRPlugin.GetEyeTextureSize((OVRPlugin.Eye)eye);
     OVRPlugin.Frustumf eyeFrustum     = OVRPlugin.GetEyeFrustum((OVRPlugin.Eye)eye);
     this.eyeDescs[(int)eye] = new OVRDisplay.EyeRenderDesc
     {
         resolution = new Vector2((float)eyeTextureSize.w, (float)eyeTextureSize.h),
         fov        = 57.29578f * new Vector2(eyeFrustum.fovX, eyeFrustum.fovY)
     };
 }
コード例 #17
0
ファイル: Sword.cs プロジェクト: oi7/LaserCop
    bool isRightHand;                                                           //Is this sword in the right hand?

    void Start()
    {
        //Get a reference to the animator component on the sword child object
        anim = GetComponentInChildren <Animator> ();

        //Determine if this is the right hand or not by examining the parent VRObjectTracking script
        VRNode node = transform.parent.GetComponent <VRObjectTracking> ().node;

        if (node == VRNode.RightHand)
        {
            isRightHand = true;
        }

        //Invoke the enable method after a delay. This is done so that the sword speed isn't being measured
        //as soon as the scene starts. After the first frame, VR tracking becomes enabled which will make
        //the sword position jump and have a high speed
        Invoke("Enable", initialDelay);
    }
コード例 #18
0
 /// <summary>
 ///
 /// </summary>
 public static Transform GetAnchor(VRNode node)
 {
     if (main == null)
     {
         //
         switch (node)
         {
         case VRNode.CenterEye:
             if (Camera.main != null)
             {
                 return(Camera.main.transform);
             }
             break;
         }
         //
         return(null);
     }
     return(main.GetAnchor(node, null));
 }
コード例 #19
0
        public virtual Vector3 EmulatePosition(VRNode node)
        {
            switch (node)
            {
            case VRNode.LeftHand:
            case VRNode.RightHand:
                Vector3   pos             = m_HandPosition[(int)(node - VRNode.LeftHand)];
                Transform centerEyeAnchor = VRContext.GetAnchor(VRNode.CenterEye);
                if (centerEyeAnchor != null)
                {
                    Transform  trackingSpace = VRContext.GetAnchor(VRNode.TrackingSpace);
                    Quaternion bodyRotation  = Quaternion.Euler(new Vector3(0.0f, centerEyeAnchor.eulerAngles.y, 0.0f));
                    pos = centerEyeAnchor.position + bodyRotation * pos +
                          ((trackingSpace == null?Quaternion.identity:trackingSpace.rotation) * GetRotation((int)(node - VRNode.LeftHand))) *
                          (Vector3.forward * m_HandLength[(int)(node - VRNode.LeftHand)]);
                    // TODO :
                    if (trackingSpace != null)
                    {
                        pos = trackingSpace.InverseTransformPoint(pos);
                    }
                }
                else
                {
                    pos = pos + GetRotation((int)(node - VRNode.LeftHand)) * (Vector3.forward * m_HandLength[(int)(node - VRNode.LeftHand)]);
                }
                return(pos);

                break;

            case VRNode.LeftHand + 2:
                return(Vector3.up * (VRContext.trackingOrigin == TrackingOrigin.EyeLevel?0:                        // Keep zero.
                                     XDevicePlugin.GetFloat(m_Handle, XDevicePlugin.kField_TrackerHeight, 0.0f))); // From ground.

                break;

            default:
                return(Vector3.zero);

                break;
            }
        }
コード例 #20
0
 public static Vector3 GetLocalPosition(VRNode node)
 {
     throw new NotImplementedException("なにこれ");
 }
コード例 #21
0
ファイル: InputTracking.cs プロジェクト: randomize/VimConfig
 public static extern Quaternion GetLocalRotation(VRNode node);
コード例 #22
0
 private static extern void INTERNAL_CALL_GetLocalRotation(VRNode node, out Quaternion value);
コード例 #23
0
 public static Quaternion GetLocalRotation(VRNode node)
 {
     throw new NotImplementedException("なにこれ");
 }
コード例 #24
0
		private void ConfigureCamera(GameObject node, VRNode eye, HMD_Config hmdConfig)
		{
			// adjust camera X-positions based on IPD
			float xDir = 0;
			if (eye == VRNode.LeftEye) { xDir = -1; }
			else if (eye == VRNode.RightEye) { xDir = +1; }

			// shift camera sideways considering any offset orientation
			node.transform.localPosition = (node.transform.localRotation * Vector3.right) * ((hmdConfig.IPD / 2) * xDir);

			foreach (Camera cam in node.GetComponents<Camera>())
			{
				// Setup perspective projection, with aspect ratio matches viewport
				float top = (float)Mathf.Tan(Mathf.Deg2Rad * hmdConfig.FieldOfView / 2) * cam.nearClipPlane;
				float bottom = -top;
				float left = cam.aspect * bottom / 2;
				float right = -left;

				// apply centre offset and adapt viewport
				float offX = hmdConfig.xOffset * (left - right) / 2;
				if (eye == VRNode.LeftEye) { cam.rect = new Rect(0.0f, 0, 0.5f, 1); }
				else if (eye == VRNode.RightEye) { cam.rect = new Rect(0.5f, 0, 0.5f, 1); offX = -offX; }
				else { cam.rect = new Rect(0.0f, 0, 1.0f, 1); offX = 0; }

				// calculate off-centre projection matrix
				Matrix4x4 projectionMatrix = cam.projectionMatrix;
				CalculateProjectionMatrix(ref projectionMatrix, left + offX, right + offX, top, bottom, cam.nearClipPlane, cam.farClipPlane);
				cam.projectionMatrix = projectionMatrix;

				// add distortion filter
				LensDistortion distortion = cam.GetComponent<LensDistortion>();
				if (distortion == null)
				{
					distortion = cam.gameObject.AddComponent<LensDistortion>();
					distortion.DistortionShader = Shader.Find("VR/LensDistortion");
				}
				distortion.ApplyConfig(hmdConfig);
				distortion.ScaleIn = 1.1f;  // TODO: Hardcoded values > calculate automatically
				distortion.ScaleOut = 0.82f; // TODO: Hardcoded values > calculate automatically
			}
		}
コード例 #25
0
 private static extern void INTERNAL_CALL_GetLocalPosition(VRNode node, out Vector3 value);
コード例 #26
0
 public static Vector3 GetLocalPosition(VRNode node)
 {
     throw new NotSupportedException("InputTracking has been moved.  Use UnityEngine.XR.InputTracking instead.");
 }
コード例 #27
0
ファイル: PlayerVRComponent.cs プロジェクト: pcbeard/TESUnity
 public static Quaternion GetLocalRotation(VRNode node)
 {
     return(Quaternion.identity);
 }
コード例 #28
0
 public static void UpdateTrackedDevice(VRNode nodeType, Vector3 position, Quaternion rotation)
 {
     VRTestMock.INTERNAL_CALL_UpdateTrackedDevice(nodeType, ref position, ref rotation);
 }
コード例 #29
0
 public static extern void AddTrackedDevice(VRNode nodeType);
コード例 #30
0
 private static extern void INTERNAL_CALL_UpdateTrackedDevice(VRNode nodeType, ref Vector3 position, ref Quaternion rotation);
コード例 #31
0
        private static void InvokeTrackingEvent(InputTracking.TrackingStateEventType eventType, VRNode nodeType, long uniqueID, bool tracked)
        {
            VRNodeState obj = default(VRNodeState);

            obj.uniqueID = (ulong)uniqueID;
            obj.nodeType = nodeType;
            obj.tracked  = tracked;
            Action <VRNodeState> action;

            switch (eventType)
            {
            case InputTracking.TrackingStateEventType.NodeAdded:
                action = InputTracking.nodeAdded;
                break;

            case InputTracking.TrackingStateEventType.NodeRemoved:
                action = InputTracking.nodeRemoved;
                break;

            case InputTracking.TrackingStateEventType.TrackingAcquired:
                action = InputTracking.trackingAcquired;
                break;

            case InputTracking.TrackingStateEventType.TrackingLost:
                action = InputTracking.trackingLost;
                break;

            default:
                throw new ArgumentException("TrackingEventHandler - Invalid EventType: " + eventType);
            }
            if (action != null)
            {
                action(obj);
            }
        }
コード例 #32
0
 private static extern void INTERNAL_CALL_GetLocalPosition(VRNode node, out Vector3 value);
コード例 #33
0
ファイル: InputTracking.cs プロジェクト: randomize/VimConfig
 public static extern Vector3 GetLocalPosition(VRNode node);
コード例 #34
0
 /// <summary>
 /// <para>The current position of the requested VRNode.</para>
 /// </summary>
 /// <param name="node">Node index.</param>
 /// <returns>
 /// <para>Position of node local to its tracking space.</para>
 /// </returns>
 public static Vector3 GetLocalPosition(VRNode node)
 {
     Vector3 vector;
     INTERNAL_CALL_GetLocalPosition(node, out vector);
     return vector;
 }
コード例 #35
0
ファイル: PlayerVRComponent.cs プロジェクト: pcbeard/TESUnity
 public static Vector3 GetLocalPosition(VRNode node)
 {
     return(Vector3.zero);
 }
コード例 #36
0
 /// <summary>
 /// <para>The current rotation of the requested VRNode.</para>
 /// </summary>
 /// <param name="node">Node index.</param>
 /// <returns>
 /// <para>Rotation of node local to its tracking space.</para>
 /// </returns>
 public static Quaternion GetLocalRotation(VRNode node)
 {
     Quaternion quaternion;
     INTERNAL_CALL_GetLocalRotation(node, out quaternion);
     return quaternion;
 }
コード例 #37
0
 /// <summary>
 ///   <para>The current position of the requested VRNode.</para>
 /// </summary>
 /// <param name="node">Node index.</param>
 /// <returns>
 ///   <para>Position of node local to its tracking space.</para>
 /// </returns>
 public static Vector3 GetLocalPosition(VRNode node)
 {
   Vector3 vector3;
   InputTracking.INTERNAL_CALL_GetLocalPosition(node, out vector3);
   return vector3;
 }
コード例 #38
0
 private static extern void INTERNAL_CALL_GetLocalRotation(VRNode node, out Quaternion value);