Пример #1
0
        internal ovrDistortionMesh(ovrDistortionMesh_Raw raw)
        {
            this.VertexCount = raw.VertexCount;
            this.pVertexData = new ovrDistortionVertex[this.VertexCount];
            this.IndexCount  = raw.IndexCount;
            this.pIndexData  = new short[this.IndexCount];

            // Copy data
            System.Type vertexType = typeof(ovrDistortionVertex);
            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] = (ovrDistortionVertex)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;
            }
        }
Пример #2
0
        // Generate distortion mesh per eye.
        // Distortion capabilities will depend on 'distortionCaps' flags; user should rely on
        // appropriate shaders based on their settings.
        // Distortion mesh data will be allocated and stored 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 overriden here.
        public ovrDistortionMesh? CreateDistortionMesh(ovrEyeType eye,
            ovrFovPort fov,
            uint distortionCaps)
        {
            ovrDistortionMesh_Raw rawMesh = new ovrDistortionMesh_Raw();

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

            ovrDistortionMesh mesh = new ovrDistortionMesh(rawMesh);
            ovrHmd_DestroyDistortionMesh(ref rawMesh);
            return mesh;
        }
Пример #3
0
 private static extern void ovrHmd_DestroyDistortionMesh(ref ovrDistortionMesh_Raw meshData);