Beispiel #1
0
        /// <summary>
        /// Returns a modifier scalar value that is the result of an intrinsic animation function.
        /// </summary>
        /// <param name="functionToken">animation function to use</param>
        /// <param name="period">period in seconds</param>
        /// <param name="phase">phase shift in seconds</param>
        /// <returns>coordinate modifier</returns>
        protected static float Animate(short functionToken, float period, float phase)
        {
            PMath.Phase = phase;
            switch (functionToken)
            {
            case 0x0: // one
                return(PMath.One());

            case 0x1: // zero
                return(PMath.Zero());

            case 0x2: // cosine
            case 0x3:
                return(Math.Abs(PMath.Cosine(period * 2.0f, 1.0f)));

            //case 0x3: // cosine (variable period)
            //  return Math.Abs(PMath.Cosine(Math.Abs(PMath.Cosine(period, 2.0f)) * 2.0f, 1.0f));
            case 0x4: // diagonal wave
            case 0x5:
                return(PMath.Triangle(period, 1.0f));

            //case 0x5: // diagonal wave (variable period)
            //  return PMath.Triangle(PMath.Cosine(period, 2.0f), 1.0f);
            case 0x6: // slide
            case 0x7:
                return(PMath.Sawtooth(period, 1.0f));

            //case 0x7: // slide (variable period)
            //  return PMath.Sawtooth(PMath.Cosine(period, 2.0f), 1.0f);
            case 0x8: // noise
                return(PMath.Noise(1.0f));

            case 0x9: // jitter
                return(PMath.Jitter(1.0f));

            case 0xa: // wander
                return(PMath.Wander(period, 1.0f));

            case 0xb: // spark
                return(PMath.Spark(1.0f));

            default:
                throw new ArgumentException(functionToken.ToString() + " is not a valid Halo shader animation function token.", "functionToken");
            }
        }