2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2005-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2013-06-23 07:49:34 +00:00
|
|
|
/*
|
|
|
|
** gl_glow.cpp
|
|
|
|
** Glowing flats like Doomsday
|
|
|
|
**
|
2016-09-14 18:01:13 +00:00
|
|
|
**/
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "sc_man.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "r_defs.h"
|
|
|
|
#include "textures/textures.h"
|
|
|
|
|
|
|
|
#include "gl/dynlights/gl_glow.h"
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Reads glow definitions from GLDEFS
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
void gl_InitGlow(FScanner &sc)
|
|
|
|
{
|
|
|
|
sc.MustGetStringName("{");
|
|
|
|
while (!sc.CheckString("}"))
|
|
|
|
{
|
|
|
|
sc.MustGetString();
|
|
|
|
if (sc.Compare("FLATS"))
|
|
|
|
{
|
|
|
|
sc.MustGetStringName("{");
|
|
|
|
while (!sc.CheckString("}"))
|
|
|
|
{
|
|
|
|
sc.MustGetString();
|
|
|
|
FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Flat,FTextureManager::TEXMAN_TryAny);
|
|
|
|
FTexture *tex = TexMan[flump];
|
2016-12-28 20:35:42 +00:00
|
|
|
if (tex) tex->gl_info.bAutoGlowing = tex->gl_info.bGlowing = tex->gl_info.bFullbright = true;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sc.Compare("WALLS"))
|
|
|
|
{
|
|
|
|
sc.MustGetStringName("{");
|
|
|
|
while (!sc.CheckString("}"))
|
|
|
|
{
|
|
|
|
sc.MustGetString();
|
|
|
|
FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Wall,FTextureManager::TEXMAN_TryAny);
|
|
|
|
FTexture *tex = TexMan[flump];
|
2016-12-28 20:35:42 +00:00
|
|
|
if (tex) tex->gl_info.bAutoGlowing = tex->gl_info.bGlowing = tex->gl_info.bFullbright = true;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sc.Compare("TEXTURE"))
|
|
|
|
{
|
|
|
|
sc.SetCMode(true);
|
|
|
|
sc.MustGetString();
|
|
|
|
FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Flat,FTextureManager::TEXMAN_TryAny);
|
|
|
|
FTexture *tex = TexMan[flump];
|
|
|
|
sc.MustGetStringName(",");
|
|
|
|
sc.MustGetString();
|
|
|
|
PalEntry color = V_GetColor(NULL, sc.String);
|
|
|
|
//sc.MustGetStringName(",");
|
|
|
|
//sc.MustGetNumber();
|
|
|
|
if (sc.CheckString(","))
|
|
|
|
{
|
|
|
|
if (sc.CheckNumber())
|
|
|
|
{
|
|
|
|
if (tex) tex->gl_info.GlowHeight = sc.Number;
|
|
|
|
if (!sc.CheckString(",")) goto skip_fb;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc.MustGetStringName("fullbright");
|
|
|
|
if (tex) tex->gl_info.bFullbright = true;
|
|
|
|
}
|
|
|
|
skip_fb:
|
|
|
|
sc.SetCMode(false);
|
|
|
|
|
|
|
|
if (tex && color != 0)
|
|
|
|
{
|
2016-12-28 20:35:42 +00:00
|
|
|
tex->gl_info.bAutoGlowing = false;
|
2013-06-23 07:49:34 +00:00
|
|
|
tex->gl_info.bGlowing = true;
|
|
|
|
tex->gl_info.GlowColor = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Checks whether a sprite should be affected by a glow
|
|
|
|
//
|
|
|
|
//==========================================================================
|
2016-12-28 20:35:42 +00:00
|
|
|
int gl_CheckSpriteGlow(sector_t *sector, int lightlevel, const DVector3 &pos)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-12-28 20:35:42 +00:00
|
|
|
float bottomglowcolor[4];
|
|
|
|
bottomglowcolor[3] = 0;
|
|
|
|
auto c = sector->planes[sector_t::floor].GlowColor;
|
|
|
|
if (c == 0)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-12-28 20:35:42 +00:00
|
|
|
FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)];
|
|
|
|
if (tex != NULL && tex->isGlowing())
|
|
|
|
{
|
|
|
|
if (!tex->gl_info.bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor));
|
|
|
|
if (tex->isGlowing()) // recheck the current animation frame.
|
|
|
|
{
|
|
|
|
tex->GetGlowColor(bottomglowcolor);
|
|
|
|
bottomglowcolor[3] = (float)tex->gl_info.GlowHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-06 10:43:27 +00:00
|
|
|
else if (c != ~0u)
|
2016-12-28 20:35:42 +00:00
|
|
|
{
|
|
|
|
bottomglowcolor[0] = c.r / 255.f;
|
|
|
|
bottomglowcolor[1] = c.g / 255.f;
|
|
|
|
bottomglowcolor[2] = c.b / 255.f;
|
|
|
|
bottomglowcolor[3] = sector->planes[sector_t::floor].GlowHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bottomglowcolor[3]> 0)
|
|
|
|
{
|
|
|
|
double floordiff = pos.Z - sector->floorplane.ZatPoint(pos);
|
|
|
|
if (floordiff < bottomglowcolor[3])
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-03-31 19:42:27 +00:00
|
|
|
int maxlight = (255 + lightlevel) >> 1;
|
2016-12-28 20:35:42 +00:00
|
|
|
double lightfrac = floordiff / bottomglowcolor[3];
|
2016-03-31 19:42:27 +00:00
|
|
|
if (lightfrac < 0) lightfrac = 0;
|
|
|
|
lightlevel = int(lightfrac*lightlevel + maxlight*(1 - lightfrac));
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return lightlevel;
|
|
|
|
}
|
|
|
|
|
2016-12-28 20:35:42 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// Checks whether a wall should glow
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
bool gl_GetWallGlow(sector_t *sector, float *topglowcolor, float *bottomglowcolor)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
bottomglowcolor[3] = topglowcolor[3] = 0;
|
|
|
|
auto c = sector->planes[sector_t::ceiling].GlowColor;
|
|
|
|
if (c == 0)
|
|
|
|
{
|
|
|
|
FTexture *tex = TexMan[sector->GetTexture(sector_t::ceiling)];
|
|
|
|
if (tex != NULL && tex->isGlowing())
|
|
|
|
{
|
|
|
|
if (!tex->gl_info.bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::ceiling));
|
|
|
|
if (tex->isGlowing()) // recheck the current animation frame.
|
|
|
|
{
|
|
|
|
ret = true;
|
|
|
|
tex->GetGlowColor(topglowcolor);
|
|
|
|
topglowcolor[3] = (float)tex->gl_info.GlowHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-06 10:43:27 +00:00
|
|
|
else if (c != ~0u)
|
2016-12-28 20:35:42 +00:00
|
|
|
{
|
|
|
|
topglowcolor[0] = c.r / 255.f;
|
|
|
|
topglowcolor[1] = c.g / 255.f;
|
|
|
|
topglowcolor[2] = c.b / 255.f;
|
|
|
|
topglowcolor[3] = sector->planes[sector_t::ceiling].GlowHeight;
|
|
|
|
ret = topglowcolor[3] > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
c = sector->planes[sector_t::floor].GlowColor;
|
|
|
|
if (c == 0)
|
|
|
|
{
|
|
|
|
FTexture *tex = TexMan[sector->GetTexture(sector_t::floor)];
|
|
|
|
if (tex != NULL && tex->isGlowing())
|
|
|
|
{
|
|
|
|
if (!tex->gl_info.bAutoGlowing) tex = TexMan(sector->GetTexture(sector_t::floor));
|
|
|
|
if (tex->isGlowing()) // recheck the current animation frame.
|
|
|
|
{
|
|
|
|
ret = true;
|
|
|
|
tex->GetGlowColor(bottomglowcolor);
|
|
|
|
bottomglowcolor[3] = (float)tex->gl_info.GlowHeight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-06 10:43:27 +00:00
|
|
|
else if (c != ~0u)
|
2016-12-28 20:35:42 +00:00
|
|
|
{
|
|
|
|
bottomglowcolor[0] = c.r / 255.f;
|
|
|
|
bottomglowcolor[1] = c.g / 255.f;
|
|
|
|
bottomglowcolor[2] = c.b / 255.f;
|
|
|
|
bottomglowcolor[3] = sector->planes[sector_t::floor].GlowHeight;
|
|
|
|
ret = bottomglowcolor[3] > 0;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "c_dispatch.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
|
|
|
|
CCMD(setglow)
|
|
|
|
{
|
|
|
|
auto s = players[0].mo->Sector;
|
|
|
|
s->planes[sector_t::floor].GlowHeight = 128;
|
|
|
|
s->planes[sector_t::floor].GlowColor = 0xff0000;
|
2017-01-05 13:45:15 +00:00
|
|
|
}
|