A visual element that shows an arrow.
Наследование: MeshElement3D
Пример #1
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)
                        });
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Called when the light changed.
        /// </summary>
        protected virtual void OnLightChanged()
        {
            this.Children.Clear();
            if (this.Light == null)
            {
                return;
            }

            var dl = this.Light as DirectionalLight;

            if (dl != null)
            {
                var    arrow    = new ArrowVisual3D();
                double distance = 10;
                double length   = 5;
                arrow.BeginEdit();
                arrow.Point1   = new Point3D() + dl.Direction * distance;
                arrow.Point2   = arrow.Point1 - dl.Direction * length;
                arrow.Diameter = 0.1 * length;
                arrow.Fill     = new SolidColorBrush(dl.Color);
                arrow.EndEdit();
                this.Children.Add(arrow);
            }

            var sl = this.Light as SpotLight;

            if (sl != null)
            {
                var sphere = new SphereVisual3D();
                sphere.BeginEdit();
                sphere.Center = sl.Position;
                sphere.Fill   = new SolidColorBrush(sl.Color);
                sphere.EndEdit();
                this.Children.Add(sphere);

                var arrow = new ArrowVisual3D();
                arrow.BeginEdit();
                arrow.Point1   = sl.Position;
                arrow.Point2   = sl.Position + sl.Direction;
                arrow.Diameter = 0.1;
                arrow.EndEdit();
                this.Children.Add(arrow);
            }

            var pl = this.Light as PointLight;

            if (pl != null)
            {
                var sphere = new SphereVisual3D();
                sphere.BeginEdit();
                sphere.Center = pl.Position;
                sphere.Fill   = new SolidColorBrush(pl.Color);
                sphere.EndEdit();
                this.Children.Add(sphere);
            }

            var al = this.Light as AmbientLight;
        }
Пример #3
0
        /// <summary>
        /// Called when the light changed.
        /// </summary>
        protected virtual void OnLightChanged()
        {
            this.Children.Clear();
            if (this.Light == null)
            {
                return;
            }

            var dl = this.Light as DirectionalLight;
            if (dl != null)
            {
                var arrow = new ArrowVisual3D();
                double distance = 10;
                double length = 5;
                arrow.BeginEdit();
                arrow.Point1 = new Point3D() + dl.Direction * distance;
                arrow.Point2 = arrow.Point1 - dl.Direction * length;
                arrow.Diameter = 0.1 * length;
                arrow.Fill = new SolidColorBrush(dl.Color);
                arrow.EndEdit();
                this.Children.Add(arrow);
            }

            var sl = this.Light as SpotLight;
            if (sl != null)
            {
                var sphere = new SphereVisual3D();
                sphere.BeginEdit();
                sphere.Center = sl.Position;
                sphere.Fill = new SolidColorBrush(sl.Color);
                sphere.EndEdit();
                this.Children.Add(sphere);

                var arrow = new ArrowVisual3D();
                arrow.BeginEdit();
                arrow.Point1 = sl.Position;
                arrow.Point2 = sl.Position + sl.Direction;
                arrow.Diameter = 0.1;
                arrow.EndEdit();
                this.Children.Add(arrow);
            }

            var pl = this.Light as PointLight;
            if (pl != null)
            {
                var sphere = new SphereVisual3D();
                sphere.BeginEdit();
                sphere.Center = pl.Position;
                sphere.Fill = new SolidColorBrush(pl.Color);
                sphere.EndEdit();
                this.Children.Add(sphere);
            }

            var al = this.Light as AmbientLight;
        }
        /// <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
            });
        }
Пример #5
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, 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 = "Internal Coordinates 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 = "Effector Position 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
            };
            robotForInternalCoordinates.SetMidFrameModel(frameEuler);

            frameQuaternion = new CombinedManipulator()
            {
                CanRotateX = false,
                CanRotateY = false,
                CanRotateZ = false
            };
        }
Пример #6
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 });
        }
Пример #7
0
        /// <summary>
        /// 3D scene initialization
        /// </summary>
        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;
            HelixViewport.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;
            HelixViewport.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;
            HelixViewport.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;
            HelixViewport.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;
            HelixViewport.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;
            HelixViewport.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;
            HelixViewport.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;
            HelixViewport.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;
            HelixViewport.Children.Add(zArrowText);

            gravityPlane = new RectangleVisual3D();
            gravityPlane.Width = 10;
            gravityPlane.Length = 10;
            var brush = new SolidColorBrush(Colors.Green);
            brush.Opacity = 0.5;
            gravityPlane.Fill = brush;
            HelixViewport.Children.Add(gravityPlane);

            gravityArrow = new ArrowVisual3D();
            gravityArrow.Direction = new Vector3D(0, 0, -1);
            gravityArrow.Point1 = new Point3D(0, 0, 0);
            gravityArrow.Point2 = new Point3D(0, 0, -3);
            gravityArrow.Diameter = 0.2;
            gravityArrow.Fill = Brushes.Green;
            HelixViewport.Children.Add(gravityArrow);

            diagonalArrow = new ArrowVisual3D();
            diagonalArrow.Direction = new Vector3D(1, 1, 1);
            diagonalArrow.Point1 = new Point3D(0, 0, 0);
            diagonalArrow.Point2 = new Point3D(cubeSize, cubeSize, cubeSize);
            diagonalArrow.Diameter = 0.1;
            diagonalArrow.Fill = Brushes.Blue;
            HelixViewport.Children.Add(diagonalArrow);

            SetupCube();
        }
        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()
        {
            _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);
        }
Пример #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) });
                    }
                }
            }
        }
        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);
        }