Пример #1
0
        public RigidTransform(SteamVR.HmdMatrix44_t pose)
        {
            var m = Matrix4x4.identity;

            m[0, 0] = pose.m[0 * 4 + 0];
            m[1, 0] = pose.m[1 * 4 + 0];
            m[2, 0] = -pose.m[2 * 4 + 0];
            m[3, 0] = pose.m[3 * 4 + 0];

            m[0, 1] = pose.m[0 * 4 + 1];
            m[1, 1] = pose.m[1 * 4 + 1];
            m[2, 1] = -pose.m[2 * 4 + 1];
            m[3, 1] = pose.m[3 * 4 + 1];

            m[0, 2] = -pose.m[0 * 4 + 2];
            m[1, 2] = -pose.m[1 * 4 + 2];
            m[2, 2] = pose.m[2 * 4 + 2];
            m[3, 2] = -pose.m[3 * 4 + 2];

            m[0, 3] = pose.m[0 * 4 + 3];
            m[1, 3] = pose.m[1 * 4 + 3];
            m[2, 3] = -pose.m[2 * 4 + 3];
            m[3, 3] = pose.m[3 * 4 + 3];

            this.pos = m.GetPosition();
            this.rot = m.GetRotation();
        }
Пример #2
0
    void Start()
    {
        Debug.Log("Testing SteamVR...");

        var hmd = SteamVR.IHmd.instance;

        if (hmd == null)
        {
            return;
        }

        int  x = 0, y = 0;
        uint w = 0, h = 0;

        hmd.GetWindowBounds(ref x, ref y, ref w, ref h);
        Debug.Log(string.Format("GetWindowBounds: {0} {1} {2} {3}", x, y, w, h));

        hmd.GetRecommendedRenderTargetSize(ref w, ref h);
        Debug.Log(string.Format("GetRecommendedRenderTargetSize: {0} {1}", w, h));

        uint X = 0, Y = 0;

        hmd.GetEyeOutputViewport(SteamVR.Hmd_Eye.Eye_Left, ref X, ref Y, ref w, ref h);
        Debug.Log(string.Format("GetEyeOutputViewport:L {0} {1} {2} {3}", X, Y, w, h));

        hmd.GetEyeOutputViewport(SteamVR.Hmd_Eye.Eye_Right, ref X, ref Y, ref w, ref h);
        Debug.Log(string.Format("GetEyeOutputViewport:R {0} {1} {2} {3}", X, Y, w, h));

        var m = hmd.GetProjectionMatrix(SteamVR.Hmd_Eye.Eye_Left, 1.0f, 1000.0f, SteamVR.GraphicsAPIConvention.API_DirectX);

        Debug.Log(string.Format("GetProjectionMatrix: {0}", m));

        float left = 0.0f, right = 0.0f, top = 0.0f, bottom = 0.0f;

        hmd.GetProjectionRaw(SteamVR.Hmd_Eye.Eye_Left, ref left, ref right, ref top, ref bottom);
        Debug.Log(string.Format("GetProjectionRaw: {0} {1} {2} {3}", left, right, top, bottom));

        var coords = hmd.ComputeDistortion(SteamVR.Hmd_Eye.Eye_Left, 0.5f, 0.5f);

        Debug.Log(string.Format("ComputeDistortion: {0}", coords));

        var eye = hmd.GetHeadFromEyePose(SteamVR.Hmd_Eye.Eye_Left);

        Debug.Log(string.Format("GetHeadFromEyePose: {0}", eye));

        var result = SteamVR.HmdTrackingResult.TrackingResult_Uninitialized;

        SteamVR.HmdMatrix44_t mL = new SteamVR.HmdMatrix44_t(), mR = new SteamVR.HmdMatrix44_t();
        if (hmd.GetViewMatrix(0.0f, ref mL, ref mR, ref result))
        {
            Debug.Log(string.Format("GetViewMatrix: {0} {1}", mL, mR));
        }
        else
        {
            Debug.Log(string.Format("GetViewMatrix: {0}", result));
        }

        var adapter = hmd.GetD3D9AdapterIndex();

        Debug.Log("GetD3D9AdapterIndex: " + adapter);

        var pose    = new SteamVR.HmdMatrix34_t();

        if (hmd.GetTrackerFromHeadPose(0.0f, ref pose, ref result))
        {
            Debug.Log("GetTrackerFromHeadPose: " + pose);
        }
        else
        {
            Debug.Log("GetTrackerFromHeadPose: " + result);
        }

        if (hmd.WillDriftInYaw())
        {
            Debug.Log("WillDriftInYaw:yes");
        }
        else
        {
            Debug.Log("WillDriftInYaw:no");
        }

        hmd.ZeroTracker();

        var zero    = hmd.GetTrackerZeroPose();

        Debug.Log("GetTrackerZeroPose: " + zero);

        var driverId = hmd.GetDriverId();

        Debug.Log("DriverId: " + driverId);

        var displayId = hmd.GetDisplayId();

        Debug.Log("DisplayId: " + displayId);

        var version = SteamVR.IHmd_Version();

        Debug.Log("IHmd_Version: " + version);
    }
Пример #3
0
    void Start()
    {
        Debug.Log("Testing SteamVR...");

        var hmd = SteamVR.IHmd.instance;
        if (hmd == null)
            return;

        int x = 0, y = 0;
        uint w = 0, h = 0;

        hmd.GetWindowBounds(ref x, ref y, ref w, ref h);
        Debug.Log(string.Format("GetWindowBounds: {0} {1} {2} {3}", x, y, w, h));

        hmd.GetRecommendedRenderTargetSize(ref w, ref h);
        Debug.Log(string.Format("GetRecommendedRenderTargetSize: {0} {1}", w, h));

        uint X = 0, Y = 0;
        hmd.GetEyeOutputViewport(SteamVR.Hmd_Eye.Eye_Left, ref X, ref Y, ref w, ref h);
        Debug.Log(string.Format("GetEyeOutputViewport:L {0} {1} {2} {3}", X, Y, w, h));

        hmd.GetEyeOutputViewport(SteamVR.Hmd_Eye.Eye_Right, ref X, ref Y, ref w, ref h);
        Debug.Log(string.Format("GetEyeOutputViewport:R {0} {1} {2} {3}", X, Y, w, h));

        var m = hmd.GetProjectionMatrix(SteamVR.Hmd_Eye.Eye_Left, 1.0f, 1000.0f, SteamVR.GraphicsAPIConvention.API_DirectX);
        Debug.Log(string.Format("GetProjectionMatrix: {0}", m));

        float left = 0.0f, right = 0.0f, top = 0.0f, bottom = 0.0f;
        hmd.GetProjectionRaw(SteamVR.Hmd_Eye.Eye_Left, ref left, ref right, ref top, ref bottom);
        Debug.Log(string.Format("GetProjectionRaw: {0} {1} {2} {3}", left, right, top, bottom));

        var coords = hmd.ComputeDistortion(SteamVR.Hmd_Eye.Eye_Left, 0.5f, 0.5f);
        Debug.Log(string.Format("ComputeDistortion: {0}", coords));

        var eye = hmd.GetHeadFromEyePose(SteamVR.Hmd_Eye.Eye_Left);
        Debug.Log(string.Format("GetHeadFromEyePose: {0}", eye));

        var result = SteamVR.HmdTrackingResult.TrackingResult_Uninitialized;
        SteamVR.HmdMatrix44_t mL = new SteamVR.HmdMatrix44_t(), mR = new SteamVR.HmdMatrix44_t();
        if (hmd.GetViewMatrix(0.0f, ref mL, ref mR, ref result))
            Debug.Log(string.Format("GetViewMatrix: {0} {1}", mL, mR));
        else
            Debug.Log(string.Format("GetViewMatrix: {0}", result));

        var adapter = hmd.GetD3D9AdapterIndex();
        Debug.Log("GetD3D9AdapterIndex: " + adapter);

        var pose = new SteamVR.HmdMatrix34_t();
        if (hmd.GetTrackerFromHeadPose(0.0f, ref pose, ref result))
            Debug.Log("GetTrackerFromHeadPose: " + pose);
        else
            Debug.Log("GetTrackerFromHeadPose: " + result);

        if (hmd.WillDriftInYaw())
            Debug.Log("WillDriftInYaw:yes");
        else
            Debug.Log("WillDriftInYaw:no");

        hmd.ZeroTracker();

        var zero = hmd.GetTrackerZeroPose();
        Debug.Log("GetTrackerZeroPose: " + zero);

        var driverId = hmd.GetDriverId();
        Debug.Log("DriverId: " + driverId);

        var displayId = hmd.GetDisplayId();
        Debug.Log("DisplayId: " + displayId);

        var version = SteamVR.IHmd_Version();
        Debug.Log("IHmd_Version: " + version);
    }