@ (G)ZDoom Editing plugin: Fixed 3D floor sides texture offsets

This commit is contained in:
codeimp 2010-09-15 18:17:38 +00:00
parent 180da20c95
commit ad111d0aca
3 changed files with 22 additions and 11 deletions

View file

@ -25,13 +25,17 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Alpha transparency // Alpha transparency
private int alpha; private int alpha;
// Vavoom type?
private bool vavoomtype;
// Properties // Properties
public int Alpha { get { return alpha; } } public int Alpha { get { return alpha; } }
public SectorLevel Floor { get { return floor; } } public SectorLevel Floor { get { return floor; } }
public SectorLevel Ceiling { get { return ceiling; } } public SectorLevel Ceiling { get { return ceiling; } }
public Linedef Linedef { get { return linedef; } } public Linedef Linedef { get { return linedef; } }
public bool VavoomType { get { return vavoomtype; } }
// Constructor // Constructor
public Effect3DFloor(SectorData data, Linedef sourcelinedef) : base(data) public Effect3DFloor(SectorData data, Linedef sourcelinedef) : base(data)
{ {
@ -76,6 +80,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
int argtype = (linedef.Args[1] & 0x03); int argtype = (linedef.Args[1] & 0x03);
if(argtype != 0) if(argtype != 0)
{ {
vavoomtype = false;
alpha = linedef.Args[3]; alpha = linedef.Args[3];
sd.Ceiling.CopyProperties(floor); sd.Ceiling.CopyProperties(floor);
sd.Floor.CopyProperties(ceiling); sd.Floor.CopyProperties(ceiling);
@ -86,6 +91,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
} }
else else
{ {
vavoomtype = true;
sd.Ceiling.CopyProperties(ceiling); sd.Ceiling.CopyProperties(ceiling);
sd.Floor.CopyProperties(floor); sd.Floor.CopyProperties(floor);
alpha = 255; alpha = 255;
@ -99,7 +105,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
ceiling.alpha = alpha; ceiling.alpha = alpha;
// Do not adjust light? (works only for non-vavoom types) // Do not adjust light? (works only for non-vavoom types)
if(((linedef.Args[2] & 1) != 0) && (argtype != 0)) if(((linedef.Args[2] & 1) != 0) && !vavoomtype)
{ {
floor.brightnessbelow = -1; floor.brightnessbelow = -1;
floor.colorbelow = PixelColor.FromInt(0); floor.colorbelow = PixelColor.FromInt(0);

View file

@ -114,6 +114,11 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// Get texture scaled size // Get texture scaled size
Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight); Vector2D tsz = new Vector2D(base.Texture.ScaledWidth, base.Texture.ScaledHeight);
// For Vavoom type 3D floors the ceiling is lower than floor and they are reversed.
// We choose here.
float sourcetopheight = extrafloor.VavoomType ? sourceside.Sector.FloorHeight : sourceside.Sector.CeilHeight;
float sourcebottomheight = extrafloor.VavoomType ? sourceside.Sector.CeilHeight : sourceside.Sector.FloorHeight;
// Determine texture coordinates plane as they would be in normal circumstances. // Determine texture coordinates plane as they would be in normal circumstances.
// We can then use this plane to find any texture coordinate we need. // We can then use this plane to find any texture coordinate we need.
// The logic here is the same as in the original VisualMiddleSingle (except that // The logic here is the same as in the original VisualMiddleSingle (except that
@ -121,25 +126,25 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
// NOTE: I use a small bias for the floor height, because if the difference in // NOTE: I use a small bias for the floor height, because if the difference in
// height is 0 then the TexturePlane doesn't work! // height is 0 then the TexturePlane doesn't work!
TexturePlane tp = new TexturePlane(); TexturePlane tp = new TexturePlane();
float floorbias = (Sidedef.Other.Sector.FloorHeight == Sidedef.Sector.FloorHeight) ? 1.0f : 0.0f; float floorbias = (sourcetopheight == sourcebottomheight) ? 1.0f : 0.0f;
if(Sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
{
// When lower unpegged is set, the lower texture is bound to the bottom
tp.tlt.y = (float)Sidedef.Sector.CeilHeight - (float)sourceside.Sector.FloorHeight;
}
tp.trb.x = tp.tlt.x + Sidedef.Line.Length; tp.trb.x = tp.tlt.x + Sidedef.Line.Length;
tp.trb.y = tp.tlt.y + ((float)sourceside.Sector.FloorHeight - ((float)Sidedef.Sector.FloorHeight + floorbias)); tp.trb.y = tp.tlt.y + (sourcetopheight - sourcebottomheight) + floorbias;
// Apply texture offset // Apply texture offset
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) 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.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.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 else
{ {
tp.tlt += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); tp.tlt += new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY);
tp.trb += 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);
} }
// Transform pixel coordinates to texture coordinates // Transform pixel coordinates to texture coordinates
@ -147,8 +152,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
tp.trb /= tsz; tp.trb /= tsz;
// Left top and right bottom of the geometry that // Left top and right bottom of the geometry that
tp.vlt = new Vector3D(vl.x, vl.y, (float)sourceside.Sector.FloorHeight); tp.vlt = new Vector3D(vl.x, vl.y, sourcetopheight);
tp.vrb = new Vector3D(vr.x, vr.y, (float)Sidedef.Sector.FloorHeight + floorbias); tp.vrb = new Vector3D(vr.x, vr.y, sourcebottomheight + floorbias);
// Make the right-top coordinates // Make the right-top coordinates
tp.trt = new Vector2D(tp.trb.x, tp.tlt.y); tp.trt = new Vector2D(tp.trb.x, tp.tlt.y);

Binary file not shown.