rtexturepool_t *mod_shared_texturepool;
rtexture_t *r_notexture;
rtexture_t *mod_shared_detailtextures[NUM_DETAILTEXTURES];
-rtexture_t *mod_shared_distorttexture;
+rtexture_t *mod_shared_distorttexture[64];
void Mod_BuildDetailTextures (void)
{
}
}
+qbyte Mod_MorphDistortTexture (double y0, double y1, double y2, double y3, double morph)
+{
+ int value = (int)(((y1 + y3 - (y0 + y2)) * morph * morph * morph) +
+ ((2 * (y0 - y1) + y2 - y3) * morph * morph) +
+ ((y2 - y0) * morph) +
+ (y1));
+
+ if (value > 255)
+ value = 255;
+ if (value < 0)
+ value = 0;
+
+ return (qbyte)value;
+}
+
void Mod_BuildDistortTexture (void)
{
- int x, y;
+ int x, y, i, j;
#define DISTORTRESOLUTION 32
- qbyte data[DISTORTRESOLUTION][DISTORTRESOLUTION][2];
- for (y=0; y<DISTORTRESOLUTION; y++)
+ qbyte data[5][DISTORTRESOLUTION][DISTORTRESOLUTION][2];
+
+ for (i=0; i<4; i++)
+ {
+ for (y=0; y<DISTORTRESOLUTION; y++)
+ {
+ for (x=0; x<DISTORTRESOLUTION; x++)
+ {
+ data[i][y][x][0] = rand () & 255;
+ data[i][y][x][1] = rand () & 255;
+ }
+ }
+ }
+
+ for (i=0; i<4; i++)
{
- for (x=0; x<DISTORTRESOLUTION; x++)
+ for (j=0; j<16; j++)
{
- data[y][x][0] = rand () & 255;
- data[y][x][1] = rand () & 255;
+ for (y=0; y<DISTORTRESOLUTION; y++)
+ {
+ for (x=0; x<DISTORTRESOLUTION; x++)
+ {
+ data[4][y][x][0] = Mod_MorphDistortTexture (data[(i-1)&3][y][x][0], data[i][y][x][0], data[(i+1)&3][y][x][0], data[(i+2)&3][y][x][0], 0.0625*j);
+ data[4][y][x][1] = Mod_MorphDistortTexture (data[(i-1)&3][y][x][1], data[i][y][x][1], data[(i+1)&3][y][x][1], data[(i+2)&3][y][x][1], 0.0625*j);
+ }
+ }
+ mod_shared_distorttexture[i*16+j] = R_LoadTexture2D(mod_shared_texturepool, va("distorttexture%i", i*16+j), DISTORTRESOLUTION, DISTORTRESOLUTION, &data[4][0][0][0], TEXTYPE_DSDT, TEXF_PRECACHE, NULL);
}
}
- mod_shared_distorttexture = R_LoadTexture2D(mod_shared_texturepool, "distorttexture", DISTORTRESOLUTION, DISTORTRESOLUTION, &data[0][0][0], TEXTYPE_DSDT, TEXF_PRECACHE, NULL);
return;
}
do
{
if (words < 10)
- strncpy(word[words++], com_token, MAX_QPATH - 1);
+ strlcpy(word[words++], com_token, sizeof (word[0]));
else
wordsoverflow = true;
}
skinfileitem = Mem_Alloc(tempmempool, sizeof(skinfileitem_t));
skinfileitem->next = skinfile->items;
skinfile->items = skinfileitem;
- strncpy(skinfileitem->name, word[1], sizeof(skinfileitem->name) - 1);
- strncpy(skinfileitem->replacement, word[2], sizeof(skinfileitem->replacement) - 1);
+ strlcpy (skinfileitem->name, word[1], sizeof (skinfileitem->name));
+ strlcpy (skinfileitem->replacement, word[2], sizeof (skinfileitem->replacement));
}
else
Con_Printf("Mod_LoadSkinFiles: parsing error in file \"%s_%i.skin\" on line #%i: wrong number of parameters to command \"%s\", see documentation in DP_GFX_SKINFILES extension in dpextensions.qc\n", loadmodel->name, i, line, word[0]);
// tag name, like "tag_weapon,"
Con_DPrintf("Mod_LoadSkinFiles: parsed tag #%i \"%s\"\n", numtags, word[0]);
memset(tags + numtags, 0, sizeof(tags[numtags]));
- strncpy(tags[numtags].name, word[0], sizeof(tags[numtags].name) - 1);
+ strlcpy (tags[numtags].name, word[0], sizeof (tags[numtags].name));
numtags++;
}
else if (words == 3 && !strcmp(word[1], ","))
skinfileitem = Mem_Alloc(tempmempool, sizeof(skinfileitem_t));
skinfileitem->next = skinfile->items;
skinfile->items = skinfileitem;
- strncpy(skinfileitem->name, word[0], sizeof(skinfileitem->name) - 1);
- strncpy(skinfileitem->replacement, word[2], sizeof(skinfileitem->replacement) - 1);
+ strlcpy (skinfileitem->name, word[0], sizeof (skinfileitem->name));
+ strlcpy (skinfileitem->replacement, word[2], sizeof (skinfileitem->replacement));
}
else
Con_Printf("Mod_LoadSkinFiles: parsing error in file \"%s_%i.skin\" on line #%i: does not look like tag or mesh specification, or replace command, see documentation in DP_GFX_SKINFILES extension in dpextensions.qc\n", loadmodel->name, i, line);