コード例 #1
0
        public void Test0()
        {
            var ps = new ParticleSystem();
              var angle = ps.Parameters.AddUniform<float>("A");
              var speed = ps.Parameters.AddUniform<float>("S");

              angle.DefaultValue = 3;
              speed.DefaultValue = 2;

              var e = new AngularVelocityEffector
              {
            ParticleSystem = ps,
            AngleParameter = "A",
            SpeedParameter = "S",
              };

              e.RequeryParameters();
              e.Initialize();

              var dt = new TimeSpan(0, 0, 0, 1);
              e.BeginUpdate(dt);
              e.UpdateParticles(dt, 10, 20);
              e.EndUpdate(dt);

              Assert.AreEqual(5, angle.DefaultValue);

              e.BeginUpdate(dt);
              e.UpdateParticles(dt, 10, 20);
              e.EndUpdate(dt);

              Assert.AreEqual(7 % ConstantsF.TwoPi, angle.DefaultValue);

              speed.DefaultValue = -17;

              e.BeginUpdate(dt);
              e.UpdateParticles(dt, 10, 20);
              e.EndUpdate(dt);

              Assert.IsTrue(Numeric.AreEqual(-10 + 2 * ConstantsF.TwoPi, angle.DefaultValue));
        }
コード例 #2
0
        public void WrongParameters()
        {
            var ps = new ParticleSystem();
              ps.Parameters.AddUniform<float>("A");
              ps.Parameters.AddUniform<float>("S");

              var e = new AngularVelocityEffector { ParticleSystem = ps };

              var dt = new TimeSpan(0, 0, 0, 1);

              // There should be no exception.
              e.RequeryParameters();
              e.Initialize();
              e.BeginUpdate(dt);
              e.UpdateParticles(dt, 10, 20);
              e.EndUpdate(dt);

              e.Uninitialize();
        }