void R_WorldEffect_f(void) { char temp[2048]; ri.ArgsBuffer(temp, sizeof(temp)); R_WorldEffectCommand(temp); }
void R_RMGInit(void) { char newSky[MAX_QPATH]; char newFog[MAX_QPATH]; shader_t *sky; shader_t *fog; fog_t *gfog; mgrid_t *grid; char temp[MAX_QPATH]; int i; unsigned short *pos; Cvar_VariableStringBuffer("RMG_sky", newSky, MAX_QPATH); // Get sunlight - this should set up all the sunlight data sky = R_FindShader( newSky, lightmapsNone, stylesDefault, qfalse ); // Remap sky // R_RemapShader("textures/tools/_sky", newSky, NULL); // Fill in the lightgrid with sunlight if(tr.world->lightGridData) { #ifdef _XBOX byte *memory = (byte *)tr.world->lightGridData; byte *array; array = memory; memory += 3; array[0] = (byte)Com_Clamp(0, 255, tr.sunAmbient[0] * 255.0f); array[1] = (byte)Com_Clamp(0, 255, tr.sunAmbient[1] * 255.0f); array[2] = (byte)Com_Clamp(0, 255, tr.sunAmbient[2] * 255.0f); array[3] = (byte)Com_Clamp(0, 255, tr.sunLight[0]); array[4] = (byte)Com_Clamp(0, 255, tr.sunLight[1]); array[5] = (byte)Com_Clamp(0, 255, tr.sunLight[2]); NormalToLatLong(tr.sunDirection, grid->latLong); #else // _XBOX grid = tr.world->lightGridData; grid->ambientLight[0][0] = (byte)Com_Clamp(0, 255, tr.sunAmbient[0] * 255.0f); grid->ambientLight[0][1] = (byte)Com_Clamp(0, 255, tr.sunAmbient[1] * 255.0f); grid->ambientLight[0][2] = (byte)Com_Clamp(0, 255, tr.sunAmbient[2] * 255.0f); R_ColorShiftLightingBytes(grid->ambientLight[0], grid->ambientLight[0]); grid->directLight[0][0] = (byte)Com_Clamp(0, 255, tr.sunLight[0]); grid->directLight[0][1] = (byte)Com_Clamp(0, 255, tr.sunLight[1]); grid->directLight[0][2] = (byte)Com_Clamp(0, 255, tr.sunLight[2]); R_ColorShiftLightingBytes(grid->directLight[0], grid->directLight[0]); NormalToLatLong(tr.sunDirection, grid->latLong); #endif // _XBOX pos = tr.world->lightGridArray; for(i=0;i<tr.world->numGridArrayElements;i++) { *pos = 0; pos++; } } // Override the global fog with the defined one if(tr.world->globalFog != -1) { Cvar_VariableStringBuffer("RMG_fog", newFog, MAX_QPATH); fog = R_FindShader( newFog, lightmapsNone, stylesDefault, qfalse); if (fog != tr.defaultShader) { gfog = tr.world->fogs + tr.world->globalFog; gfog->parms = *fog->fogParms; if (gfog->parms.depthForOpaque) { gfog->tcScale = 1.0f / ( gfog->parms.depthForOpaque * 8.0f ); tr.distanceCull = gfog->parms.depthForOpaque; Cvar_Set("RMG_distancecull", va("%f", tr.distanceCull)); } else { gfog->tcScale = 1.0f; } gfog->colorInt = ColorBytes4 ( gfog->parms.color[0], gfog->parms.color[1], gfog->parms.color[2], 1.0f ); } } Cvar_VariableStringBuffer("RMG_weather", temp, MAX_QPATH); // Set up any weather effects switch(atol(temp)) { case 0: break; case 1: R_WorldEffectCommand("rain init 1000"); R_WorldEffectCommand("rain outside"); break; case 2: R_WorldEffectCommand("snow init 1000 outside"); R_WorldEffectCommand("snow outside"); break; } }
void R_WorldEffectCommand(const char *command) { const char *token, *origCommand; token = COM_ParseExt(&command, false); if (strcmpi(token, "snow") == 0) { origCommand = command; token = COM_ParseExt(&command, false); if (strcmpi(token, "init") == 0) { // snow init <particles> token = COM_ParseExt(&command, false); if (snowSystem) { delete snowSystem; } snowSystem = new CSnowSystem(atoi(token)); } else if (strcmpi(token, "remove") == 0) { // snow remove if (snowSystem) { delete snowSystem; snowSystem = 0; } } else if (snowSystem) { snowSystem->Command(origCommand); } } else if (strcmpi(token, "rain") == 0) { origCommand = command; token = COM_ParseExt(&command, false); if (strcmpi(token, "init") == 0) { // rain init <particles> token = COM_ParseExt(&command, false); if (rainSystem) { delete rainSystem; } rainSystem = new CRainSystem(atoi(token)); } else if (strcmpi(token, "remove") == 0) { // rain remove if (rainSystem) { delete rainSystem; rainSystem = 0; } } else if (rainSystem) { rainSystem->Command(origCommand); } } else if (strcmpi(token, "debug") == 0) { token = COM_ParseExt(&command, false); if (strcmpi(token, "wind") == 0) { debugShowWind = !debugShowWind; } else if (strcmpi(token, "blah") == 0) { R_WorldEffectCommand("snow init 1000"); R_WorldEffectCommand("snow alpha 1"); R_WorldEffectCommand("snow fog"); } } }