/// <summary> /// Exports a simple model in a STA. /// </summary> /// <param name="e">The exporter.</param> /// <param name="stream">The stream.</param> protected void ExportSimpleModel(IExporter e, Stream stream) { Exception exception = null; CrossThreadTestRunner.RunInSTA( () => { var vp = new Viewport3D { Camera = CameraHelper.CreateDefaultCamera(), Width = 1280, Height = 720 }; vp.Children.Add(new DefaultLights()); var box = new BoxVisual3D(); box.UpdateModel(); vp.Children.Add(box); try { e.Export(vp, stream); } catch (Exception ex) { exception = ex; } }); if (exception != null) { throw exception; } }
public void StartDraw(HelixViewport3D helix) { brush = new SolidColorBrush(Color.FromRgb(0, 0, 255)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { box[i, j, k] = new BoxVisual3D(); } } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < n; k++) { box[i, j, k].Width = 4; box[i, j, k].Height = 4; box[i, j, k].Length = 4; box[i, j, k].Center = new System.Windows.Media.Media3D.Point3D(10 * i, 10 * j, 10 * k); box[i, j, k].Fill = brush; helix.Children.Add(box[i, j, k]); } } } }
private void CreateBoxWithEdgeLines(Point3D centerPosition, Size3D size, DiffuseMaterial material) { var boxVisual3D = new BoxVisual3D() { CenterPosition = centerPosition, Size = size, Material = material }; TestObjectsModelVisual3D.Children.Add(boxVisual3D); var wireBoxVisual3D = new WireBoxVisual3D() { CenterPosition = centerPosition, Size = size, LineColor = Colors.Yellow, LineThickness = 3 }; // Set LineDepthBias to prevent rendering wireframe at the same depth as the 3D objects. // This creates much nicer 3D lines. See the LineDepthBiasSample for more information. wireBoxVisual3D.SetDXAttribute(DXAttributeType.LineDepthBias, 0.1); TestObjectsModelVisual3D.Children.Add(wireBoxVisual3D); }
private void CreateTestScene() { _standardBoxMaterial = new DiffuseMaterial(Brushes.Silver); _standardBoxMaterial.Freeze(); _mouseOverBoxMaterial = new DiffuseMaterial(Brushes.Orange); _mouseOverBoxMaterial.Freeze(); _selectedBoxMaterial = new DiffuseMaterial(Brushes.Red); _selectedBoxMaterial.Freeze(); // 5 x 3 boxes for (int x = 0; x < 5; x++) { for (int y = 0; y < 3; y++) { var boxVisual3D = new BoxVisual3D() { CenterPosition = new Point3D(-40 + x * 20, 5, -30 + y * 30), Size = new Size3D(10, 10, 10), Material = _standardBoxMaterial }; BoxesRootVisual3D.Children.Add(boxVisual3D); } } }
public FrustumVisibilityStatus(BoxVisual3D boxVisual3D, BoundingBox bounds) { BoxVisual3D = boxVisual3D; Bounds = bounds; _visibility = ContainmentType.Contains; // == Visible }
public void Export_SimpleModel_ValidOutput() { string path = "temp.x3d"; var runner = new CrossThreadTestRunner(); runner.RunInSTA( delegate { Console.WriteLine(Thread.CurrentThread.GetApartmentState()); var vp = new Viewport3D(); vp.Camera = CameraHelper.CreateDefaultCamera(); vp.Width = 1280; vp.Height = 720; vp.Children.Add(new DefaultLightsVisual3D()); var box = new BoxVisual3D(); box.UpdateModel(); vp.Children.Add(box); using (var e = new X3DExporter(path)) { e.Export(vp); } }); var result = Validate(path); Assert.IsNull(result, result); }
private void ClearSelectedBoxVisual() { if (_currentlySelectedBoxVisual3D != null) { _currentlySelectedBoxVisual3D.Material = _standardBoxMaterial; _currentlySelectedBoxVisual3D = null; } }
private void ClearMouseOverBoxVisual() { if (_currentMouseOverBoxVisual3D != null) { _currentMouseOverBoxVisual3D.Material = _savedMouseOverMaterial ?? _standardBoxMaterial; _currentMouseOverBoxVisual3D = null; _savedMouseOverMaterial = null; } }
private void Add(Point3D p, ModelVisual3D visual) { // Create the box visual on the UI thread var box = new BoxVisual3D { Center = p, Width = 0.8, Height = 0.8, Length = 0.8 }; visual.Children.Add(box); }
internal void AddBox(Point3D?pt) { BoxVisual3D b = new BoxVisual3D(); b.Width = 1; b.Height = 1; b.Length = 1; b.Center = ToLocal((Point3D)pt); this.Children.Add(b); }
private void Create3DViewPort() { //var viewport = new HelixViewport3D(); HelixViewport3D viewport = new HelixViewport3D(); this.grid.Children.Add(viewport); var lights = new DefaultLights(); viewport.Children.Add(new GridLinesVisual3D()); viewport.Children.Add(lights); box.Width = 6; box.Height = 6; box.Length = 6; box.Fill = Brushes.Yellow; viewport.Children.Add(box); BoxVisual3D bPlane = new BoxVisual3D(); bPlane.Height = 1; bPlane.Width = 30; bPlane.Length = 30; bPlane.Fill = Brushes.Pink; bPlane.Center = new Point3D(35, 30, -1); // Plane3D bPlane = new Plane3D(); viewport.Children.Add(bPlane); BoxVisual3D cPlane = new BoxVisual3D(); cPlane.Height = 30; cPlane.Width = 1; cPlane.Length = 30; cPlane.Fill = Brushes.Pink; cPlane.Center = new Point3D(35, 15, 14); viewport.Children.Add(cPlane); BoxVisual3D dPlane = new BoxVisual3D(); dPlane.Height = 30; dPlane.Width = 30; dPlane.Length = 1; dPlane.Fill = Brushes.Pink; dPlane.Center = new Point3D(20, 30, 14); viewport.Children.Add(dPlane); BoxVisual3D ePlane = new BoxVisual3D(); ePlane.Height = 30; ePlane.Width = 30; ePlane.Length = 1; ePlane.Fill = Brushes.Pink; ePlane.Center = new Point3D(50, 30, 14); viewport.Children.Add(ePlane); }
private void RegisterMouseEventsOnBoxVisual(BoxVisual3D boxVisual3D, Ab3d.Utilities.EventManager3D eventManager3D) { var visualEventSource3D = new VisualEventSource3D(boxVisual3D); visualEventSource3D.MouseEnter += delegate(object sender, Mouse3DEventArgs e) { ClearMouseOverBoxVisual(); var hitBoxVisual3D = e.HitObject as BoxVisual3D; if (hitBoxVisual3D != null && !ReferenceEquals(hitBoxVisual3D, _currentlySelectedBoxVisual3D)) { _savedMouseOverMaterial = hitBoxVisual3D.Material; hitBoxVisual3D.Material = _mouseOverBoxMaterial; _currentMouseOverBoxVisual3D = hitBoxVisual3D; } Mouse.OverrideCursor = Cursors.Hand; }; visualEventSource3D.MouseLeave += delegate(object sender, Mouse3DEventArgs e) { var hitBoxVisual3D = e.HitObject as BoxVisual3D; if (!ReferenceEquals(hitBoxVisual3D, _currentlySelectedBoxVisual3D)) { ClearMouseOverBoxVisual(); } else { _currentMouseOverBoxVisual3D = null; } Mouse.OverrideCursor = null; }; visualEventSource3D.MouseClick += delegate(object sender, MouseButton3DEventArgs e) { ClearSelectedBoxVisual(); var hitBoxVisual3D = e.HitObject as BoxVisual3D; if (hitBoxVisual3D != null) { hitBoxVisual3D.Material = _selectedBoxMaterial; _currentlySelectedBoxVisual3D = hitBoxVisual3D; Camera1.RotationCenterPosition = hitBoxVisual3D.CenterPosition; } }; eventManager3D.RegisterEventSource3D(visualEventSource3D); }
private static BoxVisual3D CreateBox(double width, double height, double length, Color color) { var box = new BoxVisual3D(); box.Width = width; box.Height = height; box.Length = length; box.Material = new DiffuseMaterial(new SolidColorBrush(color)); return(box); }
public void UpdateBoxes(double[] heights) { for (int i = 0; i < Boxes.Count; i++) { BoxVisual3D box = Boxes[i]; Point3D center = box.Center; center.Z = heights[i] / 2; box.Center = center; box.Height = heights[i]; } }
public TranslateManipulatorScaleX(BoxVisual3D boxVisual3D) { this.childrenObject = boxVisual3D; this.manipulator = new TranslateManipulator(); manipulator.Color = Colors.Yellow; manipulator.Length = (boxVisual3D.Length / 2f) + 2f; manipulator.Direction = new Vector3D(1, 0, 0); manipulator.Diameter = 0.3; manipulator.MouseLeftButtonDown += Manipulator_MouseLeftButtonDown; manipulator.MouseLeftButtonUp += Manipulator_MouseLeftButtonUp; manipulator.MouseMove += Manipulator_MouseMove; manipulator.Bind(childrenObject); }
public LotEditorItemMarker CreateGeometry() { LotEditorItemMarker item = new LotEditorItemMarker(this); BoxVisual3D box = new BoxVisual3D(); box.Height = 2; box.Width = 2; box.Length = 2; box.Transform = new MatrixTransform3D(this.Transform); box.Material = MaterialHelper.CreateMaterial(Brushes.Black, Brushes.Blue); // this.ModelRepresentation = box; return(item); }
/// <summary> /// Exports a simple model in a STA. /// </summary> /// <param name="e">The exporter.</param> /// <param name="stream">The stream.</param> protected void ExportSimpleModel(IExporter e, Stream stream) { CrossThreadTestRunner.RunInSTA( () => { var vp = new Viewport3D { Camera = CameraHelper.CreateDefaultCamera(), Width = 1280, Height = 720 }; vp.Children.Add(new DefaultLights()); var box = new BoxVisual3D(); box.UpdateModel(); vp.Children.Add(box); e.Export(vp, stream); }); }
private void SelectBox(BoxVisual3D selectedBoxVisual3D) { if (_selectedBoxVisual3D != null) { _selectedBoxVisual3D.Material = _standardMaterial; } if (selectedBoxVisual3D != null) { selectedBoxVisual3D.Material = _selectedMaterial; _selectedBoxVisual3D = selectedBoxVisual3D; MoveCameraTo(selectedBoxVisual3D); } }
public SimulationVisualBot3D(IBotInfo bot, DetailLevel detailLevel) : base(bot) { Bot = bot; var visual = new BoxVisual3D { Fill = VisualizationConstants.BrushBotVisual, Center = new Point3D(0, 0, 0), Length = Bot.GetInfoRadius() * 2, Width = Bot.GetInfoRadius() * 2, Height = _height, }; Children.Add(visual); }
private void Init() { for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { BoxVisual3D box = new BoxVisual3D { Center = new Point3D(i * GridSize, j * GridSize, BoxInitHeight / 2), Width = BoxSize, Length = BoxSize, Height = BoxInitHeight }; Boxes.Add(box); Viewport.Children.Add(box); } } Viewport.ZoomExtents(1000); }
public void UpdateBoxes(double[] heights) { double maxHeight = 400; for (int i = 0; i < Boxes.Count; i++) { BoxVisual3D box = Boxes[i]; Point3D center = box.Center; double height = heights[i] > maxHeight ? maxHeight : heights[i]; center.Z = height / 2; box.Center = center; box.Height = height; box.Fill = new System.Windows.Media.SolidColorBrush(_theme.GetColorByValue(height)); } }
private void Init() { foreach (Point2D p in Points) { BoxVisual3D box = new BoxVisual3D { Center = new Point3D(p.x, p.y, BoxInitHeight / 2), Width = BoxSize, Length = BoxSize, Height = BoxInitHeight, Fill = System.Windows.Media.Brushes.Cyan }; Boxes.Add(box); Viewport.Children.Add(box); } var center = new TongJi.Geometry.Extent2D(Points).Center; Viewport.LookAt(new System.Windows.Media.Media3D.Point3D(center.x, center.y, 0), new System.Windows.Media.Media3D.Vector3D(0, 1, -0.8), 500); Viewport.ZoomExtents(1000); }
private BoxVisual3D Lier([NotNull] BoxVisual3D forme, [NotNull] PrismeRectangulaireWrapper source) { BindingOperations.SetBinding(forme, BoxVisual3D.HeightProperty, new Binding(nameof(source.Hauteur)) { Source = source, Mode = BindingMode.TwoWay }); BindingOperations.SetBinding(forme, BoxVisual3D.LengthProperty, new Binding(nameof(source.Longueur)) { Source = source, Mode = BindingMode.TwoWay }); BindingOperations.SetBinding(forme, BoxVisual3D.WidthProperty, new Binding(nameof(source.Largeur)) { Source = source, Mode = BindingMode.TwoWay }); return((BoxVisual3D)_Lier(forme, source)); }
public MouseSelectionAndRotation() { InitializeComponent(); _standardBoxMaterial = new DiffuseMaterial(Brushes.Silver); _standardBoxMaterial.Freeze(); _mouseOverBoxMaterial = new DiffuseMaterial(Brushes.Orange); _mouseOverBoxMaterial.Freeze(); _selectedBoxMaterial = new DiffuseMaterial(Brushes.Red); _selectedBoxMaterial.Freeze(); var eventManager3D = new Ab3d.Utilities.EventManager3D(MainViewport); // IMPORTANT !!! // To allow EventManager3D and MouseCameraController to both work with left mouse button, // we need to set UsePreviewEvents on EventManager3D to true. // This will make EventManager3D subscribe to Preview... events (PreviewMouseMove instead of MouseMove) // and therefore EventManager3D will get the mouse events before they can be handled by the MouseCameraController. eventManager3D.UsePreviewEvents = true; // 5 x 3 boxes for (int x = 0; x < 5; x++) { for (int y = 0; y < 3; y++) { var boxVisual3D = new BoxVisual3D() { CenterPosition = new Point3D(-40 + x * 20, 5, -30 + y * 30), Size = new Size3D(10, 10, 10), Material = _standardBoxMaterial }; MainViewport.Children.Add(boxVisual3D); // Register mouse events on boxVisual3D RegisterMouseEventsOnBoxVisual(boxVisual3D, eventManager3D); } } MouseCameraControllerInfo1.AddCustomInfoLine(0, MouseCameraController.MouseAndKeyboardConditions.LeftMouseButtonPressed, "Select Box"); }
private void AddStandardRenderedObjects() { for (int x = -3; x <= 3; x++) { for (int y = -3; y <= 3; y++) { var boxVisual3D = new BoxVisual3D() { CenterPosition = new Point3D(x * 30, 0, y * 30), Size = new Size3D(10, 10, 10), Material = new DiffuseMaterial(Brushes.Yellow) }; MainViewport.Children.Add(boxVisual3D); } } }
public SimulationVisualTier3D(ITierInfo tier, DetailLevel detailLevel) : base(tier) { _tier = tier; var visual = new BoxVisual3D { Fill = VisualizationConstants.BrushTierVisual, Center = new Point3D( (_tier.GetInfoTLX() + _tier.GetInfoLength()) / 2.0, (_tier.GetInfoTLY() + _tier.GetInfoWidth()) / 2.0, _tier.GetInfoZ() - TIER_HEIGHT / 2.0), Length = _tier.GetInfoLength(), Width = _tier.GetInfoWidth(), Height = TIER_HEIGHT }; Children.Add(visual); }
public void Graphics() { //параллолепипед box = new BoxVisual3D() { Height = 3, Width = 3, Length = 4, Center = new Point3D(4, 0, 1.5), Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0)), }; // конус tr1 = new TruncatedConeVisual3D() { Height = 5, Normal = new Vector3D(0, 0, 1), BaseRadius = 2, Origin = new Point3D(-1, 0, 0), Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0)), }; //конус tr2 = new TruncatedConeVisual3D() { Height = 5, Normal = new Vector3D(0, 0, -1), BaseRadius = 2, Origin = new Point3D(-6, 0, 5), Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0)), }; pole.Children.Add(tr1); pole.Children.Add(tr2); pole.Children.Add(box); rnd1 = new Random(); rnd2 = new Random(); rnd3 = new Random(); System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer(); timer.Tick += new EventHandler(TimerTick); timer.Interval = new TimeSpan(0, 0, 1); timer.Start(); }
public SimulationVisualOutputStation3D(IOutputStationInfo oStation, DetailLevel detailLevel) : base(oStation) { _oStation = oStation; var visual = new BoxVisual3D { Fill = VisualizationConstants.BrushOutputStationVisual, Center = new Point3D( _oStation.GetInfoCurrentTier().GetInfoTLX() + _oStation.GetInfoCenterX(), _oStation.GetInfoCurrentTier().GetInfoTLY() + _oStation.GetInfoCenterY(), _oStation.GetInfoCurrentTier().GetInfoZ() + STATION_HEIGHT / 2.0 ), Length = _oStation.GetInfoLength(), Width = _oStation.GetInfoWidth(), Height = STATION_HEIGHT }; Children.Add(visual); }
public SimulationVisualElevatorEntrance3D(IWaypointInfo elevator, DetailLevel detailLevel) : base(elevator) { _elevator = elevator; var visual = new BoxVisual3D { Fill = VisualizationConstants.BrushElevatorEntranceVisual, Center = new Point3D( _elevator.GetInfoCurrentTier().GetInfoTLX() + _elevator.GetInfoCenterX(), _elevator.GetInfoCurrentTier().GetInfoTLY() + _elevator.GetInfoCenterY(), _elevator.GetInfoCurrentTier().GetInfoZ() + ELEVATOR_HEIGHT / 2.0 ), Length = _elevator.GetInfoLength() * SIZE_FACTOR, Width = _elevator.GetInfoWidth() * SIZE_FACTOR, Height = ELEVATOR_HEIGHT }; Children.Add(visual); }
public void addBox(Point3D point) { BoxVisual3D box; boxes.TryGetValue(point, out box); if (box != null) { this.Children.Remove(box); boxes.Remove(point); } box = new BoxVisual3D(); box.Center = point; box.Width = 1; box.Height = 1; box.Length = 1; this.Children.Add(box); boxes.Add(point, box); }