/// <summary> /// Creates a default perspective camera. /// </summary> /// <returns>A perspective camera.</returns> public static PerspectiveCamera CreateDefaultCamera() { var camera = new PerspectiveCamera(); Reset(camera); return(camera); }
/// <summary> /// Resets the specified perspective camera. /// </summary> /// <param name="camera"> /// The camera. /// </param> public static void Reset(this PerspectiveCamera camera) { if (camera == null) { return; } camera.Position = new Point3D(20, 10, 40); camera.LookDirection = new Vector3D(-20, -10, -40); camera.UpDirection = new Vector3D(0, 1, 0); camera.FieldOfView = 45; camera.NearPlaneDistance = 0.1; camera.FarPlaneDistance = 1000; }
/// <summary> /// Initializes a new instance of the <see cref="Viewport3DX" /> class. /// </summary> public Viewport3DX() { this.perspectiveCamera = new PerspectiveCamera(); this.orthographicCamera = new OrthographicCamera(); this.perspectiveCamera.Reset(); this.orthographicCamera.Reset(); this.Camera = this.Orthographic ? (ProjectionCamera)this.orthographicCamera : this.perspectiveCamera; this.Children = new Element3DCollection(); this.rotateHandler = new RotateHandler(this); this.panHandler = new PanHandler(this); this.zoomHandler = new ZoomHandler(this); this.changeFieldOfViewHandler = new ZoomHandler(this, true); this.zoomRectangleHandler = new ZoomRectangleHandler(this); this.CommandBindings.Add(new CommandBinding(ViewportCommands.ZoomExtents, this.ZoomExtentsHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.SetTarget, this.SetTargetHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.Reset, this.ResetHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.Zoom, this.zoomHandler.Execute)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.Pan, this.panHandler.Execute)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.Rotate, this.rotateHandler.Execute)); this.CommandBindings.Add( new CommandBinding(ViewportCommands.ChangeFieldOfView, this.changeFieldOfViewHandler.Execute)); this.CommandBindings.Add( new CommandBinding(ViewportCommands.ZoomRectangle, this.zoomRectangleHandler.Execute)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.BottomView, this.BottomViewHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.TopView, this.TopViewHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.FrontView, this.FrontViewHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.BackView, this.BackViewHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.LeftView, this.LeftViewHandler)); this.CommandBindings.Add(new CommandBinding(ViewportCommands.RightView, this.RightViewHandler)); this.SetDefaultGestures(); this.fpsWatch.Start(); this.renderingEventListener = new RenderingEventListener(this.OnCompositionTargetRendering); this.Loaded += this.ControlLoaded; this.Unloaded += this.ControlUnloaded; }