void TestMesh(Assimp.Mesh netMesh, AssimpSharp.Mesh sharpMesh) { // Vertices Assert.AreEqual(netMesh.HasVertices, sharpMesh.Vertices != null); if (netMesh.HasVertices) { Assert.AreEqual(netMesh.VertexCount, sharpMesh.Vertices.Length); MathAssert.AreEqual(netMesh.Vertices, sharpMesh.Vertices); } // Faces Assert.AreEqual(netMesh.HasFaces, sharpMesh.Faces != null); if (netMesh.HasFaces) { Assert.AreEqual(netMesh.FaceCount, sharpMesh.Faces.Length); for (int i = 0; i < netMesh.FaceCount; i++) { Assert.AreEqual(netMesh.Faces[i].HasIndices, sharpMesh.Faces[i].Indices != null); Assert.AreEqual(netMesh.Faces[i].IndexCount, sharpMesh.Faces[i].Indices.Length); Assert.AreEqual(netMesh.Faces[i].Indices, sharpMesh.Faces[i].Indices); } } // Normals Assert.AreEqual(netMesh.HasNormals, sharpMesh.Normals != null); if (netMesh.HasNormals) { MathAssert.AreEqual(netMesh.Normals, sharpMesh.Normals); } // BiTangents Assert.AreEqual(netMesh.HasTangentBasis, sharpMesh.Bitangents != null && sharpMesh.Bitangents.Length > 0); if (netMesh.HasTangentBasis) { MathAssert.AreEqual(netMesh.BiTangents, sharpMesh.Bitangents); } // PrimitiveType // AssimpNet BUG!! //Assert.AreEqual(netMesh.PrimitiveType.ToString(), Enum.GetName(typeof(AssimpSharp.PrimitiveType), sharpMesh.PrimitiveTypes)); // TexureCoord for (int i = 0; i < netMesh.TextureCoordinateChannelCount; i++) { Assert.AreEqual(netMesh.HasTextureCoords(i), sharpMesh.HasTextureCoords(i)); MathAssert.AreEqual(netMesh.TextureCoordinateChannels[i], sharpMesh.TextureCoords[i]); } // VertexColorChannels for (int i = 0; i < netMesh.VertexColorChannelCount; i++) { Assert.AreEqual(netMesh.HasVertexColors(i), sharpMesh.HasVertexColors(i)); if (netMesh.HasVertexColors(i)) { Assert.AreEqual(netMesh.VertexColorChannels[i], sharpMesh.Colors[i]); } } // MaterialIndex Assert.AreEqual(netMesh.MaterialIndex, sharpMesh.MaterialIndex); // Name Assert.AreEqual(netMesh.Name, sharpMesh.Name); // UVComponentCount Assert.AreEqual(netMesh.UVComponentCount, sharpMesh.NumUVComponents); // MeshAnimationAttachments Assert.AreEqual(netMesh.HasMeshAnimationAttachments, sharpMesh.AnimMeshes != null); if (netMesh.HasMeshAnimationAttachments) { for (int i = 0; i < netMesh.MeshAnimationAttachmentCount; i++) { TestAnimationAttachment(netMesh.MeshAnimationAttachments[i], sharpMesh.AnimMeshes[i]); } } }
void TestAnimationAttachment(Assimp.MeshAnimationAttachment netAnimMesh, AssimpSharp.AnimMesh sharpAnimMesh) { Assert.AreEqual(netAnimMesh.HasVertices, sharpAnimMesh.HasPosition); if (netAnimMesh.HasVertices) { Assert.AreEqual(netAnimMesh.Vertices, sharpAnimMesh.Vertices); } Assert.AreEqual(netAnimMesh.HasNormals, sharpAnimMesh.HasNormals); if (netAnimMesh.HasNormals) { Assert.AreEqual(netAnimMesh.Normals, sharpAnimMesh.Normals); } Assert.AreEqual(netAnimMesh.HasTangentBasis, sharpAnimMesh.HasTangentsAndBitangets); if (netAnimMesh.HasTangentBasis) { Assert.AreEqual(netAnimMesh.Tangents, sharpAnimMesh.Tangents); Assert.AreEqual(netAnimMesh.BiTangents, sharpAnimMesh.Bitangents); } for (int i = 0; i < netAnimMesh.TextureCoordinateChannelCount; i++) { Assert.AreEqual(netAnimMesh.HasTextureCoords(i), sharpAnimMesh.HasTextureCoords(i)); if (netAnimMesh.HasTextureCoords(i)) { Assert.AreEqual(netAnimMesh.TextureCoordinateChannels[i], sharpAnimMesh.TextureCoords[i]); } } for (int i = 0; i < netAnimMesh.VertexColorChannelCount; i++) { Assert.AreEqual(netAnimMesh.HasVertexColors(i), sharpAnimMesh.HasVertexColors(i)); if (netAnimMesh.HasVertexColors(i)) { Assert.AreEqual(netAnimMesh.VertexColorChannels[i], sharpAnimMesh.Colors[i]); } } }