Exemple #1
0
        private Neuron[] BuildNeurons(Point3D[] positions)
        {
            Neuron[] retVal = new Neuron[positions.Length];

            for (int cntr = 0; cntr < positions.Length; cntr++)
            {
                // Material
                MaterialGroup   materials    = new MaterialGroup();
                DiffuseMaterial bodyMaterial = new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex(COLOR_ZERO)));
                materials.Children.Add(bodyMaterial);
                materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("C0C0C0")), 75d));

                // Geometry Model
                GeometryModel3D geometry = new GeometryModel3D();
                geometry.Material     = materials;
                geometry.BackMaterial = materials;
                geometry.Geometry     = UtilityWPF.GetSphere_LatLon(20, NODESIZE);

                Transform3DGroup transform = new Transform3DGroup();
                transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));
                transform.Children.Add(new TranslateTransform3D(positions[cntr].ToVector()));

                // Model Visual
                ModelVisual3D visual = new ModelVisual3D();
                visual.Content   = geometry;
                visual.Transform = transform;

                // Store it
                retVal[cntr] = new Neuron(positions[cntr], visual, bodyMaterial);
                _viewport.Children.Add(visual);
            }

            return(retVal);
        }
Exemple #2
0
        private static MaterialGroup GetSparklyMaterial()
        {
            MaterialGroup retVal = new MaterialGroup();

            retVal.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("C0FF6060"))));
            retVal.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("80FFFFFF")), 3));
            retVal.Children.Add(new EmissiveMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("40004000"))));

            return(retVal);
        }
Exemple #3
0
        private static System.Windows.Media.Media3D.Material GetModel_Rod_Composite_Material(MaterialDefinition definition)
        {
            MaterialGroup retVal = new MaterialGroup();

            Color color1 = UtilityWPF.ColorFromHex(definition.DiffuseColor);

            retVal.Children.Add(new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(color1.R, color1.G, color1.B))));     // making sure there is no semitransparency
            retVal.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("80808080")), 50));

            return(retVal);
        }
Exemple #4
0
 private void WhiteLight_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         directionalBright.Color = UtilityWPF.ColorFromHex("FFFFFF");
         directionDim.Color      = UtilityWPF.ColorFromHex("707070");
         ambient.Color           = UtilityWPF.ColorFromHex("787878");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Exemple #5
0
        /// <summary>
        /// Creates or adds to a set of colors to be used by composite weapons
        /// </summary>
        /// <param name="existing">This is a material definition that may already exist, or partially filled out</param>
        /// <param name="basedOn">This is a way to force the return hue (a spike ball's colors could be based on the handle's colors)</param>
        public static MaterialDefinition[] GetRandomMaterials_Composite(MaterialDefinition[] existing = null, ColorHSV?basedOn = null)
        {
            List <MaterialDefinition> retVal = new List <MaterialDefinition>();

            Random rand = StaticRandom.GetRandomForThread();

            if (existing != null)
            {
                retVal.AddRange(existing);
            }

            if (retVal.Count < 1)
            {
                if (basedOn == null)
                {
                    // For the first one, just pick any random color
                    retVal.Add(new MaterialDefinition()
                    {
                        DiffuseColor = UtilityWPF.GetRandomColor(0, 255).ToHex()
                    });
                }
                else
                {
                    // Make this based on the hue of the color passed in
                    retVal.Add(new MaterialDefinition()
                    {
                        DiffuseColor = UtilityWPF.HSVtoRGB(GetRandomHue(basedOn.Value.H), rand.NextDouble(100), rand.NextDouble(100)).ToHex()
                    });
                }
            }

            ColorHSV first = UtilityWPF.ColorFromHex(retVal[0].DiffuseColor).ToHSV();

            if (retVal.Count < 2)
            {
                retVal.Add(new MaterialDefinition()
                {
                    DiffuseColor = UtilityWPF.HSVtoRGB(GetRandomHue(first.H), rand.NextDouble(100), rand.NextDouble(100)).ToHex()
                });
            }

            if (retVal.Count < 3)
            {
                retVal.Add(new MaterialDefinition()
                {
                    DiffuseColor = UtilityWPF.HSVtoRGB(GetRandomHue(first.H), rand.NextDouble(100), rand.NextDouble(100)).ToHex()
                });
            }

            return(retVal.ToArray());
        }
Exemple #6
0
        private static BitmapSource DrawStrokes(IEnumerable <EncogOCR_StrokeDefinition> strokes, int width, int height, double origWidth, double origHeight)
        {
            //NOTE: InkCanvas draws lines smoother than this method.  This is a crude way to approximate the thickness/darkeness of the lines
            double scale  = Math1D.Avg(width, height) / Math1D.Avg(origWidth, origHeight);
            double reduce = 1;

            if (scale < .2)
            {
                reduce = UtilityCore.GetScaledValue(.8, 1, .05, .2, scale);
            }

            RenderTargetBitmap retVal = new RenderTargetBitmap(width, height, UtilityWPF.DPI, UtilityWPF.DPI, PixelFormats.Pbgra32);

            DrawingVisual dv = new DrawingVisual();

            using (DrawingContext ctx = dv.RenderOpen())
            {
                foreach (EncogOCR_StrokeDefinition stroke in strokes)
                {
                    SolidColorBrush brush = new SolidColorBrush(UtilityWPF.ColorFromHex(stroke.Color));

                    if (stroke.Points.Length == 1)
                    {
                        // Single Point
                        double radius = stroke.Thickness / 2d;
                        radius *= reduce;
                        ctx.DrawEllipse(brush, null, stroke.Points[0], radius, radius);
                    }
                    else
                    {
                        // Multiple Points
                        Pen pen = new Pen(brush, stroke.Thickness * reduce)
                        {
                            StartLineCap = PenLineCap.Round,
                            EndLineCap   = PenLineCap.Round,
                        };

                        for (int cntr = 0; cntr < stroke.Points.Length - 1; cntr++)
                        {
                            ctx.DrawLine(pen, stroke.Points[cntr], stroke.Points[cntr + 1]);
                        }
                    }
                }
            }

            dv.Transform = new ScaleTransform(width / origWidth, height / origHeight);

            retVal.Render(dv);

            return(retVal);
        }
Exemple #7
0
        /// <summary>
        /// Creates or adds to a set of colors to be used by klinth weapons
        /// </summary>
        /// <param name="existing">This is a material definition that may already exist, or partially filled out</param>
        /// <param name="basedOn">This is a way to force the return hue (a spike ball's colors could be based on the handle's colors)</param>
        public static MaterialDefinition[] GetRandomMaterials_Klinth(MaterialDefinition[] existing = null, ColorHSV?basedOn = null)
        {
            List <MaterialDefinition> retVal = new List <MaterialDefinition>();

            Random rand = StaticRandom.GetRandomForThread();

            if (existing != null)
            {
                retVal.AddRange(existing);
            }

            // Main color (in the case of a handle, the only color)
            if (retVal.Count < 1)
            {
                double hue;
                if (basedOn == null)
                {
                    hue = StaticRandom.NextDouble(0, 360);
                }
                else
                {
                    //hue = GetRandomHue(basedOn.Value.H);
                    hue = basedOn.Value.H;      // klinth shouldn't allow an opposite hue (it looks really bad)
                }

                retVal.Add(new MaterialDefinition()
                {
                    DiffuseColor  = UtilityWPF.HSVtoRGB(hue, StaticRandom.NextDouble(50, 80), StaticRandom.NextDouble(40, 90)).ToHex(),
                    SpecularColor = UtilityWPF.HSVtoRGB(StaticRandom.NextDouble(0, 360), StaticRandom.NextDouble(50, 80), StaticRandom.NextDouble(40, 90)).ToHex(),
                    EmissiveColor = UtilityWPF.GetRandomColor(0, 255).ToHex()
                });
            }

            // Secondary color (in the case of ball and spikes, this is the spikes)
            if (retVal.Count < 2)
            {
                ColorHSV firstDiff = UtilityWPF.ColorFromHex(retVal[0].DiffuseColor).ToHSV();
                ColorHSV firstSpec = UtilityWPF.ColorFromHex(retVal[0].SpecularColor).ToHSV();
                ColorHSV firstEmis = UtilityWPF.ColorFromHex(retVal[0].EmissiveColor).ToHSV();

                // Needs to be roughly the same color as the ball, just a bit darker
                retVal.Add(new MaterialDefinition()
                {
                    DiffuseColor  = UtilityWPF.HSVtoRGB(firstDiff.H, firstDiff.S * 1.25, firstDiff.V * .66d).ToHex(),
                    SpecularColor = UtilityWPF.HSVtoRGB(firstSpec.H, firstSpec.S * 1.1, firstSpec.V).ToHex(),
                    EmissiveColor = UtilityWPF.HSVtoRGB(firstEmis.H, firstEmis.S, firstEmis.V).ToHex(),
                });
            }

            return(retVal.ToArray());
        }
Exemple #8
0
        private Visual3D[] GetStrokeVisual(Tuple <Point3D, Vector3D>[] points)
        {
            Model3DGroup models = new Model3DGroup();

            MaterialGroup materials = new MaterialGroup();

            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("EEE"))));
            materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("FFF")), 4));

            ScreenSpaceLines3D lines = new ScreenSpaceLines3D();

            lines.Color     = UtilityWPF.ColorFromHex("EEE");
            lines.Thickness = 2;

            for (int cntr = 0; cntr < points.Length - 1; cntr++)
            {
                #region velocity line

                Point3D secondPoint = points[cntr].Item1;
                if (points[cntr].Item2.IsNearZero())
                {
                    secondPoint += Math3D.GetRandomVector_Spherical(.02);
                }
                else
                {
                    secondPoint += points[cntr].Item2 * .75;
                }

                lines.AddLine(points[cntr].Item1, secondPoint);

                #endregion
                #region dot

                GeometryModel3D geometry = new GeometryModel3D();
                geometry.Material     = materials;
                geometry.BackMaterial = materials;
                geometry.Geometry     = UtilityWPF.GetSphere_Ico(.15, 1, true);

                geometry.Transform = new TranslateTransform3D(points[cntr].Item1.ToVector());

                models.Children.Add(geometry);

                #endregion
            }

            ModelVisual3D dotVisual = new ModelVisual3D();
            dotVisual.Content = models;

            return(new Visual3D[] { lines, dotVisual });
        }
Exemple #9
0
        private static Model3D GetModel_Shop(out BotShellColorsDNA backdropColors, double radius)
        {
            Model3DGroup retVal = new Model3DGroup();

            backdropColors = new BotShellColorsDNA();
            backdropColors.DiffuseDrift  = 0;
            backdropColors.EmissiveColor = "00000000";

            #region Plate

            backdropColors.InnerColorDiffuse = "554A3A";

            // Material
            MaterialGroup material = new MaterialGroup();
            material.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex(backdropColors.InnerColorDiffuse))));
            material.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("40958265")), 20d));

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();
            geometry.Material     = material;
            geometry.BackMaterial = material;

            geometry.Geometry = UtilityWPF.GetSphere_LatLon(6, radius, radius, radius * .1);

            retVal.Children.Add(geometry);

            #endregion

            #region Gold Mineral

            // Get gold's color
            backdropColors.Light = Mineral.GetSettingsForMineralType(MineralType.Gold).DiffuseColor.ToHex();

            // Get the model of a gold mineral
            Model3D model = Mineral.GetNewVisual(MineralType.Gold);

            // Figure out the scale
            Rect3D aabb     = model.Bounds;
            double halfSize = Math1D.Max(aabb.SizeX, aabb.SizeY, aabb.SizeZ) / 2d;

            double scale = (radius * .66d) / halfSize;
            model.Transform = new ScaleTransform3D(scale, scale, scale);

            retVal.Children.Add(model);

            #endregion

            return(retVal);
        }
Exemple #10
0
        private Tuple <BillboardLine3D, Visual3D> GetChaseBallVisual_Orientation()
        {
            BillboardLine3D line = new BillboardLine3D()
            {
                Color             = UtilityWPF.ColorFromHex("C03000"),
                IsReflectiveColor = false,
                Thickness         = .2,
            };

            ModelVisual3D visual = new ModelVisual3D();

            visual.Content = line.Model;

            return(new Tuple <BillboardLine3D, Visual3D>(line, visual));
        }
Exemple #11
0
        private static Color GetWeightedColor(double weight)
        {
            Color zero = UtilityWPF.ColorFromHex(COLOR_ZERO);

            if (weight > 0d)
            {
                Color positive = UtilityWPF.ColorFromHex(COLOR_POSITIVE);
                return(UtilityWPF.AlphaBlend(positive, zero, weight));
            }
            else
            {
                Color negative = UtilityWPF.ColorFromHex(COLOR_NEGATIVE);
                return(UtilityWPF.AlphaBlend(negative, zero, Math.Abs(weight)));
            }
        }
Exemple #12
0
        private void CreateVisual()
        {
            _modelGroup = new Model3DGroup();

            #region Light

            Color lightColor = UtilityWPF.ColorFromHex("FF0000");
            _light = new PointLight(lightColor, new Point3D(0, 0, 0));
            UtilityWPF.SetAttenuation(_light, _bot.Radius * .01, .1d);

            _modelGroup.Children.Add(_light);

            #endregion

            ////TODO: Don't just make one graphic.  Make sprites, a light - maybe like a fountain
            //DiffuseMaterial material = new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("40808080")));

            //GeometryModel3D geometry = new GeometryModel3D();
            //geometry.Material = material;
            //geometry.BackMaterial = material;
            ////geometry.Geometry = UtilityWPF.GetSphere(2, 1);
            //geometry.Geometry = UtilityWPF.GetCylinder_AlongX(10, 1, .75);

            _scale = new ScaleTransform3D(1, 1, 1);
            //geometry.Transform = _scale;

            //_modelGroup.Children.Add(geometry);

            Transform3DGroup transform = new Transform3DGroup();

            _rotate = new QuaternionRotation3D(Quaternion.Identity);
            transform.Children.Add(new RotateTransform3D(_rotate));

            _translate = new TranslateTransform3D(0, 0, 0);
            transform.Children.Add(_translate);

            _modelGroup.Transform = transform;

            // Visual
            _visual = new ModelVisual3D()
            {
                Content = _modelGroup
            };

            _bot.PhysicsBody.BodyMoved += PhysicsBody_BodyMoved;
        }
Exemple #13
0
        public CompositeFilter(ConvolutionSet2D set = null, bool isEditor = true)
        {
            InitializeComponent();

            // Selected effect
            _selectEffect = new DropShadowEffect()
            {
                Direction   = 0,
                ShadowDepth = 0,
                BlurRadius  = 40,
                Color       = UtilityWPF.ColorFromHex("FFEB85"),
                Opacity     = 1,
            };

            // Context Menu
            _kernelContextMenu = (ContextMenu)this.Resources["kernelContextMenu"];

            // Combobox
            foreach (SetOperationType operation in Enum.GetValues(typeof(SetOperationType)))
            {
                cboPostOperation.Items.Add(operation);
            }
            cboPostOperation.SelectedIndex = 0;

            // Load set passed in
            if (set != null)
            {
                foreach (var child in set.Convolutions)
                {
                    InsertKernel(child);
                }

                cboPostOperation.SelectedValue = set.OperationType;

                lblInstructions.Visibility = Visibility.Collapsed;

                if (!isEditor)
                {
                    btnSave.Visibility = Visibility.Collapsed;
                }
            }

            _initialized = true;

            RefreshStatsPanel();
        }
Exemple #14
0
        public static Material GetMaterial(bool isShiny, Color color)
        {
            // This was copied from BillboardLine3D (then modified a bit)

            if (isShiny)
            {
                MaterialGroup retVal = new MaterialGroup();
                retVal.Children.Add(new DiffuseMaterial(new SolidColorBrush(color)));
                retVal.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("40989898")), 2));

                return(retVal);
            }
            else
            {
                return(UtilityWPF.GetUnlitMaterial(color));
            }
        }
Exemple #15
0
        public FlagGeneratorWindow()
        {
            InitializeComponent();

            this.Background = SystemColors.ControlBrush;

            _selectEffect = new DropShadowEffect()
            {
                Direction   = 0,
                ShadowDepth = 0,
                BlurRadius  = 14,
                Color       = UtilityWPF.ColorFromHex("0086E2"),
                Opacity     = .8,
            };

            _initialized = true;
        }
Exemple #16
0
        private ScreenSpaceLines3D BuildLinksSprtLine(Point3D from, Point3D to, double weight)
        {
            ScreenSpaceLines3D retVal = new ScreenSpaceLines3D();

            if (weight > 0)
            {
                retVal.Color = UtilityWPF.ColorFromHex(COLOR_POSITIVE);
            }
            else
            {
                retVal.Color = UtilityWPF.ColorFromHex(COLOR_NEGATIVE);
            }
            retVal.Thickness = Math.Abs(weight) * 2d;
            retVal.AddLine(from, to);

            return(retVal);
        }
Exemple #17
0
        public ImageFilters()
        {
            InitializeComponent();

            // Selected effect
            _selectEffect = new DropShadowEffect()
            {
                Direction   = 0,
                ShadowDepth = 0,
                BlurRadius  = 40,
                Color       = UtilityWPF.ColorFromHex("FFEB85"),
                Opacity     = 1,
            };

            // Context Menu
            _kernelContextMenu = (ContextMenu)this.Resources["kernelContextMenu"];

            // NegPos coloring
            foreach (ConvolutionResultNegPosColoring coloring in Enum.GetValues(typeof(ConvolutionResultNegPosColoring)))
            {
                cboEdgeColors.Items.Add(coloring);
            }
            cboEdgeColors.SelectedIndex = 0;

            // Source Image
            originalImage.Source = DownloadImage(GetImageURL());

            // Kernels
            AddDefaultKernels_Gaussian();
            AddDefaultKernels_Edges_Small();
            AddDefaultKernels_Composite();
            AddRandomKernels(2, false);
            AddRandomKernels(2, true);

            // Timer
            _refreshTimer = new DispatcherTimer()
            {
                Interval  = TimeSpan.FromMilliseconds(50),
                IsEnabled = false,
            };

            _refreshTimer.Tick += RefreshTimer_Tick;

            _initialized = true;
        }
Exemple #18
0
        //TODO: Make this a ThreadLocal
        private Model3D GetModel(Color?color = null)
        {
            var ball = UtilityWPF.GetTruncatedIcosidodecahedron(1, null);

            Model3DGroup retVal = new Model3DGroup();

            // Black
            MaterialGroup materials = new MaterialGroup();

            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("141414"))));
            materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("08FF0000")), 20));

            GeometryModel3D geometry = new GeometryModel3D();

            geometry.Material     = materials;
            geometry.BackMaterial = materials;

            geometry.Geometry = UtilityWPF.GetMeshFromTriangles(UtilityCore.Iterate(ball.Hexagons, ball.Squares).SelectMany(o => o));

            retVal.Children.Add(geometry);

            // White
            materials = new MaterialGroup();
            if (color == null)
            {
                materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("F8F8F8"))));
                //materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("222"))));
                //materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(Colors.Chartreuse)));
            }
            else
            {
                materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(color.Value)));
            }
            materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("A0FF0000")), 30));

            geometry              = new GeometryModel3D();
            geometry.Material     = materials;
            geometry.BackMaterial = materials;

            geometry.Geometry = UtilityWPF.GetMeshFromTriangles_IndependentFaces(ball.Decagons.SelectMany(o => o));

            retVal.Children.Add(geometry);

            return(retVal);
        }
Exemple #19
0
        public void SetWPFStuff(FrameworkElement mouseSource, Canvas canvas)
        {
            _isPlayerRam = true;

            _mouseSource = mouseSource;

#if SHOWMOUSE
            _canvas = canvas;

            _orthBrush = new SolidColorBrush(UtilityWPF.ColorFromHex("50808080"));

            _lines = new List <Line[]>();
#endif

            FinishSettingUp();

            _mouseSource.MouseMove += MouseSource_MouseMove;
        }
Exemple #20
0
        private Neuron[] BuildIO(Point3D[] positions, bool isInput)
        {
            Neuron[] retVal = new Neuron[positions.Length];

            for (int cntr = 0; cntr < positions.Length; cntr++)
            {
                // Material
                MaterialGroup   materials    = new MaterialGroup();
                DiffuseMaterial bodyMaterial = new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex(COLOR_ZERO)));
                materials.Children.Add(bodyMaterial);
                materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("C0C0C0")), 75d));

                // Geometry Model
                GeometryModel3D geometry = new GeometryModel3D();
                geometry.Material     = materials;
                geometry.BackMaterial = materials;

                if (isInput)
                {
                    geometry.Geometry = UtilityWPF.GetCone_AlongX(20, NODESIZE, NODESIZE);
                }
                else
                {
                    double halfSize = NODESIZE / 2d;
                    geometry.Geometry = UtilityWPF.GetCube_IndependentFaces(new Point3D(-halfSize, -halfSize, -halfSize), new Point3D(halfSize, halfSize, halfSize));
                }

                Transform3DGroup transform = new Transform3DGroup();
                transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));
                transform.Children.Add(new TranslateTransform3D(positions[cntr].ToVector()));

                // Model Visual
                ModelVisual3D visual = new ModelVisual3D();
                visual.Content   = geometry;
                visual.Transform = transform;

                // Store it
                retVal[cntr] = new Neuron(positions[cntr], visual, bodyMaterial);
                _viewport.Children.Add(visual);
            }

            return(retVal);
        }
Exemple #21
0
        private void ShowHideBlockedCells()
        {
            _isBlockedCellDirty = false;

            // Wipe out the old one
            if (_blockedCellsWireframe != null)
            {
                _viewport.Children.Remove(_blockedCellsWireframe);
                _blockedCellsWireframe = null;
            }

            // See if a new one needs to be created
            if (!chkShowBlockedCells.IsChecked.Value || _field == null)
            {
                return;
            }

            int[] blockedCellIndices = Enumerable.Range(0, _field.Size1D).Where(o => _field.Blocked[o]).ToArray();
            if (blockedCellIndices.Length == 0)
            {
                return;
            }

            Rectangle3DIndexedMapped[] cells = _field.GetCells(_sizeMult * _field.Size);

            // Get a deduped list of blocked cell's edge lines
            var lines = Rectangle3DIndexed.GetEdgeLinesDeduped(blockedCellIndices.Select(o => cells[o]));

            // Create the visual
            _blockedCellsWireframe           = new ScreenSpaceLines3D();
            _blockedCellsWireframe.Color     = UtilityWPF.ColorFromHex("60FFFFFF");
            _blockedCellsWireframe.Thickness = 1;

            Point3D[] allPoints = cells[0].AllPoints;

            foreach (var line in lines)
            {
                _blockedCellsWireframe.AddLine(allPoints[line.Item1], allPoints[line.Item2]);
            }

            _viewport.Children.Add(_blockedCellsWireframe);
        }
Exemple #22
0
        private static Tuple <DrawingVisual, SolidColorBrush> CreateEllipse(double size)
        {
            DrawingVisual retVal = new DrawingVisual();

            DrawingContext context = retVal.RenderOpen();

            double half = size / 2d;

            SolidColorBrush brush = new SolidColorBrush(UtilityWPF.ColorFromHex("80FFFFFF"));

            context.DrawEllipse(
                brush,
                new Pen(new SolidColorBrush(UtilityWPF.ColorFromHex("80000000")), 1),
                new Point(0, 0), half, half);

            // Persist the drawing content.
            context.Close();

            return(Tuple.Create(retVal, brush));
        }
Exemple #23
0
        private Visual3D GetChaseBallVisual_Position()
        {
            // Material
            MaterialGroup materials = new MaterialGroup();

            materials.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("C03000"))));
            materials.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("A0E8BF43")), 10));

            // Geometry Model
            GeometryModel3D geometry = new GeometryModel3D();

            geometry.Material     = materials;
            geometry.BackMaterial = materials;
            geometry.Geometry     = UtilityWPF.GetSphere_Ico(1, 2, true);

            // Model Visual
            ModelVisual3D retVal = new ModelVisual3D();

            retVal.Content = geometry;

            return(retVal);
        }
Exemple #24
0
        private void radLight_Checked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!_isInitialized)
                {
                    return;
                }

                _lightContainer.Children.Clear();

                if (radLightStandard.IsChecked.Value)
                {
                    _lightContainer.Children.Add(new DirectionalLight(Colors.White, new Vector3D(1, -1, -1)));
                    _lightContainer.Children.Add(new DirectionalLight(UtilityWPF.ColorFromHex("#303030"), new Vector3D(-1, 1, 1)));
                    _lightContainer.Children.Add(new AmbientLight(Colors.DimGray));
                }
                else if (radLightColored.IsChecked.Value)
                {
                    _lightContainer.Children.Add(new SpotLight(Colors.Green, new Point3D(3, 0, 0), new Vector3D(-1, 0, 0), 120, 90));
                    _lightContainer.Children.Add(new SpotLight(Colors.Orange, new Point3D(-3, 0, 0), new Vector3D(1, 0, 0), 120, 90));

                    _lightContainer.Children.Add(new SpotLight(Colors.Blue, new Point3D(0, 3, 0), new Vector3D(0, -1, 0), 120, 90));
                    _lightContainer.Children.Add(new SpotLight(Colors.Red, new Point3D(0, -3, 0), new Vector3D(0, 1, 0), 120, 90));

                    _lightContainer.Children.Add(new SpotLight(Colors.Purple, new Point3D(0, 0, 3), new Vector3D(0, 0, -1), 120, 90));
                    _lightContainer.Children.Add(new SpotLight(Colors.Yellow, new Point3D(0, 0, -3), new Vector3D(0, 0, 1), 120, 90));
                }
                else
                {
                    throw new ApplicationException("Unknown light type");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #25
0
        private Visual3D GetStrokeVisual_PATH(Tuple <Point3D, Vector3D>[] points)
        {
            //TODO: Draw the first points larger, then taper off.  May want a bezier with the velocities as control points

            ScreenSpaceLines3D retVal = new ScreenSpaceLines3D();

            retVal.Color     = UtilityWPF.ColorFromHex("CCC");
            retVal.Thickness = 2;

            if (points.Length == 1)
            {
                #region single point

                Point3D secondPoint = points[0].Item1;
                if (points[0].Item2.IsNearZero())
                {
                    secondPoint += Math3D.GetRandomVector_Spherical(.02);
                }
                else
                {
                    secondPoint += points[0].Item2;
                }

                retVal.AddLine(points[0].Item1, secondPoint);

                #endregion
            }
            else
            {
                for (int cntr = 0; cntr < points.Length - 1; cntr++)
                {
                    retVal.AddLine(points[cntr].Item1, points[cntr + 1].Item1);
                }
            }

            return(retVal);
        }
Exemple #26
0
            public NetworkOutputs(string[] names)
            {
                this.Size  = names.Length;
                this.Names = names;

                this.DistanceMult = 1.5d / Math.Sqrt(this.Size);        // the 1.5 doesn't mean anything.  It just helps push them apart a little more

                this.Hues = CreateHues(this.Size);

                #region Materials

                SpecularMaterial specular = new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("50FFFFFF")), 2);

                // Colors
                this.DotColors = this.Hues.Select(o =>
                {
                    ColorHSV color = new ColorHSV(o, 75, 75);

                    MaterialGroup material = new MaterialGroup();
                    material.Children.Add(new DiffuseMaterial(new SolidColorBrush(color.ToRGB())));
                    material.Children.Add(specular);

                    return(new Tuple <ColorHSV, Material>(color, material));
                }).ToArray();

                // Gray
                this.ColorGray = new ColorHSV(0, 0, 50);

                MaterialGroup material_Gray = new MaterialGroup();
                material_Gray.Children.Add(new DiffuseMaterial(new SolidColorBrush(this.ColorGray.ToRGB())));
                material_Gray.Children.Add(specular);

                this.DotGray = material_Gray;

                #endregion
            }
Exemple #27
0
        private Visual3D[] GetStrokeVisual_VELOCITIES(Tuple <Point3D, Vector3D>[] points)
        {
            ScreenSpaceLines3D retVal = new ScreenSpaceLines3D();

            retVal.Color     = UtilityWPF.ColorFromHex("EEE");
            retVal.Thickness = 2;

            for (int cntr = 0; cntr < points.Length - 1; cntr++)
            {
                Point3D secondPoint = points[cntr].Item1;
                if (points[cntr].Item2.IsNearZero())
                {
                    secondPoint += Math3D.GetRandomVector_Spherical(.02);
                }
                else
                {
                    secondPoint += points[cntr].Item2;
                }

                retVal.AddLine(points[cntr].Item1, secondPoint);
            }

            return(new Visual3D[] { retVal });
        }
Exemple #28
0
        private Model3D GetModel()
        {
            const double SIZE = 4;

            Model3DGroup    retVal = new Model3DGroup();
            GeometryModel3D geometry;
            MaterialGroup   material;

            var rhomb = UtilityWPF.GetRhombicuboctahedron(SIZE, SIZE, SIZE);

            TriangleIndexed[] triangles;

            #region X,Y,Z spikes

            double thickness = .2;
            double length    = SIZE * 1.5;

            retVal.Children.Add(new BillboardLine3D()
            {
                Color             = UtilityWPF.ColorFromHex("80" + ChaseColors.X),
                IsReflectiveColor = false,
                Thickness         = thickness,
                FromPoint         = new Point3D(0, 0, 0),
                ToPoint           = new Point3D(length, 0, 0)
            }.Model);

            retVal.Children.Add(new BillboardLine3D()
            {
                Color             = UtilityWPF.ColorFromHex("80" + ChaseColors.Y),
                IsReflectiveColor = false,
                Thickness         = thickness,
                FromPoint         = new Point3D(0, 0, 0),
                ToPoint           = new Point3D(0, length, 0)
            }.Model);

            retVal.Children.Add(new BillboardLine3D()
            {
                Color             = UtilityWPF.ColorFromHex("80" + ChaseColors.Z),
                IsReflectiveColor = false,
                Thickness         = thickness,
                FromPoint         = new Point3D(0, 0, 0),
                ToPoint           = new Point3D(0, 0, length)
            }.Model);

            #endregion

            #region X plates

            geometry = new GeometryModel3D();

            material = new MaterialGroup();
            material.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("80" + ChaseColors.X))));
            material.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("70DCE01D")), 5));

            geometry.Material     = material;
            geometry.BackMaterial = material;

            triangles = rhomb.Squares_Orth.
                        SelectMany(o => o).
                        Where(o => o.IndexArray.All(p => Math1D.IsNearValue(Math.Abs(o.AllPoints[p].X * 2), SIZE))).
                        ToArray();

            geometry.Geometry = UtilityWPF.GetMeshFromTriangles_IndependentFaces(triangles);

            retVal.Children.Add(geometry);

            #endregion
            #region Y plates

            geometry = new GeometryModel3D();

            material = new MaterialGroup();
            material.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("80" + ChaseColors.Y))));
            material.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("702892BF")), 3));

            geometry.Material     = material;
            geometry.BackMaterial = material;

            triangles = rhomb.Squares_Orth.
                        SelectMany(o => o).
                        Where(o => o.IndexArray.All(p => Math1D.IsNearValue(Math.Abs(o.AllPoints[p].Y * 2), SIZE))).
                        ToArray();

            geometry.Geometry = UtilityWPF.GetMeshFromTriangles_IndependentFaces(triangles);

            retVal.Children.Add(geometry);

            #endregion
            #region Z plates

            geometry = new GeometryModel3D();

            material = new MaterialGroup();
            material.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("80" + ChaseColors.Z))));
            material.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("B0CF1919")), 17));

            geometry.Material     = material;
            geometry.BackMaterial = material;

            triangles = rhomb.Squares_Orth.
                        SelectMany(o => o).
                        Where(o => o.IndexArray.All(p => Math1D.IsNearValue(Math.Abs(o.AllPoints[p].Z * 2), SIZE))).
                        ToArray();

            geometry.Geometry = UtilityWPF.GetMeshFromTriangles_IndependentFaces(triangles);

            retVal.Children.Add(geometry);

            #endregion
            #region Base

            geometry = new GeometryModel3D();

            material = new MaterialGroup();
            material.Children.Add(new DiffuseMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("305B687A"))));
            material.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("507E827A")), 12));

            geometry.Material     = material;
            geometry.BackMaterial = material;

            triangles = UtilityCore.Iterate(
                rhomb.Squares_Diag.SelectMany(o => o),
                rhomb.Triangles
                ).ToArray();

            geometry.Geometry = UtilityWPF.GetMeshFromTriangles_IndependentFaces(triangles);

            retVal.Children.Add(geometry);

            #endregion

            return(retVal);
        }
Exemple #29
0
        internal static Model3DGroup CreateGeometry(List <MaterialColorProps> materialBrushes, List <EmissiveMaterial> selectionEmissives, Transform3D transform, Color cameraBase, SpecularMaterial cameraBaseSpecular, Color cameraLensColor, SpecularMaterial cameraLensSpecular, bool isFinal)
        {
            ScaleTransform3D scaleTransformLocal = new ScaleTransform3D(SCALE, SCALE, SCALE);

            int domeSegments     = isFinal ? 2 : 10;
            int cylinderSegments = isFinal ? 6 : 35;

            Model3DGroup retVal = new Model3DGroup();

            GeometryModel3D  geometry;
            MaterialGroup    material;
            DiffuseMaterial  diffuse;
            SpecularMaterial specular;

            Transform3DGroup transformGroup = new Transform3DGroup();

            transformGroup.Children.Add(new TranslateTransform3D(CameraDirection * ((HEIGHT / 2d) - .15d)));
            transformGroup.Children.Add(scaleTransformLocal);

            #region Spotlight

            //// Even when I make it extreme, it doesn't seem to make the gradient brighter
            //SpotLight spotLight = new SpotLight();
            //spotLight.Color = Colors.White;
            ////spotLight.LinearAttenuation = 1d;
            //spotLight.LinearAttenuation = .1d;
            //spotLight.Range = 10;
            //spotLight.InnerConeAngle = 66;
            //spotLight.OuterConeAngle = 80;
            //spotLight.Direction = new Vector3D(0, 0, -1);
            //spotLight.Transform = new TranslateTransform3D(0, 0, 1);

            //retVal.Children.Add(spotLight);

            #endregion

            #region Back Lens

            if (!isFinal)
            {
                geometry = new GeometryModel3D();
                material = new MaterialGroup();

                RadialGradientBrush eyeBrush = new RadialGradientBrush();
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FFFFEA00"), 0d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FFF5E100"), 0.0187702d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FFECD800"), 0.0320388d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FFD46C00"), 0.0485437d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FFBC0000"), 0.104167d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FF8E0000"), 0.267322d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FF600000"), 0.486408d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FF3E0000"), 0.61068d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FF1D0000"), 0.713592d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FF0E0000"), 0.760544d));
                eyeBrush.GradientStops.Add(new GradientStop(UtilityWPF.ColorFromHex("#FF000000"), 1d));

                diffuse = new DiffuseMaterial(eyeBrush);
                materialBrushes.Add(new MaterialColorProps(diffuse, cameraLensColor));          // using the final's lens color, because it's a solid color
                material.Children.Add(diffuse);

                //if (!isFinal)
                //{
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                selectionEmissives.Add(selectionEmissive);
                //}

                geometry.Material     = material;
                geometry.BackMaterial = material;

                geometry.Geometry = UtilityWPF.GetCircle2D(cylinderSegments, transformGroup, transformGroup);

                retVal.Children.Add(geometry);
            }

            #endregion

            #region Glass Cover

            geometry = new GeometryModel3D();
            material = new MaterialGroup();

            if (isFinal)
            {
                material.Children.Add(new DiffuseMaterial(new SolidColorBrush(cameraLensColor)));               // no need to add these to this.MaterialBrushes (those are only for editing)
                material.Children.Add(cameraLensSpecular);
            }
            else
            {
                //NOTE: Not using the world color, because that's for final.  The editor has a HAL9000 eye, and this is a glass plate
                Color color = Color.FromArgb(26, 255, 255, 255);
                diffuse = new DiffuseMaterial(new SolidColorBrush(color));
                materialBrushes.Add(new MaterialColorProps(diffuse, color));
                material.Children.Add(diffuse);
                specular = new SpecularMaterial(new SolidColorBrush(Color.FromArgb(224, 255, 255, 255)), 95d);
                materialBrushes.Add(new MaterialColorProps(specular));
                material.Children.Add(specular);

                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                selectionEmissives.Add(selectionEmissive);
            }

            geometry.Material = material;
            //NOTE: The position handed to the camera pool is the center of this camera.  So need to leave the back material null, or it would
            //be like taking pictures with the lens cap on
            //geometry.BackMaterial = material;

            List <TubeRingBase> rings = new List <TubeRingBase>();
            rings.Add(new TubeRingRegularPolygon(0, false, 1, 1, false));
            rings.Add(new TubeRingDome(.15, false, domeSegments));

            geometry.Geometry = UtilityWPF.GetMultiRingedTube(cylinderSegments, rings, true, false, transformGroup);

            retVal.Children.Add(geometry);

            #endregion

            #region Silver Ring

            if (!isFinal)
            {
                geometry = new GeometryModel3D();
                material = new MaterialGroup();
                Color color = Color.FromRgb(90, 90, 90);
                diffuse = new DiffuseMaterial(new SolidColorBrush(color));
                materialBrushes.Add(new MaterialColorProps(diffuse, color));
                material.Children.Add(diffuse);
                specular = new SpecularMaterial(Brushes.White, 100d);
                materialBrushes.Add(new MaterialColorProps(specular));
                material.Children.Add(specular);

                //if (!isFinal)
                //{
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                selectionEmissives.Add(selectionEmissive);
                //}

                geometry.Material     = material;
                geometry.BackMaterial = material;

                geometry.Geometry = UtilityWPF.GetRing(cylinderSegments, .97, 1.03, .05, transformGroup);

                retVal.Children.Add(geometry);
            }

            #endregion

            #region Back Cover

            geometry = new GeometryModel3D();
            material = new MaterialGroup();
            diffuse  = new DiffuseMaterial(new SolidColorBrush(cameraBase));
            materialBrushes.Add(new MaterialColorProps(diffuse, cameraBase));
            material.Children.Add(diffuse);
            specular = cameraBaseSpecular;
            materialBrushes.Add(new MaterialColorProps(specular));
            material.Children.Add(specular);

            if (!isFinal)
            {
                EmissiveMaterial selectionEmissive = new EmissiveMaterial(Brushes.Transparent);
                material.Children.Add(selectionEmissive);
                selectionEmissives.Add(selectionEmissive);
            }

            geometry.Material     = material;
            geometry.BackMaterial = material;

            rings = new List <TubeRingBase>();
            rings.Add(new TubeRingDome(0, false, domeSegments));
            rings.Add(new TubeRingRegularPolygon(1.5, false, 1, 1, false));

            transformGroup = new Transform3DGroup();
            transformGroup.Children.Add(new TranslateTransform3D(0, 0, 1.65 / -2d));
            transformGroup.Children.Add(scaleTransformLocal);

            geometry.Geometry = UtilityWPF.GetMultiRingedTube(cylinderSegments, rings, true, false, transformGroup);

            retVal.Children.Add(geometry);

            #endregion

            // Transform
            retVal.Transform = transform;

            // Exit Function
            return(retVal);
        }
Exemple #30
0
        public static MineralStats GetSettingsForMineralType(MineralType mineralType)
        {
            //NOTE:  The geometry is defined in SharedVisuals.GetMineralMesh()

            switch (mineralType)
            {
            case MineralType.Ice:
                #region Ice

                // Going for an ice cube  :)

                return(new MineralStats(
                           Color.FromArgb(192, 201, 233, 242), // slightly bluish white
                           Color.FromArgb(255, 203, 212, 214),
                           66d,
                           Colors.Transparent,

                           934));

                #endregion

            case MineralType.Iron:
                #region Iron

                // This will be an iron bar (with rust)

                return(new MineralStats(
                           Color.FromArgb(255, 92, 78, 72),
                           Color.FromArgb(255, 117, 63, 40),
                           50d,
                           Colors.Transparent,

                           7900));

                #endregion

            case MineralType.Graphite:
                #region Graphite

                // A shiny lump of coal (but coal won't form in space, so I call it graphite)

                return(new MineralStats(
                           Color.FromArgb(255, 32, 32, 32),
                           Color.FromArgb(255, 209, 209, 209),
                           75d,
                           Colors.Transparent,

                           2267));

                #endregion

            case MineralType.Gold:
                #region Gold

                // A reflective gold bar

                return(new MineralStats(
                           Color.FromArgb(255, 255, 191, 0),
                           Color.FromArgb(255, 212, 138, 0),
                           75d,
                           Colors.Transparent,

                           19300));

                #endregion

            case MineralType.Platinum:
                #region Platinum

                // A reflective platinum bar/plate
                //TODO:  Make this a flat plate

                return(new MineralStats(
                           Color.FromArgb(255, 166, 166, 166),
                           Color.FromArgb(255, 125, 57, 45),
                           95d,
                           Color.FromArgb(20, 214, 214, 214),

                           21450));

                #endregion

            case MineralType.Emerald:
                #region Emerald

                // A semi transparent double trapazoid

                return(new MineralStats(
                           UtilityWPF.ColorFromHex("D948A340"), //Color.FromArgb(192, 69, 128, 64);
                           UtilityWPF.ColorFromHex("24731C"),   //Color.FromArgb(255, 26, 82, 20);
                           100d,
                           UtilityWPF.ColorFromHex("40499100"), //Color.FromArgb(64, 64, 128, 0);

                           2760));

                #endregion

            case MineralType.Saphire:
                #region Saphire

                // A jeweled oval

                return(new MineralStats(
                           Color.FromArgb(160, 39, 53, 102),
                           Color.FromArgb(255, 123, 141, 201),
                           100d,
                           Color.FromArgb(64, 17, 57, 189),

                           4000));

                #endregion

            case MineralType.Ruby:
                #region Ruby

                // A jeweled oval

                return(new MineralStats(
                           Color.FromArgb(180, 176, 0, 0),
                           Color.FromArgb(255, 255, 133, 133),
                           100d,
                           Color.FromArgb(32, 156, 53, 53),

                           4000));

                #endregion

            case MineralType.Diamond:
                #region Diamond

                // A jewel

                return(new MineralStats(
                           Color.FromArgb(128, 230, 230, 230),
                           Color.FromArgb(255, 196, 196, 196),
                           100d,
                           Color.FromArgb(32, 255, 255, 255),

                           3515));

                #endregion

            case MineralType.Rixium:
                #region Rixium

                // A petagon rod
                // There are also some toruses around it, but they are just visuals.  This rod is the collision mesh

                return(new MineralStats(
                           Color.FromArgb(192, 92, 59, 112),
                           //_specularColor = Color.FromArgb(255, 145, 63, 196);
                           Color.FromArgb(255, 77, 127, 138),
                           100d,
                           Color.FromArgb(64, 112, 94, 122),

                           66666));

                #endregion

            default:
                throw new ApplicationException("Unknown MineralType: " + mineralType.ToString());
            }
        }