Ejemplo n.º 1
0
        /// <summary>
        /// Loads all the figures from the given folder. For each figure in the
        /// folder, a random movement pattern is assigned. The figure is then
        /// added to the figlist, and the shine for each figure is set.
        /// </summary>
        /// <param name="folderName"> The folder where the figures are located. </param>
        public void LoadFigures(string file, int num = 0)
        {
            Random rnd = new Random();

            for (int i = 0; i < num; i++)
            {
                int         pattern = rnd.Next(RAND_MOVE);
                MovePattern move    = new RandomMovePattern();
                switch (pattern)
                {
                case RNDM:
                {
                    move = new RandomMovePattern();
                    break;
                }

                case FXD1:
                {
                    move = new FixedMovePattern1();
                    break;
                }

                case SINU:
                {
                    move = new SinusoidalMovePattern();
                    break;
                }

                case FXD2:
                {
                    move = new FixedMovePattern2();
                    break;
                }
                }

                Figure fig;
                fig = new Figure(file);
                fig.Load();

                fig.Translate(new Vector3(((float)(rnd.NextDouble()) - 0.5f) * INIT_BOUND,
                                          ((float)(rnd.NextDouble()) - 0.5f) * INIT_BOUND,
                                          ((float)(rnd.NextDouble()) - 0.5f) * INIT_BOUND));
                Add(fig, move);
            }
            SetShine();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads all the figures from the given folder. For each figure in the
        /// folder, a random movement pattern is assigned. The figure is then 
        /// added to the figlist, and the shine for each figure is set.
        /// </summary>
        /// <param name="folderName"> The folder where the figures are located. </param>
        public void LoadFigures(string folderName)
        {
            //read in all WRL files
             String[] files = System.IO.Directory.GetFiles(folderName, "*.wrl");
             Random rnd = new Random();

             foreach (String file in files)
             {
            int pattern = rnd.Next(RAND_MOVE);
            MovePattern move = new RandomMovePattern();
            switch (pattern)
            {
               case RNDM:
               {
                  move = new RandomMovePattern();
                  break;
               }
               case FXD1:
               {
                  move = new FixedMovePattern1();
                  break;
               }
               case SINU:
               {
                  move = new SinusoidalMovePattern();
                  break;
               }
               case FXD2:
               {
                  move = new FixedMovePattern2();
                  break;
               }
            }

            FigureMovementPair pair = new FigureMovementPair { fig = new Figure(file), movement = move };
            pair.fig.Load();
            pair.fig.Translate(new Vector3(((float)(rnd.NextDouble()) - 0.5f) * INIT_BOUND,
                              ((float)(rnd.NextDouble()) - 0.5f) * INIT_BOUND,
                              ((float)(rnd.NextDouble()) - 0.5f) * INIT_BOUND));
            figlist.Add(pair);
             }
             SetShine();
        }