From 094749feb4e37afcb86c6bf2486e76c8f50d8fa4 Mon Sep 17 00:00:00 2001 From: codeimp Date: Wed, 15 Sep 2010 20:41:40 +0000 Subject: [PATCH] @ (G)ZDoom Editing plugin: Support for UDMF light levels, individual texture scaling and offsets on sidedefs --- .../GZDoomEditing/GZDoomEditing.csproj | 4 +- .../VisualModes/BaseVisualGeometrySidedef.cs | 5 ++- .../GZDoomEditing/VisualModes/SectorData.cs | 22 ++++------ .../VisualModes/VisualCeiling.cs | 22 +++------- .../GZDoomEditing/VisualModes/VisualFloor.cs | 22 +++------- .../GZDoomEditing/VisualModes/VisualLower.cs | 32 ++++++++------ .../VisualModes/VisualMiddle3D.cs | 39 ++++++++++-------- .../VisualModes/VisualMiddleDouble.cs | 34 +++++++++------ .../VisualModes/VisualMiddleSingle.cs | 32 ++++++++------ .../GZDoomEditing/VisualModes/VisualUpper.cs | 32 ++++++++------ Tests/UDMF/udmfexample.wad | Bin 75849 -> 75941 bytes 11 files changed, 129 insertions(+), 115 deletions(-) diff --git a/Source/Plugins/GZDoomEditing/GZDoomEditing.csproj b/Source/Plugins/GZDoomEditing/GZDoomEditing.csproj index e0b14127..b8e9fcbd 100644 --- a/Source/Plugins/GZDoomEditing/GZDoomEditing.csproj +++ b/Source/Plugins/GZDoomEditing/GZDoomEditing.csproj @@ -3,7 +3,7 @@ Debug AnyCPU - 8.0.50727 + 9.0.30729 2.0 {760A9BC7-CB73-4C36-858B-994C14996FCD} Library @@ -20,6 +20,7 @@ full x86 prompt + false ..\..\..\Build\Plugins\ @@ -29,6 +30,7 @@ pdbonly x86 prompt + false diff --git a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs index 25e3dbfc..49deb373 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/BaseVisualGeometrySidedef.cs @@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // This creates vertices from a wall polygon and applies lighting - protected List CreatePolygonVertices(WallPolygon poly, TexturePlane tp, SectorData sd) + protected List CreatePolygonVertices(WallPolygon poly, TexturePlane tp, SectorData sd, int lightvalue, bool lightabsolute) { List polygons = new List(2); List verts = new List(); @@ -183,7 +183,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing if(np.Count > 0) { // Determine color - PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(l.brightnessbelow)); + int lightlevel = lightabsolute ? lightvalue : l.brightnessbelow + lightvalue; + PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallcolor = PixelColor.Modulate(l.colorbelow, wallbrightness); np.color = wallcolor.WithAlpha(255).ToInt(); diff --git a/Source/Plugins/GZDoomEditing/VisualModes/SectorData.cs b/Source/Plugins/GZDoomEditing/VisualModes/SectorData.cs index f59deeec..6dfafe34 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/SectorData.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/SectorData.cs @@ -175,24 +175,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // This sets up the basic floor and ceiling, as they would be in normal Doom circumstances private void BasicSetup() { - int color = -1, flight = sector.Brightness, clight = sector.Brightness; - bool fabs = true, cabs = true; - // Normal (flat) floor and ceiling planes floor.plane = new Plane(new Vector3D(0, 0, 1), -sector.FloorHeight); ceiling.plane = new Plane(new Vector3D(0, 0, -1), sector.CeilHeight); - // Determine colors - try - { - // Fetch ZDoom fields - color = sector.Fields.ContainsKey("lightcolor") ? (int)sector.Fields["lightcolor"].Value : -1; - flight = sector.Fields.ContainsKey("lightfloor") ? (int)sector.Fields["lightfloor"].Value : 0; - fabs = sector.Fields.ContainsKey("lightfloorabsolute") ? (bool)sector.Fields["lightfloorabsolute"].Value : false; - clight = sector.Fields.ContainsKey("lightceiling") ? (int)sector.Fields["lightceiling"].Value : 0; - cabs = sector.Fields.ContainsKey("lightceilingabsolute") ? (bool)sector.Fields["lightceilingabsolute"].Value : false; - } - catch(Exception) { } + // Fetch ZDoom fields + int color = sector.Fields.GetValue("lightcolor", -1); + int flight = sector.Fields.GetValue("lightfloor", 0); + bool fabs = sector.Fields.GetValue("lightfloorabsolute", false); + int clight = sector.Fields.GetValue("lightceiling", 0); + bool cabs = sector.Fields.GetValue("lightceilingabsolute", false); + + // Determine colors & light levels PixelColor lightcolor = PixelColor.FromInt(color); if(!fabs) flight = sector.Brightness + flight; if(!cabs) clight = sector.Brightness + clight; diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs index 6b31a2b7..df5886d6 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualCeiling.cs @@ -70,21 +70,16 @@ namespace CodeImp.DoomBuilder.GZDoomEditing WorldVertex[] verts; WorldVertex v; Sector s = level.sector; - float xpan, ypan, xscale, yscale, rotate; Vector2D texscale; base.Setup(level); - try - { - // Fetch ZDoom fields - xpan = s.Fields.ContainsKey("xpanningceiling") ? (float)s.Fields["xpanningceiling"].Value : 0.0f; - ypan = s.Fields.ContainsKey("ypanningceiling") ? (float)s.Fields["ypanningceiling"].Value : 0.0f; - xscale = s.Fields.ContainsKey("xscaleceiling") ? (float)s.Fields["xscaleceiling"].Value : 1.0f; - yscale = s.Fields.ContainsKey("yscaleceiling") ? (float)s.Fields["yscaleceiling"].Value : 1.0f; - rotate = s.Fields.ContainsKey("rotationceiling") ? (float)s.Fields["rotationceiling"].Value : 0.0f; - } - catch(Exception) { return false; } + // Fetch ZDoom fields + float rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationceiling", 0.0f)); + Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningceiling", 0.0f), + s.Fields.GetValue("ypanningceiling", 0.0f)); + Vector2D scale = new Vector2D(s.Fields.GetValue("xscaleceiling", 1.0f), + s.Fields.GetValue("yscaleceiling", 1.0f)); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongCeilTexture); @@ -105,11 +100,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing else texscale = new Vector2D(1.0f / 64.0f, 1.0f / 64.0f); - // Prepare for math! - rotate = Angle2D.DegToRad(rotate); - Vector2D scale = new Vector2D(xscale, yscale); - Vector2D offset = new Vector2D(xpan, ypan); - // Make vertices ReadOnlyCollection triverts = base.Sector.Sector.Triangles.Vertices; verts = new WorldVertex[triverts.Count]; diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs index f037c195..258cd4f5 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualFloor.cs @@ -69,21 +69,16 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { WorldVertex[] verts; Sector s = level.sector; - float xpan, ypan, xscale, yscale, rotate; Vector2D texscale; base.Setup(level); - try - { - // Fetch ZDoom fields - xpan = s.Fields.ContainsKey("xpanningfloor") ? (float)s.Fields["xpanningfloor"].Value : 0.0f; - ypan = s.Fields.ContainsKey("ypanningfloor") ? (float)s.Fields["ypanningfloor"].Value : 0.0f; - xscale = s.Fields.ContainsKey("xscalefloor") ? (float)s.Fields["xscalefloor"].Value : 1.0f; - yscale = s.Fields.ContainsKey("yscalefloor") ? (float)s.Fields["yscalefloor"].Value : 1.0f; - rotate = s.Fields.ContainsKey("rotationfloor") ? (float)s.Fields["rotationfloor"].Value : 0.0f; - } - catch(Exception) { return false; } + // Fetch ZDoom fields + float rotate = Angle2D.DegToRad(s.Fields.GetValue("rotationfloor", 0.0f)); + Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningfloor", 0.0f), + s.Fields.GetValue("ypanningfloor", 0.0f)); + Vector2D scale = new Vector2D(s.Fields.GetValue("xscalefloor", 1.0f), + s.Fields.GetValue("yscalefloor", 1.0f)); // Load floor texture base.Texture = General.Map.Data.GetFlatImage(s.LongFloorTexture); @@ -104,11 +99,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing else texscale = new Vector2D(1.0f / 64.0f, 1.0f / 64.0f); - // Prepare for math! - rotate = Angle2D.DegToRad(rotate); - Vector2D scale = new Vector2D(xscale, yscale); - Vector2D offset = new Vector2D(xpan, ypan); - // Make vertices ReadOnlyCollection triverts = base.Sector.Sector.Triangles.Vertices; verts = new WorldVertex[triverts.Count]; diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs index f13ac220..65ee9a24 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualLower.cs @@ -67,6 +67,14 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { Vector2D vl, vr; + int lightvalue = Sidedef.Fields.GetValue("light", 0); + bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); + + Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_bottom", 1.0f), + Sidedef.Fields.GetValue("scaley_bottom", 1.0f)); + Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_bottom", 0.0f), + Sidedef.Fields.GetValue("offsety_bottom", 0.0f)); + // Left and right vertices for this sidedef if(Sidedef.IsFront) { @@ -109,6 +117,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Get texture scaled size Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); + tsz = tsz * tscale; + + // Get texture offsets + Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); + tof = tof + toffset; + if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) + tof = tof * base.Texture.Scale; // Determine texture coordinates plane as they would be in normal circumstances. // We can then use this plane to find any texture coordinate we need. @@ -127,16 +142,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing tp.trb.y = tp.tlt.y + ((float)Sidedef.Other.Sector.FloorHeight - ((float)Sidedef.Sector.FloorHeight + floorbias)); // Apply texture offset - if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) - { - tp.tlt += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - tp.trb += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - } - else - { - tp.tlt += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - tp.trb += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - } + tp.tlt += tof; + tp.trb += tof; // Transform pixel coordinates to texture coordinates tp.tlt /= tsz; @@ -158,7 +165,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing poly.Add(new Vector3D(vr.x, vr.y, sd.Floor.plane.GetZ(vr))); // Determine initial color - PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(sd.Ceiling.brightnessbelow)); + int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; + PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); @@ -173,7 +181,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing bottom = sd.Floor.plane; // Process the polygon and create vertices - List verts = CreatePolygonVertices(poly, tp, sd); + List verts = CreatePolygonVertices(poly, tp, sd, lightvalue, lightabsolute); if(verts.Count > 0) { base.SetVertices(verts); diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs index c48faf57..8e0655bb 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddle3D.cs @@ -70,8 +70,17 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { Vector2D vl, vr; Sidedef sourceside = extrafloor.Linedef.Front; - this.extrafloor = extrafloor; + + int lightvalue = Sidedef.Fields.GetValue("light", 0); + bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); + + Vector2D tscale = new Vector2D(sourceside.Fields.GetValue("scalex_mid", 1.0f), + sourceside.Fields.GetValue("scaley_mid", 1.0f)); + Vector2D toffset1 = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), + Sidedef.Fields.GetValue("offsety_mid", 0.0f)); + Vector2D toffset2 = new Vector2D(sourceside.Fields.GetValue("offsetx_mid", 0.0f), + sourceside.Fields.GetValue("offsety_mid", 0.0f)); // Left and right vertices for this sidedef if(Sidedef.IsFront) @@ -113,6 +122,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Get texture scaled size Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); + tsz = tsz * tscale; + + // Get texture offsets + Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); + tof = tof + toffset1 + toffset2; + if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) + tof = tof * base.Texture.Scale; // For Vavoom type 3D floors the ceiling is lower than floor and they are reversed. // We choose here. @@ -132,20 +148,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing tp.trb.y = tp.tlt.y + (sourcetopheight - sourcebottomheight) + floorbias; // Apply texture offset - if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) - { - tp.tlt += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - tp.trb += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - tp.tlt += new Vector2D(sourceside.OffsetX * base.Texture.Scale.x, sourceside.OffsetY * base.Texture.Scale.y); - tp.trb += new Vector2D(sourceside.OffsetX * base.Texture.Scale.x, sourceside.OffsetY * base.Texture.Scale.y); - } - else - { - tp.tlt += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - tp.trb += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - tp.tlt += new Vector2D(sourceside.OffsetX, sourceside.OffsetY); - tp.trb += new Vector2D(sourceside.OffsetX, sourceside.OffsetY); - } + tp.tlt += tof; + tp.trb += tof; // Transform pixel coordinates to texture coordinates tp.tlt /= tsz; @@ -180,7 +184,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing poly.Add(new Vector3D(vr.x, vr.y, fr)); // Determine initial color - PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(sd.Ceiling.brightnessbelow)); + int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; + PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); @@ -189,7 +194,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing CropPoly(ref poly, extrafloor.Ceiling.plane, false); // Process the polygon and create vertices - List verts = CreatePolygonVertices(poly, tp, sd); + List verts = CreatePolygonVertices(poly, tp, sd, lightvalue, lightabsolute); if(verts.Count > 0) { if(extrafloor.Alpha < 255) diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs index 33ad38e6..fe8b9280 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleDouble.cs @@ -74,6 +74,14 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { Vector2D vl, vr; + int lightvalue = Sidedef.Fields.GetValue("light", 0); + bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); + + Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_mid", 1.0f), + Sidedef.Fields.GetValue("scaley_mid", 1.0f)); + Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), + Sidedef.Fields.GetValue("offsety_mid", 0.0f)); + // Texture given? if((Sidedef.MiddleTexture.Length > 0) && (Sidedef.MiddleTexture[0] != '-')) { @@ -116,9 +124,16 @@ namespace CodeImp.DoomBuilder.GZDoomEditing base.Texture = General.Map.Data.MissingTexture3D; setuponloadedtexture = 0; } - + // Get texture scaled size Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); + tsz = tsz * tscale; + + // Get texture offsets + Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); + tof = tof + toffset; + if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) + tof = tof * base.Texture.Scale; // Determine texture coordinates plane as they would be in normal circumstances. // We can then use this plane to find any texture coordinate we need. @@ -137,16 +152,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing tp.trb.y = tp.tlt.y + ((float)Sidedef.Sector.CeilHeight - ((float)Sidedef.Sector.FloorHeight + floorbias)); // Apply texture offset - if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) - { - tp.tlt += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - tp.trb += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - } - else - { - tp.tlt += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - tp.trb += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - } + tp.tlt += tof; + tp.trb += tof; // Transform pixel coordinates to texture coordinates tp.tlt /= tsz; @@ -172,7 +179,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing poly.Add(new Vector3D(vr.x, vr.y, sd.Floor.plane.GetZ(vr))); // Determine initial color - PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(sd.Ceiling.brightnessbelow)); + int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; + PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); @@ -222,7 +230,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing bottom = osd.Floor.plane; // Process the polygon and create vertices - List verts = CreatePolygonVertices(poly, tp, sd); + List verts = CreatePolygonVertices(poly, tp, sd, lightvalue, lightabsolute); if(verts.Count > 0) { // Apply alpha to vertices diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs index ac30174b..29509079 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualMiddleSingle.cs @@ -67,6 +67,14 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { Vector2D vl, vr; + int lightvalue = Sidedef.Fields.GetValue("light", 0); + bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); + + Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_mid", 1.0f), + Sidedef.Fields.GetValue("scaley_mid", 1.0f)); + Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_mid", 0.0f), + Sidedef.Fields.GetValue("offsety_mid", 0.0f)); + // Left and right vertices for this sidedef if(Sidedef.IsFront) { @@ -107,6 +115,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Get texture scaled size Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); + tsz = tsz * tscale; + + // Get texture offsets + Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); + tof = tof + toffset; + if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) + tof = tof * base.Texture.Scale; // Determine texture coordinates plane as they would be in normal circumstances. // We can then use this plane to find any texture coordinate we need. @@ -125,16 +140,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing tp.trb.y = tp.tlt.y + ((float)Sidedef.Sector.CeilHeight - ((float)Sidedef.Sector.FloorHeight + floorbias)); // Apply texture offset - if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) - { - tp.tlt += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - tp.trb += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - } - else - { - tp.tlt += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - tp.trb += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - } + tp.tlt += tof; + tp.trb += tof; // Transform pixel coordinates to texture coordinates tp.tlt /= tsz; @@ -169,12 +176,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing poly.Add(new Vector3D(vr.x, vr.y, fr)); // Determine initial color - PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(sd.Ceiling.brightnessbelow)); + int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; + PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); // Process the polygon and create vertices - List verts = CreatePolygonVertices(poly, tp, sd); + List verts = CreatePolygonVertices(poly, tp, sd, lightvalue, lightabsolute); if(verts.Count > 0) { base.SetVertices(verts); diff --git a/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs b/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs index 15bc9cee..424bb0ad 100644 --- a/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs +++ b/Source/Plugins/GZDoomEditing/VisualModes/VisualUpper.cs @@ -68,6 +68,14 @@ namespace CodeImp.DoomBuilder.GZDoomEditing { Vector2D vl, vr; + int lightvalue = Sidedef.Fields.GetValue("light", 0); + bool lightabsolute = Sidedef.Fields.GetValue("lightabsolute", false); + + Vector2D tscale = new Vector2D(Sidedef.Fields.GetValue("scalex_top", 1.0f), + Sidedef.Fields.GetValue("scaley_top", 1.0f)); + Vector2D toffset = new Vector2D(Sidedef.Fields.GetValue("offsetx_top", 0.0f), + Sidedef.Fields.GetValue("offsety_top", 0.0f)); + // Left and right vertices for this sidedef if(Sidedef.IsFront) { @@ -110,6 +118,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing // Get texture scaled size Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); + tsz = tsz * tscale; + + // Get texture offsets + Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); + tof = tof + toffset; + if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) + tof = tof * base.Texture.Scale; // Determine texture coordinates plane as they would be in normal circumstances. // We can then use this plane to find any texture coordinate we need. @@ -128,16 +143,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing tp.trb.y = tp.tlt.y + ((float)Sidedef.Sector.CeilHeight - ((float)Sidedef.Other.Sector.CeilHeight + ceilbias)); // Apply texture offset - if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) - { - tp.tlt += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - tp.trb += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); - } - else - { - tp.tlt += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - tp.trb += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); - } + tp.tlt += tof; + tp.trb += tof; // Transform pixel coordinates to texture coordinates tp.tlt /= tsz; @@ -159,7 +166,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing poly.Add(new Vector3D(vr.x, vr.y, sd.Floor.plane.GetZ(vr))); // Determine initial color - PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(sd.Ceiling.brightnessbelow)); + int lightlevel = lightabsolute ? lightvalue : sd.Ceiling.brightnessbelow + lightvalue; + PixelColor wallbrightness = PixelColor.FromInt(mode.CalculateBrightness(lightlevel)); PixelColor wallcolor = PixelColor.Modulate(sd.Ceiling.colorbelow, wallbrightness); poly.color = wallcolor.WithAlpha(255).ToInt(); @@ -173,7 +181,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing bottom = osd.Ceiling.plane; // Process the polygon and create vertices - List verts = CreatePolygonVertices(poly, tp, sd); + List verts = CreatePolygonVertices(poly, tp, sd, lightvalue, lightabsolute); if(verts.Count > 0) { base.SetVertices(verts); diff --git a/Tests/UDMF/udmfexample.wad b/Tests/UDMF/udmfexample.wad index 78741a570bc2c77ce02634c95fc392965ce6b99f..9b99e6e9e7df45bb3338ad67b51a5e7a33c6bc81 100644 GIT binary patch delta 222 zcmX?kfo17M7S4chM;8_b28Ps)oO~?$#(D+@2G(4a3bqPHhNcisMrvkyMhQ^F(gY%q zn3tZD3gR1Wc4xV4}PX9kKrm3?Z%&A-;|Q3`#(@vnB&Wl%KzgYcSCH8jL_sFfh3Kxqze@07!j3 AUjP6A delta 145 zcmZ2_k>%tC7S4chM;8_b1_sWJoO~<>7Djpo1_st#l?t{BrWO!(MrvkyMhQ^B%n%}w zn3tZD3gjDF8f