Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Point3DAsSphereVisualizationObject"/> class.
        /// </summary>
        public Point3DAsSphereVisualizationObject()
        {
            this.sphereVisual = new SphereVisual3D();

            this.UpdatePointProperties();
            this.UpdateVisibility();
        }
Exemplo n.º 2
0
        private void UpdatePoints(List <Point3D> points)
        {
            if (points != null)
            {
                while (this.spheres.Count < points.Count)
                {
                    var sphere = new SphereVisual3D()
                    {
                        Radius   = this.visualizationObject.RadiusCm * 0.01,
                        Material = new DiffuseMaterial(new SolidColorBrush(this.visualizationObject.Color)),
                    };
                    this.Children.Add(sphere);
                    this.spheres.Add(sphere);
                }

                for (int i = 0; i < this.spheres.Count; i++)
                {
                    if (i < points.Count)
                    {
                        var point = points[i];
                        this.spheres[i].Transform = new TranslateTransform3D(point.X, point.Y, point.Z);
                        this.spheres[i].Visible   = true;
                    }
                    else
                    {
                        this.spheres[i].Visible = false;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public List <SphereVisual3D> GetNodesModels(bool onlyVisible)
        {
            List <SphereVisual3D> nodesModels = new List <SphereVisual3D>();

            for (int i = 0; i < nodesPoints.Count; i++)
            {
                SphereVisual3D nodeModel = new SphereVisual3D();
                nodeModel.Center   = nodesPoints[i];
                nodeModel.Radius   = 0.25;
                nodeModel.Material = new DiffuseMaterial(new SolidColorBrush(Colors.LightBlue));

                if (onlyVisible)
                {
                    if (visibleIndeces.Contains(i))
                    {
                        nodesModels.Add(nodeModel);
                    }
                }
                else
                {
                    nodesModels.Add(nodeModel);
                }
            }
            return(nodesModels);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 描画用の球を取得する
 /// </summary>
 /// <param name="position">位置</param>
 /// <returns></returns>
 private SphereVisual3D GetSphere(Vector position)
 {
     var sphere = new SphereVisual3D();
     sphere.Material = new DiffuseMaterial(Brushes.Red);
     sphere.Transform = GetTransform(position, Vector.Forward, Vector.One * 0.25);
     return sphere;
 }
Exemplo n.º 5
0
 public TexturedObject3D()
 {
     Sphere = new SphereVisual3D()
     {
         ThetaDiv = 60, PhiDiv = 30
     };
     Children.Add(Sphere);
 }
Exemplo n.º 6
0
        static SphereVisual3D MakeSphereForBrush(Brush brush)
        {
            var sphere = new SphereVisual3D();

            sphere.Radius = Constants.SphereRadius;
            sphere.Fill   = brush;
            return(sphere);
        }
Exemplo n.º 7
0
 public static void RemoveUnitSphere(UnitData unit)
 {
     if (Players.UnitSpheres.ContainsKey(unit.UnitID))
     {
         SphereVisual3D sphere = Players.UnitSpheres[unit.UnitID];
         Battle3DViewPort.Children.Remove(sphere);
     }
 }
Exemplo n.º 8
0
        private void AjouterSphere(object sender, RoutedEventArgs e)
        {
            var sphere = new SphereVisual3D {
                Radius = i++
            };

            Formes.Add(sphere);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Generate Random Sphere
        /// </summary>
        /// <returns></returns>
        public static SphereVisual3D GetNewSphere()
        {
            Random         r      = new Random();
            SphereVisual3D sphere = new SphereVisual3D();

            sphere.Center = new Point3D(r.Next(0, 20), r.Next(0, 20), 2);

            switch (r.Next(1, 10))
            {
            case 1:
                sphere.Fill = Brushes.DarkOrange;
                break;

            case 2:
                sphere.Fill = Brushes.Aqua;
                break;

            case 3:
                sphere.Fill = Brushes.Bisque;
                break;

            case 4:
                sphere.Fill = Brushes.BlueViolet;
                break;

            case 5:
                sphere.Fill = Brushes.Coral;
                break;

            case 6:
                sphere.Fill = Brushes.DarkGreen;
                break;

            case 7:
                sphere.Fill = Brushes.DarkMagenta;
                break;

            case 8:
                sphere.Fill = Brushes.DarkTurquoise;
                break;

            case 9:
                sphere.Fill = Brushes.ForestGreen;
                break;

            case 10:
                sphere.Fill = Brushes.HotPink;
                break;

            default:
                sphere.Fill = Brushes.LightGreen;
                break;
            }

            sphere.Radius = 0.5;

            return(sphere);
        }
        private void CreateArrows()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            try
            {
                Mouse.OverrideCursor = Cursors.Hand;

                MainViewport.Children.Clear();


                var selectedArrowsNumber = GetSelectedArrowsNumber();

                _xCount = selectedArrowsNumber;
                _yCount = selectedArrowsNumber;


                var sphereVisual3D = new SphereVisual3D()
                {
                    CenterPosition = new Point3D(0, 0, 0),
                    Radius         = 10,
                    Material       = new DiffuseMaterial(Brushes.Gold)
                };

                _sphereTranslate         = new TranslateTransform3D(_sphereStartPosition.ToWpfVector3D());
                sphereVisual3D.Transform = _sphereTranslate;


                MainViewport.Children.Add(sphereVisual3D);



                _instanceData = new InstanceData[_xCount * _yCount];
                UpdateInstanceData();

                var arrowMesh3D = new Ab3d.Meshes.ArrowMesh3D(new Point3D(0, 0, 0), new Point3D(1, 0, 0), 1.0 / 15.0, 2.0 / 15.0, 45, 10, false).Geometry;

                _instancedMeshGeometryVisual3D = new InstancedMeshGeometryVisual3D(arrowMesh3D);
                _instancedMeshGeometryVisual3D.InstancesData = _instanceData;

                MainViewport.Children.Add(_instancedMeshGeometryVisual3D);


                Camera1.Refresh(); // This will regenerate camera light if it was removed with MainViewport.Children.Clear()

                TotalTextBlock.Text = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                    "Total positions: {0:#,###}; total triangles: {1:#,###}",
                                                    _xCount * _yCount * _instancedMeshGeometryVisual3D.MeshGeometry3D.Positions.Count,
                                                    _xCount * _yCount * _instancedMeshGeometryVisual3D.MeshGeometry3D.TriangleIndices.Count / 3);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
        private void CreateArrows()
        {
            double xStep = _xSize / _xCount;
            double yStep = _ySize / _yCount;

            double x, y;

            _arrows = new ArrowVisual3D[_xCount, _yCount];

            MainViewport.Children.Clear();


            var sphereVisual3D = new SphereVisual3D()
            {
                CenterPosition = new Point3D(0, 0, 0),
                Radius         = 10,
                Material       = new DiffuseMaterial(Brushes.Gold)
            };

            _sphereTranslate         = new TranslateTransform3D(_sphereStartPosition);
            sphereVisual3D.Transform = _sphereTranslate;


            MainViewport.Children.Add(sphereVisual3D);


            x = -(_xSize / 2);
            for (int xi = 0; xi < _xCount; xi++)
            {
                y = -(_ySize / 2);

                for (int yi = 0; yi < _yCount; yi++)
                {
                    double distance = GetDistance(x, y);

                    var arrowVisual3D = new ArrowVisual3D();

                    arrowVisual3D.BeginInit();
                    arrowVisual3D.StartPosition = new Point3D(x, 0, y);
                    arrowVisual3D.Radius        = _arrowsLength / 15;
                    arrowVisual3D.Material      = GetMaterialForDistance(distance);
                    arrowVisual3D.ArrowAngle    = 45;
                    arrowVisual3D.Segments      = 10;

                    var arrowDirection = GetArrowDirection(x, y);
                    arrowVisual3D.EndPosition = arrowVisual3D.StartPosition + arrowDirection;
                    arrowVisual3D.EndInit();

                    _arrows[xi, yi] = arrowVisual3D;

                    MainViewport.Children.Add(arrowVisual3D);

                    y += yStep;
                }

                x += xStep;
            }
        }
 public FormBrushesExploration()
 {
     CouleurA = 255;
     Sphere   = new SphereVisual3D {
     };
     ModificationMateriauxARGB(null, null);
     InitializeComponent();
     viewport.Children.Add(Sphere);
 }
Exemplo n.º 13
0
        private void AddSphere()
        {
            var sphere = new SphereVisual3D()
            {
                Radius = .05
            };

            this.Children.Add(sphere);
            this.spheres.Add(sphere);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        private SphereVisual3D CreateVertex(Point3D center, Brush fill)
        {
            var vert = new SphereVisual3D();

            vert.Center = center;
            vert.Radius = 0.1;
            vert.Fill   = fill;

            return(vert);
        }
Exemplo n.º 16
0
        private void DrawSphere3D(Point3D center, double radius, Brush brush, HelixToolkit.Wpf.HelixViewport3D viewport)
        {
            SphereVisual3D sphere = new SphereVisual3D();

            sphere.Center = center;
            sphere.Radius = radius;
            sphere.Fill   = brush;

            viewport.Children.Add(sphere);
        }
Exemplo n.º 17
0
        private SphereVisual3D CreateSphereVisual3D()
        {
            var sphereVisual3D = new SphereVisual3D()
            {
                CenterPosition = Position,
                Material       = GetCurrentSphereMaterial(),
                Radius         = Radius
            };

            return(sphereVisual3D);
        }
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     ball = new SphereVisual3D
     {
         Center    = new Point3D(1.5, 1, 1),
         Radius    = 0.5,
         Material  = new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(255, 197, 147))),
         Transform = new TranslateTransform3D(x, y, z),
         Visible   = true
     };
     viewPort.Children.Add(ball);
 }
Exemplo n.º 19
0
        public void addSampleView(Point3D center, Material mat)
        {
            SphereVisual3D sample = new SphereVisual3D();

            sample.Center       = center;
            sample.BackMaterial = mat;
            sample.Material     = mat;
            sample.PhiDiv       = 10;
            sample.Radius       = 0.05;
            sample.ThetaDiv     = 10;
            this.mainViewport.Children.Add(sample);
        }
        public CombinedManipulatorExploration()
        {
            var manipulator = new CombinedManipulator();

            Sphere = new SphereVisual3D()
            {
                Radius = 1
            };
            manipulator.Bind(Sphere);
            InitializeComponent();

            viewport.Children.Add(Sphere);
            viewport.Children.Add(manipulator);
        }
Exemplo n.º 21
0
        /// <summary>
        /// fills the room with the sphere representations of all devices.
        /// </summary>
        private void FillRoom()
        {
            if (deviceList != null)
            {
                ModelVisual3D model = new ModelVisual3D();
                foreach (Device dev in deviceList)
                {
                    foreach (Ball ball in dev.Form)
                    {
                        SphereVisual3D sphere = new SphereVisual3D();
                        Color          c      = Color.FromArgb(dev.color.A, dev.color.R, dev.color.G, dev.color.B);
                        Material       mat    = new DiffuseMaterial(new SolidColorBrush(c));
                        sphere.Center   = ball.Center;
                        sphere.Material = mat;
                        sphere.Radius   = ball.Radius;
                        sphere.PhiDiv   = 13;
                        sphere.ThetaDiv = 13;

                        model.Children.Add(sphere);
                    }
                }

                //for (int i = 0; i < deviceList.Count; i++)
                //{
                //    for (int j = 0; j < deviceList[i].Form.Count; j++)
                //    {

                //        Point3D center = deviceList[i].Form[j].Center;
                //        double rad = deviceList[i].Form[j].Radius;

                //        HelixToolkit.Wpf.SphereVisual3D sphere = new HelixToolkit.Wpf.SphereVisual3D();



                //        Material mat = new DiffuseMaterial(new SolidColorBrush(Colors.Gray));

                //        sphere.Center = center;
                //        sphere.Material = mat;
                //        sphere.Radius = rad;
                //        sphere.Visible = true;
                //        sphere.PhiDiv = 13;
                //        sphere.ThetaDiv = 13;

                //        model.Children.Add(sphere);
                //    }
                //}
                mainViewport.Children.Add(model);
            }
        }
Exemplo n.º 22
0
        public LotEditorItemMarker CreateGeometry()
        {
            LotEditorItemMarker item = new LotEditorItemMarker(this);

            SphereVisual3D point = new SphereVisual3D();

            point.Radius = 2;

            point.Material = MaterialHelper.CreateMaterial(Brushes.Black, Brushes.Aqua);

            item.ManipulatorModel    = point.Model;
            item.Transform           = new TranslateTransform3D(Point.X, Point.Y, Point.Z);
            this.ModelRepresentation = item;
            return(item);
        }
        private void CreateSampleObjects()
        {
            var spherePositions = new List <Point3D>();

            SampleObjectsVisual3D.Children.Clear();

            var rnd = new Random();

            float planeCellSize = _planarShadowRenderingProvider != null ? _planarShadowRenderingProvider.ShadowPlaneSize.X / 10 : 40;

            while (spherePositions.Count < 10)
            {
                int cellXIndex = rnd.Next(10);
                int cellYIndex = rnd.Next(10);

                var spherePosition = new Point3D((cellXIndex - 5) * planeCellSize + planeCellSize / 2,
                                                 0,
                                                 (cellYIndex - 5) * planeCellSize + planeCellSize / 2);

                // Check if this position was already taken
                if (spherePositions.Any(p => Ab3d.Utilities.MathUtils.IsSame((float)p.X, spherePosition.X) && Ab3d.Utilities.MathUtils.IsSame(p.Z, spherePosition.Z)))
                {
                    continue;
                }

                spherePositions.Add(spherePosition);


                // t defines an animation time between 0 and 1.
                double t = rnd.NextDouble();

                var sphereVisual3D = new SphereVisual3D()
                {
                    CenterPosition = spherePosition,
                    Radius         = planeCellSize * 0.25,
                    Material       = new DiffuseMaterial(new SolidColorBrush(System.Windows.Media.Color.FromRgb((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)))),
                    Tag            = t
                };

                sphereVisual3D.Transform = new TranslateTransform3D(0, GetAnimatedHeight(t), 0);

                SampleObjectsVisual3D.Children.Add(sphereVisual3D);
            }

            StartAnimation();
        }
Exemplo n.º 24
0
        public SimulationVisualWaypoint3D(IWaypointInfo waypoint, DetailLevel detailLevel)
            : base(waypoint)
        {
            _waypoint = waypoint;
            var visual = new SphereVisual3D
            {
                Fill   = VisualizationConstants.BrushWaypointVisual,
                Center = new Point3D(waypoint.GetInfoCenterX(), waypoint.GetInfoCenterY(), waypoint.GetInfoCurrentTier().GetInfoZ() + WAYPOINT_LIFT),
                Radius = waypoint.GetInfoLength() / 2.0
            };

            Children.Add(visual);
            // Add connections to other ones (if detailed drawing mode)
            //foreach (var otherWP in waypoint.GetInfoConnectedWaypoints())
            //{
            //    // TODO draw connection to other wp
            //}
        }
        private void ShowSpheres(List <SphereInfo> spheres)
        {
            RootVisual3D.Children.Clear();

            foreach (var sphereInfo in spheres)
            {
                var sphereVisual3D = new SphereVisual3D()
                {
                    CenterPosition = sphereInfo.CenterPosition,
                    Radius         = 3,
                    Material       = new DiffuseMaterial(new SolidColorBrush(sphereInfo.Color))
                };

                RootVisual3D.Children.Add(sphereVisual3D);
            }

            _shownSphereData = spheres;
        }
Exemplo n.º 26
0
        public VertexUI(Vertex vertex) : base(vertex)
        {
            Vertex = vertex;
            var sphere = new SphereVisual3D();

            sphere.Model.Material = MaterialHelper.CreateMaterial(Color.FromRgb(255, 0, 0));
            sphere.Center         = vertex.Point.Multiply(SCALE_FACTOR);
            sphere.Radius         = sphere.Radius * 0.5;

            VisualElement = sphere;

            Material colorMaterial;

            switch (vertex.Type)
            {
            case 0:
                colorMaterial = DefaultVertexMaterial;
                break;

            case 1:
                colorMaterial = BindVertexMaterial;
                break;

            case 2:
                colorMaterial = ControlVertexMaterial;
                break;

            case 3:
                colorMaterial = MassVertexMaterial;
                break;

            default:
                colorMaterial = UnknownVertexMaterial;
                break;
            }


            var groupMaterial = new MaterialGroup();

            groupMaterial.Children.Add(colorMaterial);
            Material = groupMaterial;

            Title = "Узел №" + vertex.Number;
        }
Exemplo n.º 27
0
        private VisualObjectData ParsePushTriggerObject(VisualObjectData obj)
        {
            var sphere = new SphereVisual3D();


            if (!double.TryParse(obj.ObjectData.GetProperty("radius"), out var tempRadius))
            {
                tempRadius = 2.5 * 4;
            }

            tempRadius    = tempRadius / 4;
            sphere.Radius = tempRadius;
            obj.Offset.Z += tempRadius / 2;

            sphere.Material = new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(128, 255, 171, 0)));

            obj.Model = sphere;
            return(obj);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Translates a point into a solid drawable object
        /// </summary>
        /// <param name="point">The point to draw</param>
        /// <param name="color">The color of the object</param>
        /// <param name="offSetX">An optional offset by which the object gets shifted along the x-axis</param>
        /// <param name="offSetY">An optional offset by which the object gets shifted along the y-axis</param>
        /// <param name="offSetZ">An optional offset by which the object gets shifted along the z-axis</param>
        /// <returns>The newly composed drawable object</returns>
        public static ModelVisual3D Translate(
            MeshPoint point,
            Color color,
            double offSetX = 0,
            double offSetY = 0,
            double offSetZ = 0,
            double radius  = 0.1)
        {
            SphereVisual3D sphere = new SphereVisual3D();

            sphere.Center = new Point3D(
                point.X + offSetX,
                point.Y + offSetY,
                point.Z + offSetZ);
            sphere.Radius   = radius;
            sphere.Material = new DiffuseMaterial(GeneratePlainBrush(color));
            sphere.SetName(point.VolatileID.ToString()); // TODO remove debug?
            return(sphere);
        }
Exemplo n.º 29
0
        // Ambient_Light
        private VisualObjectData ParseLightObject(VisualObjectData obj)
        {
            obj.Offset = new Vector3D(0, 0, 0);
            var sphere = new SphereVisual3D();

            sphere.Radius = 2.5;

            var color = ColorFromArray(obj.ObjectData.Floats);

            // Black light, don't show so that we can see actual colors
            if (color.R == 0 && color.G == 0 && color.B == 0)
            {
                return(null);
            }

            sphere.Material = new DiffuseMaterial(new SolidColorBrush(color));

            obj.Model = sphere;
            return(obj);
        }
Exemplo n.º 30
0
        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);
        }