Esempio n. 1
0
        private static GeometryModel3D GetEggModel(Point3D position, double radius, BotShellColorsDNA colors)
        {
            // Material
            MaterialGroup material = new MaterialGroup();

            Color baseColor = UtilityWPF.ColorFromHex(colors.InnerColorDiffuse);

            ColorHSV driftedColor = baseColor.ToHSV();
            driftedColor = new ColorHSV(UtilityWPF.GetCappedAngle(driftedColor.H + (colors.DiffuseDrift * StaticRandom.NextDouble(0, 4))), driftedColor.S, driftedColor.V);

            material.Children.Add(new DiffuseMaterial(new SolidColorBrush(driftedColor.ToRGB())));
            material.Children.Add(new SpecularMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("80FFFFFF")), 20));
            material.Children.Add(new EmissiveMaterial(new SolidColorBrush(UtilityWPF.ColorFromHex("20" + colors.EmissiveColor.Substring(colors.EmissiveColor.Length - 6)))));

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

            retVal.Geometry = UtilityWPF.GetSphere_LatLon(5, radius);

            Transform3DGroup transform = new Transform3DGroup();
            transform.Children.Add(new ScaleTransform3D(new Vector3D(.75d, .75d, 1d)));
            transform.Children.Add(new RotateTransform3D(new QuaternionRotation3D(Math3D.GetRandomRotation())));
            transform.Children.Add(new TranslateTransform3D(position.ToVector()));

            retVal.Transform = transform;

            return retVal;
        }
            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
            }
        private static Visual3D TestSamples_Draw(SketchSample[] sketches, double[] hues)
        {
            const double RADIUS = .5;
            const double DOTRADIUS = .035;

            #region Materials

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

            var material_Color = 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 { Color = color, Material = material };
                }).ToArray();

            ColorHSV color_Gray = new ColorHSV(0, 0, 50);
            MaterialGroup material_Gray = new MaterialGroup();
            material_Gray.Children.Add(new DiffuseMaterial(new SolidColorBrush(color_Gray.ToRGB())));
            material_Gray.Children.Add(specular);

            #endregion

            Model3DGroup group = new Model3DGroup();

            foreach (SketchSample sketch in sketches)
            {
                int? matchIndex = UtilityEncog.IsMatch(sketch.NNOutput);

                Material material;
                if (matchIndex == null)
                {
                    sketch.IsMatch = false;
                    sketch.Color = color_Gray;
                    material = material_Gray;
                }
                else
                {
                    sketch.IsMatch = true;
                    sketch.Color = material_Color[matchIndex.Value].Color;
                    material = material_Color[matchIndex.Value].Material;
                }

                sketch.Position = Math3D.GetRandomVector_Spherical(RADIUS).ToPoint();
                sketch.Translate_3DDot = new TranslateTransform3D(sketch.Position.ToVector());

                // Geometry Model
                GeometryModel3D geometry = new GeometryModel3D();
                geometry.Material = material;
                geometry.BackMaterial = material;
                geometry.Geometry = UtilityWPF.GetSphere_Ico(DOTRADIUS, 1, true);

                geometry.Transform = sketch.Translate_3DDot;

                group.Children.Add(geometry);
            }

            ModelVisual3D visual = new ModelVisual3D();
            visual.Content = group;
            return visual;
        }