private CollisionShape LoadShapeFromFile(string fileName, float mass, Vector3 scale, string baseDirectory) { string fullPath = Path.Combine(baseDirectory, fileName); string extension = Path.GetExtension(fullPath); switch (extension) { case ".obj": WavefrontObj obj = WavefrontObj.Load(fullPath); var mesh = CreateTriangleMesh(obj.Indices, obj.Vertices, scale); if (mass == 0) { const bool useQuantization = true; return(new BvhTriangleMeshShape(mesh, useQuantization)); } else { // TODO: convex decomposition GImpactCollisionAlgorithm.RegisterAlgorithm((CollisionDispatcher)World.Dispatcher); var shape = new GImpactMeshShape(mesh); shape.Margin = 0; shape.UpdateBound(); return(shape); } default: throw new NotSupportedException(); } }
private void LoadFile(string fileName, string baseDirectory, Matrix transform) { string fullPath = Path.Combine(baseDirectory, fileName); string extension = Path.GetExtension(fullPath); switch (extension) { case ".obj": WavefrontObj obj = WavefrontObj.Load(fullPath); var mesh = CreateTriangleMesh(obj.Indices, obj.Vertices, Vector3.One); CreateMeshBody(mesh, transform); break; default: throw new NotSupportedException(); } }
private CollisionShape LoadShapeFromFile(string fileName, string baseDirectory) { string fullPath = Path.Combine(baseDirectory, fileName); string extension = Path.GetExtension(fullPath); switch (extension) { case ".obj": WavefrontObj obj = WavefrontObj.Load(fullPath); var mesh = CreateTriangleMesh(obj.Indices, obj.Vertices, Vector3.One); const bool useQuantization = true; return(new BvhTriangleMeshShape(mesh, useQuantization)); default: throw new NotSupportedException(); } }