Пример #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
        /// <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 });
        }
Пример #6
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) });
                    }
                }
            }
        }