799
799
else if (!_stricmp (*token, "-basic"))
800
800
stage->alphafunc = -ALPHAFUNC_BASIC;
802
void rs_stage_lensflare (rs_stage_t *stage, char **token)
804
stage->lensflare = true;
806
void rs_stage_normalmap (rs_stage_t *stage, char **token)
808
stage->normalmap = true;
802
void rs_stage_lensflare (rs_stage_t *stage, char **token)
804
stage->lensflare = true;
806
void rs_stage_normalmap (rs_stage_t *stage, char **token)
808
stage->normalmap = true;
810
810
static rs_stagekey_t rs_stagekeys[] =
812
812
{ "colormap", &rs_stage_colormap },
813
813
{ "map", &rs_stage_map },
814
814
{ "model", &rs_stage_model },
815
{ "scroll", &rs_stage_scroll },
815
{ "scroll", &rs_stage_scroll },
816
816
{ "frames", &rs_stage_frames },
817
817
{ "blendfunc", &rs_stage_blendfunc },
818
818
{ "alphashift", &rs_stage_alphashift },
827
827
{ "angle", &rs_stage_angle },
828
828
{ "scale", &rs_stage_scale },
829
829
{ "dynamic", &rs_stage_dynamic },
830
{ "alphafunc", &rs_stage_alphafunc },
831
{ "lensflare", &rs_stage_lensflare },
830
{ "alphafunc", &rs_stage_alphafunc },
831
{ "lensflare", &rs_stage_lensflare },
832
832
{ "normalmap", &rs_stage_normalmap },
1024
1023
void RS_ScanPathForScripts (void)
1026
1025
char script[MAX_OSPATH];
1027
char dirstring[1024], *c;
1029
int script_count, i;
1033
path = FS_NextPath(path);
1034
Com_sprintf(dirstring, sizeof(dirstring), "%s/scripts/*.rscript", path);
1035
if ((script_list = FS_ListFiles(dirstring, &script_count, SFF_SUBDIR, 0)) != 0)
1042
for (i = 0; i < script_count-1; i++)
1044
c = COM_SkipPath(script_list[i]);
1045
Com_sprintf(script, MAX_OSPATH, "scripts/%s", c);
1046
RS_LoadScript(script);
1049
FS_FreeFileList(script_list, script_count);
1051
if(gl_normalmaps->value) { //search for normal map scripts ONLY if we are using normal mapping
1054
path = FS_NextPath(path);
1055
Com_sprintf(dirstring, sizeof(dirstring), "%s/scripts/normals/*.rscript", path);
1056
if ((script_list = FS_ListFiles(dirstring, &script_count, SFF_SUBDIR, 0)) != 0)
1063
for (i = 0; i < script_count-1; i++)
1065
c = COM_SkipPath(script_list[i]);
1066
Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
1067
RS_LoadScript(script);
1070
FS_FreeFileList(script_list, script_count);
1074
void RS_ScanPathForScripts (void)
1076
char script[MAX_OSPATH];
1077
char dirstring[1024], *c;
1079
struct _finddata_t fileinfo;
1080
char *dir = FS_Gamedir();
1081
char *basedir = va("./%s", BASEDIRNAME);
1083
if (strcmp(dir,basedir))
1086
Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/*.rscript", basedir);
1087
handle = _findfirst (dirstring, &fileinfo);
1093
if (fileinfo.name[0] == '.')
1096
c = COM_SkipPath(fileinfo.name);
1097
Com_sprintf(script, MAX_OSPATH, "scripts/%s", c);
1098
RS_LoadScript (script);
1099
} while (_findnext( handle, &fileinfo ) != -1);
1101
_findclose (handle);
1106
Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/*.rscript", dir);
1107
handle = _findfirst (dirstring, &fileinfo);
1113
if (fileinfo.name[0] == '.')
1116
c = COM_SkipPath(fileinfo.name);
1026
char **script_list, *c;
1027
int script_count, i;
1030
script_list = FS_ListFilesInFS("scripts/*.rscript", &script_count, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);
1033
for (i = 0; i < script_count; i++)
1035
c = COM_SkipPath(script_list[i]);
1117
1036
Com_sprintf(script, MAX_OSPATH, "scripts/%s", c);
1118
RS_LoadScript (script);
1119
} while (_findnext( handle, &fileinfo ) != -1);
1121
_findclose (handle);
1124
if(gl_normalmaps->value) { //search for normal map scripts ONLY if we are using normal mapping
1126
if (strcmp(dir,basedir))
1129
Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/normals/*.rscript", basedir);
1130
handle = _findfirst (dirstring, &fileinfo);
1136
if (fileinfo.name[0] == '.')
1139
c = COM_SkipPath(fileinfo.name);
1140
Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
1141
RS_LoadScript (script);
1142
} while (_findnext( handle, &fileinfo ) != -1);
1144
_findclose (handle);
1149
Com_sprintf (dirstring, sizeof(dirstring), "%s/scripts/normals/*.rscript", dir);
1150
handle = _findfirst (dirstring, &fileinfo);
1156
if (fileinfo.name[0] == '.')
1159
c = COM_SkipPath(fileinfo.name);
1160
Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
1161
RS_LoadScript (script);
1162
} while (_findnext( handle, &fileinfo ) != -1);
1164
_findclose (handle);
1037
RS_LoadScript(script);
1040
FS_FreeFileList(script_list, script_count);
1044
if(gl_normalmaps->value) { //search for normal map scripts ONLY if we are using normal mapping
1046
script_list = FS_ListFilesInFS("scripts/normals/*.rscript", &script_count, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);
1049
for (i = 0; i < script_count; i++)
1051
c = COM_SkipPath(script_list[i]);
1052
Com_sprintf(script, MAX_OSPATH, "scripts/normals/%s", c);
1053
RS_LoadScript(script);
1056
FS_FreeFileList(script_list, script_count);
1170
1061
void RS_SetEnvmap (vec3_t v, float *os, float *ot)
1222
__inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
1224
_inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
1227
float cost = cos(degrees), sint = sin(degrees);
1228
float is = *os, it = *ot, c_s, c_t;
1230
c_s = fa->c_s - (int)fa->c_s;
1231
c_t = fa->c_t - (int)fa->c_t;
1233
*os = cost * (is - c_s) + sint * (c_t - it) + c_s;
1234
*ot = cost * (it - c_t) + sint * (is - c_s) + c_t;
1113
__inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
1115
_inline void RS_RotateST (float *os, float *ot, float degrees, msurface_t *fa)
1118
float cost = cos(degrees), sint = sin(degrees);
1119
float is = *os, it = *ot, c_s, c_t;
1121
c_s = fa->c_s - (int)fa->c_s;
1122
c_t = fa->c_t - (int)fa->c_t;
1124
*os = cost * (is - c_s) + sint * (c_t - it) + c_s;
1125
*ot = cost * (it - c_t) + sint * (is - c_s) + c_t;
1238
1129
#ifdef __unix__
1239
1130
__inline void RS_RotateST2 (float *os, float *ot, float degrees)
1247
1138
*os = cost * (is - 0.5) + sint * (0.5 - it) + 0.5;
1248
1139
*ot = cost * (it - 0.5) + sint * (is - 0.5) + 0.5;
1251
void RS_SetTexcoords (rs_stage_t *stage, float *os, float *ot, msurface_t *fa)
1253
RS_ScaleTexcoords(stage, os, ot);
1256
if (stage->rot_speed)
1257
RS_RotateST (os, ot, -stage->rot_speed * rs_realtime * 0.0087266388888888888888888888888889, fa);
1142
void RS_SetTexcoords (rs_stage_t *stage, float *os, float *ot, msurface_t *fa)
1144
RS_ScaleTexcoords(stage, os, ot);
1147
if (stage->rot_speed)
1148
RS_RotateST (os, ot, -stage->rot_speed * rs_realtime * 0.0087266388888888888888888888888889, fa);
1260
1151
void RS_SetTexcoords2D (rs_stage_t *stage, float *os, float *ot)
1262
float txm = 0, tym = 0;
1153
float txm = 0, tym = 0;
1265
1156
if (stage->scale.scaleX)
1571
1465
GLSTATE_DISABLE_ALPHATEST
1573
if(stage->normalmap)
1576
qglDepthMask (GL_FALSE);
1577
qglEnable (GL_BLEND);
1579
// set the correct blending mode for normal maps
1580
qglBlendFunc (GL_ZERO, GL_SRC_COLOR);
1582
GL_SelectTexture(GL_TEXTURE0_ARB);
1583
GL_MBind (GL_TEXTURE0_ARB, stage->texture->texnum);
1584
qglEnable (GL_TEXTURE_2D);
1585
qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
1586
qglTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_DOT3_RGB_ARB);
1588
qglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
1589
qglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
1590
qglTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PRIMARY_COLOR_ARB);
1591
qglTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
1596
1468
if (rs->subdivide)