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="ClassicModes\DragThingsMode.cs" />
<Compile Include="General\LineLengthLabel.cs" /> <Compile Include="General\LineLengthLabel.cs" />
<Compile Include="VisualModes\BaseVisualGeometry.cs" /> <Compile Include="VisualModes\BaseVisualGeometry.cs" />
<Compile Include="VisualModes\BaseVisualGeometrySector.cs" />
<Compile Include="VisualModes\BaseVisualGeometrySidedef.cs" />
<Compile Include="VisualModes\BaseVisualMode.cs" /> <Compile Include="VisualModes\BaseVisualMode.cs" />
<Compile Include="VisualModes\BaseVisualSector.cs" /> <Compile Include="VisualModes\BaseVisualSector.cs" />
<Compile Include="ClassicModes\DragVerticesMode.cs" /> <Compile Include="ClassicModes\DragVerticesMode.cs" />

View file

@ -36,7 +36,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
internal class BaseVisualGeometry : VisualGeometry internal abstract class BaseVisualGeometry : VisualGeometry
{ {
#region ================== Constants #region ================== Constants
@ -50,18 +50,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion #endregion
#region ================== Constructor / Destructor #region ================== Constructor / Setup
// Constructor // Constructor
public BaseVisualGeometry() : base() public BaseVisualGeometry(VisualSector vs) : base(vs)
{ {
} }
// Constructor for sidedefs // 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 #endregion
#region ================== Methods #region ================== Methods

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

View file

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

View file

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

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
internal class VisualLower : BaseVisualGeometry internal sealed class VisualLower : BaseVisualGeometrySidedef
{ {
#region ================== Constants #region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables #region ================== Variables
private float top;
private float bottom;
#endregion #endregion
#region ================== Properties #region ================== Properties
@ -59,14 +56,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup #region ================== Constructor / Setup
// Constructor // Constructor
public VisualLower(Sidedef s) : base(s) public VisualLower(VisualSector vs, Sidedef s) : base(vs, s)
{ {
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
// This builds the geometry. Returns false when no geometry created. // This builds the geometry. Returns false when no geometry created.
public bool Setup() public override bool Setup()
{ {
// Calculate size of this wall part // Calculate size of this wall part
float geotop = (float)Sidedef.Other.Sector.FloorHeight; 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); verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y);
// Keep properties // Keep properties
this.top = geotop; base.top = geotop;
this.bottom = geobottom; base.bottom = geobottom;
// Apply vertices // Apply vertices
base.SetVertices(verts); base.SetVertices(verts);
@ -158,22 +155,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #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 #endregion
} }
} }

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
internal class VisualMiddleDouble : BaseVisualGeometry internal sealed class VisualMiddleDouble : BaseVisualGeometrySidedef
{ {
#region ================== Constants #region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables #region ================== Variables
private float top;
private float bottom;
#endregion #endregion
#region ================== Properties #region ================== Properties
@ -59,7 +56,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup #region ================== Constructor / Setup
// Constructor // Constructor
public VisualMiddleDouble(Sidedef s) : base(s) public VisualMiddleDouble(VisualSector vs, Sidedef s) : base(vs, s)
{ {
// Set render pass // Set render pass
this.RenderPass = RenderPass.Mask; this.RenderPass = RenderPass.Mask;
@ -69,7 +66,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
// This builds the geometry. Returns false when no geometry created. // This builds the geometry. Returns false when no geometry created.
public bool Setup() public override bool Setup()
{ {
// Calculate size of this wall part // Calculate size of this wall part
float geotop = (float)Math.Min(Sidedef.Sector.CeilHeight, Sidedef.Other.Sector.CeilHeight); 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); verts[5] = new WorldVertex(v2.x, v2.y, texbottom, pc.ToInt(), t2.x, t2.y);
// Keep properties // Keep properties
this.top = textop; base.top = textop;
this.bottom = texbottom; base.bottom = texbottom;
// Apply vertices // Apply vertices
base.SetVertices(verts); base.SetVertices(verts);
@ -169,22 +166,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #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 #endregion
} }
} }

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
internal class VisualMiddleSingle : BaseVisualGeometry internal sealed class VisualMiddleSingle : BaseVisualGeometrySidedef
{ {
#region ================== Constants #region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables #region ================== Variables
private float top;
private float bottom;
#endregion #endregion
#region ================== Properties #region ================== Properties
@ -59,14 +56,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup #region ================== Constructor / Setup
// Constructor // Constructor
public VisualMiddleSingle(Sidedef s) : base(s) public VisualMiddleSingle(VisualSector vs, Sidedef s) : base(vs, s)
{ {
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
// This builds the geometry. Returns false when no geometry created. // This builds the geometry. Returns false when no geometry created.
public bool Setup() public override bool Setup()
{ {
// Calculate size of this wall part // Calculate size of this wall part
float geotop = (float)Sidedef.Sector.CeilHeight; 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); verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y);
// Keep properties // Keep properties
this.top = geotop; base.top = geotop;
this.bottom = geobottom; base.bottom = geobottom;
// Apply vertices // Apply vertices
base.SetVertices(verts); base.SetVertices(verts);
@ -158,22 +155,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #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 #endregion
} }
} }

View file

@ -39,7 +39,7 @@ using CodeImp.DoomBuilder.VisualModes;
namespace CodeImp.DoomBuilder.BuilderModes namespace CodeImp.DoomBuilder.BuilderModes
{ {
internal class VisualUpper : BaseVisualGeometry internal sealed class VisualUpper : BaseVisualGeometrySidedef
{ {
#region ================== Constants #region ================== Constants
@ -47,9 +47,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables #region ================== Variables
private float top;
private float bottom;
#endregion #endregion
#region ================== Properties #region ================== Properties
@ -59,14 +56,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Constructor / Setup #region ================== Constructor / Setup
// Constructor // Constructor
public VisualUpper(Sidedef s) : base(s) public VisualUpper(VisualSector vs, Sidedef s) : base(vs, s)
{ {
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
// This builds the geometry. Returns false when no geometry created. // This builds the geometry. Returns false when no geometry created.
public bool Setup() public override bool Setup()
{ {
// Calculate size of this wall part // Calculate size of this wall part
float geotop = (float)Sidedef.Sector.CeilHeight; 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); verts[5] = new WorldVertex(v2.x, v2.y, geobottom, pc.ToInt(), t2.x, t2.y);
// Keep properties // Keep properties
this.top = geotop; base.top = geotop;
this.bottom = geobottom; base.bottom = geobottom;
// Apply vertices // Apply vertices
base.SetVertices(verts); base.SetVertices(verts);
@ -158,22 +155,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods #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 #endregion
} }
} }

View file

@ -109,16 +109,18 @@ namespace CodeImp.DoomBuilder.VisualModes
/// <summary> /// <summary>
/// This creates sector-global visual geometry. This geometry is always visible when any of the sector is visible. /// This creates sector-global visual geometry. This geometry is always visible when any of the sector is visible.
/// </summary> /// </summary>
public VisualGeometry() public VisualGeometry(VisualSector vs)
{ {
this.sector = vs;
} }
/// <summary> /// <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. /// 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> /// </summary>
/// <param name="sd"></param> /// <param name="sd"></param>
public VisualGeometry(Sidedef sd) public VisualGeometry(VisualSector vs, Sidedef sd)
{ {
this.sector = vs;
this.sidedef = sd; this.sidedef = sd;
} }

View file

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

View file

@ -977,6 +977,7 @@ namespace CodeImp.DoomBuilder.Windows
// Release and show the mouse // Release and show the mouse
Cursor.Clip = originalclip; Cursor.Clip = originalclip;
Cursor.Position = display.PointToScreen(new Point(display.ClientSize.Width / 2, display.ClientSize.Height / 2));
Cursor.Show(); Cursor.Show();
} }
} }