private void radCamera_Checked(object sender, RoutedEventArgs e) { if (_camera1 == null || _camera2 == null) { // This event is getting invoked from InitializeComponent return; } #region Disable Controls chkIsActive4.IsEnabled = false; button1.IsEnabled = false; #endregion #region Dispose Current Trackballs if (_trackball2 != null) { _trackball2.EventSource = null; _trackball2 = null; } if (_trackball3 != null) { _trackball3.EventSource = null; _trackball3 = null; } if (_trackball4 != null) { _trackball4.EventSource = null; _trackball4 = null; } #endregion if (radCamera1.IsChecked.Value) { #region Camera 1 _camera1.Position = new Point3D(0, 0, 25); _camera1.LookDirection = new Vector3D(0, 0, -10); _camera1.UpDirection = new Vector3D(0, 1, 0); _camera1.FieldOfView = 45; _viewport.Camera = _camera1; #endregion } else if (radCamera2.IsChecked.Value) { #region Camera 2 //_camera2.Position = new Point3D(0, 0, 25); //_camera2.LookDirection = new Vector3D(0, 0, -10); //_camera2.UpDirection = new Vector3D(0, 1, 0); //_camera2.FieldOfView = 45; _camera2.Position = new Point3D(0, 25, 0); // this alternate location is to test placing the camera somewhere other than the z axis _camera2.LookDirection = new Vector3D(0, -1, 0); _camera2.UpDirection = new Vector3D(0, 0, -1); _camera2.FieldOfView = 45; _trackball2 = new TrackballTransform(_camera2); _trackball2.EventSource = grdViewPort; _camera2.Transform = _trackball2.Transform; _viewport.Camera = _camera2; #endregion } else if (radCamera3.IsChecked.Value) { #region Camera 3 //_camera3.Position = new Point3D(0, 0, 25); //_camera3.LookDirection = new Vector3D(0, 0, -10); //_camera3.UpDirection = new Vector3D(0, 1, 0); //_camera3.FieldOfView = 45; _camera3.Position = new Point3D(0, 25, 0); // this alternate location is to test placing the camera somewhere other than the z axis _camera3.LookDirection = new Vector3D(0, -1, 0); _camera3.UpDirection = new Vector3D(0, 0, -1); _camera3.FieldOfView = 45; _trackball3 = new TrackBallRoam_local(_camera3); _trackball3.EventSource = grdViewPort; _viewport.Camera = _camera3; #endregion } else if (radCamera4.IsChecked.Value) { #region Camera 4 chkIsActive4.IsEnabled = true; button1.IsEnabled = true; _camera4.Position = new Point3D(0, 0, 25); _camera4.LookDirection = new Vector3D(0, 0, -10); _camera4.UpDirection = new Vector3D(0, 1, 0); _camera4.FieldOfView = 45; //_camera4.Position = new Point3D(0, 25, 0); // this alternate location is to test placing the camera somewhere other than the z axis //_camera4.LookDirection = new Vector3D(0, -1, 0); //_camera4.UpDirection = new Vector3D(0, 0, -1); //_camera4.FieldOfView = 45; _trackball4 = new TrackBallRoam(_camera4); _trackball4.EventSource = grdViewPort; _trackball4.AllowZoomOnMouseWheel = true; _trackball4.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.MouseComplete)); _trackball4.IsActive = chkIsActive4.IsChecked.Value; _viewport.Camera = _camera4; #endregion } else { MessageBox.Show("Unknown camera selected", this.Title, MessageBoxButton.OK, MessageBoxImage.Error); _viewport.Camera = null; } }