示例#1
0
        /// <summary>
        /// Metoda slouzi k automatickemu vygenerovani objektu na scenu v pozadovanem poctu
        /// </summary>
        /// <param name="random">Random generator cisel</param>
        private void CreateShapes(Random random)
        {
            Shapes = new List <Shape>();

            double width, height, depth;
            int    randInt = 0;

            for (int i = 0; i < shapeCount; ++i)
            {
                randInt = random.Next(2);

                if (randInt == 0)
                {
                    Sphere tmpS = new Sphere(new Material(Vector.RandomColor),
                                             Vector.RandomPointInSphere(radius), 0.5 + random.NextDouble());
                    Shapes.Add(tmpS);
                }
                else if (randInt == 1)
                {
                    width  = 0.5 + random.NextDouble();
                    height = 0.5 + random.NextDouble();
                    depth  = 0.5 + random.NextDouble();

                    Cuboid c = new Cuboid(new Material(Vector.RandomColor),
                                          Vector.RandomPointInCuboid(width, height, depth), width,
                                          height, depth);
                    Shapes.Add(c);
                }

                /*else
                 * {
                 *  depth = 0.5 + random.NextDouble();
                 *
                 *  shapes[i] = new Plane(new Material(Vector.RandomColor),
                 *      Vector.RandomPointInPlane(depth), depth);
                 * }*/
            }
        }