working on visual mode

This commit is contained in:
codeimp 2008-12-05 15:38:50 +00:00
parent fdd817f292
commit 0102cf3166
14 changed files with 231 additions and 127 deletions

View file

@ -103,6 +103,8 @@
<Compile Include="ClassicModes\DragThingsMode.cs" />
<Compile Include="General\LineLengthLabel.cs" />
<Compile Include="VisualModes\BaseVisualGeometry.cs" />
<Compile Include="VisualModes\BaseVisualGeometrySector.cs" />
<Compile Include="VisualModes\BaseVisualGeometrySidedef.cs" />
<Compile Include="VisualModes\BaseVisualMode.cs" />
<Compile Include="VisualModes\BaseVisualSector.cs" />
<Compile Include="ClassicModes\DragVerticesMode.cs" />

View file

@ -36,7 +36,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class BaseVisualGeometry : VisualGeometry
internal abstract class BaseVisualGeometry : VisualGeometry
{
#region ================== Constants
@ -50,22 +50,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion
#region ================== Constructor / Destructor
#region ================== Constructor / Setup
// Constructor
public BaseVisualGeometry() : base()
public BaseVisualGeometry(VisualSector vs) : base(vs)
{
}
// Constructor for sidedefs
public BaseVisualGeometry(Sidedef sd) : base(sd)
public BaseVisualGeometry(VisualSector vs, Sidedef sd) : base(vs, sd)
{
}
// This is for setting up new geometry
public abstract bool Setup();
#endregion
#region ================== Methods
#endregion
#region ================== Events

View file

@ -0,0 +1,79 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
internal abstract class BaseVisualGeometrySector : BaseVisualGeometry
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor
public BaseVisualGeometrySector(VisualSector vs) : base(vs)
{
}
#endregion
#region ================== Methods
#endregion
#region ================== Events
// Edit button released
public override void OnEditEnd()
{
List<Sector> sectors = new List<Sector>();
sectors.Add(this.Sector.Sector);
DialogResult result = General.Interface.ShowEditSectors(sectors);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
}
#endregion
}
}

View file

@ -0,0 +1,98 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.VisualModes;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
internal abstract class BaseVisualGeometrySidedef : BaseVisualGeometry
{
#region ================== Constants
#endregion
#region ================== Variables
protected float top;
protected float bottom;
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Destructor
// Constructor for sidedefs
public BaseVisualGeometrySidedef(VisualSector vs, Sidedef sd) : base(vs, sd)
{
}
#endregion
#region ================== Methods
// This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
// Check if intersection point is between top and bottom
return (pickintersect.z >= bottom) && (pickintersect.z <= top);
}
// This performs an accurate test for object picking
public override bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
{
// The fast reject pass is already as accurate as it gets,
// so we just return the intersection distance here
u_ray = pickrayu;
return true;
}
#endregion
#region ================== Events
// Edit button released
public override void OnEditEnd()
{
List<Linedef> lines = new List<Linedef>();
lines.Add(this.Sidedef.Line);
DialogResult result = General.Interface.ShowEditLinedefs(lines);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
}
#endregion
}
}

View file

@ -86,12 +86,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.ClearGeometry();
// Create floor
VisualFloor vf = new VisualFloor();
if(vf.Setup(base.Sector)) base.AddGeometry(vf);
VisualFloor vf = new VisualFloor(this);
if(vf.Setup()) base.AddGeometry(vf);
// Create ceiling
VisualCeiling vc = new VisualCeiling();
if(vc.Setup(base.Sector)) base.AddGeometry(vc);
VisualCeiling vc = new VisualCeiling(this);
if(vc.Setup()) base.AddGeometry(vc);
// Go for all sidedefs
foreach(Sidedef sd in base.Sector.Sidedefs)
@ -100,21 +100,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(sd.Other != null)
{
// Create upper part
VisualUpper vu = new VisualUpper(sd);
VisualUpper vu = new VisualUpper(this, sd);
if(vu.Setup()) base.AddGeometry(vu);
// Create lower part
VisualLower vl = new VisualLower(sd);
VisualLower vl = new VisualLower(this, sd);
if(vl.Setup()) base.AddGeometry(vl);
// Create middle part
VisualMiddleDouble vm = new VisualMiddleDouble(sd);
VisualMiddleDouble vm = new VisualMiddleDouble(this, sd);
if(vm.Setup()) base.AddGeometry(vm);
}
else
{
// Create middle part
VisualMiddleSingle vm = new VisualMiddleSingle(sd);
VisualMiddleSingle vm = new VisualMiddleSingle(this, sd);
if(vm.Setup()) base.AddGeometry(vm);
}
}

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualCeiling : BaseVisualGeometry
internal sealed class VisualCeiling : BaseVisualGeometrySector
{
#region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private float pickrayu;
private Vector3D pickintersect;
#endregion
#region ================== Properties
@ -59,18 +56,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup
// Constructor
public VisualCeiling()
public VisualCeiling(VisualSector vs) : base(vs)
{
// We have no destructor
GC.SuppressFinalize(this);
}
// This builds the geometry. Returns false when no geometry created.
public bool Setup(Sector s)
public override bool Setup()
{
WorldVertex[] verts;
WorldVertex v;
Sector s = base.Sector.Sector;
// Load floor texture
base.Texture = General.Map.Data.GetFlatImage(s.LongCeilTexture);
if(base.Texture == null) base.Texture = General.Map.Data.MissingTexture3D;

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualFloor : BaseVisualGeometry
internal sealed class VisualFloor : BaseVisualGeometrySector
{
#region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private float pickrayu;
private Vector3D pickintersect;
#endregion
#region ================== Properties
@ -59,16 +56,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup
// Constructor
public VisualFloor()
public VisualFloor(VisualSector vs) : base(vs)
{
// We have no destructor
GC.SuppressFinalize(this);
}
// This builds the geometry. Returns false when no geometry created.
public bool Setup(Sector s)
public override bool Setup()
{
WorldVertex[] verts;
Sector s = base.Sector.Sector;
// Load floor texture
base.Texture = General.Map.Data.GetFlatImage(s.LongFloorTexture);

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualLower : BaseVisualGeometry
internal sealed class VisualLower : BaseVisualGeometrySidedef
{
#region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private float top;
private float bottom;
#endregion
#region ================== Properties
@ -59,14 +56,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup
// Constructor
public VisualLower(Sidedef s) : base(s)
public VisualLower(VisualSector vs, Sidedef s) : base(vs, s)
{
// We have no destructor
GC.SuppressFinalize(this);
}
// This builds the geometry. Returns false when no geometry created.
public bool Setup()
public override bool Setup()
{
// Calculate size of this wall part
float geotop = (float)Sidedef.Other.Sector.FloorHeight;
@ -140,8 +137,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y);
// Keep properties
this.top = geotop;
this.bottom = geobottom;
base.top = geotop;
base.bottom = geobottom;
// Apply vertices
base.SetVertices(verts);
@ -158,22 +155,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
// Check if intersection point is between top and bottom
return (pickintersect.z >= bottom) && (pickintersect.z <= top);
}
// This performs an accurate test for object picking
public override bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
{
// The fast reject pass is already as accurate as it gets,
// so we just return the intersection distance here
u_ray = pickrayu;
return true;
}
#endregion
}
}

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualMiddleDouble : BaseVisualGeometry
internal sealed class VisualMiddleDouble : BaseVisualGeometrySidedef
{
#region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private float top;
private float bottom;
#endregion
#region ================== Properties
@ -59,7 +56,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup
// Constructor
public VisualMiddleDouble(Sidedef s) : base(s)
public VisualMiddleDouble(VisualSector vs, Sidedef s) : base(vs, s)
{
// Set render pass
this.RenderPass = RenderPass.Mask;
@ -69,7 +66,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// This builds the geometry. Returns false when no geometry created.
public bool Setup()
public override bool Setup()
{
// Calculate size of this wall part
float geotop = (float)Math.Min(Sidedef.Sector.CeilHeight, Sidedef.Other.Sector.CeilHeight);
@ -151,8 +148,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
verts[5] = new WorldVertex(v2.x, v2.y, texbottom, pc.ToInt(), t2.x, t2.y);
// Keep properties
this.top = textop;
this.bottom = texbottom;
base.top = textop;
base.bottom = texbottom;
// Apply vertices
base.SetVertices(verts);
@ -169,22 +166,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
// Check if intersection point is between top and bottom
return (pickintersect.z >= bottom) && (pickintersect.z <= top);
}
// This performs an accurate test for object picking
public override bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
{
// The fast reject pass is already as accurate as it gets,
// so we just return the intersection distance here
u_ray = pickrayu;
return true;
}
#endregion
}
}

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualMiddleSingle : BaseVisualGeometry
internal sealed class VisualMiddleSingle : BaseVisualGeometrySidedef
{
#region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private float top;
private float bottom;
#endregion
#region ================== Properties
@ -59,14 +56,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup
// Constructor
public VisualMiddleSingle(Sidedef s) : base(s)
public VisualMiddleSingle(VisualSector vs, Sidedef s) : base(vs, s)
{
// We have no destructor
GC.SuppressFinalize(this);
}
// This builds the geometry. Returns false when no geometry created.
public bool Setup()
public override bool Setup()
{
// Calculate size of this wall part
float geotop = (float)Sidedef.Sector.CeilHeight;
@ -140,8 +137,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y);
// Keep properties
this.top = geotop;
this.bottom = geobottom;
base.top = geotop;
base.bottom = geobottom;
// Apply vertices
base.SetVertices(verts);
@ -158,22 +155,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
// Check if intersection point is between top and bottom
return (pickintersect.z >= bottom) && (pickintersect.z <= top);
}
// This performs an accurate test for object picking
public override bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
{
// The fast reject pass is already as accurate as it gets,
// so we just return the intersection distance here
u_ray = pickrayu;
return true;
}
#endregion
}
}

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class VisualUpper : BaseVisualGeometry
internal sealed class VisualUpper : BaseVisualGeometrySidedef
{
#region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
private float top;
private float bottom;
#endregion
#region ================== Properties
@ -59,14 +56,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup
// Constructor
public VisualUpper(Sidedef s) : base(s)
public VisualUpper(VisualSector vs, Sidedef s) : base(vs, s)
{
// We have no destructor
GC.SuppressFinalize(this);
}
// This builds the geometry. Returns false when no geometry created.
public bool Setup()
public override bool Setup()
{
// Calculate size of this wall part
float geotop = (float)Sidedef.Sector.CeilHeight;
@ -140,8 +137,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y);
// Keep properties
this.top = geotop;
this.bottom = geobottom;
base.top = geotop;
base.bottom = geobottom;
// Apply vertices
base.SetVertices(verts);
@ -158,22 +155,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This performs a fast test in object picking
public override bool PickFastReject(Vector3D from, Vector3D to, Vector3D dir)
{
// Check if intersection point is between top and bottom
return (pickintersect.z >= bottom) && (pickintersect.z <= top);
}
// This performs an accurate test for object picking
public override bool PickAccurate(Vector3D from, Vector3D to, Vector3D dir, ref float u_ray)
{
// The fast reject pass is already as accurate as it gets,
// so we just return the intersection distance here
u_ray = pickrayu;
return true;
}
#endregion
}
}

View file

@ -109,16 +109,18 @@ namespace CodeImp.DoomBuilder.VisualModes
/// <summary>
/// This creates sector-global visual geometry. This geometry is always visible when any of the sector is visible.
/// </summary>
public VisualGeometry()
public VisualGeometry(VisualSector vs)
{
this.sector = vs;
}
/// <summary>
/// This creates visual geometry that is bound to a sidedef. This geometry is only visible when the sidedef is visible. It is automatically back-face culled during rendering and automatically XY intersection tested as well as back-face culled during object picking.
/// </summary>
/// <param name="sd"></param>
public VisualGeometry(Sidedef sd)
public VisualGeometry(VisualSector vs, Sidedef sd)
{
this.sector = vs;
this.sidedef = sd;
}

View file

@ -177,7 +177,6 @@ namespace CodeImp.DoomBuilder.VisualModes
public void AddGeometry(VisualGeometry geo)
{
updategeo = true;
geo.Sector = this;
allgeometry.Add(geo);
if(geo.Sidedef != null)
{

View file

@ -977,10 +977,11 @@ namespace CodeImp.DoomBuilder.Windows
// Release and show the mouse
Cursor.Clip = originalclip;
Cursor.Position = display.PointToScreen(new Point(display.ClientSize.Width / 2, display.ClientSize.Height / 2));
Cursor.Show();
}
}
// This requests exclusive mouse input
public void StartExclusiveMouseInput()
{