ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

static void compute_light_positions ( GLcontext *  ctx) [static]

Update state derived from light position, spot direction. Called upon: _NEW_MODELVIEW _NEW_LIGHT _TNL_NEW_NEED_EYE_COORDS

Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled. Also update on lighting space changes.

Definition at line 1092 of file light.c.

Referenced by _mesa_update_tnl_spaces().

{
   struct gl_light *light;
   static const GLfloat eye_z[3] = { 0, 0, 1 };

   if (!ctx->Light.Enabled)
      return;

   if (ctx->_NeedEyeCoords) {
      COPY_3V( ctx->_EyeZDir, eye_z );
   }
   else {
      TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m );
   }

   foreach (light, &ctx->Light.EnabledList) {

      if (ctx->_NeedEyeCoords) {
         /* _Position is in eye coordinate space */
     COPY_4FV( light->_Position, light->EyePosition );
      }
      else {
         /* _Position is in object coordinate space */
     TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv,
              light->EyePosition );
      }

      if (!(light->_Flags & LIGHT_POSITIONAL)) {
     /* VP (VP) = Normalize( Position ) */
     COPY_3V( light->_VP_inf_norm, light->_Position );
     NORMALIZE_3FV( light->_VP_inf_norm );

     if (!ctx->Light.Model.LocalViewer) {
        /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
        ADD_3V( light->_h_inf_norm, light->_VP_inf_norm, ctx->_EyeZDir);
        NORMALIZE_3FV( light->_h_inf_norm );
     }
     light->_VP_inf_spot_attenuation = 1.0;
      }
      else {
         /* positional light w/ homogeneous coordinate, divide by W */
         GLfloat wInv = (GLfloat)1.0 / light->_Position[3];
         light->_Position[0] *= wInv;
         light->_Position[1] *= wInv;
         light->_Position[2] *= wInv;
      }

      if (light->_Flags & LIGHT_SPOT) {
     if (ctx->_NeedEyeCoords) {
        COPY_3V( light->_NormDirection, light->EyeDirection );
     }
         else {
        TRANSFORM_NORMAL( light->_NormDirection,
                  light->EyeDirection,
                  ctx->ModelviewMatrixStack.Top->m);
     }

     NORMALIZE_3FV( light->_NormDirection );

     if (!(light->_Flags & LIGHT_POSITIONAL)) {
        GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm,
                    light->_NormDirection);

        if (PV_dot_dir > light->_CosCutoff) {
           double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
           int k = (int) x;
           light->_VP_inf_spot_attenuation =
          (GLfloat) (light->_SpotExpTable[k][0] +
           (x-k)*light->_SpotExpTable[k][1]);
        }
        else {
           light->_VP_inf_spot_attenuation = 0;
            }
     }
      }
   }
}

Generated on Sun May 27 2012 04:58:14 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.