/// <summary> /// This converts the enums into a bunch of mappings /// NOTE: It's ok to add a prebuilt mouse then a prebuilt keyboard /// </summary> public static TrackBallMapping[] GetPrebuilt(PrebuiltMapping mapping) { List<TrackBallMapping> retVal = new List<TrackBallMapping>(); TrackBallMapping complexMapping = null; // NOTE: Order is important, the most complex mouse/button combo must be added before the more simple // mouse only (or the mouse only would win) switch (mapping) { case PrebuiltMapping.MouseComplete: #region Complete // Get everything except the left retVal.AddRange(GetPrebuilt(PrebuiltMapping.MouseComplete_NoLeft)); // Left retVal.Add(new TrackBallMapping(CameraMovement.Pan, MouseButton.Left)); #endregion break; case PrebuiltMapping.MouseComplete_NoLeft: #region Complete_NoLeft // Middle Button complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); retVal.Add(new TrackBallMapping(CameraMovement.RotateAroundLookDirection, MouseButton.Middle, new Key[] { Key.LeftCtrl, Key.RightCtrl })); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); retVal.Add(new TrackBallMapping(CameraMovement.Zoom, MouseButton.Middle, new Key[] { Key.LeftShift, Key.RightShift })); retVal.Add(new TrackBallMapping(CameraMovement.Pan_AutoScroll, MouseButton.Middle)); // Left+Right Buttons (emulate middle) complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Pan_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); retVal.Add(complexMapping); // Right Button complexMapping = new TrackBallMapping(CameraMovement.RotateInPlace_AutoScroll); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); retVal.Add(new TrackBallMapping(CameraMovement.RotateInPlace, MouseButton.Right, new Key[] { Key.LeftCtrl, Key.RightCtrl })); retVal.Add(new TrackBallMapping(CameraMovement.Orbit_AutoScroll, MouseButton.Right, new Key[] { Key.LeftAlt, Key.RightAlt })); retVal.Add(new TrackBallMapping(CameraMovement.Orbit, MouseButton.Right)); #endregion break; case PrebuiltMapping.MouseComplete_NoLeft_RightRotateInPlace: #region Complete_NoLeft // Middle Button complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); retVal.Add(new TrackBallMapping(CameraMovement.RotateAroundLookDirection, MouseButton.Middle, new Key[] { Key.LeftCtrl, Key.RightCtrl })); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); retVal.Add(new TrackBallMapping(CameraMovement.Zoom, MouseButton.Middle, new Key[] { Key.LeftShift, Key.RightShift })); retVal.Add(new TrackBallMapping(CameraMovement.Pan_AutoScroll, MouseButton.Middle)); // Left+Right Buttons (emulate middle) complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); retVal.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Pan_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); retVal.Add(complexMapping); // Right Button complexMapping = new TrackBallMapping(CameraMovement.Orbit_AutoScroll); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); retVal.Add(complexMapping); retVal.Add(new TrackBallMapping(CameraMovement.Orbit, MouseButton.Right, new Key[] { Key.LeftCtrl, Key.RightCtrl })); retVal.Add(new TrackBallMapping(CameraMovement.RotateInPlace_AutoScroll, MouseButton.Right, new Key[] { Key.LeftAlt, Key.RightAlt })); retVal.Add(new TrackBallMapping(CameraMovement.RotateInPlace, MouseButton.Right)); #endregion break; case PrebuiltMapping.Keyboard_ASDW_In: #region Keyboard_ASDW_In retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_In, Key.W)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Out, Key.S)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Left, Key.A)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Right, Key.D)); #endregion break; case PrebuiltMapping.Keyboard_ASDW_Up: #region Keyboard_ASDW_In retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Up, Key.W)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Down, Key.S)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Left, Key.A)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Right, Key.D)); #endregion break; case PrebuiltMapping.Keyboard_Arrows_In: #region Keyboard_ASDW_In retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_In, Key.Up)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Out, Key.Down)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Left, Key.Left)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Right, Key.Right)); #endregion break; case PrebuiltMapping.Keyboard_Arrows_Up: #region Keyboard_ASDW_In retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Up, Key.Up)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Down, Key.Down)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Left, Key.Left)); retVal.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Right, Key.Right)); #endregion break; default: throw new ApplicationException("Unknown PrebuiltMapping: " + mapping.ToString()); } // Exit Function return retVal.ToArray(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { #region Trackball // Trackball _trackball = new TrackBallRoam(_camera); _trackball.KeyPanScale = 1d; _trackball.EventSource = grdViewPort; //NOTE: If this control doesn't have a background color set, the trackball won't see events (I think transparent is ok, just not null) _trackball.AllowZoomOnMouseWheel = true; #region copied from MouseComplete_NoLeft - middle button changed TrackBallMapping complexMapping = null; // Middle Button complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateAroundLookDirection, MouseButton.Middle, new Key[] { Key.LeftCtrl, Key.RightCtrl })); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Zoom, MouseButton.Middle, new Key[] { Key.LeftShift, Key.RightShift })); //retVal.Add(new TrackBallMapping(CameraMovement.Pan_AutoScroll, MouseButton.Middle)); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan, MouseButton.Middle)); // Left+Right Buttons (emulate middle) complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); _trackball.Mappings.Add(complexMapping); //complexMapping = new TrackBallMapping(CameraMovement.Pan_AutoScroll); complexMapping = new TrackBallMapping(CameraMovement.Pan); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); _trackball.Mappings.Add(complexMapping); // Right Button complexMapping = new TrackBallMapping(CameraMovement.RotateInPlace_AutoScroll); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateInPlace, MouseButton.Right, new Key[] { Key.LeftCtrl, Key.RightCtrl })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit_AutoScroll, MouseButton.Right, new Key[] { Key.LeftAlt, Key.RightAlt })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit, MouseButton.Right)); #endregion //_trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.Keyboard_ASDW_In)); // let the ship get asdw instead of the camera //_trackball.GetOrbitRadius += new GetOrbitRadiusHandler(Trackball_GetOrbitRadius); _trackball.ShouldHitTestOnOrbit = true; #endregion #region Init World // Set the size of the world to something a bit random (gets boring when it's always the same size) double halfSize = 50d; _boundryMin = new Point3D(-halfSize, -halfSize, -halfSize); _boundryMax = new Point3D(halfSize, halfSize, halfSize); _world = new World(); _world.Updating += new EventHandler<WorldUpdatingArgs>(World_Updating); List<Point3D[]> innerLines, outerLines; _world.SetCollisionBoundry(out innerLines, out outerLines, _boundryMin, _boundryMax); // Draw the lines _boundryLines = new ScreenSpaceLines3D(true); _boundryLines.Thickness = 1d; _boundryLines.Color = _colors.BoundryLines; _viewport.Children.Add(_boundryLines); foreach (Point3D[] line in innerLines) { _boundryLines.AddLine(line[0], line[1]); } #endregion #region Materials _materialManager = new MaterialManager(_world); // Part Game.Newt.v2.NewtonDynamics.Material material = new Game.Newt.v2.NewtonDynamics.Material(); _material_Part = _materialManager.AddMaterial(material); // Ship material = new Game.Newt.v2.NewtonDynamics.Material(); _material_Ship = _materialManager.AddMaterial(material); //_materialManager.RegisterCollisionEvent(_material_Ship, _material_Asteroid, Collision_Ship); #endregion #region Map _map = new Map(_viewport, null, _world); //_map.SnapshotFequency_Milliseconds = 125; //_map.SnapshotMaxItemsPerNode = 10; _map.ShouldBuildSnapshots = false; //_map.ShouldShowSnapshotLines = true; //_map.ShouldSnapshotCentersDrift = false; #endregion #region Fields _radiation = new RadiationField(); _radiation.AmbientRadiation = 1d; _gravity = new GravityFieldUniform(); #endregion _world.UnPause(); #region Solver Timer _solverTimer = new DispatcherTimer(); _solverTimer.Interval = TimeSpan.FromMilliseconds(trkSimSpeed.Value); _solverTimer.Tick += new EventHandler(SolverTimer_Tick); _solverTimer.IsEnabled = true; #endregion } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
public Editor() { //TODO: Research loading/saving in xaml //System.Windows.Markup.XamlReader test2 = new System.Windows.Markup.XamlReader(); //System.Windows.Markup.XamlWriter test3; //MeshGeometry3D test; InitializeComponent(); // Without this, the xaml can't bind to the custom dependency properties this.DataContext = this; #region Camera Trackball _trackball = new TrackBallRoam(_camera); _trackball.EventSource = grdViewPort; //NOTE: If this control doesn't have a background color set, the trackball won't see events (I think transparent is ok, just not null) _trackball.AllowZoomOnMouseWheel = true; _trackball.ZoomScale *= .25d; _trackball.KeyPanScale *= .1d; //_trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.MouseComplete_NoLeft)); #region copied from MouseComplete_NoLeft - middle button changed TrackBallMapping complexMapping = null; // Middle Button complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateAroundLookDirection, MouseButton.Middle, new Key[] { Key.LeftCtrl, Key.RightCtrl })); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Zoom, MouseButton.Middle, new Key[] { Key.LeftShift, Key.RightShift })); //retVal.Add(new TrackBallMapping(CameraMovement.Pan_AutoScroll, MouseButton.Middle)); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan, MouseButton.Middle)); // Left+Right Buttons (emulate middle) complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); _trackball.Mappings.Add(complexMapping); //complexMapping = new TrackBallMapping(CameraMovement.Pan_AutoScroll); complexMapping = new TrackBallMapping(CameraMovement.Pan); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); _trackball.Mappings.Add(complexMapping); // Right Button complexMapping = new TrackBallMapping(CameraMovement.RotateInPlace_AutoScroll); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateInPlace, MouseButton.Right, new Key[] { Key.LeftCtrl, Key.RightCtrl })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit_AutoScroll, MouseButton.Right, new Key[] { Key.LeftAlt, Key.RightAlt })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit, MouseButton.Right)); #endregion _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_In, Key.OemPlus)); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_In, Key.Add)); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Out, Key.OemMinus)); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan_Keyboard_Out, Key.Subtract)); _trackball.ShouldHitTestOnOrbit = true; _trackball.UserMovedCamera += new EventHandler<UserMovedCameraArgs>(Trackball_UserMovedCamera); #endregion _dragHitShape = new DragHitShape(); //TODO: Add this to the options (the visual should let the user drag a cone) //_dragHitShape.ConstrainMinDotProduct = _options.DragHitShape_ConstrainMinDotProduct; ChangeDragHitShape(); // Compass Rose _compassRose = GetCompassRose(_options.EditorColors); _viewport.Children.Add(_compassRose); #region Ship name textbox // The textbox's cursor can't be set directly, but is the opposite of background. If I just use null or transparent, the cursor is still // black, so I'm making the background transparent black, which makes the cursor white; //txtName.Background = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); //txtShipName.Background = new SolidColorBrush(Color.FromArgb(0, _options.EditorColors.Background.R, _options.EditorColors.Background.G, _options.EditorColors.Background.B)); txtDesignName.Background = new SolidColorBrush(Color.FromArgb(25, _options.EditorColors.Panel_Background.R, _options.EditorColors.Panel_Background.G, _options.EditorColors.Panel_Background.B)); txtDesignName.Foreground = new SolidColorBrush(_options.EditorColors.PartVisual_TextColor); #endregion _isInitialized = true; btnNewLayer_Click(this, new RoutedEventArgs()); // all layers btnNewLayer_Click(this, new RoutedEventArgs()); // first real layer }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { #region Trackball // Trackball _trackball = new TrackBallRoam(_camera); _trackball.KeyPanScale = 1d; _trackball.EventSource = grdViewPort; //NOTE: If this control doesn't have a background color set, the trackball won't see events (I think transparent is ok, just not null) _trackball.AllowZoomOnMouseWheel = true; #region copied from MouseComplete_NoLeft - middle button changed TrackBallMapping complexMapping = null; // Middle Button complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateAroundLookDirection, MouseButton.Middle, new Key[] { Key.LeftCtrl, Key.RightCtrl })); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Zoom, MouseButton.Middle, new Key[] { Key.LeftShift, Key.RightShift })); //retVal.Add(new TrackBallMapping(CameraMovement.Pan_AutoScroll, MouseButton.Middle)); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan, MouseButton.Middle)); // Left+Right Buttons (emulate middle) complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); _trackball.Mappings.Add(complexMapping); //complexMapping = new TrackBallMapping(CameraMovement.Pan_AutoScroll); complexMapping = new TrackBallMapping(CameraMovement.Pan); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); _trackball.Mappings.Add(complexMapping); // Right Button complexMapping = new TrackBallMapping(CameraMovement.RotateInPlace_AutoScroll); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateInPlace, MouseButton.Right, new Key[] { Key.LeftCtrl, Key.RightCtrl })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit_AutoScroll, MouseButton.Right, new Key[] { Key.LeftAlt, Key.RightAlt })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit, MouseButton.Right)); #endregion //_trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.Keyboard_ASDW_In)); // let the ship get asdw instead of the camera //_trackball.GetOrbitRadius += new GetOrbitRadiusHandler(Trackball_GetOrbitRadius); _trackball.ShouldHitTestOnOrbit = true; #endregion #region Init World _world = new World(); double halfSize = 200d; List<Point3D[]> innerLines, outerLines; _world.SetCollisionBoundry(out innerLines, out outerLines, new Point3D(-halfSize, -halfSize, -halfSize), new Point3D(halfSize, halfSize, halfSize)); #endregion #region Fields _radiation = new RadiationField(); _radiation.AmbientRadiation = 1d; _gravity = new GravityFieldUniform(); #endregion } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { #region Trackball // Trackball _trackball = new TrackBallRoam(_camera); _trackball.KeyPanScale = 1d; _trackball.EventSource = grdViewPort; //NOTE: If this control doesn't have a background color set, the trackball won't see events (I think transparent is ok, just not null) _trackball.AllowZoomOnMouseWheel = true; #region copied from MouseComplete_NoLeft - middle button changed TrackBallMapping complexMapping = null; // Middle Button complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateAroundLookDirection, MouseButton.Middle, new Key[] { Key.LeftCtrl, Key.RightCtrl })); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Middle); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Zoom, MouseButton.Middle, new Key[] { Key.LeftShift, Key.RightShift })); //retVal.Add(new TrackBallMapping(CameraMovement.Pan_AutoScroll, MouseButton.Middle)); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Pan, MouseButton.Middle)); // Left+Right Buttons (emulate middle) complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.RotateAroundLookDirection); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom_AutoScroll); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); complexMapping = new TrackBallMapping(CameraMovement.Zoom); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftShift, Key.RightShift }); _trackball.Mappings.Add(complexMapping); //complexMapping = new TrackBallMapping(CameraMovement.Pan_AutoScroll); complexMapping = new TrackBallMapping(CameraMovement.Pan); complexMapping.Add(MouseButton.Left); complexMapping.Add(MouseButton.Right); _trackball.Mappings.Add(complexMapping); // Right Button complexMapping = new TrackBallMapping(CameraMovement.RotateInPlace_AutoScroll); complexMapping.Add(MouseButton.Right); complexMapping.Add(new Key[] { Key.LeftCtrl, Key.RightCtrl }); complexMapping.Add(new Key[] { Key.LeftAlt, Key.RightAlt }); _trackball.Mappings.Add(complexMapping); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.RotateInPlace, MouseButton.Right, new Key[] { Key.LeftCtrl, Key.RightCtrl })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit_AutoScroll, MouseButton.Right, new Key[] { Key.LeftAlt, Key.RightAlt })); _trackball.Mappings.Add(new TrackBallMapping(CameraMovement.Orbit, MouseButton.Right)); #endregion //_trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.Keyboard_ASDW_In)); // let the ship get asdw instead of the camera //_trackball.GetOrbitRadius += new GetOrbitRadiusHandler(Trackball_GetOrbitRadius); _trackball.ShouldHitTestOnOrbit = true; #endregion }