- double nDelta;
- int16_ iHeight, iWidth;
-
- pSpotLight->nDiameter = iDiameter;
-#ifdef VERBOSE
- printf( "%s: Light Diameter: %d\n", progclass, pSpotLight->nDiameter );
-#endif
-
- pSpotLight->aLightMap = calloc( pSpotLight->nDiameter * pSpotLight->nDiameter, sizeof(uint8_) );
- memset( pSpotLight->aLightMap, 0, pSpotLight->nDiameter * pSpotLight->nDiameter );
-
- /* The falloff max values... 3/4 of the entire lightmap. */
- pSpotLight->nRadius = (uint16_)(pSpotLight->nDiameter / 2.5F);
-
- for( iHeight=-pSpotLight->nRadius; iHeight<pSpotLight->nRadius; iHeight++ )
- for( iWidth=-pSpotLight->nRadius; iWidth<pSpotLight->nRadius; iWidth++ )
- {
- nDelta = ( nColorCount * 2.5F ) - ( ( sqrt( pow( iWidth+0.5F, 2 ) + pow( iHeight+0.5F, 2 ) ) / pSpotLight->nRadius ) * ( nColorCount * 2.5F ) );
- nDelta += nColorCount;
- if( nDelta >= ( nColorCount * 2 ) ) nDelta = ( nColorCount * 2 ) - 1;
- if( nDelta >= nColorCount )
- pSpotLight->aLightMap[ ( ( iHeight + (pSpotLight->nDiameter/2) ) * pSpotLight->nDiameter ) + iWidth + (pSpotLight->nDiameter/2) ] = (uint8_)nDelta;
- }
-
- /* The actual lightmap... 1/2 of the entire lightmap. */
- pSpotLight->nRadius = pSpotLight->nDiameter / 4;