Added functionality for rendering only sides/planes of a 3D floor

This commit is contained in:
MascaraSnake 2016-01-13 19:27:21 +01:00
parent f54af8087f
commit 36ec727743
5 changed files with 35 additions and 23 deletions

View File

@ -39,29 +39,29 @@ namespace CodeImp.DoomBuilder.IO
public SRB2MapSetIO(WAD wad, MapManager manager) : base(wad, manager)
{
//Dictionary contents: Type, flags, translucency, flags when noclimb is active
//Type: 1 = solid, 2 = water, 3 = intangible, +4 = render insides
//Type: 1 = solid, 2 = water, 3 = intangible, +4 = render insides, +64 = don't render planes, +128 = don't render sides
//Flags: 1 = disable lighting effects (e.g. shadows), 2 = restrict lighting effects to insides, 4 = fog
//Translucency: 0 = invisible, 1 = read from front upper texture, 2 = opaque
threeDFloorTypes = new Dictionary<int, int[]>() {
{ 100, new int[4] { 1, 0, 2, 0} },
{ 101, new int[4] { 1, 1, 2, 1} },
{ 102, new int[4] { 1, 1, 1, 1} },
{ 103, new int[4] { 1, 1, 2, 1} },
{ 104, new int[4] { 1, 1, 2, 0} },
{ 103, new int[4] { 65, 1, 2, 1} },
{ 104, new int[4] { 129, 1, 2, 0} },
{ 105, new int[4] { 1, 1, 0, 1} },
{ 120, new int[4] { 6, 0, 2, 2} },
{ 121, new int[4] { 6, 0, 1, 2} },
{ 122, new int[4] { 6, 0, 2, 2} },
{ 123, new int[4] { 6, 0, 1, 2} },
{ 122, new int[4] { 134, 0, 2, 2} },
{ 123, new int[4] { 134, 0, 1, 2} },
{ 124, new int[4] { 6, 0, 1, 2} },
{ 125, new int[4] { 6, 0, 1, 2} },
{ 125, new int[4] { 134, 0, 1, 2} },
{ 140, new int[4] { 1, 0, 2, 1} },
{ 141, new int[4] { 1, 0, 1, 1} },
{ 142, new int[4] { 1, 0, 1, 1} },
{ 142, new int[4] { 129, 0, 1, 1} },
{ 143, new int[4] { 1, 0, 2, 1} },
{ 144, new int[4] { 1, 0, 1, 1} },
{ 145, new int[4] { 1, 0, 1, 1} },
{ 146, new int[4] { 1, 0, 2, 1} },
{ 145, new int[4] { 129, 0, 1, 1} },
{ 146, new int[4] { 65, 0, 2, 1} },
{ 150, new int[4] { 1, 0, 2, 0} },
{ 151, new int[4] { 1, 0, 2, 0} },
{ 152, new int[4] { 1, 0, 2, 0} },
@ -88,7 +88,7 @@ namespace CodeImp.DoomBuilder.IO
{ 202, new int[4] { 7, 5, 2, 5} },
{ 220, new int[4] { 3, 0, 2, 0} },
{ 221, new int[4] { 3, 1, 1, 0} },
{ 222, new int[4] { 3, 1, 2, 0} },
{ 222, new int[4] { 67, 1, 2, 0} },
{ 223, new int[4] { 3, 1, 0, 1} },
{ 250, new int[4] { 1, 0, 2, 0} },
{ 251, new int[4] { 1, 0, 2, 0} },

View File

@ -782,7 +782,9 @@ namespace CodeImp.DoomBuilder.Map
int value = Convert.ToInt32(tex, 16);
bool exists = (value & 0x1) == 0x1; //FF_EXISTS
bool solid = ((value & 0x2) == 0x2) || ((value & 0x4) == 0x4); //FF_BLOCKPLAYER/FF_BLOCKOTHERS/FF_SOLID
bool render = ((value & 0x8) == 0x8) || ((value & 0x10) == 0x10); //FF_RENDERSIDES/FF_RENDERPLANES/FF_RENDERALL
bool rendersides = (value & 0x8) == 0x8; //FF_RENDERSIDES
bool renderplanes = (value & 0x10) == 0x10; //FF_RENDERPLANES
bool render = rendersides || renderplanes;
bool water = (value & 0x20) == 0x20; //FF_SWIMMABLE
bool noshade = (value & 0x40) == 0x40; //FF_NOSHADE
bool translucent = (value & 0x1000) == 0x1000; //FF_TRANSLUCENT
@ -793,6 +795,8 @@ namespace CodeImp.DoomBuilder.Map
{
Args[1] = water ? 2 : (solid ? 1 : 3);
if (inside) Args[1] += 4;
if (!renderplanes) Args[1] += 64;
if (!rendersides) Args[1] += 128;
}
if (noshade) Args[2] += 1;
if (doubleshadow) Args[2] += 2;

View File

@ -51,9 +51,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
public bool IgnoreBottomHeight { get { return ignorebottomheight; } } //mxd
public bool Sloped3dFloor { get { return sloped3dfloor; } } //mxd
public bool ClipSidedefs { get { return clipsides; } } //mxd
public bool DontRenderPlanes { get { return General.Map.SRB2 && (linedef.Args[1] & (int)FloorTypes.DontRenderPlanes) == (int)FloorTypes.DontRenderPlanes; } }
public bool DontRenderSides { get { return General.Map.SRB2 && (linedef.Args[1] & (int)FloorTypes.DontRenderSides) == (int)FloorTypes.DontRenderSides; } }
//mxd. 3D-Floor Flags
[Flags]
//mxd. 3D-Floor Flags
[Flags]
public enum Flags
{
None = 0,
@ -77,7 +79,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
RenderInside = 4,
HiTagIsLineID = 8,
InvertVisibilityRules = 16,
InvertShootabilityRules = 32
InvertShootabilityRules = 32,
//Fake flags added for SRB2
DontRenderPlanes = 64,
DontRenderSides = 128
}
// Constructor
@ -153,9 +158,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(sd.FloorGlow == null || !sd.FloorGlow.Fullbright) ceiling.color = 0;
}
// Apply alpha
floor.alpha = alpha;
ceiling.alpha = alpha;
// Apply alpha
floor.alpha = DontRenderPlanes ? 0 : alpha;
ceiling.alpha = DontRenderPlanes ? 0 : alpha;
//mxd
floor.extrafloor = true;

View File

@ -277,15 +277,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
List<WorldVertex> verts = CreatePolygonVertices(polygons, tp, sd, lightvalue, lightabsolute);
if(verts.Count > 2)
{
if(extrafloor.Sloped3dFloor) this.RenderPass = RenderPass.Mask; //mxd
if (extrafloor.Sloped3dFloor) this.RenderPass = RenderPass.Mask; //mxd
else if(extrafloor.RenderAdditive) this.RenderPass = RenderPass.Additive; //mxd
else if(extrafloor.Alpha < 255) this.RenderPass = RenderPass.Alpha;
else if(extrafloor.Alpha < 255 || extrafloor.DontRenderSides) this.RenderPass = RenderPass.Alpha;
else this.RenderPass = RenderPass.Mask;
if(extrafloor.Alpha < 255)
if(extrafloor.Alpha < 255 || extrafloor.DontRenderSides)
{
// Apply alpha to vertices
byte alpha = (byte)General.Clamp(extrafloor.Alpha, 0, 255);
if (extrafloor.DontRenderSides) alpha = 0;
if(alpha < 255)
{
for(int i = 0; i < verts.Count; i++)

View File

@ -206,7 +206,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. This calculates light with doom-style wall shading
PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel, Sidedef));
int wallcolor = PixelColor.Modulate(levelcolor, wallbrightness).WithAlpha((byte)extrafloor.Alpha).ToInt();
byte alpha = (byte)extrafloor.Alpha;
if (extrafloor.DontRenderSides) alpha = 0;
int wallcolor = PixelColor.Modulate(levelcolor, wallbrightness).WithAlpha(alpha).ToInt();
fogfactor = CalculateFogDensity(lightlevel);
// Cut off the part above the 3D floor and below the 3D ceiling
@ -258,9 +260,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
List<WorldVertex> verts = CreatePolygonVertices(polygons, tp, sd, lightvalue, lightabsolute);
if(verts.Count > 2)
{
if(extrafloor.Sloped3dFloor) this.RenderPass = RenderPass.Mask; //mxd
if (extrafloor.Sloped3dFloor) this.RenderPass = RenderPass.Mask; //mxd
else if(extrafloor.RenderAdditive) this.RenderPass = RenderPass.Additive; //mxd
else if(extrafloor.Alpha < 255) this.RenderPass = RenderPass.Alpha;
else if(extrafloor.Alpha < 255 || extrafloor.DontRenderSides) this.RenderPass = RenderPass.Alpha;
else this.RenderPass = RenderPass.Mask;
//mxd. Inner sides always have extrafloor color