コード例 #1
0
        /// <summary>
        /// Moves the figure based on the randomly generated translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in each direction. Translates and
        /// Rotates in all 3 axes.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_x = (float)(rand.NextDouble()) * xDir * TRANS_MULT;
            float trans_y = (float)(rand.NextDouble()) * yDir * TRANS_MULT;
            float trans_z = (float)(rand.NextDouble()) * zDir * TRANS_MULT;

            x += trans_x;
            y += trans_y;
            z += trans_z;
            if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0))
            {
                xDir *= -1;
            }
            if ((y >= LIMIT && yDir > 0) || (y < 0 && yDir < 0))
            {
                yDir *= -1;
            }
            if ((z >= LIMIT && zDir > 0) || (z < 0 && zDir < 0))
            {
                zDir *= -1;
            }

            fig.Translate(new Vector3(trans_x, trans_y, trans_z));

            float rot_x = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
            float rot_y = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
            float rot_z = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;

            fig.RotateX(rot_x);
            fig.RotateY(rot_y);
            fig.RotateZ(rot_z);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: bristevenski/SchoolWork
        private void MakeProjectile()
        {
            Figure temp = new Figure(projectile);

            temp.Load();
            temp.Translate(Ship.Instance.Position);
            MovePattern move = new MoveStraight(Ship.Instance.Direction, 1.0f);

            projectiles.Add(temp, move, 100000000);
        }
コード例 #3
0
ファイル: MovePattern.cs プロジェクト: LastTalon/Portfolio
        /// <summary>
        /// Moves the figure based on the fixed translation and
        /// scale amounts. Uses a limit for the translation to keep the
        /// figure within a certain bound. Translates in z-direction only,
        /// keeping x and y intact. Scales in z-direction only, keeping x
        /// and y intact.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_z = (float)(zDir * Z_DIST);

             z += trans_z;
             if ((z >= LIMIT && zDir > 0) || (z < 0 && zDir < 0))
            zDir *= -1;

             fig.Translate(new Vector3(0.0f, 0.0f, trans_z));
             fig.Scale(new Vector3(1.0f, 1.0f, (float)Math.Pow(SCALE_MULT, zDir)));
        }
コード例 #4
0
        /// <summary>
        /// Moves the figure based on the fixed translation and
        /// scale amounts. Uses a limit for the translation to keep the
        /// figure within a certain bound. Translates in z-direction only,
        /// keeping x and y intact. Scales in z-direction only, keeping x
        /// and y intact.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_z = (float)(zDir * Z_DIST);

            z += trans_z;
            if ((z >= LIMIT && zDir > 0) || (z < 0 && zDir < 0))
            {
                zDir *= -1;
            }

            fig.Translate(new Vector3(0.0f, 0.0f, trans_z));
            fig.Scale(new Vector3(1.0f, 1.0f, (float)Math.Pow(SCALE_MULT, zDir)));
        }
コード例 #5
0
        /// <summary>
        /// Moves the figure based a sinusoidal translation. Creates a
        /// "wave" like movement. Rotates the figure during this translation
        /// in the around the y-axis.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_x = (float)(xDir * DIST);
            float trans_z = -(float)(xDir * DIST);
            float trans_y = (float)Math.Sin(x) * Y_DIST;

            x += trans_x;
            if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0))
            {
                xDir *= -1;
            }

            fig.Translate(new Vector3(trans_x, trans_y, trans_z));
            fig.RotateY(ROT_Y);
        }
コード例 #6
0
ファイル: FigureList.cs プロジェクト: bristevenski/SchoolWork
        /// <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();
        }
コード例 #7
0
        /// <summary>
        /// Moves the figure based on the fixed translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in both y and z directions. Translates
        /// in the y and z directions, leaving x intact. Rotates around the
        /// x-axis.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_y = (float)(y_dir * DIST);
            float trans_z = (float)(z_dir * DIST);

            y += trans_y;
            z += trans_z;
            if ((y >= LIMIT && y_dir > 0) || (y < 0 && y_dir < 0))
            {
                y_dir *= -1;
            }
            if ((z >= LIMIT && z_dir > 0) || (z < 0 && z_dir < 0))
            {
                z_dir *= -1;
            }

            fig.Translate(new Vector3(0.0f, trans_y, trans_z));
            fig.RotateX(ROTATE);
        }
コード例 #8
0
ファイル: MovePattern.cs プロジェクト: LastTalon/Portfolio
        /// <summary>
        /// Moves the figure based on the fixed translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in both y and z directions. Translates 
        /// in the y and z directions, leaving x intact. Rotates around the 
        /// x-axis.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_y = (float)(y_dir * DIST);
             float trans_z = (float)(z_dir * DIST);

             y += trans_y;
             z += trans_z;
             if ((y >= LIMIT && y_dir > 0) || (y < 0 && y_dir < 0))
            y_dir *= -1;
             if ((z >= LIMIT && z_dir > 0) || (z < 0 && z_dir < 0))
            z_dir *= -1;

             fig.Translate(new Vector3(0.0f, trans_y, trans_z));
             fig.RotateX(ROTATE);
        }
コード例 #9
0
ファイル: MovePattern.cs プロジェクト: LastTalon/Portfolio
        /// <summary>
        /// Moves the figure based a sinusoidal translation. Creates a
        /// "wave" like movement. Rotates the figure during this translation
        /// in the around the y-axis.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_x = (float)(xDir * DIST);
             float trans_z = -(float)(xDir * DIST);
             float trans_y = (float)Math.Sin(x) * Y_DIST;

             x += trans_x;
             if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0))
            xDir *= -1;

             fig.Translate(new Vector3(trans_x, trans_y, trans_z));
             fig.RotateY(ROT_Y);
        }
コード例 #10
0
ファイル: MovePattern.cs プロジェクト: LastTalon/Portfolio
        /// <summary>
        /// Moves the figure based on the randomly generated translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in each direction. Translates and
        /// Rotates in all 3 axes.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_x = (float)(rand.NextDouble()) * xDir * TRANS_MULT;
             float trans_y = (float)(rand.NextDouble()) * yDir * TRANS_MULT;
             float trans_z = (float)(rand.NextDouble()) * zDir * TRANS_MULT;

             x += trans_x;
             y += trans_y;
             z += trans_z;
             if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0))
            xDir *= -1;
             if ((y >= LIMIT && yDir > 0) || (y < 0 && yDir < 0))
            yDir *= -1;
             if ((z >= LIMIT && zDir > 0) || (z < 0 && zDir < 0))
            zDir *= -1;

             fig.Translate(new Vector3(trans_x, trans_y, trans_z));

             float rot_x = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
             float rot_y = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
             float rot_z = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;

             fig.RotateX(rot_x);
             fig.RotateY(rot_y);
             fig.RotateZ(rot_z);
        }
コード例 #11
0
ファイル: MovePattern.cs プロジェクト: LastTalon/Portfolio
 public override void Move(Figure fig)
 {
     dir.Mult(move_amt);
      fig.Translate(dir);
 }
コード例 #12
0
 public override void Move(Figure fig)
 {
     fig.Translate(dir);
 }