public MainWindow() { InitializeComponent(); cubit = new CubeVisual3D { SideLength = a * b, Fill = Brushes.SandyBrown }; Loaded += this.MainWindowLoaded; }
public void Visible_ChangeValue_GeometryShouldBeChanged() { var cube = new CubeVisual3D(); Assert.IsNotNull(((GeometryModel3D)cube.Content).Geometry); cube.Visible = false; Assert.IsNull(((GeometryModel3D)cube.Content).Geometry); cube.Visible = true; Assert.IsNotNull(((GeometryModel3D)cube.Content).Geometry); }
public Window1() { InitializeComponent(); cubit = new CubeVisual3D { SideLength = a * b, Fill = Brushes.SandyBrown }; Loaded += Window1_Loaded; }
public MainWindow() { InitializeComponent(); cubit = new CubeVisual3D { SideLength = a * b, Fill = Brushes.SandyBrown }; Loaded += this.MainWindowLoaded; }
public ManipulatorGizmo() { manipulatorVisual = new ManipulatorGizmoVisual(); manipulatorVisual.Diameter = 35; manipulatorVisual.TransformChanged += ManipulatorVisual_TransformChanged; dummyVisual = new CubeVisual3D(); dummyVisual.Fill = new SolidColorBrush(Colors.Gold); dummyVisual.Visible = false; }
public void Visible_ChangeValue_GeometryShouldBeChanged() { var cube = new CubeVisual3D(); Assert.IsNotNull(((GeometryModel3D)cube.Content).Geometry); cube.Visible = false; Assert.IsNull(((GeometryModel3D)cube.Content).Geometry); cube.Visible = true; Assert.IsNotNull(((GeometryModel3D)cube.Content).Geometry); }
private void Create3DViewPort() { var hVp3D = new HelixViewport3D(); var lights = new DefaultLights(); var sphere = new SphereVisual3D(); var cube = new CubeVisual3D(); hVp3D.Children.Add(lights); hVp3D.Children.Add(sphere); }
void CreateModel() { var cube = new CubeVisual3D { Center = new Point3D(3, 0, 0), Fill = new SolidColorBrush(Colors.Yellow), SideLength = 0.9f }; Model = cube; }
void Viewer3D_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (!IsLoaded) { return; } //var cube = DataContext as CubeMesh; if (DataContext is StockCube) { while (view.Children.Count > 0) { view.Remove(view.Children.LastOrDefault()); } var sc = DataContext as StockCube; var c = new CubeVisual3D { Height = sc.Height, Length = sc.Length, Width = sc.Width }; //c.Center.Offset(sc.X, sc.Y,sc.Z); c.Center = new Point3D(sc.X, sc.Y, sc.Z); view.Add(c); DrawAxis(2); ZoomToFit(); return; } // Prendo il riferimento alla BindingList contenuta nei ViewModel _myShapeListRef = DataContext as ObservableCollection <IEntity3D>; if (_myShapeListRef != null) { //BackgroundWorker backgroundWorker = new BackgroundWorker(); //backgroundWorker.DoWork += new DoWorkEventHandler(BackgroundWorkerDoWork); //backgroundWorker.RunWorkerAsync(); DrawScene(); } else { while (view.Children.Count > 0) { view.Remove(view.Children.LastOrDefault()); } } }
private void InitializeHelix() { _items.Clear(); _controllerObjects = new ObservableConcurrentDictionary <MotionControllerModel, SphereVisual3D>(); _items.Add(new SunLight()); _items.Add(new GridLinesVisual3D { Width = 500, Length = 500 }); CubeVisual3D camera = new CubeVisual3D { SideLength = 10, Fill = new SolidColorBrush(Colors.Blue), Center = new Point3D(_camera.Calibration.TranslationToWorld[0, 0], _camera.Calibration.TranslationToWorld[2, 0], _camera.Calibration.TranslationToWorld[1, 0]) }; _items.Add(camera); ArrowVisual3D axis = new ArrowVisual3D { Origin = new Point3D(0, 0, 0), Direction = new Vector3D(100, 0, 0), Diameter = 2, Fill = new SolidColorBrush(Colors.Red) }; _items.Add(axis); axis = new ArrowVisual3D { Origin = new Point3D(0, 0, 0), Direction = new Vector3D(0, 100, 0), Diameter = 2, Fill = new SolidColorBrush(Colors.Green) }; _items.Add(axis); axis = new ArrowVisual3D { Origin = new Point3D(0, 0, 0), Direction = new Vector3D(0, 0, 100), Diameter = 2, Fill = new SolidColorBrush(Colors.Blue) }; _items.Add(axis); }
public void IEditable_ChangeTwoProperties_TesselateIsCalledOnce() { // Tessellate is called for default values in the constructor var cube = new CubeVisual3D(); cube.BeginEdit(); cube.SideLength = 2; cube.Fill = GradientBrushes.Rainbow; // Tessellate is called here cube.EndEdit(); // verified manually.... }
public void IEditable_ChangeTwoProperties_TesselateIsCalledOnce() { // Tessellate is called for default values in the constructor var cube = new CubeVisual3D(); cube.BeginEdit(); cube.SideLength = 2; cube.Fill = GradientBrushes.Rainbow; // Tessellate is called here cube.EndEdit(); // verified manually.... }
public Element() { Tube = new TubeVisual3D(); Tube.Path = new Point3DCollection(); Tube.Path.Add(new Point3D(-15, 0, 0)); Tube.Path.Add(new Point3D(15, 0, 0)); Tube.Diameter = tubeDiameter; Tube.IsSectionClosed = true; Tube.Fill = new SolidColorBrush(Colors.Silver); Tube.IsPathClosed = false; Sphere = new CubeVisual3D(); //Sphere.Center = new Point3D(15, 0, 0); Sphere.Fill = new SolidColorBrush(Colors.Silver); Sphere.SideLength = 0.75; }
public void Initialize() { wheels = new SphereVisual3D[4]; offsetXRotationAxis = new Vector3D(0.0, 1.0, 0.0); offsetYRotationAxis = new Vector3D(-1.0, 0.0, 0.0); PlatformSize = DefaultPlatformSize; Model = new ModelVisual3D(); platform = new CubeVisual3D(); platform.Fill = Brushes.Purple; platform.SideLength = PlatformSize; var platformTransformGroup = new Transform3DGroup(); platformTransformGroup.Children.Add(new ScaleTransform3D(new Vector3D(1.0, 1.0, platformHeightFactor))); platformTransformGroup.Children.Add(new TranslateTransform3D(0.0, 0.0, wheelRadius * 2 + PlatformSize * platformHeightFactor / 2)); platform.Transform = platformTransformGroup; Model.Children.Add(platform); for (int i = 0; i < 4; i++) { var wheel = new SphereVisual3D(); wheel.Radius = wheelRadius; wheel.Material = Materials.Blue; var wheelPosition = PlatformSize / 2 - wheelRadius; var wheelTransformGroup = new Transform3DGroup(); wheelTransformGroup.Children.Add(new TranslateTransform3D(-wheelPosition * (i % 2 * 2 - 1), wheelPosition * (i % 2 * 2 - 1) * (i >= 2 ? 1.0 : -1.0), 0.5)); wheel.Transform = wheelTransformGroup; Model.Children.Add(wheel); wheels[i] = wheel; } rim = new TubeVisual3D(); rim.Fill = Brushes.White; rim.Diameters = new DoubleCollection { 1.5, 0.0 }; rim.Path = new Point3DCollection { new Point3D(0, 0, 1.5), new Point3D(0, 0, 1.75) }; Model.Children.Add(rim); }
private static void DrawCube() { if (Battle3DViewPort == null) { Battle3DViewPort = Application.Current.FindResource("Battle3DViewPort") as HelixViewport3D; } // Battle3DViewPort = new HelixViewport3D(); //var view = new HelixViewport3D(); int roomSize = 20; var lights = new DefaultLights(); LinearGradientBrush horGradBrushBlue = new LinearGradientBrush(); horGradBrushBlue.StartPoint = new Point(0, 0.5); horGradBrushBlue.EndPoint = new Point(1, 0.5); horGradBrushBlue.GradientStops.Add(new GradientStop(Colors.RoyalBlue, 0.0)); horGradBrushBlue.GradientStops.Add(new GradientStop(Colors.Blue, 0.4)); LinearGradientBrush horGradBrushGreen = new LinearGradientBrush(); horGradBrushGreen.StartPoint = new Point(0, 0.5); horGradBrushGreen.EndPoint = new Point(1, 0.5); horGradBrushGreen.GradientStops.Add(new GradientStop(Colors.Green, 0.5)); horGradBrushGreen.GradientStops.Add(new GradientStop(Colors.ForestGreen, 1.0)); RadialGradientBrush radGradBrush = new RadialGradientBrush(); radGradBrush.GradientOrigin = new Point(0.75, 0.75); radGradBrush.Center = new Point(0.5, 0.5); radGradBrush.RadiusX = 0.5; radGradBrush.RadiusY = 0.5; radGradBrush.GradientStops.Add(new GradientStop(Colors.RoyalBlue, 0.0)); radGradBrush.GradientStops.Add(new GradientStop(Colors.Blue, 0.4)); radGradBrush.Freeze(); horGradBrushBlue.Freeze(); Rectangle myRectangle = new Rectangle(); myRectangle.Width = 200; myRectangle.Height = 100; myRectangle.Fill = radGradBrush; CubeVisual3D cube = new CubeVisual3D(); int x = 0; int y = 0; int z = 0; for (x = 0; x < roomSize; x++) { for (y = 0; y < roomSize; y++) { for (z = 0; z < roomSize; z++) { if (z == 0) { cube = new CubeVisual3D(); cube.SideLength = 1; cube.Center = new Point3D(x, y, z); cube.Fill = horGradBrushGreen; Battle3DViewPort.Children.Add(cube); } else if (z == 1 && x >= 5 && y >= 5) { cube = new CubeVisual3D(); cube.SideLength = 1; cube.Center = new Point3D(x, y, z); cube.Fill = horGradBrushGreen; Battle3DViewPort.Children.Add(cube); } else if (z >= 2 && z <= 10 && x > 10 && y > 10 && x < roomSize - 5 && y < roomSize - 5) { cube = new CubeVisual3D(); cube.SideLength = 1; cube.Center = new Point3D(x, y, z); cube.Fill = horGradBrushBlue; Battle3DViewPort.Children.Add(cube); } } } } GridLinesVisual3D grid2 = new GridLinesVisual3D(); grid2.Center = new Point3D(12, 12, 1.52); grid2.Length = 15; grid2.Width = 15; grid2.MajorDistance = 5; grid2.MinorDistance = 1; grid2.Thickness = .02; grid2.Fill = Brushes.Black; Battle3DViewPort.Children.Add(grid2); GridLinesVisual3D grid = new GridLinesVisual3D(); grid.Center = new Point3D(9.5, 9.5, .52); grid.Length = 20; grid.Width = 20; grid.MajorDistance = 5; grid.MinorDistance = 1; grid.Thickness = .02; grid.Fill = Brushes.Black; Battle3DViewPort.Children.Add(grid); foreach (KeyValuePair <Guid, SphereVisual3D> sphere in Players.UnitSpheres) { Battle3DViewPort.Children.Add(sphere.Value); } //foreach(SphereVisual3D sphere in Players.UnitSpheres) //{ //} // Players.UnitSpheres.Add(Guid.NewGuid(), new SphereVisual3D()); //Players.UnitSpheres.Last().Value.Center = new Point3D(5, 5, 3); //Players.UnitSpheres.Last().Value.Fill = Brushes.DarkOrange; //Players.UnitSpheres.Last().Value.Radius = 0.5; //Battle3DViewPort.Children.Add(Players.UnitSpheres.Last().Value); //UnitModel.Content = Display3d("CuteDarkVador.STL"); //var transGroup = new Transform3DGroup(); //transGroup.Children.Add(new ScaleTransform3D(new Vector3D(.01, .01, .01))); //transGroup.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90))); //transGroup.Children.Add(new TranslateTransform3D(new Vector3D(5, 10, 2))); //UnitModel.Transform = transGroup; Battle3DViewPort.ZoomExtents(); //view.Children.Add(cube); //BattleScreenCanvas.Children.Add(BattleViewPort); }
private void InitializeHelix() { _helixItems.Add(new SunLight()); _helixItems.Add(new GridLinesVisual3D { Width = 500, Length = 500 }); foreach (CameraModel cameraModel in Cameras) { CubeVisual3D cube = new CubeVisual3D(); cube.SideLength = 10; cube.Fill = new SolidColorBrush(Colors.Blue); cube.Center = new Point3D(cameraModel.Calibration.TranslationToWorld[0, 0], cameraModel.Calibration.TranslationToWorld[2, 0], cameraModel.Calibration.TranslationToWorld[1, 0]); _helixItems.Add(cube); } if (Cameras.Count == 4) { ArrowVisual3D arrow = new ArrowVisual3D { Point1 = new Point3D( GetCamera(0).Calibration.TranslationToWorld[0, 0], GetCamera(0).Calibration.TranslationToWorld[2, 0], GetCamera(0).Calibration.TranslationToWorld[1, 0]), Point2 = new Point3D( GetCamera(2).Calibration.TranslationToWorld[0, 0], GetCamera(2).Calibration.TranslationToWorld[2, 0], GetCamera(2).Calibration.TranslationToWorld[1, 0]), Fill = new SolidColorBrush(Colors.Yellow) }; _helixItems.Add(arrow); arrow = new ArrowVisual3D { Point1 = new Point3D( GetCamera(1).Calibration.TranslationToWorld[0, 0], GetCamera(1).Calibration.TranslationToWorld[2, 0], GetCamera(1).Calibration.TranslationToWorld[1, 0]), Point2 = new Point3D( GetCamera(3).Calibration.TranslationToWorld[0, 0], GetCamera(3).Calibration.TranslationToWorld[2, 0], GetCamera(3).Calibration.TranslationToWorld[1, 0]), Fill = new SolidColorBrush(Colors.Yellow) }; _helixItems.Add(arrow); } ArrowVisual3D axis = new ArrowVisual3D { Origin = new Point3D(0, 0, 0), Direction = new Vector3D(100, 0, 0), Diameter = 2, Fill = new SolidColorBrush(Colors.Red) }; _helixItems.Add(axis); axis = new ArrowVisual3D { Origin = new Point3D(0, 0, 0), Direction = new Vector3D(0, 100, 0), Diameter = 2, Fill = new SolidColorBrush(Colors.Green) }; _helixItems.Add(axis); axis = new ArrowVisual3D { Origin = new Point3D(0, 0, 0), Direction = new Vector3D(0, 0, 100), Diameter = 2, Fill = new SolidColorBrush(Colors.Blue) }; _helixItems.Add(axis); }
public void Geometry_WithDefaultValues_NumberOfTriangleIndicesShouldBe36() { var cube = new CubeVisual3D(); var g = (MeshGeometry3D)((GeometryModel3D)cube.Content).Geometry; Assert.AreEqual(36, g.TriangleIndices.Count); }