Add UDMF colormap fields
This commit is contained in:
parent
cae99654be
commit
e545e5f9ba
|
@ -1130,8 +1130,7 @@ static void P_LoadSidedefs(UINT8 *data)
|
||||||
case 455: // Fade colormaps! mazmazz 9/12/2018 (:flag_us:)
|
case 455: // Fade colormaps! mazmazz 9/12/2018 (:flag_us:)
|
||||||
// SoM: R_CreateColormap will only create a colormap in software mode...
|
// SoM: R_CreateColormap will only create a colormap in software mode...
|
||||||
// Perhaps we should just call it instead of doing the calculations here.
|
// Perhaps we should just call it instead of doing the calculations here.
|
||||||
sd->colormap_data = R_CreateColormap(msd->toptexture, msd->midtexture,
|
sd->colormap_data = R_CreateColormapFromLinedef(msd->toptexture, msd->midtexture, msd->bottomtexture);
|
||||||
msd->bottomtexture);
|
|
||||||
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1384,6 +1383,19 @@ static void ParseTextmapVertexParameter(UINT32 i, char *param, char *val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct textmap_colormap_s {
|
||||||
|
boolean used;
|
||||||
|
INT32 lightcolor;
|
||||||
|
UINT8 lightalpha;
|
||||||
|
INT32 fadecolor;
|
||||||
|
UINT8 fadealpha;
|
||||||
|
UINT8 fadestart;
|
||||||
|
UINT8 fadeend;
|
||||||
|
UINT8 flags;
|
||||||
|
} textmap_colormap_t;
|
||||||
|
|
||||||
|
textmap_colormap_t textmap_colormap = { false, 0, 25, 0, 25, 0, 31, 0 };
|
||||||
|
|
||||||
static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
|
static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
|
||||||
{
|
{
|
||||||
if (fastcmp(param, "heightfloor"))
|
if (fastcmp(param, "heightfloor"))
|
||||||
|
@ -1412,6 +1424,46 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
|
||||||
sectors[i].floorpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
|
sectors[i].floorpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
|
||||||
else if (fastcmp(param, "rotationceiling"))
|
else if (fastcmp(param, "rotationceiling"))
|
||||||
sectors[i].ceilingpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
|
sectors[i].ceilingpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
|
||||||
|
else if (fastcmp(param, "lightcolor"))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.lightcolor = atol(val);
|
||||||
|
}
|
||||||
|
else if (fastcmp(param, "lightalpha"))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.lightalpha = atol(val);
|
||||||
|
}
|
||||||
|
else if (fastcmp(param, "fadecolor"))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.fadecolor = atol(val);
|
||||||
|
}
|
||||||
|
else if (fastcmp(param, "fadealpha"))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.fadealpha = atol(val);
|
||||||
|
}
|
||||||
|
else if (fastcmp(param, "fadestart"))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.fadestart = atol(val);
|
||||||
|
}
|
||||||
|
else if (fastcmp(param, "fadeend"))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.fadeend = atol(val);
|
||||||
|
}
|
||||||
|
else if (fastcmp(param, "colormapfog") && fastcmp("true", val))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.flags |= CMF_FOG;
|
||||||
|
}
|
||||||
|
else if (fastcmp(param, "colormapfadesprites") && fastcmp("true", val))
|
||||||
|
{
|
||||||
|
textmap_colormap.used = true;
|
||||||
|
textmap_colormap.flags |= CMF_FADEFULLBRIGHTSPRITES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ParseTextmapSidedefParameter(UINT32 i, char *param, char *val)
|
static void ParseTextmapSidedefParameter(UINT32 i, char *param, char *val)
|
||||||
|
@ -1585,6 +1637,14 @@ static void TextmapFixFlatOffsets(sector_t *sec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static INT32 P_ColorToRGBA(INT32 color, UINT8 alpha)
|
||||||
|
{
|
||||||
|
UINT8 r = (color >> 16) & 0xFF;
|
||||||
|
UINT8 g = (color >> 8) & 0xFF;
|
||||||
|
UINT8 b = color & 0xFF;
|
||||||
|
return R_PutRgbaRGBA(r, g, b, alpha);
|
||||||
|
}
|
||||||
|
|
||||||
/** Loads the textmap data, after obtaining the elements count and allocating their respective space.
|
/** Loads the textmap data, after obtaining the elements count and allocating their respective space.
|
||||||
*/
|
*/
|
||||||
static void P_LoadTextmap(void)
|
static void P_LoadTextmap(void)
|
||||||
|
@ -1638,8 +1698,22 @@ static void P_LoadTextmap(void)
|
||||||
|
|
||||||
sc->floorpic_angle = sc->ceilingpic_angle = 0;
|
sc->floorpic_angle = sc->ceilingpic_angle = 0;
|
||||||
|
|
||||||
|
textmap_colormap.used = false;
|
||||||
|
textmap_colormap.lightcolor = 0;
|
||||||
|
textmap_colormap.lightalpha = 25;
|
||||||
|
textmap_colormap.fadecolor = 0;
|
||||||
|
textmap_colormap.fadealpha = 25;
|
||||||
|
textmap_colormap.fadestart = 0;
|
||||||
|
textmap_colormap.fadeend = 31;
|
||||||
|
textmap_colormap.flags = 0;
|
||||||
TextmapParse(sectorsPos[i], i, ParseTextmapSectorParameter);
|
TextmapParse(sectorsPos[i], i, ParseTextmapSectorParameter);
|
||||||
P_InitializeSector(sc);
|
P_InitializeSector(sc);
|
||||||
|
if (textmap_colormap.used)
|
||||||
|
{
|
||||||
|
INT32 rgba = P_ColorToRGBA(textmap_colormap.lightcolor, textmap_colormap.lightalpha);
|
||||||
|
INT32 fadergba = P_ColorToRGBA(textmap_colormap.fadecolor, textmap_colormap.fadealpha);
|
||||||
|
sc->extra_colormap = R_CreateColormap(rgba, fadergba, textmap_colormap.fadestart, textmap_colormap.fadeend, textmap_colormap.flags);
|
||||||
|
}
|
||||||
TextmapFixFlatOffsets(sc);
|
TextmapFixFlatOffsets(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
26
src/r_data.c
26
src/r_data.c
|
@ -2046,7 +2046,7 @@ extracolormap_t *R_ColormapForName(char *name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_CreateColormap
|
// R_CreateColormapFromLinedef
|
||||||
//
|
//
|
||||||
// This is a more GL friendly way of doing colormaps: Specify colormap
|
// This is a more GL friendly way of doing colormaps: Specify colormap
|
||||||
// data in a special linedef's texture areas and use that to generate
|
// data in a special linedef's texture areas and use that to generate
|
||||||
|
@ -2185,10 +2185,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
|
||||||
return lighttable;
|
return lighttable;
|
||||||
}
|
}
|
||||||
|
|
||||||
extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3)
|
extracolormap_t *R_CreateColormapFromLinedef(char *p1, char *p2, char *p3)
|
||||||
{
|
{
|
||||||
extracolormap_t *extra_colormap, *exc;
|
|
||||||
|
|
||||||
// default values
|
// default values
|
||||||
UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25;
|
UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25;
|
||||||
UINT32 fadestart = 0, fadeend = 31;
|
UINT32 fadestart = 0, fadeend = 31;
|
||||||
|
@ -2311,6 +2309,13 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3)
|
||||||
rgba = R_PutRgbaRGBA(cr, cg, cb, ca);
|
rgba = R_PutRgbaRGBA(cr, cg, cb, ca);
|
||||||
fadergba = R_PutRgbaRGBA(cfr, cfg, cfb, cfa);
|
fadergba = R_PutRgbaRGBA(cfr, cfg, cfb, cfa);
|
||||||
|
|
||||||
|
return R_CreateColormap(rgba, fadergba, fadestart, fadeend, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
extracolormap_t *R_CreateColormap(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags)
|
||||||
|
{
|
||||||
|
extracolormap_t *extra_colormap;
|
||||||
|
|
||||||
// Did we just make a default colormap?
|
// Did we just make a default colormap?
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, flags, LUMPERROR))
|
if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, flags, LUMPERROR))
|
||||||
|
@ -2322,17 +2327,16 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3)
|
||||||
|
|
||||||
// Look for existing colormaps
|
// Look for existing colormaps
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags, LUMPERROR);
|
extra_colormap = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags, LUMPERROR);
|
||||||
#else
|
#else
|
||||||
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags);
|
extra_colormap = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags);
|
||||||
#endif
|
#endif
|
||||||
if (exc)
|
if (extra_colormap)
|
||||||
return exc;
|
return extra_colormap;
|
||||||
|
|
||||||
CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%x) fadergba(%x)\n", rgba, fadergba);
|
||||||
cr, cg, cb, ca, cfr, cfg, cfb, cfa);
|
|
||||||
|
|
||||||
extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL);
|
extra_colormap = Z_Calloc(sizeof(*extra_colormap), PU_LEVEL, NULL);
|
||||||
|
|
||||||
extra_colormap->fadestart = (UINT16)fadestart;
|
extra_colormap->fadestart = (UINT16)fadestart;
|
||||||
extra_colormap->fadeend = (UINT16)fadeend;
|
extra_colormap->fadeend = (UINT16)fadeend;
|
||||||
|
|
|
@ -147,7 +147,8 @@ boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, bo
|
||||||
extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap);
|
extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap);
|
||||||
|
|
||||||
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
|
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
|
||||||
extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3);
|
extracolormap_t * R_CreateColormapFromLinedef(char *p1, char *p2, char *p3);
|
||||||
|
extracolormap_t* R_CreateColormap(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags);
|
||||||
extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend,
|
extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend,
|
||||||
boolean subR, boolean subG, boolean subB, boolean subA,
|
boolean subR, boolean subG, boolean subB, boolean subA,
|
||||||
boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA,
|
boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA,
|
||||||
|
|
Loading…
Reference in New Issue