コード例 #1
0
        /// <summary>
        /// Set all lights' parameters to effect.
        /// Note this completely clobbers any transitional effects.
        /// </summary>
        /// <param name="effect"></param>
        public void SetToEffect(Effect effect)
        {
            if (LightList != null)
            {
                for (int i = 0; i < LightList.Length; ++i)
                {
                    Light light = LightList[i];

                    Vector3 color   = light.Color;
                    float   maxChan = Math.Max(color.X, Math.Max(color.Y, color.Z));

                    lightColors[i] = light.Color;
                    lightDir[i]    = new Vector4(light.Direction, maxChan);

                    string dirParam = "LightDirection" + i.ToString();
                    if (effect.Parameters[dirParam] != null)
                    {
                        effect.Parameters[dirParam].SetValue(new Vector4(light.Direction, maxChan));
                    }
                    string colorParam = "LightColor" + i.ToString();
                    if (effect.Parameters[colorParam] != null)
                    {
                        effect.Parameters[colorParam].SetValue(light.Color);
                    }
                }

                lightWrap = Wrap;
                Parameter(EffectParams.Wrap).SetValue(ShaderGlobals.MakeWrapVec(Wrap));
            }
        }
コード例 #2
0
 public void SetToEffectWhileTransitioning(Effect effect)
 {
     for (int i = 0; i < lightColors.Length; i++)
     {
         string dirParam = "LightDirection" + i.ToString();
         if (effect.Parameters[dirParam] != null)
         {
             effect.Parameters[dirParam].SetValue(lightDir[i]);
         }
         string colorParam = "LightColor" + i.ToString();
         if (effect.Parameters[colorParam] != null)
         {
             effect.Parameters[colorParam].SetValue(lightColors[i]);
         }
     }
     if (effect.Parameters["LightWrap"] != null)
     {
         effect.Parameters["LightWrap"].SetValue(ShaderGlobals.MakeWrapVec(lightWrap));
     }
 }   // end of SetToEffectWhileTransitioning()