コード例 #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");
            }
        }
コード例 #2
0
        public override int BeginApply()
        {
            base.BeginApply();

            if (technique == null)
            {
                return(0);
            }
            else
            {
                effect.SetValue(cameraHandle, new Vector4(MdxRender.Camera.Position.X, MdxRender.Camera.Position.Y, MdxRender.Camera.Position.Z, 1.0f));
                effect.SetValue(wvpHandle, MdxRender.Device.Transform.World * MdxRender.Device.Transform.View * MdxRender.Device.Transform.Projection);
                effect.SetValue(worldHandle, MdxRender.Device.Transform.World);

                effect.SetValue(offsetHandle, shaderTransparentPlasmaValues.OffsetAmount.Value);
                effect.SetValue(intensityHandle, 1.0f);

                if (shaderTransparentPlasmaValues.PrimaryAnimationDirection.I == 0.0f)
                {
                    effect.SetValue(pIHandle, 0.0f);
                }
                else
                {
                    effect.SetValue(pIHandle, PMath.Sawtooth(shaderTransparentPlasmaValues.PrimaryAnimationPeriod.Value / shaderTransparentPlasmaValues.PrimaryAnimationDirection.I, 1.0f));
                }
                if (shaderTransparentPlasmaValues.PrimaryAnimationDirection.J == 0.0f)
                {
                    effect.SetValue(pJHandle, 0.0f);
                }
                else
                {
                    effect.SetValue(pJHandle, PMath.Sawtooth(shaderTransparentPlasmaValues.PrimaryAnimationPeriod.Value / shaderTransparentPlasmaValues.PrimaryAnimationDirection.J, 1.0f));
                }
                if (shaderTransparentPlasmaValues.PrimaryAnimationDirection.K == 0.0f)
                {
                    effect.SetValue(pKHandle, 0.0f);
                }
                else
                {
                    effect.SetValue(pKHandle, PMath.Sawtooth(shaderTransparentPlasmaValues.PrimaryAnimationPeriod.Value / shaderTransparentPlasmaValues.PrimaryAnimationDirection.K, 1.0f));
                }

                if (shaderTransparentPlasmaValues.SecondaryAnimationDirection.I == 0.0f)
                {
                    effect.SetValue(sIHandle, 0.0f);
                }
                else
                {
                    effect.SetValue(sIHandle, PMath.Sawtooth(shaderTransparentPlasmaValues.SecondaryAnimationPeriod.Value / shaderTransparentPlasmaValues.SecondaryAnimationDirection.I, 1.0f));
                }
                if (shaderTransparentPlasmaValues.SecondaryAnimationDirection.J == 0.0f)
                {
                    effect.SetValue(sJHandle, 0.0f);
                }
                else
                {
                    effect.SetValue(sJHandle, PMath.Sawtooth(shaderTransparentPlasmaValues.SecondaryAnimationPeriod.Value / shaderTransparentPlasmaValues.SecondaryAnimationDirection.J, 1.0f));
                }
                if (shaderTransparentPlasmaValues.SecondaryAnimationDirection.K == 0.0f)
                {
                    effect.SetValue(sKHandle, 0.0f);
                }
                else
                {
                    effect.SetValue(sKHandle, PMath.Sawtooth(shaderTransparentPlasmaValues.SecondaryAnimationPeriod.Value / shaderTransparentPlasmaValues.SecondaryAnimationDirection.K, 1.0f));
                }

                effect.CommitChanges();
                return(effect.Begin(FX.DoNotSaveState));
            }
        }