public IScene Create(Mesh mesh) { Scene scene = new Scene(mesh); scene.CameraManipulator = new CameraManipulator(scene); scene.RotationManipulator = new RotationManipulator(scene); scene.ZoomManipulator = new ZoomManipulator(scene); return scene; }
public MeshGeometry3D ToMeshGeometry3D(Mesh mesh) { if (mesh == null) { return null; } return new MeshGeometry3D { Positions = new Point3DCollection(mesh.Points), TriangleIndices = new Int32Collection(mesh.Elements.SelectMany(element => element.TriangleIndices)) }; }
public Scene(Mesh mesh) { IServiceLocator serviceLocator = ServiceLocator.Current; IMeshConverter meshConverter = serviceLocator.GetInstance<IMeshConverter>(); IWireframeGenerator wireframeGenerator = serviceLocator.GetInstance<IWireframeGenerator>(); this.mesh = mesh; this.meshGeometry3D = meshConverter.ToMeshGeometry3D(this.mesh); this.center = this.MeshGeometry3D.Bounds.Location + 0.5 * (Vector3D)this.MeshGeometry3D.Bounds.Size; this.radius = 0.5*((Vector3D) this.meshGeometry3D.Bounds.Size).Length; this.wireframeGeometry3D = new Lazy<MeshGeometry3D>(() => wireframeGenerator.Generate(this), LazyThreadSafetyMode.PublicationOnly); }