Esempio n. 1
0
		private static extern void ovrHmd_DestroyDistortionMesh(ref DistortionMesh_Raw meshData);
Esempio n. 2
0
		internal DistortionMesh(DistortionMesh_Raw raw)
		{
			this.VertexCount = raw.VertexCount;
			this.pVertexData = new DistortionVertex[this.VertexCount];
			this.IndexCount  = raw.IndexCount;
			this.pIndexData  = new short[this.IndexCount];

			// Copy data
			System.Type vertexType = typeof(DistortionVertex);
			Int32 vertexSize = Marshal.SizeOf(vertexType);
			Int32 indexSize  = sizeof(short);
			Int64 pvertices  = raw.pVertexData.ToInt64();
			Int64 pindices   = raw.pIndexData.ToInt64();

			// TODO: Investigate using Marshal.Copy() or Buffer.BlockCopy() for improved performance

			for (int i = 0; i < raw.VertexCount; i++)
			{
				pVertexData[i] = (DistortionVertex)Marshal.PtrToStructure(new IntPtr(pvertices), vertexType);
				pvertices += vertexSize;
			}
			// Indices are stored as shorts.
			for (int j = 0; j < raw.IndexCount; j++)
			{
				pIndexData[j] = Marshal.ReadInt16(new IntPtr(pindices));
				pindices += indexSize;
			}
		}
Esempio n. 3
0
        /// <summary>
		/// Generate distortion mesh per eye.
		/// Distortion capabilities will depend on 'distortionCaps' flags. Users should
		/// render using the appropriate shaders based on their settings.
		/// Distortion mesh data will be allocated and written into the ovrDistortionMesh data structure,
		/// which should be explicitly freed with ovrHmd_DestroyDistortionMesh.
		/// Users should call ovrHmd_GetRenderScaleAndOffset to get uvScale and Offset values for rendering.
		/// The function shouldn't fail unless theres is a configuration or memory error, in which case
		/// ovrDistortionMesh values will be set to null.
		/// This is the only function in the SDK reliant on eye relief, currently imported from profiles,
		/// or overridden here.
        /// </summary>
		public DistortionMesh? CreateDistortionMesh(Eye eye, FovPort fov, uint distortionCaps)
		{
			DistortionMesh_Raw rawMesh = new DistortionMesh_Raw();

            bool result = ovrHmd_CreateDistortionMesh(HmdPtr, eye, fov, distortionCaps, out rawMesh) != 0;
            if (!result)
			{
				return null;
			}

			DistortionMesh mesh = new DistortionMesh(rawMesh);
			ovrHmd_DestroyDistortionMesh(ref rawMesh);
			return mesh;
		}
Esempio n. 4
0
File: OvrCapi.cs Progetto: uxl/rdgvr
        public DistortionMesh? CreateDistortionMeshDebug(Eye eye, FovPort fov, uint distortionCaps, float debugEyeReliefOverrideInMeters)
        {
            DistortionMesh_Raw rawMesh = new DistortionMesh_Raw();

            bool result = ovrHmd_CreateDistortionMeshDebug(
                HmdPtr,
                eye,
                fov,
                distortionCaps,
                out rawMesh,
                debugEyeReliefOverrideInMeters) != 0;

            if (!result)
            {
                return null;
            }

            DistortionMesh mesh = new DistortionMesh(rawMesh);
            ovrHmd_DestroyDistortionMesh(ref rawMesh);
            return mesh;
        }