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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Ray3DVisualizationObject"/> class.
        /// </summary>
        public Ray3DVisualizationObject()
        {
            this.rayArrow = new ArrowVisual3D()
            {
                ThetaDiv = ThetaDivDefault, Fill = new SolidColorBrush(this.Color), Diameter = this.ThicknessMm / 1000.0
            };

            this.UpdateVisibility();
        }
Beispiel #3
0
        protected virtual void OnScaleFactorPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            var oldValue = (int)e.OldValue;
            var newValue = (int)e.NewValue;

            if (oldValue != newValue)
            {
                if (newValue > 0)
                {
                    if (_lines != null)
                    {
                        RemoveVisualChildren(_lines, _xaxis, _yaxis, _zaxis);
                    }
                    _lines = new LinesVisual3D {
                        Thickness = 0.5,
                        Color     = Colors.Black,
                        Points    = new Point3DCollection(new[] {
                            new Point3D(-newValue, +newValue, +newValue),
                            new Point3D(+newValue, +newValue, +newValue),
                            new Point3D(-newValue, +newValue, -newValue),
                            new Point3D(+newValue, +newValue, -newValue),
                            new Point3D(-newValue, -newValue, +newValue),
                            new Point3D(+newValue, -newValue, +newValue),
                            new Point3D(-newValue, -newValue, -newValue),
                            new Point3D(+newValue, -newValue, -newValue),

                            new Point3D(+newValue, -newValue, +newValue),
                            new Point3D(+newValue, +newValue, +newValue),
                            new Point3D(+newValue, -newValue, -newValue),
                            new Point3D(+newValue, +newValue, -newValue),
                            new Point3D(-newValue, -newValue, +newValue),
                            new Point3D(-newValue, +newValue, +newValue),
                            new Point3D(-newValue, -newValue, -newValue),
                            new Point3D(-newValue, +newValue, -newValue),

                            new Point3D(+newValue, +newValue, -newValue),
                            new Point3D(+newValue, +newValue, +newValue),
                            new Point3D(+newValue, -newValue, -newValue),
                            new Point3D(+newValue, -newValue, +newValue),
                            new Point3D(-newValue, +newValue, -newValue),
                            new Point3D(-newValue, +newValue, +newValue),
                            new Point3D(-newValue, -newValue, -newValue),
                            new Point3D(-newValue, -newValue, +newValue),
                        })
                    };
                    _xaxis = MakeArrowVisual(newValue, 0, 0, Brushes.Red);
                    _yaxis = MakeArrowVisual(0, newValue, 0, Brushes.Green);
                    _zaxis = MakeArrowVisual(0, 0, newValue, Brushes.Blue);
                    AddVisualChildren(_lines, _xaxis, _yaxis, _zaxis);
                }
            }
        }
        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);
        }
Beispiel #5
0
        public static void CreateACoordinateArrow(ModelVisual3D model, Point3D point, Quaternion quat, Color xaxiscolor, Color yaxiscolor, Color zaxiscolor, Color basecolor)
        {
            double ArrowLength   = .10;
            double ArrowDiameter = .01;


            var rotatetransform = new RotateTransform3D(new QuaternionRotation3D(quat))
            {
                CenterX = point.X, CenterY = point.Y, CenterZ = point.Z
            };
            var xaxis = new ArrowVisual3D();

            xaxis.BeginEdit();
            xaxis.Fill      = new SolidColorBrush(xaxiscolor);
            xaxis.Diameter  = ArrowDiameter;
            xaxis.Origin    = point;
            xaxis.Direction = new Vector3D(ArrowLength, 0, 0);
            xaxis.Transform = rotatetransform;
            xaxis.EndEdit();
            model.Children.Add(xaxis);

            var yaxis = new ArrowVisual3D();

            yaxis.BeginEdit();
            yaxis.Fill      = new SolidColorBrush(yaxiscolor);
            yaxis.Diameter  = ArrowDiameter;
            yaxis.Origin    = point;
            yaxis.Direction = new Vector3D(0, ArrowLength, 0);
            yaxis.Transform = rotatetransform;
            yaxis.EndEdit();
            model.Children.Add(yaxis);

            var zaxis = new ArrowVisual3D();

            zaxis.BeginEdit();
            zaxis.Fill      = new SolidColorBrush(zaxiscolor);
            zaxis.Diameter  = ArrowDiameter;
            zaxis.Origin    = point;
            zaxis.Direction = new Vector3D(0, 0, ArrowLength);
            zaxis.Transform = rotatetransform;
            zaxis.EndEdit();
            model.Children.Add(zaxis);

            model.Children.Add(new CubeVisual3D {
                Center = point, SideLength = ArrowDiameter * 3.5, Fill = new SolidColorBrush(basecolor)
            });
        }
Beispiel #6
0
 private void AddAxes()
 {
     var arrowVisualX = new ArrowVisual3D()
     {
         Fill = System.Windows.Media.Brushes.Red
     };
     var arrowVisualY = new ArrowVisual3D()
     {
         Fill = System.Windows.Media.Brushes.Green
     };
     var arrowVisualZ = new ArrowVisual3D()
     {
         Fill = System.Windows.Media.Brushes.Blue
     };
     this.axes.Add(Tuple.Create(arrowVisualX, arrowVisualY, arrowVisualZ));
     this.Children.Add(arrowVisualX);
     this.Children.Add(arrowVisualY);
     this.Children.Add(arrowVisualZ);
 }
Beispiel #7
0
        /// <summary>
        /// Adds the StartElements for one Axis of the Coordinate System.
        /// </summary>
        /// <param name="direction">The Direction of the Axis.</param>
        /// <param name="brush">The Brush defines the Color of the Arrow and Label.</param>
        /// <param name="position">Position of the Axis Label.</param>
        /// <param name="text">The Axis Label Text.</param>
        private void AddAxisInfo(Vector3D direction, Brush brush, Point3D position, string text)
        {
            var asix = new ArrowVisual3D()
            {
                Direction  = direction,
                HeadLength = 2,
                Diameter   = 0.05,
                Fill       = brush
            };

            _startElements.Add(new Visual3DViewModel(null, asix, $"{text} - Axis"));

            var axisLabel = new BillboardTextVisual3D()
            {
                Position   = position,
                Text       = text,
                Foreground = brush,
                FontSize   = 18
            };

            _startElements.Add(new Visual3DViewModel(null, axisLabel, text));
        }
Beispiel #8
0
        /// <summary>
        /// Called when the geometry has changed.
        /// </summary>
        protected virtual void OnGeometryChanged()
        {
            this.Children.Clear();
            double l = this.ArrowLengths;
            double d = l * 0.1;

            var xaxis = new ArrowVisual3D();

            xaxis.BeginEdit();
            xaxis.Point2   = new Point3D(l, 0, 0);
            xaxis.Diameter = d;
            xaxis.Fill     = new SolidColorBrush(this.XAxisColor);
            xaxis.EndEdit();
            this.Children.Add(xaxis);

            var yaxis = new ArrowVisual3D();

            yaxis.BeginEdit();
            yaxis.Point2   = new Point3D(0, l, 0);
            yaxis.Diameter = d;
            yaxis.Fill     = new SolidColorBrush(this.YAxisColor);
            yaxis.EndEdit();
            this.Children.Add(yaxis);

            var zaxis = new ArrowVisual3D();

            zaxis.BeginEdit();
            zaxis.Point2   = new Point3D(0, 0, l);
            zaxis.Diameter = d;
            zaxis.Fill     = new SolidColorBrush(this.ZAxisColor);
            zaxis.EndEdit();
            this.Children.Add(zaxis);

            this.Children.Add(new CubeVisual3D {
                SideLength = d, Fill = Brushes.Black
            });
        }
Beispiel #9
0
        private void InitializeScene()
        {
            const double maxVal = 8;

            var arrowX = new ArrowVisual3D();

            arrowX.Direction = new Vector3D(1, 0, 0);
            arrowX.Point1    = new Point3D(0, 0, 0);
            arrowX.Point2    = new Point3D(maxVal, 0, 0);
            arrowX.Diameter  = 0.1;
            arrowX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowX);

            arrowX           = new ArrowVisual3D();
            arrowX.Direction = new Vector3D(1, 0, 0);
            arrowX.Point1    = new Point3D(0, 0, 0);
            arrowX.Point2    = new Point3D(maxVal, 0, 0);
            arrowX.Diameter  = 0.1;
            arrowX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowX);

            var arrowMX = new ArrowVisual3D();

            arrowMX.Direction = new Vector3D(-1, 0, 0);
            arrowMX.Point1    = new Point3D(0, 0, 0);
            arrowMX.Point2    = new Point3D(-maxVal, 0, 0);
            arrowMX.Diameter  = 0.1;
            arrowMX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMX);

            arrowMX           = new ArrowVisual3D();
            arrowMX.Direction = new Vector3D(-1, 0, 0);
            arrowMX.Point1    = new Point3D(0, 0, 0);
            arrowMX.Point2    = new Point3D(-maxVal, 0, 0);
            arrowMX.Diameter  = 0.1;
            arrowMX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMX);

            var arrowY = new ArrowVisual3D();

            arrowY.Direction = new Vector3D(0, 1, 0);
            arrowY.Point1    = new Point3D(0, 0, 0);
            arrowY.Point2    = new Point3D(0, maxVal, 0);
            arrowY.Diameter  = 0.1;
            arrowY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowY);

            arrowY           = new ArrowVisual3D();
            arrowY.Direction = new Vector3D(0, 1, 0);
            arrowY.Point1    = new Point3D(0, 0, 0);
            arrowY.Point2    = new Point3D(0, maxVal, 0);
            arrowY.Diameter  = 0.1;
            arrowY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowY);

            var arrowMY = new ArrowVisual3D();

            arrowMY.Direction = new Vector3D(0, -1, 0);
            arrowMY.Point1    = new Point3D(0, 0, 0);
            arrowMY.Point2    = new Point3D(0, -maxVal, 0);
            arrowMY.Diameter  = 0.1;
            arrowMY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMY);

            arrowMY           = new ArrowVisual3D();
            arrowMY.Direction = new Vector3D(0, -1, 0);
            arrowMY.Point1    = new Point3D(0, 0, 0);
            arrowMY.Point2    = new Point3D(0, -maxVal, 0);
            arrowMY.Diameter  = 0.1;
            arrowMY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMY);

            var arrowZ = new ArrowVisual3D();

            arrowZ.Direction = new Vector3D(0, 0, 1);
            arrowZ.Point1    = new Point3D(0, 0, 0);
            arrowZ.Point2    = new Point3D(0, 0, maxVal);
            arrowZ.Diameter  = 0.1;
            arrowZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowZ);

            arrowZ           = new ArrowVisual3D();
            arrowZ.Direction = new Vector3D(0, 0, 1);
            arrowZ.Point1    = new Point3D(0, 0, 0);
            arrowZ.Point2    = new Point3D(0, 0, maxVal);
            arrowZ.Diameter  = 0.1;
            arrowZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowZ);

            var arrowMZ = new ArrowVisual3D();

            arrowMZ.Direction = new Vector3D(0, 0, -1);
            arrowMZ.Point1    = new Point3D(0, 0, 0);
            arrowMZ.Point2    = new Point3D(0, 0, -maxVal);
            arrowMZ.Diameter  = 0.1;
            arrowMZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMZ);

            arrowMZ           = new ArrowVisual3D();
            arrowMZ.Direction = new Vector3D(0, 0, -1);
            arrowMZ.Point1    = new Point3D(0, 0, 0);
            arrowMZ.Point2    = new Point3D(0, 0, -maxVal);
            arrowMZ.Diameter  = 0.1;
            arrowMZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMZ);

            var xArrowText = new TextVisual3D();

            xArrowText.Text       = "X";
            xArrowText.Position   = new Point3D(maxVal - 0.5, 0, 0.5);
            xArrowText.Height     = 0.5;
            xArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(xArrowText);

            xArrowText            = new TextVisual3D();
            xArrowText.Text       = "X";
            xArrowText.Position   = new Point3D(maxVal - 0.5, 0, 0.5);
            xArrowText.Height     = 0.5;
            xArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(xArrowText);

            var yArrowText = new TextVisual3D();

            yArrowText.Text       = "Y";
            yArrowText.Position   = new Point3D(0, maxVal - 0.5, 0.5);
            yArrowText.Height     = 0.5;
            yArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(yArrowText);

            yArrowText            = new TextVisual3D();
            yArrowText.Text       = "Y";
            yArrowText.Position   = new Point3D(0, maxVal - 0.5, 0.5);
            yArrowText.Height     = 0.5;
            yArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(yArrowText);

            var zArrowText = new TextVisual3D();

            zArrowText.Text       = "Z";
            zArrowText.Position   = new Point3D(0.5, 0, maxVal - 0.5);
            zArrowText.Height     = 0.5;
            zArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(zArrowText);

            zArrowText            = new TextVisual3D();
            zArrowText.Text       = "Z";
            zArrowText.Position   = new Point3D(0.5, 0, maxVal - 0.5);
            zArrowText.Height     = 0.5;
            zArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(zArrowText);

            var leftText = new TextVisual3D();

            leftText.Text       = "Euler Angles Interpolation";
            leftText.Position   = new Point3D(0, 0, maxVal + 0.5);
            leftText.Height     = 1;
            leftText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(leftText);

            var rightText = new TextVisual3D();

            rightText.Text       = "Quaternion Interpolation";
            rightText.Position   = new Point3D(0, 0, maxVal + 0.5);
            rightText.Height     = 1;
            rightText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(rightText);

            SetupStartConfiguration();
            SetupEndConfiguration();

            frameEuler = new CombinedManipulator()
            {
                CanRotateX = false,
                CanRotateY = false,
                CanRotateZ = false
            };

            frameQuaternion = new CombinedManipulator()
            {
                CanRotateX = false,
                CanRotateY = false,
                CanRotateZ = false
            };
        }
Beispiel #10
0
        /// <summary>
        /// Called when show lights is changed.
        /// </summary>
        protected void OnShowLightsChanged()
        {
            this.lightsVisual.Children.Clear();
            if (this.ShowLights)
            {
                foreach (var light in this.lightGroup.Children)
                {
                    var pl = light as PointLight;
                    if (pl != null)
                    {
                        var sphere = new SphereVisual3D();
                        sphere.BeginEdit();
                        sphere.Center = pl.Position;
                        sphere.Radius = 1.0;
                        sphere.Fill = new SolidColorBrush(pl.Color);
                        sphere.EndEdit();
                        this.lightsVisual.Children.Add(sphere);
                    }

                    var dl = light as DirectionalLight;
                    if (dl != null)
                    {
                        var dir = dl.Direction;
                        dir.Normalize();

                        var target = new Point3D(0, 0, 0);
                        var source = target - (dir * 20);
                        var p2 = source + (dir * 10);

                        var sphere = new SphereVisual3D();
                        sphere.BeginEdit();
                        sphere.Center = source;
                        sphere.Radius = 1.0;
                        sphere.Fill = new SolidColorBrush(dl.Color);
                        sphere.EndEdit();
                        this.lightsVisual.Children.Add(sphere);

                        var arrow = new ArrowVisual3D();
                        arrow.BeginEdit();
                        arrow.Point1 = source;
                        arrow.Point2 = p2;
                        arrow.Diameter = 0.5;
                        arrow.Fill = new SolidColorBrush(dl.Color);
                        arrow.EndEdit();
                        this.lightsVisual.Children.Add(arrow);
                    }

                    var al = light as AmbientLight;
                    if (al != null)
                    {
                        var pos = new Point3D(0, 0, 20);
                        this.lightsVisual.Children.Add(
                            new CubeVisual3D { Center = pos, SideLength = 1.0, Fill = new SolidColorBrush(al.Color) });
                    }
                }
            }
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        /// <summary>Creates the plot elements.</summary>
        /// <remarks>Changes to the bounding box and other parameters will not take effect until this method is called.</remarks>
        public void CreateElements()
        {
            Children.Clear();
            Children.Add(new DefaultLights());

            string[] labels = AxisLabels.Split(',');
            if (labels.Length < 3)
            {
                labels = new string[] { "X", "Y", "Z" }
            }
            ;

            double bbSize        = Math.Max(Math.Max(BoundingBox.SizeX, BoundingBox.SizeY), BoundingBox.SizeZ);
            double lineThickness = bbSize / 1000;
            double arrowOffset   = lineThickness * 30;

            labelOffset        = lineThickness * 50;
            minDistanceSquared = MinDistance * MinDistance;

            if (Elements.HasFlag(EElements.Grid))
            {
                var grid = new GridLinesVisual3D();
                grid.Center        = new Point3D(BoundingBox.X + 0.5 * BoundingBox.SizeX, BoundingBox.Y + 0.5 * BoundingBox.SizeY, BoundingBox.Z);
                grid.Length        = BoundingBox.SizeX;
                grid.Width         = BoundingBox.SizeY;
                grid.MinorDistance = TickSize;
                grid.MajorDistance = bbSize;
                grid.Thickness     = lineThickness;
                grid.Fill          = AxisBrush;
                Children.Add(grid);
            }

            if (Elements.HasFlag(EElements.Axes))
            {
                var arrow = new ArrowVisual3D();
                arrow.Point2   = new Point3D((BoundingBox.X + BoundingBox.SizeX) + arrowOffset, 0.0, 0.0);
                arrow.Diameter = lineThickness * 5;
                arrow.Fill     = AxisBrush;
                Children.Add(arrow);

                var label = new BillboardTextVisual3D();
                label.Text       = labels[0];
                label.FontWeight = FontWeights.Bold;
                label.Foreground = AxisBrush;
                label.Position   = new Point3D((BoundingBox.X + BoundingBox.SizeX) + labelOffset, 0.0, 0.0);
                Children.Add(label);

                arrow          = new ArrowVisual3D();
                arrow.Point2   = new Point3D(0.0, (BoundingBox.Y + BoundingBox.SizeY) + arrowOffset, 0.0);
                arrow.Diameter = lineThickness * 5;
                arrow.Fill     = AxisBrush;
                Children.Add(arrow);

                label            = new BillboardTextVisual3D();
                label.Text       = labels[1];
                label.FontWeight = FontWeights.Bold;
                label.Foreground = AxisBrush;
                label.Position   = new Point3D(0.0, (BoundingBox.Y + BoundingBox.SizeY) + labelOffset, 0.0);
                Children.Add(label);

                if (BoundingBox.SizeZ > 0)
                {
                    arrow          = new ArrowVisual3D();
                    arrow.Point2   = new Point3D(0.0, 0.0, (BoundingBox.Z + BoundingBox.SizeZ) + arrowOffset);
                    arrow.Diameter = lineThickness * 5;
                    arrow.Fill     = AxisBrush;
                    Children.Add(arrow);

                    label            = new BillboardTextVisual3D();
                    label.Text       = labels[2];
                    label.FontWeight = FontWeights.Bold;
                    label.Foreground = AxisBrush;
                    label.Position   = new Point3D(0.0, 0.0, (BoundingBox.Z + BoundingBox.SizeZ) + labelOffset);
                    Children.Add(label);
                }
            }

            if (Elements.HasFlag(EElements.BoundingBox) && BoundingBox.SizeZ > 0)
            {
                var box = new BoundingBoxWireFrameVisual3D();
                box.BoundingBox = BoundingBox;
                box.Thickness   = 1;
                box.Color       = AxisBrush.Color;
                Children.Add(box);
            }

            if (Elements.HasFlag(EElements.Marker))
            {
                marker            = new TruncatedConeVisual3D();
                marker.Height     = labelOffset;
                marker.BaseRadius = 0.0;
                marker.TopRadius  = labelOffset / 5;
                marker.TopCap     = true;
                marker.Origin     = new Point3D(0.0, 0.0, 0.0);
                marker.Normal     = new Vector3D(-1.0, -1.0, 1.0);
                marker.Fill       = MarkerBrush;
                Children.Add(marker);

                coords            = new BillboardTextVisual3D();
                coordinateFormat  = string.Format("{{0:F6}}, {{1:F6}}, {{2:F6}}", DecimalPlaces, DecimalPlaces, DecimalPlaces); // "{0:F2}, {1:F2}, {2:F2}"
                coords.Text       = string.Format(coordinateFormat, 0.0, 0.0, 0.0);
                coords.Foreground = MarkerBrush;
                coords.Position   = new Point3D(-labelOffset, -labelOffset, labelOffset);
                Children.Add(coords);
            }
            else
            {
                marker = null;
                coords = null;
            }

            if (trace != null)
            {
                foreach (LinesVisual3D p in trace)
                {
                    Children.Add(p);
                }
                path = trace[trace.Count - 1];
            }
        }
Beispiel #13
0
            private ModelVisual3D CreateLightModels(IEnumerable <Model3D> lights)
            {
                var lightModelsVisual = new ModelVisual3D();

                var yellowEmissiveMaterial = new MaterialGroup();

                yellowEmissiveMaterial.Children.Add(new DiffuseMaterial(Brushes.Black));
                yellowEmissiveMaterial.Children.Add(new EmissiveMaterial(Brushes.Yellow));

                foreach (var light in lights.OfType <Light>())
                {
                    Visual3D lightVisual = null;

                    var pointLight = light as PointLight;

                    if (pointLight != null)
                    {
                        var pointLightSphere = new SphereVisual3D()
                        {
                            CenterPosition = pointLight.Position,
                            Radius         = 3,
                            Material       = yellowEmissiveMaterial
                        };

                        pointLight.Changed += delegate(object sender, EventArgs args)
                        {
                            pointLightSphere.CenterPosition = pointLight.Position;
                        };

                        lightVisual = pointLightSphere;
                    }
                    else
                    {
                        var spotLight = light as SpotLight;

                        if (spotLight != null)
                        {
                            var spotLightVector = spotLight.Direction;
                            spotLightVector.Normalize();

                            var spotLightArrow = new ArrowVisual3D()
                            {
                                StartPosition = spotLight.Position - spotLightVector * 20,
                                EndPosition   = spotLight.Position,
                                Radius        = 2,
                                Material      = yellowEmissiveMaterial
                            };

                            spotLight.Changed += delegate(object sender, EventArgs args)
                            {
                                var spotLightDirection = spotLight.Direction;
                                spotLightDirection.Normalize();

                                spotLightArrow.StartPosition = spotLight.Position;
                                spotLightArrow.EndPosition   = spotLight.Position + spotLightDirection * 20;
                            };

                            lightVisual = spotLightArrow;
                        }
                    }
                    // TODO: DirectionalLight is not supported (it could be rendered as PlaneVisual3D with additional ArrowVisual3Ds)

                    if (lightVisual != null)
                    {
                        lightModelsVisual.Children.Add(lightVisual);
                    }
                }

                return(lightModelsVisual);
            }
Beispiel #14
0
        public void MainSmirnov()
        {
            rnd = 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();

            rectangle = new BoxVisual3D
            {
                Height = 3,
                Width  = 3,
                Length = 6,
                Center = new Point3D(0, 0, 0),
            };
            MyHelix.Children.Add(rectangle);

            strelka1 = new ArrowVisual3D
            {
                HeadLength = 2,
                Diameter   = 1,
                Point1     = new Point3D(0, 0, 0),
                Point2     = new Point3D(0, 0, 4),
            };
            MyHelix.Children.Add(strelka1);

            strelka4 = new ArrowVisual3D
            {
                HeadLength = 2,
                Diameter   = 1,
                Point1     = new Point3D(0, 0, 0),
                Point2     = new Point3D(0, 0, -4),
            };
            MyHelix.Children.Add(strelka4);

            strelka2 = new ArrowVisual3D
            {
                HeadLength = 2,
                Diameter   = 1,
                Point1     = new Point3D(0, 0, 0),
                Point2     = new Point3D(0, -4, 0),
            };
            MyHelix.Children.Add(strelka2);

            strelka3 = new ArrowVisual3D
            {
                HeadLength = 2,
                Diameter   = 1,
                Point1     = new Point3D(0, 0, 0),
                Point2     = new Point3D(0, 4, 0),
            };
            MyHelix.Children.Add(strelka3);

            void TimerTick(object sender, EventArgs e)
            {
                color          = Color.FromRgb(0, (byte)rnd.Next(0, 255), (byte)rnd.Next(0, 255));;
                rectangle.Fill = new SolidColorBrush(color);
                strelka1.Fill  = new SolidColorBrush(color);
                strelka2.Fill  = new SolidColorBrush(color);
                strelka3.Fill  = new SolidColorBrush(color);
                strelka4.Fill  = new SolidColorBrush(color);
            }
        }
Beispiel #15
0
        private void InitializeScene()
        {
            linearInterpolator          = new LinearInterpolator();
            sphericalLinearInterpolator = new SphericalLinearInterpolator();
            realTimeInterpolator        = new RealTimeInterpolator();

            const double maxVal = 8;

            var arrowX = new ArrowVisual3D();

            arrowX.Direction = new Vector3D(1, 0, 0);
            arrowX.Point1    = new Point3D(0, 0, 0);
            arrowX.Point2    = new Point3D(maxVal, 0, 0);
            arrowX.Diameter  = 0.1;
            arrowX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowX);

            arrowX           = new ArrowVisual3D();
            arrowX.Direction = new Vector3D(1, 0, 0);
            arrowX.Point1    = new Point3D(0, 0, 0);
            arrowX.Point2    = new Point3D(maxVal, 0, 0);
            arrowX.Diameter  = 0.1;
            arrowX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowX);

            var arrowMX = new ArrowVisual3D();

            arrowMX.Direction = new Vector3D(-1, 0, 0);
            arrowMX.Point1    = new Point3D(0, 0, 0);
            arrowMX.Point2    = new Point3D(-maxVal, 0, 0);
            arrowMX.Diameter  = 0.1;
            arrowMX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMX);

            arrowMX           = new ArrowVisual3D();
            arrowMX.Direction = new Vector3D(-1, 0, 0);
            arrowMX.Point1    = new Point3D(0, 0, 0);
            arrowMX.Point2    = new Point3D(-maxVal, 0, 0);
            arrowMX.Diameter  = 0.1;
            arrowMX.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMX);

            var arrowY = new ArrowVisual3D();

            arrowY.Direction = new Vector3D(0, 0, 1);
            arrowY.Point1    = new Point3D(0, 0, 0);
            arrowY.Point2    = new Point3D(0, 0, maxVal);
            arrowY.Diameter  = 0.1;
            arrowY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowY);

            arrowY           = new ArrowVisual3D();
            arrowY.Direction = new Vector3D(0, 0, 1);
            arrowY.Point1    = new Point3D(0, 0, 0);
            arrowY.Point2    = new Point3D(0, 0, maxVal);
            arrowY.Diameter  = 0.1;
            arrowY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowY);

            var arrowMY = new ArrowVisual3D();

            arrowMY.Direction = new Vector3D(0, 0, -1);
            arrowMY.Point1    = new Point3D(0, 0, 0);
            arrowMY.Point2    = new Point3D(0, 0, -maxVal);
            arrowMY.Diameter  = 0.1;
            arrowMY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMY);

            arrowMY           = new ArrowVisual3D();
            arrowMY.Direction = new Vector3D(0, 0, -1);
            arrowMY.Point1    = new Point3D(0, 0, 0);
            arrowMY.Point2    = new Point3D(0, 0, -maxVal);
            arrowMY.Diameter  = 0.1;
            arrowMY.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMY);

            var arrowZ = new ArrowVisual3D();

            arrowZ.Direction = new Vector3D(0, 1, 0);
            arrowZ.Point1    = new Point3D(0, 0, 0);
            arrowZ.Point2    = new Point3D(0, maxVal, 0);
            arrowZ.Diameter  = 0.1;
            arrowZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowZ);

            arrowZ           = new ArrowVisual3D();
            arrowZ.Direction = new Vector3D(0, 1, 0);
            arrowZ.Point1    = new Point3D(0, 0, 0);
            arrowZ.Point2    = new Point3D(0, maxVal, 0);
            arrowZ.Diameter  = 0.1;
            arrowZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowZ);

            var arrowMZ = new ArrowVisual3D();

            arrowMZ.Direction = new Vector3D(0, -1, 0);
            arrowMZ.Point1    = new Point3D(0, 0, 0);
            arrowMZ.Point2    = new Point3D(0, -maxVal, 0);
            arrowMZ.Diameter  = 0.1;
            arrowMZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportLeft.Children.Add(arrowMZ);

            arrowMZ           = new ArrowVisual3D();
            arrowMZ.Direction = new Vector3D(0, 0, -1);
            arrowMZ.Point1    = new Point3D(0, 0, 0);
            arrowMZ.Point2    = new Point3D(0, -maxVal, 0);
            arrowMZ.Diameter  = 0.1;
            arrowMZ.Fill      = System.Windows.Media.Brushes.Black;
            HelixViewportRight.Children.Add(arrowMZ);

            var xArrowText = new TextVisual3D();

            xArrowText.Text       = "X";
            xArrowText.Position   = new Point3D(maxVal - 0.5, 0, 0.5);
            xArrowText.Height     = 0.5;
            xArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(xArrowText);

            xArrowText            = new TextVisual3D();
            xArrowText.Text       = "X";
            xArrowText.Position   = new Point3D(maxVal - 0.5, 0, 0.5);
            xArrowText.Height     = 0.5;
            xArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(xArrowText);

            var yArrowText = new TextVisual3D();

            yArrowText.Text       = "Z";
            yArrowText.Position   = new Point3D(0, 0.5, maxVal - 0.5);
            yArrowText.Height     = 0.5;
            yArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(yArrowText);

            yArrowText            = new TextVisual3D();
            yArrowText.Text       = "Z";
            yArrowText.Position   = new Point3D(0, 0.5, maxVal - 0.5);
            yArrowText.Height     = 0.5;
            yArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(yArrowText);

            var zArrowText = new TextVisual3D();

            zArrowText.Text       = "Y";
            zArrowText.Position   = new Point3D(0.5, maxVal - 0.5, 0);
            zArrowText.Height     = 0.5;
            zArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(zArrowText);

            zArrowText            = new TextVisual3D();
            zArrowText.Text       = "Y";
            zArrowText.Position   = new Point3D(0.5, maxVal - 0.5, 0);
            zArrowText.Height     = 0.5;
            zArrowText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(zArrowText);

            var leftText = new TextVisual3D();

            leftText.Text       = "Internal angles interpolation";
            leftText.Position   = new Point3D(0, 0, maxVal + 0.5);
            leftText.Height     = 1;
            leftText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportLeft.Children.Add(leftText);

            var rightText = new TextVisual3D();

            rightText.Text       = "Inverse chain";
            rightText.Position   = new Point3D(0, 0, maxVal + 0.5);
            rightText.Height     = 1;
            rightText.FontWeight = System.Windows.FontWeights.Bold;
            HelixViewportRight.Children.Add(rightText);


            var floor = new RectangleVisual3D
            {
                Fill   = new SolidColorBrush(Color.FromArgb(30, 0, 0, 0)),
                Normal = new Vector3D(0, 0, 1),
                Origin = new Point3D(0, 0, 0)
            };

            floor.Width           = floor.Length = 10;
            floor.LengthDirection = new Vector3D(1, 0, 0);

            HelixViewportLeft.Children.Add(floor);

            var wall = new RectangleVisual3D
            {
                Fill   = new SolidColorBrush(Color.FromArgb(30, 0, 0, 0)),
                Normal = new Vector3D(0, 0, 1),
                Origin = new Point3D(0, 0, 0)
            };

            wall.Width           = wall.Length = 10;
            wall.LengthDirection = new Vector3D(1, 0, 0);
            HelixViewportRight.Children.Add(wall);


            frameEuler = new CombinedManipulator()
            {
                CanRotateX = false,
                CanRotateY = false,
                CanRotateZ = false
            };

            frameQuaternion = new CombinedManipulator()
            {
                CanRotateX = false,
                CanRotateY = false,
                CanRotateZ = false
            };
        }