// Token: 0x0600065A RID: 1626 RVA: 0x0001E5E4 File Offset: 0x0001C7E4
        public global::UnityEngine.Vector2 GetAxis(global::Valve.VR.EVRButtonId buttonId = global::Valve.VR.EVRButtonId.k_EButton_Axis0)
        {
            this.Update();
            global::UnityEngine.Vector2 result;
            switch (buttonId)
            {
            case global::Valve.VR.EVRButtonId.k_EButton_Axis0:
                result = new global::UnityEngine.Vector2(this.state.rAxis0.x, this.state.rAxis0.y);
                break;

            case global::Valve.VR.EVRButtonId.k_EButton_Axis1:
                result = new global::UnityEngine.Vector2(this.state.rAxis1.x, this.state.rAxis1.y);
                break;

            case global::Valve.VR.EVRButtonId.k_EButton_Axis2:
                result = new global::UnityEngine.Vector2(this.state.rAxis2.x, this.state.rAxis2.y);
                break;

            case global::Valve.VR.EVRButtonId.k_EButton_Axis3:
                result = new global::UnityEngine.Vector2(this.state.rAxis3.x, this.state.rAxis3.y);
                break;

            case global::Valve.VR.EVRButtonId.k_EButton_Axis4:
                result = new global::UnityEngine.Vector2(this.state.rAxis4.x, this.state.rAxis4.y);
                break;

            default:
                result = global::UnityEngine.Vector2.zero;
                break;
            }
            return(result);
        }
示例#2
0
 // Token: 0x0600057D RID: 1405 RVA: 0x0001B524 File Offset: 0x00019724
 public static global::UnityEngine.Vector3 GetBarycentric(global::UnityEngine.Vector2 v1, global::UnityEngine.Vector2 v2, global::UnityEngine.Vector2 v3, global::UnityEngine.Vector2 p)
 {
     global::UnityEngine.Vector3 vector = default(global::UnityEngine.Vector3);
     vector.x = ((v2.y - v3.y) * (p.x - v3.x) + (v3.x - v2.x) * (p.y - v3.y)) / ((v2.y - v3.y) * (v1.x - v3.x) + (v3.x - v2.x) * (v1.y - v3.y));
     vector.y = ((v3.y - v1.y) * (p.x - v3.x) + (v1.x - v3.x) * (p.y - v3.y)) / ((v3.y - v1.y) * (v2.x - v3.x) + (v1.x - v3.x) * (v2.y - v3.y));
     vector.z = 1f - vector.x - vector.y;
     return(vector);
 }
示例#3
0
        // Token: 0x0600045C RID: 1116 RVA: 0x00015B58 File Offset: 0x00013D58
        protected override void OnUpdate()
        {
            base.OnUpdate();
            global::SteamVR_Controller.Device controller = base.Controller;
            bool pressDown = controller.GetPressDown(12884901888UL);

            if (pressDown)
            {
                global::VRGIN.Core.VR.Input.Mouse.LeftButtonDown();
                this.pressDownTime = global::UnityEngine.Time.unscaledTime;
            }
            bool pressUp = controller.GetPressUp(4UL);

            if (pressUp)
            {
                bool flag = this.Gui;
                if (flag)
                {
                    this.AbandonGUI();
                }
                else
                {
                    this.TakeGUI(global::System.Linq.Enumerable.FirstOrDefault <global::VRGIN.Visuals.GUIQuad>(global::VRGIN.Visuals.GUIQuadRegistry.Quads, (global::VRGIN.Visuals.GUIQuad q) => !q.IsOwned));
                }
            }
            bool touchDown = controller.GetTouchDown(4294967296UL);

            if (touchDown)
            {
                this.touchDownPosition      = controller.GetAxis(global::Valve.VR.EVRButtonId.k_EButton_Axis0);
                this.touchDownMousePosition = global::VRGIN.Native.MouseOperations.GetClientCursorPosition();
            }
            bool flag2 = controller.GetTouch(4294967296UL) && global::UnityEngine.Time.unscaledTime - this.pressDownTime > 0.3f;

            if (flag2)
            {
                global::UnityEngine.Vector2 axis   = controller.GetAxis(global::Valve.VR.EVRButtonId.k_EButton_Axis0);
                global::UnityEngine.Vector2 vector = axis - ((global::VRGIN.Core.VR.HMD == global::VRGIN.Core.HMDType.Oculus) ? global::UnityEngine.Vector2.zero : this.touchDownPosition);
                float num = (global::VRGIN.Core.VR.HMD == global::VRGIN.Core.HMDType.Oculus) ? (global::UnityEngine.Time.unscaledDeltaTime * 5f) : 1f;
                this._DeltaX += (double)(vector.x * (float)global::VRGIN.Core.VRGUI.Width) * 0.1 * (double)num;
                this._DeltaY += (double)(-(double)vector.y * (float)global::VRGIN.Core.VRGUI.Height) * 0.2 * (double)num;
                int num2 = (int)((this._DeltaX > 0.0) ? global::System.Math.Floor(this._DeltaX) : global::System.Math.Ceiling(this._DeltaX));
                int num3 = (int)((this._DeltaY > 0.0) ? global::System.Math.Floor(this._DeltaY) : global::System.Math.Ceiling(this._DeltaY));
                this._DeltaX -= (double)num2;
                this._DeltaY -= (double)num3;
                global::VRGIN.Core.VR.Input.Mouse.MoveMouseBy(num2, num3);
                this.touchDownPosition = axis;
            }
            bool pressUp2 = controller.GetPressUp(12884901888UL);

            if (pressUp2)
            {
                global::VRGIN.Core.VR.Input.Mouse.LeftButtonUp();
                this.pressDownTime = 0f;
            }
        }
示例#4
0
        // Token: 0x06000632 RID: 1586 RVA: 0x0001DEF0 File Offset: 0x0001C0F0
        private static string FieldToString(string memberName, object value)
        {
            bool   flag = value == null;
            string result;

            if (flag)
            {
                result = null;
            }
            else
            {
                if (memberName != null)
                {
                    if (memberName == "cullingMask")
                    {
                        return(string.Join(", ", global::EscalationVR.UnityHelper.GetLayerNames((int)value)));
                    }
                    if (memberName == "renderer")
                    {
                        return(((global::UnityEngine.Renderer)value).material.shader.name);
                    }
                }
                bool flag2 = value is global::UnityEngine.Vector3;
                if (flag2)
                {
                    global::UnityEngine.Vector3 vector = (global::UnityEngine.Vector3)value;
                    result = string.Format("({0:0.000}, {1:0.000}, {2:0.000})", vector.x, vector.y, vector.z);
                }
                else
                {
                    bool flag3 = value is global::UnityEngine.Vector2;
                    if (flag3)
                    {
                        global::UnityEngine.Vector2 vector2 = (global::UnityEngine.Vector2)value;
                        result = string.Format("({0:0.000}, {1:0.000})", vector2.x, vector2.y);
                    }
                    else
                    {
                        result = value.ToString();
                    }
                }
            }
            return(result);
        }
示例#5
0
        // Token: 0x06000477 RID: 1143 RVA: 0x000163B8 File Offset: 0x000145B8
        private void CheckRotationalPress()
        {
            bool pressDown = base.Controller.GetPressDown(global::Valve.VR.EVRButtonId.k_EButton_Axis0);

            if (pressDown)
            {
                global::UnityEngine.Vector2 axis = base.Controller.GetAxis(global::Valve.VR.EVRButtonId.k_EButton_Axis0);
                this._ProspectedPlayArea.Reset();
                bool flag = axis.x < -0.2f;
                if (flag)
                {
                    this._ProspectedPlayArea.Rotation -= 20f;
                }
                else
                {
                    bool flag2 = axis.x > 0.2f;
                    if (flag2)
                    {
                        this._ProspectedPlayArea.Rotation += 20f;
                    }
                }
                this._ProspectedPlayArea.Apply();
            }
        }
示例#6
0
        // Token: 0x0600024D RID: 589 RVA: 0x0000E760 File Offset: 0x0000C960
        public void Rebuild()
        {
            this.modelMesh       = new global::UnityEngine.Mesh();
            this.modelMesh.name  = "ProceduralPlaneMesh";
            this.meshFilter      = base.gameObject.GetComponent <global::UnityEngine.MeshFilter>();
            this.meshFilter.mesh = this.modelMesh;
            bool flag = this.xSegments < 1;

            if (flag)
            {
                this.xSegments = 1;
            }
            bool flag2 = this.ySegments < 1;

            if (flag2)
            {
                this.ySegments = 1;
            }
            this.numVertexColumns = this.xSegments + 1;
            this.numVertexRows    = this.ySegments + 1;
            int num  = this.numVertexColumns * this.numVertexRows;
            int num2 = num;
            int num3 = this.xSegments * this.ySegments * 2;
            int num4 = num3 * 3;

            global::UnityEngine.Vector3[] array  = new global::UnityEngine.Vector3[num];
            global::UnityEngine.Vector2[] array2 = new global::UnityEngine.Vector2[num2];
            int[] array3 = new int[num4];
            float num5   = this.width / (float)this.xSegments;
            float num6   = this.height / (float)this.ySegments;
            float num7   = 1f / (float)this.xSegments;
            float num8   = 1f / (float)this.ySegments;
            float num9   = -this.width / 2f;
            float num10  = -this.height / 2f;
            float num11  = this.angleSpan * 3.14159274f / 180f;
            float num12  = 1f;
            float num13  = (float)global::UnityEngine.Screen.width / (float)global::UnityEngine.Screen.height;
            float num14  = num11 / num12;

            for (int i = 0; i < this.numVertexRows; i++)
            {
                for (int j = 0; j < this.numVertexColumns; j++)
                {
                    global::UnityEngine.Vector3 vector;
                    vector..ctor((float)j * num5 + num9 + this.bottomLeftOffset.x * (float)(this.numVertexColumns - 1 - j) / (float)(this.numVertexColumns - 1) * (float)(this.numVertexRows - 1 - i) / (float)(this.numVertexRows - 1) + this.bottomRightOffset.x * (float)j / (float)(this.numVertexColumns - 1) * (float)(this.numVertexRows - 1 - i) / (float)(this.numVertexRows - 1) + this.topLeftOffset.x * (float)(this.numVertexColumns - 1 - j) / (float)(this.numVertexColumns - 1) * (float)i / (float)(this.numVertexRows - 1) + this.topRightOffset.x * (float)j / (float)(this.numVertexColumns - 1) * (float)i / (float)(this.numVertexRows - 1), (float)i * num6 + num10 + this.bottomLeftOffset.y * (float)(this.numVertexColumns - 1 - j) / (float)(this.numVertexColumns - 1) * (float)(this.numVertexRows - 1 - i) / (float)(this.numVertexRows - 1) + this.bottomRightOffset.y * (float)j / (float)(this.numVertexColumns - 1) * (float)(this.numVertexRows - 1 - i) / (float)(this.numVertexRows - 1) + this.topLeftOffset.y * (float)(this.numVertexColumns - 1 - j) / (float)(this.numVertexColumns - 1) * (float)i / (float)(this.numVertexRows - 1) + this.topRightOffset.y * (float)j / (float)(this.numVertexColumns - 1) * (float)i / (float)(this.numVertexRows - 1) - (this.height - 1f) / 2f, this.distance);
                    float num15 = global::UnityEngine.Mathf.Lerp(num13 * this.height * vector.x, global::UnityEngine.Mathf.Cos(1.57079637f - vector.x * num14) * this.distance, global::UnityEngine.Mathf.Clamp01(this.curviness));
                    float num16 = global::UnityEngine.Mathf.Sin(1.57079637f - vector.x * num14 * global::UnityEngine.Mathf.Clamp01(this.curviness));
                    int   num17 = i * this.numVertexColumns + j;
                    array[num17] = new global::UnityEngine.Vector3(num15, vector.y, num16);
                    bool flag3 = this.curviness > 1f;
                    if (flag3)
                    {
                        float num18 = this.curviness - 1f;
                        array[num17] = global::UnityEngine.Vector3.Lerp(array[num17], array[num17].normalized * this.distance, global::UnityEngine.Mathf.Clamp01(num18));
                    }
                    array2[num17] = new global::UnityEngine.Vector2((float)j * num7, (float)i * num8);
                    bool flag4 = i == 0 || j >= this.numVertexColumns - 1;
                    if (!flag4)
                    {
                        int num19 = (i - 1) * this.xSegments * 6 + j * 6;
                        array3[num19]     = i * this.numVertexColumns + j;
                        array3[num19 + 1] = i * this.numVertexColumns + j + 1;
                        array3[num19 + 2] = (i - 1) * this.numVertexColumns + j;
                        array3[num19 + 3] = (i - 1) * this.numVertexColumns + j;
                        array3[num19 + 4] = i * this.numVertexColumns + j + 1;
                        array3[num19 + 5] = (i - 1) * this.numVertexColumns + j + 1;
                    }
                }
            }
            this.modelMesh.Clear();
            this.modelMesh.vertices  = array;
            this.modelMesh.uv        = array2;
            this.modelMesh.triangles = array3;
            this.modelMesh.RecalculateNormals();
            this.modelMesh.RecalculateBounds();
        }
示例#7
0
 // Token: 0x0600057F RID: 1407 RVA: 0x0001B6A4 File Offset: 0x000198A4
 public static global::UnityEngine.Vector3[] GetMappedPoints(this global::UnityEngine.Mesh aMesh, global::UnityEngine.Vector2 aUVPos)
 {
     global::System.Collections.Generic.List <global::UnityEngine.Vector3> list = new global::System.Collections.Generic.List <global::UnityEngine.Vector3>();
     global::UnityEngine.Vector3[] vertices = aMesh.vertices;
     global::UnityEngine.Vector2[] uv       = aMesh.uv;
     int[] triangles = aMesh.triangles;
     for (int i = 0; i < triangles.Length; i += 3)
     {
         int num  = triangles[i];
         int num2 = triangles[i + 1];
         int num3 = triangles[i + 2];
         global::UnityEngine.Vector3 barycentric = global::VRGIN.Helpers.MeshExtension.GetBarycentric(uv[num], uv[num2], uv[num3], aUVPos);
         bool flag = global::VRGIN.Helpers.MeshExtension.InTriangle(barycentric);
         if (flag)
         {
             global::UnityEngine.Vector3 vector = barycentric.x * vertices[num] + barycentric.y * vertices[num2] + barycentric.z * vertices[num3];
             list.Add(vector);
         }
     }
     return(list.ToArray());
 }
 // Token: 0x060000E9 RID: 233 RVA: 0x0000A130 File Offset: 0x00008330
 private void Update()
 {
     foreach (int num in this.controllerIndices)
     {
         global::SteamVR_Overlay instance = global::SteamVR_Overlay.instance;
         bool flag = instance && this.point && this.pointer;
         if (flag)
         {
             global::SteamVR_Utils.RigidTransform transform = global::SteamVR_Controller.Input(num).transform;
             this.pointer.transform.localPosition = transform.pos;
             this.pointer.transform.localRotation = transform.rot;
             global::SteamVR_Overlay.IntersectionResults intersectionResults = default(global::SteamVR_Overlay.IntersectionResults);
             bool flag2 = instance.ComputeIntersection(transform.pos, transform.rot * global::UnityEngine.Vector3.forward, ref intersectionResults);
             bool flag3 = flag2;
             if (flag3)
             {
                 this.point.transform.localPosition = intersectionResults.point;
                 this.point.transform.localRotation = global::UnityEngine.Quaternion.LookRotation(intersectionResults.normal);
             }
         }
         else
         {
             foreach (global::Valve.VR.EVRButtonId evrbuttonId in this.buttonIds)
             {
                 bool pressDown = global::SteamVR_Controller.Input(num).GetPressDown(evrbuttonId);
                 if (pressDown)
                 {
                     global::UnityEngine.Debug.Log(evrbuttonId.ToString() + " press down");
                 }
                 bool pressUp = global::SteamVR_Controller.Input(num).GetPressUp(evrbuttonId);
                 if (pressUp)
                 {
                     global::UnityEngine.Debug.Log(evrbuttonId.ToString() + " press up");
                     bool flag4 = evrbuttonId == global::Valve.VR.EVRButtonId.k_EButton_Axis1;
                     if (flag4)
                     {
                         global::SteamVR_Controller.Input(num).TriggerHapticPulse(500, global::Valve.VR.EVRButtonId.k_EButton_Axis0);
                         this.PrintControllerStatus(num);
                     }
                 }
                 bool press = global::SteamVR_Controller.Input(num).GetPress(evrbuttonId);
                 if (press)
                 {
                     global::UnityEngine.Debug.Log(evrbuttonId);
                 }
             }
             foreach (global::Valve.VR.EVRButtonId buttonId in this.axisIds)
             {
                 bool touchDown = global::SteamVR_Controller.Input(num).GetTouchDown(buttonId);
                 if (touchDown)
                 {
                     global::UnityEngine.Debug.Log(buttonId.ToString() + " touch down");
                 }
                 bool touchUp = global::SteamVR_Controller.Input(num).GetTouchUp(buttonId);
                 if (touchUp)
                 {
                     global::UnityEngine.Debug.Log(buttonId.ToString() + " touch up");
                 }
                 bool touch = global::SteamVR_Controller.Input(num).GetTouch(buttonId);
                 if (touch)
                 {
                     global::UnityEngine.Vector2 axis = global::SteamVR_Controller.Input(num).GetAxis(buttonId);
                     string text = "axis: ";
                     global::UnityEngine.Vector2 vector = axis;
                     global::UnityEngine.Debug.Log(text + vector.ToString());
                 }
             }
         }
     }
 }
示例#9
0
    // Token: 0x060000A2 RID: 162 RVA: 0x00007B2C File Offset: 0x00005D2C
    public void BuildMesh()
    {
        global::Valve.VR.HmdQuad_t hmdQuad_t = default(global::Valve.VR.HmdQuad_t);
        bool flag = !global::SteamVR_PlayArea.GetBounds(this.size, ref hmdQuad_t);

        if (!flag)
        {
            global::Valve.VR.HmdVector3_t[] array = new global::Valve.VR.HmdVector3_t[]
            {
                hmdQuad_t.vCorners0,
                hmdQuad_t.vCorners1,
                hmdQuad_t.vCorners2,
                hmdQuad_t.vCorners3
            };
            this.vertices = new global::UnityEngine.Vector3[array.Length * 2];
            for (int i = 0; i < array.Length; i++)
            {
                global::Valve.VR.HmdVector3_t hmdVector3_t = array[i];
                this.vertices[i] = new global::UnityEngine.Vector3(hmdVector3_t.v0, 0.01f, hmdVector3_t.v2);
            }
            bool flag2 = this.borderThickness == 0f;
            if (flag2)
            {
                base.GetComponent <global::UnityEngine.MeshFilter>().mesh = null;
            }
            else
            {
                for (int j = 0; j < array.Length; j++)
                {
                    int num  = (j + 1) % array.Length;
                    int num2 = (j + array.Length - 1) % array.Length;
                    global::UnityEngine.Vector3 normalized  = (this.vertices[num] - this.vertices[j]).normalized;
                    global::UnityEngine.Vector3 normalized2 = (this.vertices[num2] - this.vertices[j]).normalized;
                    global::UnityEngine.Vector3 vector      = this.vertices[j];
                    vector += global::UnityEngine.Vector3.Cross(normalized, global::UnityEngine.Vector3.up) * this.borderThickness;
                    vector += global::UnityEngine.Vector3.Cross(normalized2, global::UnityEngine.Vector3.down) * this.borderThickness;
                    this.vertices[array.Length + j] = vector;
                }
                int[] 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
                };
                global::UnityEngine.Vector2[] uv = new global::UnityEngine.Vector2[]
                {
                    new global::UnityEngine.Vector2(0f, 0f),
                    new global::UnityEngine.Vector2(1f, 0f),
                    new global::UnityEngine.Vector2(0f, 0f),
                    new global::UnityEngine.Vector2(1f, 0f),
                    new global::UnityEngine.Vector2(0f, 1f),
                    new global::UnityEngine.Vector2(1f, 1f),
                    new global::UnityEngine.Vector2(0f, 1f),
                    new global::UnityEngine.Vector2(1f, 1f)
                };
                global::UnityEngine.Color[] colors = new global::UnityEngine.Color[]
                {
                    this.color,
                    this.color,
                    this.color,
                    this.color,
                    new global::UnityEngine.Color(this.color.r, this.color.g, this.color.b, 0f),
                    new global::UnityEngine.Color(this.color.r, this.color.g, this.color.b, 0f),
                    new global::UnityEngine.Color(this.color.r, this.color.g, this.color.b, 0f),
                    new global::UnityEngine.Color(this.color.r, this.color.g, this.color.b, 0f)
                };
                global::UnityEngine.Mesh mesh = new global::UnityEngine.Mesh();
                base.GetComponent <global::UnityEngine.MeshFilter>().mesh = mesh;
                mesh.vertices  = this.vertices;
                mesh.uv        = uv;
                mesh.colors    = colors;
                mesh.triangles = triangles;
                global::UnityEngine.MeshRenderer component = base.GetComponent <global::UnityEngine.MeshRenderer>();
                component.material             = global::UnityEngine.Resources.GetBuiltinResource <global::UnityEngine.Material>("Sprites-Default.mat");
                component.reflectionProbeUsage = 0;
                component.shadowCastingMode    = 0;
                component.receiveShadows       = false;
                component.useLightProbes       = false;
            }
        }
    }
示例#10
0
 // Token: 0x060000FD RID: 253 RVA: 0x0000A9B4 File Offset: 0x00008BB4
 public static global::UnityEngine.Vector2 Abs(global::UnityEngine.Vector2 A)
 {
     return(new global::UnityEngine.Vector2(global::SteamVR_Utils.Abs(A.x), global::SteamVR_Utils.Abs(A.y)));
 }
示例#11
0
    // Token: 0x060000C9 RID: 201 RVA: 0x00008D80 File Offset: 0x00006F80
    private global::SteamVR_RenderModel.RenderModel LoadRenderModel(global::Valve.VR.CVRRenderModels renderModels, string renderModelName, string baseName)
    {
        global::System.IntPtr zero = global::System.IntPtr.Zero;
        global::Valve.VR.EVRRenderModelError evrrenderModelError;
        for (;;)
        {
            evrrenderModelError = renderModels.LoadRenderModel_Async(renderModelName, ref zero);
            bool flag = evrrenderModelError != global::Valve.VR.EVRRenderModelError.Loading;
            if (flag)
            {
                break;
            }
            global::System.Threading.Thread.Sleep(1);
        }
        bool flag2 = evrrenderModelError > global::Valve.VR.EVRRenderModelError.None;

        global::SteamVR_RenderModel.RenderModel result;
        if (flag2)
        {
            global::UnityEngine.Debug.LogError(string.Format("Failed to load render model {0} - {1}", renderModelName, evrrenderModelError.ToString()));
            result = null;
        }
        else
        {
            global::Valve.VR.RenderModel_t renderModel_t  = (global::Valve.VR.RenderModel_t)global::System.Runtime.InteropServices.Marshal.PtrToStructure(zero, typeof(global::Valve.VR.RenderModel_t));
            global::UnityEngine.Vector3[]  array          = new global::UnityEngine.Vector3[renderModel_t.unVertexCount];
            global::UnityEngine.Vector3[]  array2         = new global::UnityEngine.Vector3[renderModel_t.unVertexCount];
            global::UnityEngine.Vector2[]  array3         = new global::UnityEngine.Vector2[renderModel_t.unVertexCount];
            global::System.Type            typeFromHandle = typeof(global::Valve.VR.RenderModel_Vertex_t);
            int num = 0;
            while ((long)num < (long)((ulong)renderModel_t.unVertexCount))
            {
                global::System.IntPtr intPtr;
                intPtr..ctor(renderModel_t.rVertexData.ToInt64() + (long)(num * global::System.Runtime.InteropServices.Marshal.SizeOf(typeFromHandle)));
                global::Valve.VR.RenderModel_Vertex_t renderModel_Vertex_t = (global::Valve.VR.RenderModel_Vertex_t)global::System.Runtime.InteropServices.Marshal.PtrToStructure(intPtr, typeFromHandle);
                array[num]  = new global::UnityEngine.Vector3(renderModel_Vertex_t.vPosition.v0, renderModel_Vertex_t.vPosition.v1, -renderModel_Vertex_t.vPosition.v2);
                array2[num] = new global::UnityEngine.Vector3(renderModel_Vertex_t.vNormal.v0, renderModel_Vertex_t.vNormal.v1, -renderModel_Vertex_t.vNormal.v2);
                array3[num] = new global::UnityEngine.Vector2(renderModel_Vertex_t.rfTextureCoord0, renderModel_Vertex_t.rfTextureCoord1);
                num++;
            }
            int     num2   = (int)(renderModel_t.unTriangleCount * 3U);
            short[] array4 = new short[num2];
            global::System.Runtime.InteropServices.Marshal.Copy(renderModel_t.rIndexData, array4, 0, array4.Length);
            int[] array5 = new int[num2];
            int   num3   = 0;
            while ((long)num3 < (long)((ulong)renderModel_t.unTriangleCount))
            {
                array5[num3 * 3]     = (int)array4[num3 * 3 + 2];
                array5[num3 * 3 + 1] = (int)array4[num3 * 3 + 1];
                array5[num3 * 3 + 2] = (int)array4[num3 * 3];
                num3++;
            }
            global::UnityEngine.Mesh mesh = new global::UnityEngine.Mesh();
            mesh.vertices  = array;
            mesh.normals   = array2;
            mesh.uv        = array3;
            mesh.triangles = array5;
            mesh.Optimize();
            global::UnityEngine.Material material = global::SteamVR_RenderModel.materials[renderModel_t.diffuseTextureId] as global::UnityEngine.Material;
            bool flag3 = material == null || material.mainTexture == null;
            if (flag3)
            {
                global::System.IntPtr zero2 = global::System.IntPtr.Zero;
                for (;;)
                {
                    evrrenderModelError = renderModels.LoadTexture_Async(renderModel_t.diffuseTextureId, ref zero2);
                    bool flag4 = evrrenderModelError != global::Valve.VR.EVRRenderModelError.Loading;
                    if (flag4)
                    {
                        break;
                    }
                    global::System.Threading.Thread.Sleep(1);
                }
                bool flag5 = evrrenderModelError == global::Valve.VR.EVRRenderModelError.None;
                if (flag5)
                {
                    global::Valve.VR.RenderModel_TextureMap_t renderModel_TextureMap_t = (global::Valve.VR.RenderModel_TextureMap_t)global::System.Runtime.InteropServices.Marshal.PtrToStructure(zero2, typeof(global::Valve.VR.RenderModel_TextureMap_t));
                    global::UnityEngine.Texture2D             texture2D = new global::UnityEngine.Texture2D((int)renderModel_TextureMap_t.unWidth, (int)renderModel_TextureMap_t.unHeight, 5, false);
                    bool flag6 = global::UnityEngine.SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL");
                    if (flag6)
                    {
                        byte[] array6 = new byte[(int)(renderModel_TextureMap_t.unWidth * renderModel_TextureMap_t.unHeight * '\u0004')];
                        global::System.Runtime.InteropServices.Marshal.Copy(renderModel_TextureMap_t.rubTextureMapData, array6, 0, array6.Length);
                        global::UnityEngine.Color32[] array7 = new global::UnityEngine.Color32[(int)(renderModel_TextureMap_t.unWidth * renderModel_TextureMap_t.unHeight)];
                        int num4 = 0;
                        for (int i = 0; i < (int)renderModel_TextureMap_t.unHeight; i++)
                        {
                            for (int j = 0; j < (int)renderModel_TextureMap_t.unWidth; j++)
                            {
                                byte b  = array6[num4++];
                                byte b2 = array6[num4++];
                                byte b3 = array6[num4++];
                                byte b4 = array6[num4++];
                                array7[i * (int)renderModel_TextureMap_t.unWidth + j] = new global::UnityEngine.Color32(b, b2, b3, b4);
                            }
                        }
                        texture2D.SetPixels32(array7);
                        texture2D.Apply();
                    }
                    else
                    {
                        texture2D.Apply();
                        for (;;)
                        {
                            evrrenderModelError = renderModels.LoadIntoTextureD3D11_Async(renderModel_t.diffuseTextureId, texture2D.GetNativeTexturePtr());
                            bool flag7 = evrrenderModelError != global::Valve.VR.EVRRenderModelError.Loading;
                            if (flag7)
                            {
                                break;
                            }
                            global::System.Threading.Thread.Sleep(1);
                        }
                    }
                    material             = new global::UnityEngine.Material((this.shader != null) ? this.shader : global::EscalationVR.UnityHelper.GetShader("Standard"));
                    material.mainTexture = texture2D;
                    global::SteamVR_RenderModel.materials[renderModel_t.diffuseTextureId] = material;
                    renderModels.FreeTexture(zero2);
                }
                else
                {
                    global::UnityEngine.Debug.Log("Failed to load render model texture for render model " + renderModelName);
                }
            }
            base.StartCoroutine(this.FreeRenderModel(zero));
            result = new global::SteamVR_RenderModel.RenderModel(mesh, material);
        }
        return(result);
    }