public void _03TestModel() { var watch = new Stopwatch(); var mesh = objWorker.Parse("C:\\Projects\\cow-engine\\assets\\cow.obj"); var triangles = (mesh as TriangleMesh).triangles; watch.Start(); var tree = new KdTree(triangles); watch.Stop(); var time = watch.Elapsed; Console.WriteLine($"{time.Milliseconds}"); Assert.Less(time.Milliseconds, 200); }
private Mesh GetMesh(SceneFormat.SceneObject parsedObject) { switch (parsedObject.MeshCase) { case SceneFormat.SceneObject.MeshOneofCase.Sphere: return(new Sphere((float)parsedObject.Sphere.Radius)); case SceneFormat.SceneObject.MeshOneofCase.Cube: return(new Box(ConvertVector(parsedObject.Cube.Size) * 0.5f)); case SceneFormat.SceneObject.MeshOneofCase.Plane: return(new Plane()); case SceneFormat.SceneObject.MeshOneofCase.Disk: return(new Disk((float)parsedObject.Disk.Radius)); case SceneFormat.SceneObject.MeshOneofCase.MeshedObject: return(ObjWorker.Parse(parsedObject.MeshedObject.Reference)); default: throw new Exception("Unsupported mesh"); } }