Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        private static System.Windows.Media.Media3D.Material GetModel_Rod_CompositeSprtMaterial(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;
        }