- Handles on floor are shown

- Fixed a problem where the wrong plane was assigned to ceiling surfaces
This commit is contained in:
biwa 2020-01-01 21:47:33 +01:00
parent 4bfbe567c1
commit 55135f2982
6 changed files with 42 additions and 37 deletions

View file

@ -706,6 +706,7 @@
<EmbeddedResource Include="Resources\world3d_skybox.fp" /> <EmbeddedResource Include="Resources\world3d_skybox.fp" />
<EmbeddedResource Include="Resources\world3d_skybox.vp" /> <EmbeddedResource Include="Resources\world3d_skybox.vp" />
<EmbeddedResource Include="Resources\world3d_vertex_color.fp" /> <EmbeddedResource Include="Resources\world3d_vertex_color.fp" />
<EmbeddedResource Include="Resources\world3d_slopehandle.vp" />
<None Include="Resources\Zoom.png" /> <None Include="Resources\Zoom.png" />
<None Include="Resources\Properties.png" /> <None Include="Resources\Properties.png" />
<None Include="Resources\NewMap2.png" /> <None Include="Resources\NewMap2.png" />

View file

@ -65,6 +65,7 @@ namespace CodeImp.DoomBuilder.Rendering
DeclareUniform(UniformName.texturefactor, "texturefactor", UniformType.Vec4); DeclareUniform(UniformName.texturefactor, "texturefactor", UniformType.Vec4);
DeclareUniform(UniformName.fogsettings, "fogsettings", UniformType.Vec4); DeclareUniform(UniformName.fogsettings, "fogsettings", UniformType.Vec4);
DeclareUniform(UniformName.fogcolor, "fogcolor", UniformType.Vec4); DeclareUniform(UniformName.fogcolor, "fogcolor", UniformType.Vec4);
DeclareUniform(UniformName.slopeHandleLength, "slopeHandleLength", UniformType.Float);
DeclareShader(ShaderName.display2d_fsaa, "display2d.vp", "display2d_fsaa.fp"); DeclareShader(ShaderName.display2d_fsaa, "display2d.vp", "display2d_fsaa.fp");
DeclareShader(ShaderName.display2d_normal, "display2d.vp", "display2d_normal.fp"); DeclareShader(ShaderName.display2d_normal, "display2d.vp", "display2d_normal.fp");
@ -88,6 +89,8 @@ namespace CodeImp.DoomBuilder.Rendering
DeclareShader(ShaderName.world3d_constant_color, "world3d_customvertexcolor.vp", "world3d_constant_color.fp"); DeclareShader(ShaderName.world3d_constant_color, "world3d_customvertexcolor.vp", "world3d_constant_color.fp");
DeclareShader(ShaderName.world3d_lightpass, "world3d_lightpass.vp", "world3d_lightpass.fp"); DeclareShader(ShaderName.world3d_lightpass, "world3d_lightpass.vp", "world3d_lightpass.fp");
DeclareShader(ShaderName.world3d_slope_handle, "world3d_slopehandle.vp", "world3d_constant_color.fp");
SetupSettings(); SetupSettings();
} }
@ -632,7 +635,8 @@ namespace CodeImp.DoomBuilder.Rendering
world3d_main_highlight_fog_vertexcolor, world3d_main_highlight_fog_vertexcolor,
world3d_vertex_color, world3d_vertex_color,
world3d_constant_color, world3d_constant_color,
world3d_lightpass world3d_lightpass,
world3d_slope_handle
} }
public enum UniformType : int public enum UniformType : int
@ -665,7 +669,8 @@ namespace CodeImp.DoomBuilder.Rendering
campos, campos,
texturefactor, texturefactor,
fogsettings, fogsettings,
fogcolor fogcolor,
slopeHandleLength
} }
public enum VertexFormat : int { Flat, World } public enum VertexFormat : int { Flat, World }

View file

@ -684,19 +684,15 @@ namespace CodeImp.DoomBuilder.Rendering
private void RenderSlopeHandles() private void RenderSlopeHandles()
{ {
/*
if (visualslopehandles == null) return; if (visualslopehandles == null) return;
graphics.SetAlphaBlendEnable(true); graphics.SetAlphaBlendEnable(true);
graphics.SetAlphaTestEnable(false); graphics.SetAlphaTestEnable(false);
graphics.SetZWriteEnable(false); graphics.SetZWriteEnable(false);
graphics.SetSourceBlend(Blend.SourceAlpha); graphics.SetSourceBlend(Blend.SourceAlpha);
graphics.SetDestinationBlend(Blend.SourceAlpha); graphics.SetDestinationBlend(Blend.InverseSourceAlpha);
graphics.Shaders.World3D.BeginPass(18); graphics.SetShader(ShaderName.world3d_slope_handle);
// world = Matrix.Identity;
// ApplyMatrices3D();
foreach (VisualSlope handle in visualslopehandles) foreach (VisualSlope handle in visualslopehandles)
{ {
@ -712,22 +708,25 @@ namespace CodeImp.DoomBuilder.Rendering
color = General.Colors.Vertices; color = General.Colors.Vertices;
world = handle.Position; world = handle.Position;
ApplyMatrices3D(); graphics.SetUniform(UniformName.world, ref world);
graphics.SetUniform(UniformName.slopeHandleLength, handle.Length);
handle.Update(color); //handle.Update();
graphics.Shaders.World3D.VertexColor = color.ToColorValue(); graphics.SetUniform(UniformName.vertexColor, color.ToColorValue());
graphics.Shaders.World3D.SlopeHandleLength = handle.Length; //graphics.Shaders.World3D.SlopeHandleLength = handle.Length;
graphics.Shaders.World3D.ApplySettings();
// graphics.Device.SetStreamSource(0, handle.GeoBuffer, 0, WorldVertex.Stride); // graphics.Device.SetStreamSource(0, handle.GeoBuffer, 0, WorldVertex.Stride);
graphics.Device.SetStreamSource(0, visualslopehandle.Geometry, 0, WorldVertex.Stride); //graphics.Device.SetStreamSource(0, visualslopehandle.Geometry, 0, WorldVertex.Stride);
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); //graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
graphics.SetVertexBuffer(visualslopehandle.Geometry);
graphics.Draw(PrimitiveType.TriangleList, 0, 2);
} }
// Done // Done
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f)); graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
*/
} }
//mxd //mxd

View file

@ -61,6 +61,12 @@ namespace CodeImp.DoomBuilder.Rendering
WorldVertex v2 = new WorldVertex(1.0f, 8.0f, 0.5f); WorldVertex v2 = new WorldVertex(1.0f, 8.0f, 0.5f);
WorldVertex v3 = new WorldVertex(0.0f, 8.0f, 0.5f); WorldVertex v3 = new WorldVertex(0.0f, 8.0f, 0.5f);
//WorldVertex v0 = new WorldVertex(0.0f, 0.0f, 0.5f);
//WorldVertex v1 = new WorldVertex(32.0f, 0.0f, 0.5f);
//WorldVertex v2 = new WorldVertex(32.0f, 32.0f, 0.5f);
//WorldVertex v3 = new WorldVertex(0.0f, 32.0f, 0.5f);
v0.c = v1.c = PixelColor.INT_WHITE; v0.c = v1.c = PixelColor.INT_WHITE;
v2.c = v3.c = PixelColor.INT_WHITE_NO_ALPHA; v2.c = v3.c = PixelColor.INT_WHITE_NO_ALPHA;

View file

@ -107,18 +107,17 @@ namespace CodeImp.DoomBuilder.VisualModes
return true; return true;
} }
public virtual bool Update(PixelColor color) public virtual void Update() {}
{
return true;
}
public void SetPosition(Vector3D pos, Geometry.Plane plane, float angle) public void SetPosition(Vector3D pos, Geometry.Plane plane, float angle)
{ {
Matrix translate = Matrix.Translation(pos.x, pos.y, pos.z); Matrix translate = Matrix.Translation(pos.x, pos.y, pos.z);
Matrix rotate = Matrix.RotationZ(angle);
Vector3 v = new Vector3(plane.Normal.x, plane.Normal.y, plane.Normal.z); Vector3 v = new Vector3(plane.Normal.x, plane.Normal.y, plane.Normal.z);
// Matrix rotate = Matrix.RotationAxis(v, angle); // Matrix rotate = Matrix.RotationAxis(v, angle);
//position = Matrix.Multiply(rotate, translate); //position = Matrix.Multiply(rotate, translate);
position = Matrix.Multiply(rotate, translate);
} }
#endregion #endregion

View file

@ -82,8 +82,7 @@ namespace CodeImp.DoomBuilder.VisualModes
return new RectangleF(left - SIZE, top - SIZE, right - left + SIZE*2, bottom - top + SIZE*2); return new RectangleF(left - SIZE, top - SIZE, right - left + SIZE*2, bottom - top + SIZE*2);
} }
public bool Setup() { return Setup(General.Colors.Vertices); } public bool Setup()
public bool Setup(PixelColor color)
{ {
if (sidedef == null) if (sidedef == null)
return false; return false;
@ -102,13 +101,14 @@ namespace CodeImp.DoomBuilder.VisualModes
// Line2D line = new Line2D(ld.Line.GetCoordinatesAt(ld.LengthInv * SIZE), ld.Line.GetCoordinatesAt(1.0f - (ld.LengthInv * SIZE))); // Line2D line = new Line2D(ld.Line.GetCoordinatesAt(ld.LengthInv * SIZE), ld.Line.GetCoordinatesAt(1.0f - (ld.LengthInv * SIZE)));
Line2D line = ld.Line; Line2D line = ld.Line;
UpdatePosition();
return true; return true;
} }
public override bool Update(PixelColor color) public override void Update()
{ {
UpdatePosition(); UpdatePosition();
return Setup(color);
} }
/// <summary> /// <summary>
@ -373,25 +373,20 @@ namespace CodeImp.DoomBuilder.VisualModes
foreach (SectorLevel l in levels) foreach (SectorLevel l in levels)
{ {
if (up)
{
l.sector.FloorSlope = plane.Normal;
l.sector.FloorSlopeOffset = plane.Offset;
Vector2D center = new Vector2D(l.sector.BBox.X + l.sector.BBox.Width / 2, Vector2D center = new Vector2D(l.sector.BBox.X + l.sector.BBox.Width / 2,
l.sector.BBox.Y + l.sector.BBox.Height / 2); l.sector.BBox.Y + l.sector.BBox.Height / 2);
if (l.plane.Normal.z >= 0.0f)
{
l.sector.FloorSlope = plane.Normal;
l.sector.FloorSlopeOffset = plane.Offset;
l.sector.FloorHeight = (int)new Plane(l.sector.FloorSlope, l.sector.FloorSlopeOffset).GetZ(center); l.sector.FloorHeight = (int)new Plane(l.sector.FloorSlope, l.sector.FloorSlopeOffset).GetZ(center);
} }
else else
{ {
plane = plane.GetInverted(); Plane downplane = plane.GetInverted();
l.sector.CeilSlope = plane.Normal; l.sector.CeilSlope = downplane.Normal;
l.sector.CeilSlopeOffset = plane.Offset; l.sector.CeilSlopeOffset = downplane.Offset;
Vector2D center = new Vector2D(l.sector.BBox.X + l.sector.BBox.Width / 2,
l.sector.BBox.Y + l.sector.BBox.Height / 2);
l.sector.CeilHeight = (int)new Plane(l.sector.CeilSlope, l.sector.CeilSlopeOffset).GetZ(center); l.sector.CeilHeight = (int)new Plane(l.sector.CeilSlope, l.sector.CeilSlopeOffset).GetZ(center);
} }