internal Mesh GetDistortionMesh(View viewId, Mesh oldMesh) { IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VuforiaManagerImpl.MeshData))); VuforiaWrapper.Instance.RenderingPrimitives_GetDistortionMesh((int)viewId, intPtr); VuforiaManagerImpl.MeshData arg_3F_0 = (VuforiaManagerImpl.MeshData)Marshal.PtrToStructure(intPtr, typeof(VuforiaManagerImpl.MeshData)); Marshal.FreeHGlobal(intPtr); return(MeshUtils.UpdateMesh(arg_3F_0, oldMesh, false, false)); }
public static Mesh UpdateMesh(VuforiaManagerImpl.MeshData meshData, Mesh oldMesh, bool setNormalsUpwards, bool swapYZ) { if (meshData.numVertexValues == 0 || meshData.numTriangleIndices == 0) { return(null); } if (oldMesh == null) { oldMesh = new Mesh(); } else { oldMesh.Clear(); } MeshUtils.CopyPositions(meshData.positionsArray, meshData.numVertexValues, oldMesh, swapYZ); MeshUtils.CopyTriangles(meshData.triangleIdxArray, meshData.numTriangleIndices, oldMesh); if (meshData.hasNormals == 1) { MeshUtils.CopyNormals(meshData.normalsArray, meshData.numVertexValues, oldMesh, swapYZ); } else if (setNormalsUpwards) { Vector3[] array = new Vector3[meshData.numVertexValues / 3]; for (int i = 0; i < array.Length; i++) { array[i] = Vector3.up; } oldMesh.normals = array; } else { oldMesh.RecalculateNormals(); } if (meshData.hasTexCoords == 1) { MeshUtils.CopyTexCoords(meshData.texCoordsArray, meshData.numVertexValues * 2 / 3, oldMesh); } else { Vector2[] array2 = new Vector2[meshData.numVertexValues / 3]; for (int j = 0; j < meshData.numVertexValues / 3; j++) { array2[j] = new Vector2(0.5f, 0.5f); } oldMesh.uv = array2; } return(oldMesh); }