private void Window_Loaded(object sender, RoutedEventArgs e) { try { // Init World _world = new World(); _world.Updating += new EventHandler<WorldUpdatingArgs>(World_Updating); _world.SetWorldSize(new Point3D(-100, -100, -100), new Point3D(100, 100, 100)); _world.UnPause(); // 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.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.MouseComplete)); //_trackball.GetOrbitRadius += new GetOrbitRadiusHandler(Trackball_GetOrbitRadius); // Trackball Controls SetupModelTrackball(); SetupFlowTrackball(); _field = new FluidFieldUniform() { Viscosity = trkFlowViscosity.Value, Flow = GetWorldFlow() }; // Fluid lines AddFluidVisuals(Convert.ToInt32(NUMFLUIDVISUALS * _flowViscosity)); // Force lines _forceLines = new ScreenSpaceLines3D(true); _forceLines.Color = _colors.ForceLine; _forceLines.Thickness = 2d; _viewport.Children.Add(_forceLines); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { // Init World _world = new World(); _world.Updating += new EventHandler<WorldUpdatingArgs>(World_Updating); _world.SetWorldSize(new Point3D(-100, -100, -100), new Point3D(100, 100, 100)); _world.UnPause(); // Camera Trackball _trackball = new TrackBallRoam(_camera); //_trackball.ShouldHitTestOnOrbit = true; _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.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.MouseComplete)); //_trackball.GetOrbitRadius += new GetOrbitRadiusHandler(Trackball_GetOrbitRadius); // Trackball Controls SetupModelTrackball(); SetupFlowTrackball(); // Fluid lines AddFluidVisuals(Convert.ToInt32(NUMFLUIDVISUALS * _flowViscosity)); // Force lines _fluidHullForceLines = new ScreenSpaceLines3D(true); _fluidHullForceLines.Color = _colors.ForceLine; _fluidHullForceLines.Thickness = 2d; _viewport.Children.Add(_fluidHullForceLines); // Field - may want to only add this when a body is added _field = new FluidField3D(20); _field.Diffusion = 0; _field.Damping = 0; //GetFluidViscocity(); // this stays zero (see comments in VelocityViscocityChanged) _field.BoundryType = FluidFieldBoundryType3D.Open_Slaved; _fieldUniform = new FluidFieldUniform(); _field.OpenBoundryParent = _fieldUniform; _field.SizeWorld = 10d; // This changes whenever a body is swapped out _fieldCells = _field.GetCells(); _fieldField = new FluidFieldField(_field); _fieldField.Viscosity = GetFluidViscocity(); _isInitialized = true; ShowHideFluidBoundry(); ShowHideBlockedCells(); VelocityViscocityChanged(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }