Esempio n. 1
0
        /// <summary>
        /// This summary has not been prepared yet. NOSUMMARY - pantal07
        /// </summary>
        public static Material MakeMaterial(string material, string type, double specularPower)
        {
            switch (type)
            {
            case "Specular":
                return(new SpecularMaterial(BrushFactory.MakeBrush(material), specularPower));

            case "Emissive":
                return(new EmissiveMaterial(BrushFactory.MakeBrush(material)));

            case "Diffuse":
                return(new DiffuseMaterial(BrushFactory.MakeBrush(material)));

            default:
                throw new ArgumentException(string.Format(
                                                "Specified material ({0}) of type ({1}) could not be created.", material, type));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// This summary has not been prepared yet. NOSUMMARY - pantal07
        /// </summary>
        public static Material GetRandomMaterial(int seed, bool opaque, bool allowNulls)
        {
            Random rand = new Random(seed);

            int brushTypeCount, materialTypeCount;

            if (allowNulls)
            {
                brushTypeCount    = 7;
                materialTypeCount = 5;
            }
            else
            {
                brushTypeCount    = 6;
                materialTypeCount = 4;
            }

            // Create Brush
            Brush brush = null;

            switch (rand.Next() % brushTypeCount)
            {
            case 0:
                brush = BrushFactory.GetRandomLinearGradientBrush(rand.Next(), opaque);
                break;

            case 1:
                brush = BrushFactory.GetRandomRadialGradientBrush(rand.Next(), opaque);
                break;

            case 2:
                brush = BrushFactory.GetRandomImageBrush(rand.Next(), opaque);
                break;

            case 3:
                brush = BrushFactory.GetRandomDrawingBrush(rand.Next(), opaque);
                break;

            case 4:
                brush = BrushFactory.GetRandomVisualBrush(rand.Next(), opaque);
                break;

            case 5:
                brush = BrushFactory.GetRandomSolidColorBrush(rand.Next(), opaque);
                break;

            default:
                // null brush
                break;
            }
            brush = BrushFactory.GetRandomDrawingBrush(rand.Next(), opaque);

            // Create material
            Material material = null;

            switch (rand.Next() % materialTypeCount)
            {
            case 0:
                material = new DiffuseMaterial(brush);
                break;

            case 1:
                material = new EmissiveMaterial(brush);
                break;

            case 2:
                material = new SpecularMaterial(brush, rand.NextDouble() * 100.0);
                break;

            case 3:
                material = new MaterialGroup();
                int childCount = rand.Next(0, 4);
                for (int i = 0; i < childCount; i++)
                {
                    ((MaterialGroup)material).Children.Add(GetRandomMaterial(rand.Next(), opaque, allowNulls));
                }
                break;

            default:
                // null material
                break;
            }
            return(material);
        }