public static OVRPlugin.Hand GetHandFromMeshType(OVRPlugin.MeshType meshType) { return(meshType == OVRPlugin.MeshType.HandLeft ? OVRPlugin.Hand.HandLeft : meshType == OVRPlugin.MeshType.HandRight ? OVRPlugin.Hand.HandRight : OVRPlugin.Hand.None); }
public static OVRPlugin.SkeletonType GetSkeletonTypeFromMeshType(OVRPlugin.MeshType meshType) { return(meshType == OVRPlugin.MeshType.HandLeft ? OVRPlugin.SkeletonType.HandLeft : meshType == OVRPlugin.MeshType.HandRight ? OVRPlugin.SkeletonType.HandRight : OVRPlugin.SkeletonType.None); }
private IEnumerator InitializeHandMesh() { bool success = false; while (!success) { var mesh = new OVRPlugin.Mesh(); OVRPlugin.MeshType meshType = GetHandMeshTypeFromOVRHandType(_hand.HandType); if (OVRPlugin.GetMesh(meshType, out mesh)) { success = InitializeMesh(ref mesh); } yield return(null); } }
public MeshData(OVRPlugin.MeshType meshType, OVRPlugin.Mesh mesh) { MeshType = meshType; Mesh = mesh; }
private static Mesh InitializeMesh(OVRPlugin.MeshType meshType, OVRPlugin.Mesh ovrpMesh) { var mesh = new Mesh(); //Same routine that initializes OVRMesh (without API call as data is provided) //var ovrpMesh = new OVRPlugin.Mesh(); //if (OVRPlugin.GetMesh(meshType, out ovrpMesh)) //{ var vertices = new Vector3[ovrpMesh.NumVertices]; for (int i = 0; i < ovrpMesh.NumVertices; ++i) { vertices[i] = ovrpMesh.VertexPositions[i].FromFlippedZVector3f(); } mesh.vertices = vertices; var uv = new Vector2[ovrpMesh.NumVertices]; for (int i = 0; i < ovrpMesh.NumVertices; ++i) { uv[i] = new Vector2(ovrpMesh.VertexUV0[i].x, -ovrpMesh.VertexUV0[i].y); } mesh.uv = uv; var triangles = new int[ovrpMesh.NumIndices]; for (int i = 0; i < ovrpMesh.NumIndices; ++i) { triangles[i] = ovrpMesh.Indices[ovrpMesh.NumIndices - i - 1]; } mesh.triangles = triangles; var normals = new Vector3[ovrpMesh.NumVertices]; for (int i = 0; i < ovrpMesh.NumVertices; ++i) { normals[i] = ovrpMesh.VertexNormals[i].FromFlippedZVector3f(); } mesh.normals = normals; var boneWeights = new BoneWeight[ovrpMesh.NumVertices]; for (int i = 0; i < ovrpMesh.NumVertices; ++i) { var currentBlendWeight = ovrpMesh.BlendWeights[i]; var currentBlendIndices = ovrpMesh.BlendIndices[i]; boneWeights[i].boneIndex0 = (int)currentBlendIndices.x; boneWeights[i].weight0 = currentBlendWeight.x; boneWeights[i].boneIndex1 = (int)currentBlendIndices.y; boneWeights[i].weight1 = currentBlendWeight.y; boneWeights[i].boneIndex2 = (int)currentBlendIndices.z; boneWeights[i].weight2 = currentBlendWeight.z; boneWeights[i].boneIndex3 = (int)currentBlendIndices.w; boneWeights[i].weight3 = currentBlendWeight.w; } mesh.boneWeights = boneWeights; //} return(mesh); }