Ejemplo n.º 1
0
        public void Test0()
        {
            var ps        = new ParticleSystem();
            var direction = ps.Parameters.AddUniform <float>("D");

            var e = new StartValueEffector <float>
            {
                ParticleSystem = ps,
                Parameter      = "D",
            };

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

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

            Assert.AreEqual(0, direction.DefaultValue);

            e.Distribution = new ConstValueDistribution <float>(23);

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

            Assert.AreEqual(23, direction.DefaultValue);
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            var ps = new ParticleSystem();
              var direction = ps.Parameters.AddVarying<float>("D");

              var e = new StartValueEffector<float>
              {
            ParticleSystem = ps,
            Parameter = "D",
              };

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

              e.RequeryParameters();
              e.Initialize();
              e.InitializeParticles(10, 20, null);
              e.BeginUpdate(dt);
              e.UpdateParticles(dt, 10, 20);
              e.EndUpdate(dt);

              Assert.AreEqual(0, direction.Values[11]);

              e.Distribution = new ConstValueDistribution<float>(23);

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

              Assert.AreEqual(23, direction.Values[11]);
        }
Ejemplo n.º 3
0
        public void EffectorTest()
        {
            var sve0 = new StartValueEffector <float> {
                Parameter = "Abc", Distribution = new UniformDistributionF(1, 2)
            };
            var sve1 = Serialize(sve0);

            Assert.IsTrue(sve0.Parameter == sve1.Parameter);

            sve0 = new StartValueEffector <float> {
                Parameter = "Abc", DefaultValue = -7
            };
            sve1 = Serialize(sve0);
            Assert.IsTrue(sve0.DefaultValue == sve1.DefaultValue);
        }
Ejemplo n.º 4
0
        public void WrongParameters()
        {
            var ps = new ParticleSystem();

            ps.Parameters.AddUniform <float>("D");

            var e = new StartValueEffector <float> {
                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();
        }
Ejemplo n.º 5
0
        public void Uninitialize()
        {
            var ps  = new ParticleSystem();
            var wp0 = new WeakReference(ps.Parameters.AddVarying <Vector3>(ParticleParameterNames.Direction));

            var e = new StartValueEffector <Vector3>
            {
                ParticleSystem = ps,
                Parameter      = ParticleParameterNames.Direction
            };

            e.RequeryParameters();
            e.Uninitialize();

            e.ParticleSystem = null;
            ps = null;

            GC.Collect();
            GC.WaitForFullGCComplete();

            Assert.IsFalse(wp0.IsAlive);
        }
Ejemplo n.º 6
0
        public void Uninitialize()
        {
            var ps = new ParticleSystem();
              var wp0 = new WeakReference(ps.Parameters.AddVarying<Vector3F>(ParticleParameterNames.Direction));

              var e = new StartValueEffector<Vector3F>
              {
            ParticleSystem = ps,
            Parameter = ParticleParameterNames.Direction
              };

              e.RequeryParameters();
              e.Uninitialize();

              e.ParticleSystem = null;
              ps = null;

              GC.Collect();
              GC.WaitForFullGCComplete();

              Assert.IsFalse(wp0.IsAlive);
        }
Ejemplo n.º 7
0
        public void WrongParameters()
        {
            var ps = new ParticleSystem();
              ps.Parameters.AddUniform<float>("D");

              var e = new StartValueEffector<float> { 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();
        }