コード例 #1
0
ファイル: Emitter.cs プロジェクト: lvarvel/aura
 public EmitterBase(double period, List<ParticleSystem> particleSystems, DirectionalClamp clamp, int? rSeed = null, bool repeat = false)
     : base(period, particleSystems, rSeed, repeat)
 {
     Clamp = clamp;
 }
コード例 #2
0
ファイル: Ranges.cs プロジェクト: lvarvel/aura
        public static void TestClamp(TestResults results)
        {
            DirectionalClamp d = new DirectionalClamp();
            results.ReportMessage("Begining test of Directional Clamp bitmask.");
            if (d.ClampedX || d.ClampedY || d.ClampedZ)
            {
                results.ReportError("Empty bitmask is not zero");
            }
            else
                results.ReportMessage("Empty bitmask is zero");

            results.ReportMessage("Starting test 1");
            d.ClampedPositiveX = true;
            if (d.ClampedPositiveX)
                results.ReportMessage("Test 1 success. Clamp is reflexive.");
            else
                results.ReportError("Test 1 failure. Clamp is not reflexive.");

            d.NoClamp = true;
            if (d.ClampedX || d.ClampedY || d.ClampedZ)
            {
                results.ReportError("Empty bitmask is not zero");
            }
            results.ReportMessage("Starting test 2");
            d.ClampedZ = true;
            if (d.ClampedNegativeZ && d.ClampedPositiveZ)
                results.ReportMessage("Test 2 success. Dimentional/Polar\n options interoperate correctly.");
            else
                results.ReportError("Test 2 failure. Dimentional/Polar options do not interoperate");
        }
コード例 #3
0
ファイル: Util.cs プロジェクト: lvarvel/aura
        /// <summary>
        /// Returns a random, normalized vector3
        /// Remember to return it to the pool when you're done with it
        /// </summary>
        /// <param name="clamp"></param>
        /// <returns></returns>
        public static Vector3 GetRandomEmissionNormal(DirectionalClamp clamp)
        {
            //Note: code is very, very hacky.  There was't a whole lot I could do to fix this
            Vector3 result = Vector3Pool.Instance.Get();
            #region Check trivial case
            if (clamp.ClampedX && clamp.ClampedY && clamp.ClampedZ)
            {
                result.AssignValues(0, 0, 0);
                return result;
            }
            #endregion
            float l = 0;
            do
            {
                result.X = (float)r.NextDouble() * r.NextSign();
                result.Y = (float)r.NextDouble() * r.NextSign();
                result.Z = (float)r.NextDouble() * r.NextSign();
                l = result.length();
            } while (l == 0); //Note: There is a 1/2^96 % chance that the length will be zero, which will cause divide by zero errors

            result.X /= l;
            result.Y /= l;
            result.Z /= l;

            if (clamp.NoClamp) return result;

            #region XClamping
            if (clamp.ClampedX)
            {
                result.X = 0;
            }
            else
            {
                if (clamp.ClampedPositiveX)
                {
                    result.X *= (result.X > 0) ? -1 : 1;
                }
                else if (clamp.ClampedNegativeX)
                {
                    result.X *= (result.X < 0) ? -1 : 1;
                }
            }
            #endregion

            #region YClamping
            if (clamp.ClampedY)
            {
                result.Y = 0;
            }
            else
            {
                if (clamp.ClampedPositiveY)
                {
                    result.Y *= (result.Y > 0) ? -1 : 1;
                }
                else if (clamp.ClampedNegativeY)
                {
                    result.Y *= (result.Y < 0) ? -1 : 1;
                }
            }
            #endregion

            #region ZClamping
            if (clamp.ClampedZ)
            {
                result.Z = 0;
            }
            else
            {
                if (clamp.ClampedPositiveZ)
                {
                    result.Z *= (result.Z > 0) ? -1 : 1;
                }
                else if (clamp.ClampedNegativeZ)
                {
                    result.Z *= (result.Z < 0) ? -1 : 1;
                }
            }
            #endregion

            result.normalize();
            return result;
        }