// returns light in range from 0 to 1. colorVec R_LightPoint (Vector& p) { SurfaceHandle_t surfID; Vector end; colorVec c; Vector color; end[0] = p[0]; end[1] = p[1]; end[2] = p[2] - 2048; surfID = R_LightVec( p, end, true, color ); if( IS_SURF_VALID( surfID ) ) { c.r = LinearToScreenGamma( color[0] ) * 255; c.g = LinearToScreenGamma( color[1] ) * 255; c.b = LinearToScreenGamma( color[2] ) * 255; c.a = 1; } else { c.r = c.g = c.b = c.a = 0; } return c; }
//----------------------------------------------------------------------------- // A method to get the material color + texture coordinate //----------------------------------------------------------------------------- IMaterial* BrushModel_GetLightingAndMaterial( const Vector &start, const Vector &end, Vector &diffuseLightColor, Vector &baseColor) { float textureS, textureT; IMaterial *material; int surfID = R_LightVec( start, end, true, diffuseLightColor, &textureS, &textureT ); if( !IS_SURF_VALID( surfID ) || !MSurf_TexInfo( surfID ) ) { // Con_Printf( "didn't hit anything\n" ); return 0; } else { material = MSurf_TexInfo( surfID )->material; material->GetLowResColorSample( textureS, textureT, baseColor.Base() ); // Con_Printf( "%s: diff: %f %f %f base: %f %f %f\n", material->GetName(), diffuseLightColor[0], diffuseLightColor[1], diffuseLightColor[2], baseColor[0], baseColor[1], baseColor[2] ); return material; } }