コード例 #1
0
 public bool GetWorkingCollisionBoundsInfo(out HmdQuad_t[] pQuadsBuffer)
 {
     uint num = 0u;
     bool flag = this.FnTable.GetWorkingCollisionBoundsInfo(null, ref num);
     pQuadsBuffer = new HmdQuad_t[num];
     return this.FnTable.GetWorkingCollisionBoundsInfo(pQuadsBuffer, ref num);
 }
コード例 #2
0
	private void CreateSpaceGuardWalls()
	{
		switch (ConfigurationManager.GetConfiguration())
		{
			case ConfigurationManager.Configuration.HTC_Vive:
				CVRChaperone chaperone = OpenVR.Chaperone;
				HmdQuad_t  area = new HmdQuad_t();
				chaperone.GetPlayAreaRect(ref area);
				CreateWall(area.vCorners0.v0, area.vCorners0.v2, area.vCorners1.v0, area.vCorners1.v2, "Wall1");
				CreateWall(area.vCorners1.v0, area.vCorners1.v2, area.vCorners2.v0, area.vCorners2.v2, "Wall2");
				CreateWall(area.vCorners2.v0, area.vCorners2.v2, area.vCorners3.v0, area.vCorners3.v2, "Wall3");
				CreateWall(area.vCorners3.v0, area.vCorners3.v2, area.vCorners0.v0, area.vCorners0.v2, "Wall4");
				chaperone.ForceBoundsVisible(false);
				break;

			case ConfigurationManager.Configuration.MoCapRoom:
				CreateWall(-2, -2,  2, -2, "Front");
				CreateWall( 2, -2,  2,  2, "Right");
				CreateWall( 2,  2, -2,  2, "Back");
				CreateWall(-2,  2, -2, -2, "Left");
				break;

			default:
				break;
		}
	}
コード例 #3
0
    //Handles scaling of UI tools for different room sizes
    void Position3DUI()
    {
        ToolContainer = GameObject.Find("ToolContainer").transform;
        foreach (var wc in FindObjectsOfType <WandController>())
        {
            wc.DrawingControlContainer = ToolContainer;
        }
        //Shelves = GameObject.Find("ControlContainer").transform;
        Valve.VR.HmdQuad_t roomDims = new Valve.VR.HmdQuad_t();
        SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref roomDims);
        RoomScale = new Vector3(Mathf.Abs(roomDims.vCorners0.v0 - roomDims.vCorners2.v0), Mathf.Abs(roomDims.vCorners0.v2 - roomDims.vCorners2.v2), 1);


        if (false)//RoomScale.x < 0.1f && RoomScale.y < 0.1f)
        {
            // Destroy(GameObject.Find("ToolContainer"));
            //Destroy(GameObject.Find("ControlContainer"));
            ToolContainer.Translate(-0.5f * 3, 0, 0);
            Shelves.Translate(0, 0, 0.5f * 3);
        }
        else
        {
            ToolContainer.Translate(-0.5f * RoomScale.x, 0, 0);
            //Shelves.Translate(0, 0, 0.5f * RoomScale.y);
        }
    }
コード例 #4
0
    void ScaleToPlayArea()
    {
        var rect = new Valve.VR.HmdQuad_t();

        SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref rect);
        transform.localScale = new Vector3(Mathf.Abs(rect.vCorners0.v0 - rect.vCorners2.v0), transform.localScale.y, transform.localScale.z);
    }
コード例 #5
0
 public bool GetLivePhysicalBoundsInfo(out HmdQuad_t[] pQuadsBuffer)
 {
     uint num = 0u;
     bool flag = this.FnTable.GetLivePhysicalBoundsInfo(null, ref num);
     pQuadsBuffer = new HmdQuad_t[num];
     return this.FnTable.GetLivePhysicalBoundsInfo(pQuadsBuffer, ref num);
 }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        SteamVR_PlayArea playAreaScript = VRCamera.GetComponent <SteamVR_PlayArea>();

        Valve.VR.HmdQuad_t quad = new Valve.VR.HmdQuad_t();
        SteamVR_PlayArea.GetBounds(playAreaScript.size, ref quad);

        // Calc width of room
        float sizeX = quad.vCorners0.v0 - quad.vCorners3.v0;
        float sizeZ = quad.vCorners0.v2 - quad.vCorners2.v2;

        Debug.Log(sizeX);
        Debug.Log(sizeZ);
        //Instantiate(box, new Vector3(quad.vCorners0.v0, quad.vCorners0.v1, quad.vCorners0.v2), Quaternion.identity);
        //Instantiate(box, new Vector3(quad.vCorners1.v0, quad.vCorners1.v1, quad.vCorners1.v2), Quaternion.identity);
        //Instantiate(box, new Vector3(quad.vCorners2.v0, quad.vCorners2.v1, quad.vCorners2.v2), Quaternion.identity);
        //Instantiate(box, new Vector3(quad.vCorners3.v0, quad.vCorners3.v1, quad.vCorners3.v2), Quaternion.identity);
        Vector3 center = VRCamera.transform.position;

        /// Create the walls
        // Horizontal (along x axis), which means z varies
        Instantiate(Wall, new Vector3(0, 0, sizeZ), new Quaternion());
        Instantiate(Wall, new Vector3(0, 0, -sizeZ), new Quaternion());
        // Vertical (along z axis), which means 90 degree rotation and x varies
        //Instantiate(Wall, new Vector3(sizeX, 0, 0), new Quaternion());
        //Instantiate(Wall, new Vector3(-sizeX, 0, 0), new Quaternion());
        Instantiate(Wall, new Vector3(sizeX, 0, 0), Quaternion.Euler(0, 90, 0));
        Instantiate(Wall, new Vector3(-sizeX, 0, 0), Quaternion.Euler(0, 90, 0));

        //Vector3 FrontWallPosition = ;
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        rect = new Valve.VR.HmdQuad_t();
        SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref rect);

        transform.localScale = new Vector3(Mathf.Abs(rect.vCorners0.v0 - rect.vCorners2.v0), floorThickness, Mathf.Abs(rect.vCorners0.v2 - rect.vCorners2.v2));
        transform.position   = new Vector3(0f, -floorThickness / 2f, 0f);
    }
コード例 #8
0
    void Awake()
    {
        Valve.VR.HmdQuad_t roomSize = new Valve.VR.HmdQuad_t();
        SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref roomSize);
        Vector3 calibratedScale = transform.localScale;

        calibratedScale.x    = Mathf.Abs(roomSize.vCorners0.v0 - roomSize.vCorners1.v0);
        calibratedScale.z    = Mathf.Abs(roomSize.vCorners0.v2 - roomSize.vCorners3.v2);
        transform.localScale = calibratedScale;
    }
コード例 #9
0
    public static bool GetBounds( Size size, ref HmdQuad_t pRect )
    {
        if (size == Size.Calibrated)
        {
            var initOpenVR = (!SteamVR.active && !SteamVR.usingNativeSupport);
            if (initOpenVR)
            {
                var error = EVRInitError.None;
                OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
            }

            var chaperone = OpenVR.Chaperone;
            bool success = (chaperone != null) && chaperone.GetPlayAreaRect(ref pRect);
            if (!success)
                Debug.LogWarning("Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");

            if (initOpenVR)
                OpenVR.Shutdown();

            return success;
        }
        else
        {
            try
            {
                var str = size.ToString().Substring(1);
                var arr = str.Split(new char[] {'x'}, 2);

                // convert to half size in meters (from cm)
                var x = float.Parse(arr[0]) / 200;
                var z = float.Parse(arr[1]) / 200;

                pRect.vCorners0.v0 =  x;
                pRect.vCorners0.v1 =  0;
                pRect.vCorners0.v2 =  z;

                pRect.vCorners1.v0 =  x;
                pRect.vCorners1.v1 =  0;
                pRect.vCorners1.v2 = -z;

                pRect.vCorners2.v0 = -x;
                pRect.vCorners2.v1 =  0;
                pRect.vCorners2.v2 = -z;

                pRect.vCorners3.v0 = -x;
                pRect.vCorners3.v1 =  0;
                pRect.vCorners3.v2 =  z;

                return true;
            }
            catch {}
        }

        return false;
    }
コード例 #10
0
    /// <summary>
    /// Draws the gridlines based on the size of the play area provided by steam VR.
    /// </summary>
    void DrawGridlines()
    {
        if (SnapDistance == 0)
        {
            return;
        }
        ClearGridlines();
        Valve.VR.HmdQuad_t roomDims = new Valve.VR.HmdQuad_t();
        SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref roomDims);
        Vector3 RoomScale = new Vector3(Mathf.Abs(roomDims.vCorners0.v0 - roomDims.vCorners2.v0), Mathf.Abs(roomDims.vCorners0.v2 - roomDims.vCorners2.v2), 1);
        float   roomWidth = RoomScale.x;
        float   roomDepth = RoomScale.y;
        float   height    = 3;

        for (int i = -(int)((roomWidth / SnapDistance)); i <= (int)((roomWidth / SnapDistance)); i++)
        {
            for (int j = -(int)((height / SnapDistance)); j <= (int)((height / SnapDistance)); j++)
            {
                var gl = Instantiate(GridlinePrefab);
                var lr = gl.GetComponent <LineRenderer>();
                lr.SetPosition(0, new Vector3(i * SnapDistance, j * SnapDistance, -roomDepth));
                lr.SetPosition(1, new Vector3(i * SnapDistance, j * SnapDistance, roomDepth));
                gl.transform.position = new Vector3(i * SnapDistance, j * SnapDistance, 0);
                Gridlines.Add(gl);
            }
        }

        for (int i = -(int)((roomDepth / SnapDistance)); i <= (int)((roomDepth / SnapDistance)); i++)
        {
            for (int j = -(int)((height / SnapDistance)); j <= (int)((height / SnapDistance)); j++)
            {
                var gl = Instantiate(GridlinePrefab);
                var lr = gl.GetComponent <LineRenderer>();
                lr.SetPosition(0, new Vector3(-roomWidth, j * SnapDistance, i * SnapDistance));
                lr.SetPosition(1, new Vector3(roomWidth, j * SnapDistance, i * SnapDistance));
                gl.transform.position = new Vector3(0, j * SnapDistance, i * SnapDistance);
                Gridlines.Add(gl);
            }
        }

        for (int i = -(int)((roomWidth / SnapDistance)); i <= (int)((roomWidth / SnapDistance)); i++)
        {
            for (int j = -(int)((roomDepth / SnapDistance)); j <= (int)((roomDepth / SnapDistance)); j++)
            {
                var gl = Instantiate(GridlinePrefab);
                var lr = gl.GetComponent <LineRenderer>();
                lr.SetPosition(0, new Vector3(i * SnapDistance, -height, j * SnapDistance));
                lr.SetPosition(1, new Vector3(i * SnapDistance, height, j * SnapDistance));
                gl.transform.position = new Vector3(i * SnapDistance, 0, j * SnapDistance);
                Gridlines.Add(gl);
            }
        }
    }
コード例 #11
0
	public static bool GetBounds( Size size, ref HmdQuad_t pRect )
	{
		if (size == Size.Calibrated)
		{
			var error = EVRInitError.None;
			if (!SteamVR.active)
			{
				OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
				if (error != EVRInitError.None)
					return false;
			}

			var pChaperone = OpenVR.GetGenericInterface(OpenVR.IVRChaperone_Version, ref error);
			if (pChaperone == System.IntPtr.Zero || error != EVRInitError.None)
			{
				if (!SteamVR.active)
					OpenVR.Shutdown();
				return false;
			}

			var chaperone = new CVRChaperone(pChaperone);

			bool success = chaperone.GetPlayAreaRect( ref pRect );
			if (!success)
				Debug.LogWarning("Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");

			if (!SteamVR.active)
				OpenVR.Shutdown();

			return success;
		}
		else
		{
			try
			{
				var str = size.ToString().Substring(1);
				var arr = str.Split(new char[] {'x'}, 2);
				// convert to half size in meters (from cm)
				var x = float.Parse(arr[0]) / 200;
				var z = float.Parse(arr[1]) / 200;
				pRect.vCorners = new HmdVector3_t[ 4 ];
				pRect.vCorners[ 0 ].v = new float[ 3 ] { x, 0, z };
				pRect.vCorners[ 1 ].v = new float[ 3 ] { x, 0, -z };
				pRect.vCorners[ 2 ].v = new float[ 3 ] { -x, 0, -z };
				pRect.vCorners[ 3 ].v = new float[ 3 ] { -x, 0, z };
				return true;
			}
			catch {}
		}

		return false;
	}
コード例 #12
0
    IEnumerator SetPanelBounds()
    {
        Valve.VR.HmdQuad_t rect = new Valve.VR.HmdQuad_t();

        while (!SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref rect))
        {
            yield return(new WaitForSeconds(0.1f));
        }

        Vector3 newScale = new Vector3(Mathf.Abs(rect.vCorners0.v0 - rect.vCorners2.v0), this.transform.localScale.y, Mathf.Abs(rect.vCorners0.v2 - rect.vCorners2.v2));

        this.transform.localScale = newScale;
    }
コード例 #13
0
 public static bool GetBounds(SteamVR_PlayArea.Size size, ref HmdQuad_t pRect)
 {
     if (size == SteamVR_PlayArea.Size.Calibrated)
     {
         bool flag = !SteamVR.active && !SteamVR.usingNativeSupport;
         if (flag)
         {
             EVRInitError eVRInitError = EVRInitError.None;
             OpenVR.Init(ref eVRInitError, EVRApplicationType.VRApplication_Other);
         }
         CVRChaperone chaperone = OpenVR.Chaperone;
         bool flag2 = chaperone != null && chaperone.GetPlayAreaRect(ref pRect);
         if (!flag2)
         {
             UnityEngine.Debug.LogWarning("Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");
         }
         if (flag)
         {
             OpenVR.Shutdown();
         }
         return flag2;
     }
     try
     {
         string text = size.ToString().Substring(1);
         string[] array = text.Split(new char[]
         {
             'x'
         }, 2);
         float num = float.Parse(array[0]) / 200f;
         float num2 = float.Parse(array[1]) / 200f;
         pRect.vCorners0.v0 = num;
         pRect.vCorners0.v1 = 0f;
         pRect.vCorners0.v2 = num2;
         pRect.vCorners1.v0 = num;
         pRect.vCorners1.v1 = 0f;
         pRect.vCorners1.v2 = -num2;
         pRect.vCorners2.v0 = -num;
         pRect.vCorners2.v1 = 0f;
         pRect.vCorners2.v2 = -num2;
         pRect.vCorners3.v0 = -num;
         pRect.vCorners3.v1 = 0f;
         pRect.vCorners3.v2 = num2;
         return true;
     }
     catch
     {
     }
     return false;
 }
コード例 #14
0
ファイル: LargeMan.cs プロジェクト: Valalala/vrTestDemos
    IEnumerator playSizeFind()
    {
        playSize = new Valve.VR.HmdQuad_t();

        while (!check)
        {
            yield return(new WaitForSeconds(1));

            check = Valve.VR.OpenVR.Chaperone.GetPlayAreaRect(ref playSize);
            //print("running?");
        }

        startCorner = new Vector3(playSize.vCorners1.v0, 0, playSize.vCorners1.v2);
        playX       = playSize.vCorners0.v0 - playSize.vCorners1.v0;
        playZ       = -playSize.vCorners0.v2 + playSize.vCorners2.v2;
    }
    private void BuildMesh()
    {
        var rect = new HmdQuad_t();
        GetBounds(ref rect);
        var corners = new HmdVector3_t[] { rect.vCorners0, rect.vCorners1, rect.vCorners2, rect.vCorners3 };

        vertices = new Vector3[corners.Length * 2];
        for (int i = 0; i < corners.Length; i++)
        {
            var c = corners[i];
            vertices[i] = new Vector3(c.v0, 0.01f, c.v2);
        }

        for (int i = 0; i < corners.Length; i++)
        {
            vertices[corners.Length + i] = vertices[i];
        }
    }
コード例 #16
0
    IEnumerator getPlayArea()
    {
        var rect = new Valve.VR.HmdQuad_t();

        while (!SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref rect))
        {
            yield return(new WaitForSeconds(1f));
        }

        Vector3 newScale = new Vector3(Mathf.Abs(rect.vCorners0.v0 - rect.vCorners2.v0), this.transform.localScale.y, Mathf.Abs(rect.vCorners0.v2 - rect.vCorners2.v2));

        if (false)
        {
            Debug.Log("Quad Ecke0 x:" + rect.vCorners0.v0 + " y: " + rect.vCorners0.v1 + " z: " + rect.vCorners0.v2);
            Debug.Log("Quad Ecke1 x:" + rect.vCorners1.v0 + " y: " + rect.vCorners1.v1 + " z: " + rect.vCorners1.v2);
            Debug.Log("Quad Ecke2 x:" + rect.vCorners2.v0 + " y: " + rect.vCorners2.v1 + " z: " + rect.vCorners2.v2);
            Debug.Log("Quad Ecke3 x:" + rect.vCorners3.v0 + " y: " + rect.vCorners3.v1 + " z: " + rect.vCorners3.v2);
            Debug.Log("New Scale would be x:" + newScale.x + " y: " + newScale.y + " z:" + newScale.z);
        }
        playAreaX = newScale.x;
        playAreaY = newScale.z;
    }
 public void GetBounds(ref HmdQuad_t pRect)
 {
     checkAndUpdateBounds();
     if (steamVR_PlayArea.size == SteamVR_PlayArea.Size.Calibrated)
     {
         pRect.vCorners0.v2 = steamVrBounds.vCorners0.v2 + (steamVrBounds.vCorners0.v2 + vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners0.v2 = pRect.vCorners0.v2 > steamVrBounds.vCorners0.v2 ? steamVrBounds.vCorners0.v2 : pRect.vCorners0.v2;
         pRect.vCorners1.v0 = steamVrBounds.vCorners1.v0 + (steamVrBounds.vCorners1.v0 + vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners1.v0 = pRect.vCorners1.v0 > steamVrBounds.vCorners1.v0 ? steamVrBounds.vCorners1.v0 : pRect.vCorners1.v0;
         pRect.vCorners2.v2 = steamVrBounds.vCorners2.v2 + (steamVrBounds.vCorners2.v2 - vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners2.v2 = pRect.vCorners2.v2 < steamVrBounds.vCorners2.v2 ? steamVrBounds.vCorners2.v2 : pRect.vCorners2.v2;
         pRect.vCorners3.v0 = steamVrBounds.vCorners3.v0 + (steamVrBounds.vCorners3.v0 - vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners3.v0 = pRect.vCorners3.v0 < steamVrBounds.vCorners3.v0 ? steamVrBounds.vCorners3.v0 : pRect.vCorners3.v0;
     }
     else
     {
         pRect.vCorners0.v2 = steamVrBounds.vCorners0.v2 + (steamVrBounds.vCorners0.v2 - vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners0.v2 = pRect.vCorners0.v2 < steamVrBounds.vCorners0.v2 ? steamVrBounds.vCorners0.v2 : pRect.vCorners0.v2;
         pRect.vCorners1.v0 = steamVrBounds.vCorners1.v0 + (steamVrBounds.vCorners1.v0 - vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners1.v0 = pRect.vCorners1.v0 < steamVrBounds.vCorners1.v0 ? steamVrBounds.vCorners1.v0 : pRect.vCorners1.v0;
         pRect.vCorners2.v2 = steamVrBounds.vCorners2.v2 + (steamVrBounds.vCorners2.v2 + vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners2.v2 = pRect.vCorners2.v2 > steamVrBounds.vCorners2.v2 ? steamVrBounds.vCorners2.v2 : pRect.vCorners2.v2;
         pRect.vCorners3.v0 = steamVrBounds.vCorners3.v0 + (steamVrBounds.vCorners3.v0 + vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
         pRect.vCorners3.v0 = pRect.vCorners3.v0 > steamVrBounds.vCorners3.v0 ? steamVrBounds.vCorners3.v0 : pRect.vCorners3.v0;
     }
     pRect.vCorners0.v1 = 0;
     pRect.vCorners1.v1 = 0;
     pRect.vCorners2.v1 = 0;
     pRect.vCorners3.v1 = 0;
     pRect.vCorners0.v0 = steamVrBounds.vCorners0.v0 + (steamVrBounds.vCorners0.v0 - vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
     pRect.vCorners0.v0 = pRect.vCorners0.v0 < steamVrBounds.vCorners0.v0 ? steamVrBounds.vCorners0.v0 : pRect.vCorners0.v0;
     pRect.vCorners1.v2 = steamVrBounds.vCorners1.v2 + (steamVrBounds.vCorners1.v2 + vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
     pRect.vCorners1.v2 = pRect.vCorners1.v2 > steamVrBounds.vCorners1.v2 ? steamVrBounds.vCorners1.v2 : pRect.vCorners1.v2;
     pRect.vCorners2.v0 = steamVrBounds.vCorners2.v0 + (steamVrBounds.vCorners2.v0 + vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
     pRect.vCorners2.v0 = pRect.vCorners2.v0 > steamVrBounds.vCorners2.v0 ? steamVrBounds.vCorners2.v0 : pRect.vCorners2.v0;
     pRect.vCorners3.v2 = steamVrBounds.vCorners3.v2 + (steamVrBounds.vCorners3.v2 - vrtk_RoomExtender.headZoneRadius) * vrtk_RoomExtender.additionalMovementMultiplier;
     pRect.vCorners3.v2 = pRect.vCorners3.v2 < steamVrBounds.vCorners3.v2 ? steamVrBounds.vCorners3.v2 : pRect.vCorners3.v2;
 }
コード例 #18
0
ファイル: TeleportVive.cs プロジェクト: sweenr/ped-sim
    /// \brief Requests the chaperone boundaries of the SteamVR play area.  This doesn't work if you haven't performed
    ///        Room Setup.
    /// \param p0, p1, p2, p3 Points that make up the chaperone boundaries.
    /// 
    /// \returns If the play area retrieval was successful
    public static bool GetChaperoneBounds(out Vector3 p0, out Vector3 p1, out Vector3 p2, out Vector3 p3)
    {
        var initOpenVR = (!SteamVR.active && !SteamVR.usingNativeSupport);
        if (initOpenVR)
        {
            var error = EVRInitError.None;
            OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
        }

        var chaperone = OpenVR.Chaperone;
        HmdQuad_t rect = new HmdQuad_t();
        bool success = (chaperone != null) && chaperone.GetPlayAreaRect(ref rect);
        p0 = new Vector3(rect.vCorners0.v0, rect.vCorners0.v1, rect.vCorners0.v2);
        p1 = new Vector3(rect.vCorners1.v0, rect.vCorners1.v1, rect.vCorners1.v2);
        p2 = new Vector3(rect.vCorners2.v0, rect.vCorners2.v1, rect.vCorners2.v2);
        p3 = new Vector3(rect.vCorners3.v0, rect.vCorners3.v1, rect.vCorners3.v2);
        if (!success)
            Debug.LogWarning("Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");

        if (initOpenVR)
            OpenVR.Shutdown();

        return success;
    }
コード例 #19
0
    public void BuildMesh()
    {
        var rect = new HmdQuad_t();
        if ( !GetBounds( size, ref rect ) )
            return;

        var corners = new HmdVector3_t[] { rect.vCorners0, rect.vCorners1, rect.vCorners2, rect.vCorners3 };

        vertices = new Vector3[corners.Length * 2];
        for (int i = 0; i < corners.Length; i++)
        {
            var c = corners[i];
            vertices[i] = new Vector3(c.v0, 0.01f, c.v2);
        }

        if (borderThickness == 0.0f)
        {
            GetComponent<MeshFilter>().mesh = null;
            return;
        }

        for (int i = 0; i < corners.Length; i++)
        {
            int next = (i + 1) % corners.Length;
            int prev = (i + corners.Length - 1) % corners.Length;

            var nextSegment = (vertices[next] - vertices[i]).normalized;
            var prevSegment = (vertices[prev] - vertices[i]).normalized;

            var vert = vertices[i];
            vert += Vector3.Cross(nextSegment, Vector3.up) * borderThickness;
            vert += Vector3.Cross(prevSegment, Vector3.down) * borderThickness;

            vertices[corners.Length + i] = vert;
        }

        var triangles = new int[]
        {
            0, 1, 4,
            1, 5, 4,
            1, 2, 5,
            2, 6, 5,
            2, 3, 6,
            3, 7, 6,
            3, 0, 7,
            0, 4, 7
        };

        var uv = new Vector2[]
        {
            new Vector2(0.0f, 0.0f),
            new Vector2(1.0f, 0.0f),
            new Vector2(0.0f, 0.0f),
            new Vector2(1.0f, 0.0f),
            new Vector2(0.0f, 1.0f),
            new Vector2(1.0f, 1.0f),
            new Vector2(0.0f, 1.0f),
            new Vector2(1.0f, 1.0f)
        };

        var colors = new Color[]
        {
            color,
            color,
            color,
            color,
            new Color(color.r, color.g, color.b, 0.0f),
            new Color(color.r, color.g, color.b, 0.0f),
            new Color(color.r, color.g, color.b, 0.0f),
            new Color(color.r, color.g, color.b, 0.0f)
        };

        var mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;
        mesh.vertices = vertices;
        mesh.uv = uv;
        mesh.colors = colors;
        mesh.triangles = triangles;

        var renderer = GetComponent<MeshRenderer>();
        #if UNITY_EDITOR
        renderer.material = UnityEditor.AssetDatabase.GetBuiltinExtraResource<Material>("Sprites-Default.mat");
        #else
        renderer.material = Resources.GetBuiltinResource<Material>("Sprites-Default.mat");
        #endif
        renderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
        renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
        renderer.receiveShadows = false;
        renderer.lightProbeUsage = LightProbeUsage.Off;
    }
コード例 #20
0
ファイル: openvr_api.cs プロジェクト: 2asoft/SpaceEngineers
	public abstract bool SetWorkingPhysicalBoundsInfo(HmdQuad_t [] pQuadsBuffer);
コード例 #21
0
ファイル: openvr_api.cs プロジェクト: zekiguven/TERRA-Engine
	public abstract bool GetWorkingHardBoundsInfo(out HmdQuad_t [] pQuadsBuffer);
コード例 #22
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public abstract bool GetWorkingPlayAreaRect(ref HmdQuad_t rect);
コード例 #23
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public abstract void SetWorkingCollisionBoundsInfo(HmdQuad_t [] pQuadsBuffer);
コード例 #24
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public override bool GetWorkingPlayAreaRect(ref HmdQuad_t rect)
	{
		CheckIfUsable();
		bool result = VRNativeEntrypoints.VR_IVRChaperoneSetup_GetWorkingPlayAreaRect(m_pVRChaperoneSetup,ref rect);
		return result;
	}
コード例 #25
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public override void SetWorkingCollisionBoundsInfo(HmdQuad_t [] pQuadsBuffer)
	{
		CheckIfUsable();
		VRNativeEntrypoints.VR_IVRChaperoneSetup_SetWorkingCollisionBoundsInfo(m_pVRChaperoneSetup,pQuadsBuffer,(uint) pQuadsBuffer.Length);
	}
コード例 #26
0
    // Update is called once per frame
    void Update()
    {
        var  rect    = new Valve.VR.HmdQuad_t();
        bool success = OpenVR.Chaperone.GetPlayAreaRect(ref rect);

        //initialize playspace measures and send them to leap
        if (success && !GameSpaceMeasuresInitialized)
        {
            float[] x_values = { rect.vCorners0.v0, rect.vCorners1.v0, rect.vCorners2.v0, rect.vCorners3.v0 };
            float   max_x    = Mathf.Max(x_values);
            float   min_x    = Mathf.Min(x_values);

            /*GameObject sphere1 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
             * sphere1.transform.parent = transform;
             * sphere1.transform.localPosition = new Vector3(rect.vCorners0.v0, rect.vCorners0.v1, rect.vCorners0.v2);
             *
             * GameObject sphere2 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
             * sphere2.transform.parent = transform;
             * sphere2.transform.localPosition = new Vector3(rect.vCorners1.v0, rect.vCorners1.v1, rect.vCorners1.v2);
             *
             * GameObject sphere3 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
             * sphere3.transform.parent = transform;
             * sphere3.transform.localPosition = new Vector3(rect.vCorners2.v0, rect.vCorners2.v1, rect.vCorners2.v2);
             *
             * GameObject sphere4 = GameObject.CreatePrimitive(PrimitiveType.Sphere);
             * sphere4.transform.parent = transform;
             * sphere4.transform.localPosition = new Vector3(rect.vCorners3.v0, rect.vCorners3.v1, rect.vCorners3.v2);*/

            float[] z_values = { rect.vCorners0.v2, rect.vCorners1.v2, rect.vCorners2.v2, rect.vCorners3.v2 };
            float   max_z    = Mathf.Max(z_values);
            float   min_z    = Mathf.Min(z_values);

            Vector2 measures = new Vector2(max_x - min_x, max_z - min_z);

            //initialize playspace measures
            viveParamsAuthorityManager.SetPlaySpaceMeasures(measures);
            GameSpaceMeasuresInitialized = true;
        }

        lastRightGrabPinch = rightGrabPinch;
        rightGrabPinch     = SteamVR_Actions._default.GrabPinch.GetState(SteamVR_Input_Sources.RightHand);

        //game space extension
        Vector3 shift = calculateGameSpaceShift();


        //Debug.Log("Gamespace Extension Possible: " + sharedParameters.GameSpaceExtensionPossible());
        //ask if Leap Player also allows game space extension
        if (sharedParameters.GameSpaceExtensionPossible())
        {
            thisFrameExtensionPossible = true;
            transform.position        += new Vector3(shift.x, 0.0f, shift.z);
        }
        else
        {
            thisFrameExtensionPossible = false;
        }

        //currently stopped extending game space
        if (!thisFrameExtensionPossible && lastFrameExtensionPossible)
        {
            viveParamsAuthorityManager.SetPosition(transform.position);
        }
        lastFrameExtensionPossible = thisFrameExtensionPossible;
    }
コード例 #27
0
	public bool GetWorkingPlayAreaRect(ref HmdQuad_t rect)
	{
		bool result = FnTable.GetWorkingPlayAreaRect(ref rect);
		return result;
	}
コード例 #28
0
 public bool SetWorkingPhysicalBoundsInfo(HmdQuad_t[] pQuadsBuffer)
 {
     return this.FnTable.SetWorkingPhysicalBoundsInfo(pQuadsBuffer, (uint)pQuadsBuffer.Length);
 }
コード例 #29
0
ファイル: openvr_api.cs プロジェクト: zekiguven/TERRA-Engine
	public abstract void SetWorkingHardBoundsInfo(HmdQuad_t [] pQuadsBuffer);
コード例 #30
0
        public void BuildMesh()
        {
            var rect = new HmdQuad_t();

            if (!GetBounds(size, ref rect))
            {
                return;
            }

            var corners = new HmdVector3_t[] { rect.vCorners0, rect.vCorners1, rect.vCorners2, rect.vCorners3 };

            vertices = new Vector3[corners.Length * 2];
            for (int i = 0; i < corners.Length; i++)
            {
                var c = corners[i];
                vertices[i] = new Vector3(c.v0, 0.01f, c.v2);
            }

            if (borderThickness == 0.0f)
            {
                GetComponent <MeshFilter>().mesh = null;
                return;
            }

            for (int i = 0; i < corners.Length; i++)
            {
                int next = (i + 1) % corners.Length;
                int prev = (i + corners.Length - 1) % corners.Length;

                var nextSegment = (vertices[next] - vertices[i]).normalized;
                var prevSegment = (vertices[prev] - vertices[i]).normalized;

                var vert = vertices[i];
                vert += Vector3.Cross(nextSegment, Vector3.up) * borderThickness;
                vert += Vector3.Cross(prevSegment, Vector3.down) * borderThickness;

                vertices[corners.Length + i] = vert;
            }

            var triangles = new int[]
            {
                0, 4, 1,
                1, 4, 5,
                1, 5, 2,
                2, 5, 6,
                2, 6, 3,
                3, 6, 7,
                3, 7, 0,
                0, 7, 4
            };

            var uv = new Vector2[]
            {
                new Vector2(0.0f, 0.0f),
                new Vector2(1.0f, 0.0f),
                new Vector2(0.0f, 0.0f),
                new Vector2(1.0f, 0.0f),
                new Vector2(0.0f, 1.0f),
                new Vector2(1.0f, 1.0f),
                new Vector2(0.0f, 1.0f),
                new Vector2(1.0f, 1.0f)
            };

            var colors = new Color[]
            {
                color,
                color,
                color,
                color,
                new Color(color.r, color.g, color.b, 0.0f),
                new Color(color.r, color.g, color.b, 0.0f),
                new Color(color.r, color.g, color.b, 0.0f),
                new Color(color.r, color.g, color.b, 0.0f)
            };

            var mesh = new Mesh();

            GetComponent <MeshFilter>().mesh = mesh;
            mesh.vertices  = vertices;
            mesh.uv        = uv;
            mesh.colors    = colors;
            mesh.triangles = triangles;

            var renderer = GetComponent <MeshRenderer>();

            renderer.material             = new Material(Shader.Find("Sprites/Default"));
            renderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
            renderer.shadowCastingMode    = UnityEngine.Rendering.ShadowCastingMode.Off;
            renderer.receiveShadows       = false;
            renderer.lightProbeUsage      = LightProbeUsage.Off;
        }
コード例 #31
0
 public bool GetWorkingPlayAreaRect(ref HmdQuad_t rect)
 {
     return this.FnTable.GetWorkingPlayAreaRect(ref rect);
 }
コード例 #32
0
ファイル: openvr_api.cs プロジェクト: 2asoft/SpaceEngineers
	public abstract bool GetLivePhysicalBoundsInfo(out HmdQuad_t [] pQuadsBuffer);
コード例 #33
0
ファイル: World.cs プロジェクト: hsuanhauliu/RuGo
    public void ShowShelf(bool show)
    {
        if (!show)
        {
            BurstBubble();
            StartCoroutine(DelayHideShelf());
        }
        else
        {
            mGadgetShelf.SetActive(show);
            mGadgetShelf.GetComponent <AudioSource>().Play();

            Transform myCamera           = GameManager.Instance.MainCamera.transform;
            Vector3   pureCameraRotation = myCamera.rotation.eulerAngles;

            // Get play area size
            Valve.VR.HmdQuad_t roomSize = new Valve.VR.HmdQuad_t();
            Vector3            offset   = Vector3.zero;

            if (SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref roomSize))
            {
                Valve.VR.HmdVector3_t[] roomCorners = new Valve.VR.HmdVector3_t[] { roomSize.vCorners0, roomSize.vCorners1, roomSize.vCorners2, roomSize.vCorners3 };
                Vector3[] cornerPositions           = new Vector3[roomCorners.Length];
                for (int i = 0; i < roomCorners.Length; i++)
                {
                    cornerPositions[i] = new Vector3(roomCorners[i].v0, roomCorners[i].v1, roomCorners[i].v2);
                }

                // Get two corners
                float minX = 0.0f;
                float minZ = 0.0f;
                float maxX = 0.0f;
                float maxZ = 0.0f;
                for (int i = 0; i < cornerPositions.Length; i++)
                {
                    minX = Math.Min(minX, cornerPositions[i].x);
                    maxX = Math.Max(maxX, cornerPositions[i].x);
                    minZ = Math.Min(minZ, cornerPositions[i].z);
                    maxZ = Math.Max(maxZ, cornerPositions[i].z);
                }

                // Calculate the shelf's position
                Vector3 shelfPosition = myCamera.position + myCamera.forward * shelfRadius;

                if (shelfPosition.x < 0 && shelfPosition.x < minX)
                {
                    offset += new Vector3(minX - shelfPosition.x, 0, 0);
                }
                else if (shelfPosition.x > 0 && shelfPosition.x > maxX)
                {
                    offset -= new Vector3(shelfPosition.x - maxX, 0, 0);
                }

                if (shelfPosition.z < 0 && shelfPosition.z < minZ)
                {
                    offset += new Vector3(0, 0, minZ - shelfPosition.z);
                }
                else if (shelfPosition.z > 0 && shelfPosition.z > maxZ)
                {
                    offset -= new Vector3(0, 0, shelfPosition.z - maxZ);
                }
            }

            mGadgetShelf.transform.position = myCamera.position + offset;
            mGadgetShelf.transform.rotation = Quaternion.Euler(0.0f, myCamera.rotation.eulerAngles.y - 90.0f, 0.0f);

            for (int i = 0; i < shelfGadgetContainersPositions.Length; i++)
            {
                StartCoroutine(ShiftContainer(i, shelfGadgetContainersPositions[i]));
                StartCoroutine(RotateGadget(i));
            }

            for (int i = 0; i < NUM_SAVE_SLOTS; i++)
            {
                StartCoroutine(ShiftContainer(shelfGadgetContainersPositions.Length + i, shelfFileContainersPositions[i]));
                StartCoroutine(RotateGadget(shelfGadgetContainersPositions.Length + i));
            }
        }
    }
コード例 #34
0
	public bool GetWorkingCollisionBoundsInfo(out HmdQuad_t [] pQuadsBuffer)
	{
		uint punQuadsCount = 0;
		bool result = FnTable.GetWorkingCollisionBoundsInfo(null,ref punQuadsCount);
		pQuadsBuffer= new HmdQuad_t[punQuadsCount];
		result = FnTable.GetWorkingCollisionBoundsInfo(pQuadsBuffer,ref punQuadsCount);
		return result;
	}
コード例 #35
0
    void calculateAnalytics()
    {
        //gonna need a better algorithm for more tools

        if (Valve.VR.OpenVR.IsHmdPresent())
        {
            Valve.VR.HmdQuad_t roomDims = new Valve.VR.HmdQuad_t();
            SteamVR_PlayArea.GetBounds(SteamVR_PlayArea.Size.Calibrated, ref roomDims);
            Vector3 roomScale = new Vector3(Mathf.Abs(roomDims.vCorners0.v0 - roomDims.vCorners2.v0), Mathf.Abs(roomDims.vCorners0.v2 - roomDims.vCorners2.v2), 1);
            roomWidth  = roomScale.x;
            roomHeight = roomScale.y;
        }

        int   mostToolNum   = 0;
        float mostToolTimed = 0;

        foreach (KeyValuePair <string, ToolData> pair in toolMap)
        {
            if (pair.Value.Count > mostToolNum)
            {
                mostToolGrab = pair.Value.Name;
                mostToolNum  = pair.Value.Count;
            }

            if (pair.Value.Time > mostToolTimed)
            {
                mostToolTime  = pair.Value.Name;
                mostToolTimed = pair.Value.Time;
            }
        }

        string mostCommonPairLetters = MostCommonSubstring();

        if (mostCommonPairLetters.Length == 2)
        {
            string firstTool  = toolMap[mostCommonPairLetters[0].ToString()].Name;
            string secondTool = toolMap[mostCommonPairLetters[1].ToString()].Name;
            mostCommonToolPairs = firstTool + " to " + secondTool;
        }

        timeCamera       = toolMap["A"].Time;
        numCamera        = toolMap["A"].Count;
        timeBoolean      = toolMap["B"].Time;
        numBoolean       = toolMap["B"].Count;
        timeClone        = toolMap["C"].Time;
        numClone         = toolMap["C"].Count;
        timeDrawFace     = toolMap["D"].Time;
        numDrawFace      = toolMap["D"].Count;
        timeExtrude      = toolMap["E"].Time;
        numExtrude       = toolMap["E"].Count;
        timeLoft         = toolMap["F"].Time;
        numLoft          = toolMap["F"].Count;
        timeGroup        = toolMap["G"].Time;
        numGroup         = toolMap["G"].Count;
        timePrimitive    = toolMap["I"].Time;
        numPrimitive     = toolMap["I"].Count;
        timeClipping     = toolMap["K"].Time;
        numClipping      = toolMap["K"].Count;
        timeLine         = toolMap["L"].Time;
        numLine          = toolMap["L"].Count;
        timeMirror       = toolMap["M"].Time;
        numMirror        = toolMap["M"].Count;
        timeSelection    = toolMap["N"].Time;
        numSelection     = toolMap["N"].Count;
        timePolygon      = toolMap["O"].Time;
        numPolygon       = toolMap["O"].Count;
        timePaint        = toolMap["P"].Time;
        numPaint         = toolMap["P"].Count;
        timeEraser       = toolMap["R"].Time;
        numEraser        = toolMap["R"].Count;
        timeSpline       = toolMap["S"].Time;
        numSpline        = toolMap["S"].Count;
        timeGravity      = toolMap["V"].Time;
        numGravity       = toolMap["V"].Count;
        timeExtrudeCurve = toolMap["X"].Time;
        numExtrudeCurve  = toolMap["X"].Count;
        timeMeasuring    = toolMap["Z"].Time;
        numMeasuring     = toolMap["Z"].Count;

        //here i get the most used shapes and sections
        // this can be done more efficiently
        List <int> shapeList   = new List <int>();
        List <int> sectionList = new List <int>();

        shapeList.Add(numTriangle);
        shapeList.Add(numSquare);
        shapeList.Add(numCircle);
        sectionList.Add(numIsec);
        sectionList.Add(numCsec);
        sectionList.Add(numLsec);
        sectionList.Add(numTsec);

        int shapeNum = shapeList[0];
        int shapeInd = 0;
        int secNum   = sectionList[0];
        int secInd   = 0;

        for (int k = 0; k < shapeList.Count; k++)
        {
            if (shapeList[k] > shapeNum)
            {
                shapeNum = shapeList[k];
                shapeInd = k;
            }
        }

        for (int l = 0; l < sectionList.Count; l++)
        {
            if (sectionList[l] > shapeNum)
            {
                secNum = sectionList[l];
                secInd = l;
            }
        }

        if (shapeNum > 0)
        {
            switch (shapeInd)
            {
            case 0:
                commonShape = "Triangle";
                break;

            case 1:
                commonShape = "Square";
                break;

            case 2:
                commonShape = "Circle";
                break;
            }
        }
        else
        {
            commonShape = "NONE";
        }

        if (secNum > 0)
        {
            switch (secInd)
            {
            case 0:
                commonSection = "I Section";
                break;

            case 1:
                commonSection = "C Section";
                break;

            case 2:
                commonSection = "L Section";
                break;

            case 3:
                commonSection = "T Section";
                break;
            }
        }
        else
        {
            commonSection = "NONE";
        }

        if (shapeNum > secNum)
        {
            shapeVsSection = "Shape";
        }
        else if (secNum > shapeNum)
        {
            shapeVsSection = "Section";
        }
        else if (secNum == shapeNum)
        {
            shapeVsSection = "Equal";
        }

        float saveSum = 0;

        numSaves = saveSizes.Count;
        if (numSaves > 0)
        {
            for (int i = 0; i < numSaves; i++)
            {
                saveSum += saveSizes[i];
            }
            avgSaveSize = saveSum / numSaves;
        }
        else
        {
            avgSaveSize = 0;
        }


        //for now, just get color average, not common colors - pretty innacurate
        float sumR = 0;
        float sumG = 0;
        float sumB = 0;

        for (int ci = 0; ci < colors.Count; ci++)
        {
            float r = colors[ci].r;
            float g = colors[ci].g;
            float b = colors[ci].b;

            sumR += r;
            sumG += g;
            sumB += b;
        }

        float avgR = sumR / colors.Count;
        float avgG = sumG / colors.Count;
        float avgB = sumB / colors.Count;

        avgR *= 255.0f;
        avgG *= 255.0f;
        avgB *= 255.0f;

        avgColor = "(" + avgR + "," + avgG + "," + avgB + ")";

        if (heights.Count > 0)
        {
            userHeight = heights[heights.Count * 3 / 4];
        }
        else
        {
            userHeight = 0;
        }

        userHeight *= 1.5f;

        maxPeople = maxActive + maxPassiveVR + maxPassiveController + maxTheatre;

        TrackerScript.AddAction("*");
    }
コード例 #36
0
	public void SetWorkingCollisionBoundsInfo(HmdQuad_t [] pQuadsBuffer)
	{
		FnTable.SetWorkingCollisionBoundsInfo(pQuadsBuffer,(uint) pQuadsBuffer.Length);
	}
コード例 #37
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public override bool GetLiveCollisionBoundsInfo(out HmdQuad_t [] pQuadsBuffer)
	{
		CheckIfUsable();
		uint punQuadsCount = 0;
		bool result = VRNativeEntrypoints.VR_IVRChaperoneSetup_GetLiveCollisionBoundsInfo(m_pVRChaperoneSetup,null,ref punQuadsCount);
		pQuadsBuffer= new HmdQuad_t[punQuadsCount];
		result = VRNativeEntrypoints.VR_IVRChaperoneSetup_GetLiveCollisionBoundsInfo(m_pVRChaperoneSetup,pQuadsBuffer,ref punQuadsCount);
		return result;
	}
コード例 #38
0
	public bool SetWorkingPhysicalBoundsInfo(HmdQuad_t [] pQuadsBuffer)
	{
		bool result = FnTable.SetWorkingPhysicalBoundsInfo(pQuadsBuffer,(uint) pQuadsBuffer.Length);
		return result;
	}
コード例 #39
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	internal static extern bool VR_IVRChaperoneSetup_GetWorkingPlayAreaRect(IntPtr instancePtr, ref HmdQuad_t rect);
コード例 #40
0
	public bool GetLivePhysicalBoundsInfo(out HmdQuad_t [] pQuadsBuffer)
	{
		uint punQuadsCount = 0;
		bool result = FnTable.GetLivePhysicalBoundsInfo(null,ref punQuadsCount);
		pQuadsBuffer= new HmdQuad_t[punQuadsCount];
		result = FnTable.GetLivePhysicalBoundsInfo(pQuadsBuffer,ref punQuadsCount);
		return result;
	}
コード例 #41
0
ファイル: openvr_api.cs プロジェクト: Black4Blade/NewtonVR
	public abstract bool GetLiveCollisionBoundsInfo(out HmdQuad_t [] pQuadsBuffer);
コード例 #42
0
    void Awake()
    {
        resetDimensions();

        // Remember the dimensions of the base:
        initialBaseWidth = rectBase.GetComponent <Renderer>().bounds.size.x;
        initialBaseDepth = rectBase.GetComponent <Renderer>().bounds.size.z;

        if (viveRig.activeInHierarchy)
        {
            // Default values:
            float width = 3f;
            float depth = 2f;
            // Try to get the room size from the mesh:
            SteamVR_PlayArea playArea = viveRig.GetComponent <SteamVR_PlayArea>();
            if (playArea != null)
            {
                Valve.VR.HmdQuad_t rect = new Valve.VR.HmdQuad_t();
                if (SteamVR_PlayArea.GetBounds(playArea.size, ref rect))
                {
                    var corners = new Valve.VR.HmdVector3_t[] { rect.vCorners0, rect.vCorners1, rect.vCorners2, rect.vCorners3 };

                    Vector2 min = new Vector2(float.MaxValue, float.MaxValue);
                    Vector2 max = new Vector2(float.MinValue, float.MinValue);
                    for (int i = 0; i < corners.Length; i++)
                    {
                        if (corners [i].v0 < min.x)
                        {
                            min.x = corners [i].v0;
                        }
                        if (corners [i].v2 < min.y)
                        {
                            min.y = corners [i].v2;
                        }

                        if (corners [i].v0 > max.x)
                        {
                            max.x = corners [i].v0;
                        }
                        if (corners [i].v2 > max.y)
                        {
                            max.y = corners [i].v2;
                        }
                    }

                    Vector2 size = max - min;
                    width = size.x;
                    depth = size.y;
                }
            }

            /*Mesh roomMesh = viveRig.GetComponent<MeshFilter>().mesh;
             * if (roomMesh != null) {
             *      width = roomMesh.bounds.size.x;
             *      depth = roomMesh.bounds.size.z;
             *      SteamVR_PlayArea playArea.
             *      Debug.Log ("Room mesh found. Setting room size to " + width + "x" + depth + "m.");
             * }*/
            setRectangular(width, depth);
        }
        else
        {
            setRounded();
        }
    }
コード例 #43
0
        public static bool GetBounds(Size size, ref HmdQuad_t pRect)
        {
            if (size == Size.Calibrated)
            {
                bool temporarySession = false;
                if (Application.isEditor && Application.isPlaying == false)
                {
                    temporarySession = SteamVR.InitializeTemporarySession();
                }

                var  chaperone = OpenVR.Chaperone;
                bool success   = (chaperone != null) && chaperone.GetPlayAreaRect(ref pRect);
                if (!success)
                {
                    Debug.LogWarning(
                        "<b>[SteamVR]</b> Failed to get Calibrated Play Area bounds!  Make sure you have tracking first, and that your space is calibrated.");
                }

                if (temporarySession)
                {
                    SteamVR.ExitTemporarySession();
                }

                return(success);
            }
            else
            {
                try
                {
                    var str = size.ToString().Substring(1);
                    var arr = str.Split(new char[] { 'x' }, 2);

                    // convert to half size in meters (from cm)
                    var x = float.Parse(arr[0]) / 200;
                    var z = float.Parse(arr[1]) / 200;

                    pRect.vCorners0.v0 = x;
                    pRect.vCorners0.v1 = 0;
                    pRect.vCorners0.v2 = -z;

                    pRect.vCorners1.v0 = -x;
                    pRect.vCorners1.v1 = 0;
                    pRect.vCorners1.v2 = -z;

                    pRect.vCorners2.v0 = -x;
                    pRect.vCorners2.v1 = 0;
                    pRect.vCorners2.v2 = z;

                    pRect.vCorners3.v0 = x;
                    pRect.vCorners3.v1 = 0;
                    pRect.vCorners3.v2 = z;

                    return(true);
                }
                catch
                {
                }
            }

            return(false);
        }
コード例 #44
0
ファイル: openvr_api.cs プロジェクト: 2asoft/SpaceEngineers
	public override bool SetWorkingPhysicalBoundsInfo(HmdQuad_t [] pQuadsBuffer)
	{
		CheckIfUsable();
		bool result = VRNativeEntrypoints.VR_IVRChaperoneSetup_SetWorkingPhysicalBoundsInfo(m_pVRChaperoneSetup,pQuadsBuffer,(uint) pQuadsBuffer.Length);
		return result;
	}