mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
@ work on (G)ZDoom Editing plugin
This commit is contained in:
parent
fd7797db5e
commit
1830eee6c9
5 changed files with 41 additions and 33 deletions
|
@ -538,14 +538,15 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
SectorData sd = GetSectorData(General.Map.VisualCamera.Sector);
|
||||
if(!sd.Built) sd.BuildLevels(this);
|
||||
|
||||
SectorLevel floorlevel = sd.GetLevelBelow(General.Map.VisualCamera.Position + new Vector3D(0.0f, 0.0f, 0.0001f));
|
||||
SectorLevel ceillevel = sd.GetLevelAbove(General.Map.VisualCamera.Position - new Vector3D(0.0f, 0.0f, 0.0001f));
|
||||
if(floorlevel == null) floorlevel = sd.Floor;
|
||||
if(ceillevel == null) ceillevel = sd.Ceiling;
|
||||
Vector3D feetposition = General.Map.VisualCamera.Position - new Vector3D(0, 0, cameraflooroffset - 7.0f);
|
||||
SectorLevel floorlevel = sd.GetLevelBelow(feetposition);
|
||||
SectorLevel ceillevel = sd.GetLevelAbove(feetposition);
|
||||
if(floorlevel == null) floorlevel = sd.Levels[0];
|
||||
if(ceillevel == null) ceillevel = sd.Levels[sd.Levels.Count - 1];
|
||||
|
||||
// Camera below floor level?
|
||||
float floorheight = floorlevel.plane.GetZ(General.Map.VisualCamera.Position);
|
||||
if(General.Map.VisualCamera.Position.z < (floorheight + cameraflooroffset + 0.0001f))
|
||||
if(General.Map.VisualCamera.Position.z < (floorheight + cameraflooroffset + 0.01f))
|
||||
{
|
||||
// Stay above floor
|
||||
gravity = new Vector3D(0.0f, 0.0f, 0.0f);
|
||||
|
@ -556,10 +557,12 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
else
|
||||
{
|
||||
// Fall down
|
||||
gravity += new Vector3D(0.0f, 0.0f, (float)(GRAVITY * deltatime));
|
||||
gravity.z += (float)(GRAVITY * deltatime);
|
||||
if(gravity.z > 3.0f) gravity.z = 3.0f;
|
||||
General.Map.VisualCamera.Position += gravity;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Camera above ceiling level?
|
||||
float ceilheight = ceillevel.plane.GetZ(General.Map.VisualCamera.Position);
|
||||
if(General.Map.VisualCamera.Position.z > (ceilheight - cameraceilingoffset))
|
||||
|
@ -569,6 +572,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
General.Map.VisualCamera.Position.y,
|
||||
ceilheight - cameraceilingoffset);
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -193,13 +193,18 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
|
||||
SectorLevel f = new SectorLevel(sd.Floor);
|
||||
SectorLevel c = new SectorLevel(sd.Ceiling);
|
||||
|
||||
|
||||
// A 3D floor's color is always that of the sector it is placed in
|
||||
f.color = 0;
|
||||
|
||||
// Do not adjust light?
|
||||
if((l.Args[2] & 1) != 0)
|
||||
{
|
||||
f.color = 0;
|
||||
f.brightnessbelow = -1;
|
||||
f.colorbelow = PixelColor.FromInt(0);
|
||||
c.color = 0;
|
||||
c.brightnessbelow = -1;
|
||||
c.colorbelow = PixelColor.FromInt(0);
|
||||
}
|
||||
|
||||
levels.Add(f);
|
||||
|
@ -238,8 +243,27 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
|
||||
// Now that we know the levels in this sector (and in the right order) we
|
||||
// can determine the lighting in between and on the levels.
|
||||
|
||||
|
||||
// Start from the absolute ceiling and go down to 'cast' the lighting
|
||||
for(int i = levels.Count - 2; i >= 0; i--)
|
||||
{
|
||||
SectorLevel l = levels[i];
|
||||
SectorLevel pl = levels[i + 1];
|
||||
|
||||
// Set color when no color is specified, or when a 3D floor is placed above the absolute floor
|
||||
if((l.color == 0) || ((l == floor) && (levels.Count > 2)))
|
||||
{
|
||||
PixelColor floorbrightness = PixelColor.FromInt(mode.CalculateBrightness(pl.brightnessbelow));
|
||||
PixelColor floorcolor = PixelColor.Modulate(pl.colorbelow, floorbrightness);
|
||||
l.color = floorcolor.WithAlpha(255).ToInt();
|
||||
}
|
||||
|
||||
if(l.colorbelow.a == 0)
|
||||
l.colorbelow = pl.colorbelow;
|
||||
|
||||
if(l.brightnessbelow == -1)
|
||||
l.brightnessbelow = pl.brightnessbelow;
|
||||
}
|
||||
|
||||
// Done
|
||||
built = true;
|
||||
isbuilding = false;
|
||||
|
|
|
@ -71,8 +71,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
WorldVertex v;
|
||||
Sector s = level.sector;
|
||||
float xpan, ypan, xscale, yscale, rotate;
|
||||
int color, light;
|
||||
bool absolute;
|
||||
Vector2D texscale;
|
||||
|
||||
try
|
||||
|
@ -83,9 +81,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
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;
|
||||
color = s.Fields.ContainsKey("lightcolor") ? (int)s.Fields["lightcolor"].Value : -1;
|
||||
light = s.Fields.ContainsKey("lightceiling") ? (int)s.Fields["lightceiling"].Value : 0;
|
||||
absolute = s.Fields.ContainsKey("lightceilingabsolute") ? (bool)s.Fields["lightceilingabsolute"].Value : false;
|
||||
}
|
||||
catch(Exception) { return false; }
|
||||
|
||||
|
@ -112,11 +107,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
rotate = Angle2D.DegToRad(rotate);
|
||||
Vector2D scale = new Vector2D(xscale, yscale);
|
||||
Vector2D offset = new Vector2D(xpan, ypan);
|
||||
if(!absolute) light = s.Brightness + light;
|
||||
PixelColor lightcolor = PixelColor.FromInt(color);
|
||||
PixelColor brightness = PixelColor.FromInt(mode.CalculateBrightness(light));
|
||||
PixelColor finalcolor = PixelColor.Modulate(lightcolor, brightness);
|
||||
color = finalcolor.WithAlpha(255).ToInt();
|
||||
|
||||
// Make vertices
|
||||
ReadOnlyCollection<Vector2D> triverts = base.Sector.Sector.Triangles.Vertices;
|
||||
|
@ -124,7 +114,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
for(int i = 0; i < triverts.Count; i++)
|
||||
{
|
||||
// Color shading
|
||||
verts[i].c = color;
|
||||
verts[i].c = level.color;
|
||||
|
||||
// Vertex coordinates
|
||||
verts[i].x = triverts[i].x;
|
||||
|
|
|
@ -70,8 +70,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
WorldVertex[] verts;
|
||||
Sector s = level.sector;
|
||||
float xpan, ypan, xscale, yscale, rotate;
|
||||
int color, light;
|
||||
bool absolute;
|
||||
Vector2D texscale;
|
||||
|
||||
try
|
||||
|
@ -82,9 +80,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
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;
|
||||
color = s.Fields.ContainsKey("lightcolor") ? (int)s.Fields["lightcolor"].Value : -1;
|
||||
light = s.Fields.ContainsKey("lightfloor") ? (int)s.Fields["lightfloor"].Value : 0;
|
||||
absolute = s.Fields.ContainsKey("lightfloorabsolute") ? (bool)s.Fields["lightfloorabsolute"].Value : false;
|
||||
}
|
||||
catch(Exception) { return false; }
|
||||
|
||||
|
@ -111,11 +106,6 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
rotate = Angle2D.DegToRad(rotate);
|
||||
Vector2D scale = new Vector2D(xscale, yscale);
|
||||
Vector2D offset = new Vector2D(xpan, ypan);
|
||||
if(!absolute) light = s.Brightness + light;
|
||||
PixelColor lightcolor = PixelColor.FromInt(color);
|
||||
PixelColor brightness = PixelColor.FromInt(mode.CalculateBrightness(light));
|
||||
PixelColor finalcolor = PixelColor.Modulate(lightcolor, brightness);
|
||||
color = finalcolor.WithAlpha(255).ToInt();
|
||||
|
||||
// Make vertices
|
||||
ReadOnlyCollection<Vector2D> triverts = base.Sector.Sector.Triangles.Vertices;
|
||||
|
@ -123,7 +113,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
for(int i = 0; i < triverts.Count; i++)
|
||||
{
|
||||
// Color shading
|
||||
verts[i].c = color;
|
||||
verts[i].c = level.color;
|
||||
|
||||
// Vertex coordinates
|
||||
verts[i].x = triverts[i].x;
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue