generic system to display sector brightness and textures in their polygons (still buggy, working on it)
BIN
Resources/Icons/ViewBrightness.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
Resources/Icons/ViewNormal.png
Normal file
After Width: | Height: | Size: 239 B |
BIN
Resources/Icons/ViewTextureCeiling.png
Normal file
After Width: | Height: | Size: 559 B |
BIN
Resources/Icons/ViewTextureFloor.png
Normal file
After Width: | Height: | Size: 562 B |
|
@ -140,6 +140,7 @@
|
|||
<Compile Include="Map\MapElement.cs" />
|
||||
<Compile Include="Map\UniFields.cs" />
|
||||
<Compile Include="Map\UniValue.cs" />
|
||||
<Compile Include="Rendering\ViewMode.cs" />
|
||||
<Compile Include="Types\BoolHandler.cs" />
|
||||
<Compile Include="Types\ColorHandler.cs" />
|
||||
<Compile Include="Types\EnumBitsHandler.cs" />
|
||||
|
@ -610,6 +611,10 @@
|
|||
<None Include="Resources\Copy.png" />
|
||||
<None Include="Resources\Cut.png" />
|
||||
<Content Include="Resources\DB2.ico" />
|
||||
<None Include="Resources\ViewBrightness.png" />
|
||||
<None Include="Resources\ViewTextureCeiling.png" />
|
||||
<None Include="Resources\ViewTextureFloor.png" />
|
||||
<None Include="Resources\ViewNormal.png" />
|
||||
<None Include="Resources\KnownTextureSet.png" />
|
||||
<EmbeddedResource Include="Resources\Hourglass3D.png" />
|
||||
<None Include="Resources\Failed.png" />
|
||||
|
|
|
@ -161,26 +161,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
PixelColor brightnesscolor = new PixelColor(255, (byte)s.Brightness, (byte)s.Brightness, (byte)s.Brightness);
|
||||
int brightnessint = brightnesscolor.ToInt();
|
||||
|
||||
// This was only to test if it would work
|
||||
// It works, but it is very slow
|
||||
/*
|
||||
// Load texture image
|
||||
ImageData texture = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
||||
if(!texture.IsLoaded) texture.LoadImage();
|
||||
|
||||
// Make vertices
|
||||
FlatVertex[] verts = new FlatVertex[s.Vertices.Length];
|
||||
s.Vertices.CopyTo(verts, 0);
|
||||
for(int i = 0; i < verts.Length; i++)
|
||||
{
|
||||
verts[i].u = verts[i].x / texture.ScaledWidth;
|
||||
verts[i].v = verts[i].y / texture.ScaledHeight;
|
||||
}
|
||||
|
||||
// Render the geometry
|
||||
renderer.RenderGeometry(verts, texture, true);
|
||||
*/
|
||||
|
||||
// Render the geometry
|
||||
FlatVertex[] verts = new FlatVertex[s.FlatVertices.Length];
|
||||
s.FlatVertices.CopyTo(verts, 0);
|
||||
|
|
|
@ -227,6 +227,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Redrawing display
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -133,7 +133,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnRedrawDisplay()
|
||||
{
|
||||
bool viewchanged = CheckViewChanged();
|
||||
|
||||
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Start rendering structure
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -138,7 +138,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnRedrawDisplay()
|
||||
{
|
||||
bool viewchanged = CheckViewChanged();
|
||||
|
||||
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Start rendering
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -221,6 +221,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
if(viewchanged)
|
||||
{
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines and vertices
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -115,7 +115,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnRedrawDisplay()
|
||||
{
|
||||
bool viewchanged = CheckViewChanged();
|
||||
|
||||
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Start rendering
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -784,6 +784,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This redraws the display
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -873,7 +873,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnRedrawDisplay()
|
||||
{
|
||||
UpdateRectangleComponents();
|
||||
|
||||
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -111,7 +111,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Get the selection
|
||||
FindReplaceObject[] selection = BuilderPlug.Me.FindReplaceForm.GetSelection();
|
||||
|
||||
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -219,6 +219,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This redraws the display
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -311,6 +311,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This redraws the display
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines and vertices
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -121,6 +121,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This redraws the display
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines and vertices
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -123,6 +123,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// This redraws the display
|
||||
public override void OnRedrawDisplay()
|
||||
{
|
||||
renderer.RedrawSurface();
|
||||
|
||||
// Render lines and vertices
|
||||
if(renderer.StartPlotter(true))
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ using CodeImp.DoomBuilder.Editing;
|
|||
using CodeImp.DoomBuilder.Plugins;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -111,6 +112,44 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Events
|
||||
|
||||
// When floor surface geometry is created for classic modes
|
||||
public override void OnSectorFloorSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
|
||||
{
|
||||
ImageData img = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
||||
if(img != null)
|
||||
{
|
||||
// Make scalars
|
||||
float sw = 1.0f / img.ScaledWidth;
|
||||
float sh = 1.0f / img.ScaledHeight;
|
||||
|
||||
// Make proper texture coordinates
|
||||
for(int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
vertices[i].u = vertices[i].u * sw;
|
||||
vertices[i].v = vertices[i].v * sw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When ceiling surface geometry is created for classic modes
|
||||
public override void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
|
||||
{
|
||||
ImageData img = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
||||
if(img != null)
|
||||
{
|
||||
// Make scalars
|
||||
float sw = 1.0f / img.ScaledWidth;
|
||||
float sh = 1.0f / img.ScaledHeight;
|
||||
|
||||
// Make proper texture coordinates
|
||||
for(int i = 0; i < vertices.Length; i++)
|
||||
{
|
||||
vertices[i].u = vertices[i].u * sw;
|
||||
vertices[i].v = vertices[i].v * sw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When the editing mode changes
|
||||
public override bool OnModeChange(EditMode oldmode, EditMode newmode)
|
||||
{
|
||||
|
|
|
@ -504,6 +504,11 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
Dictionary<long, long> useditems = new Dictionary<long, long>();
|
||||
|
||||
// TODO: Move the map scanning part to the application thread (into the
|
||||
// UpdateUsedTextures function)
|
||||
// We shouldn't do this in the background, because we're not supposed
|
||||
// to access the map from this thread! The map could change!
|
||||
|
||||
// Go through the map to find the used textures
|
||||
foreach(Sidedef sd in General.Map.Map.Sidedefs)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Methods
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
// Leave when already loaded
|
||||
if(this.IsImageLoaded) return;
|
||||
|
@ -71,7 +71,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
height = bitmap.Size.Height;
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
base.LocalLoadImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Methods
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
Stream lumpdata;
|
||||
MemoryStream mem;
|
||||
|
@ -102,7 +102,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
base.LocalLoadImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -180,8 +180,29 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
}
|
||||
|
||||
// This loads theimage
|
||||
public void LoadImage()
|
||||
{
|
||||
// Keep original dimensions
|
||||
int oldwidth = width;
|
||||
int oldheight = height;
|
||||
float oldscaledwidth = scaledwidth;
|
||||
float oldscaledheight = scaledheight;
|
||||
|
||||
// Do the loading
|
||||
LocalLoadImage();
|
||||
|
||||
// Anything changed?
|
||||
if((oldwidth != width) || (oldheight != height) ||
|
||||
(oldscaledwidth != scaledwidth) || (oldscaledheight != scaledheight))
|
||||
{
|
||||
// Notify the main thread about the change so that sectors can update their buffers
|
||||
General.MainWindow.ImageDataLoaded(this);
|
||||
}
|
||||
}
|
||||
|
||||
// This requests loading the image
|
||||
public virtual void LoadImage()
|
||||
protected virtual void LocalLoadImage()
|
||||
{
|
||||
BitmapData bmpdata = null;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Methods
|
||||
|
||||
// Dont do anything
|
||||
public override void LoadImage() { bitmap = CodeImp.DoomBuilder.Properties.Resources.UnknownImage; }
|
||||
protected override void LocalLoadImage() { bitmap = CodeImp.DoomBuilder.Properties.Resources.UnknownImage; }
|
||||
internal override void CreateTexture() { }
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Methods
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
Stream bitmapdata;
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
bitmapdata.Dispose();
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
base.LocalLoadImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Methods
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
IImageReader reader;
|
||||
MemoryStream mem;
|
||||
|
@ -108,7 +108,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
base.LocalLoadImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
#region ================== Methods
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
Stream lumpdata;
|
||||
MemoryStream mem;
|
||||
|
@ -101,7 +101,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
base.LocalLoadImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// This loads the image
|
||||
public override void LoadImage()
|
||||
protected override void LocalLoadImage()
|
||||
{
|
||||
uint datalength = (uint)(width * height * sizeof(PixelColor));
|
||||
IImageReader reader;
|
||||
|
@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// Pass on to base
|
||||
base.LoadImage();
|
||||
base.LocalLoadImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ namespace CodeImp.DoomBuilder
|
|||
internal D3DDevice Graphics { get { return graphics; } }
|
||||
public IRenderer2D Renderer2D { get { return renderer2d; } }
|
||||
public IRenderer3D Renderer3D { get { return renderer3d; } }
|
||||
internal Renderer2D CRenderer2D { get { return renderer2d; } }
|
||||
internal Renderer3D CRenderer3D { get { return renderer3d; } }
|
||||
public GameConfiguration Config { get { return config; } }
|
||||
internal ConfigurationInfo ConfigSettings { get { return configinfo; } }
|
||||
public GridSetup Grid { get { return grid; } }
|
||||
|
@ -235,14 +237,14 @@ namespace CodeImp.DoomBuilder
|
|||
io.Write(map, TEMP_MAP_HEADER, 1);
|
||||
CreateRequiredLumps(tempwad, TEMP_MAP_HEADER);
|
||||
|
||||
// Update structures
|
||||
map.Update();
|
||||
thingsfilter.Update();
|
||||
|
||||
// Load data manager
|
||||
General.WriteLogLine("Loading data resources...");
|
||||
data = new DataManager();
|
||||
data.Load(configinfo.Resources, options.Resources);
|
||||
|
||||
// Update structures
|
||||
map.Update();
|
||||
thingsfilter.Update();
|
||||
|
||||
// Bind any methods
|
||||
General.Actions.BindMethods(this);
|
||||
|
@ -319,16 +321,16 @@ namespace CodeImp.DoomBuilder
|
|||
General.ShowErrorMessage("Unable to read the map data structures with the specified configuration.", MessageBoxButtons.OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update structures
|
||||
map.Update();
|
||||
thingsfilter.Update();
|
||||
|
||||
// Load data manager
|
||||
General.WriteLogLine("Loading data resources...");
|
||||
data = new DataManager();
|
||||
maplocation = new DataLocation(DataLocation.RESOURCE_WAD, filepathname, false, false);
|
||||
data.Load(configinfo.Resources, options.Resources, maplocation);
|
||||
|
||||
// Update structures
|
||||
map.Update();
|
||||
thingsfilter.Update();
|
||||
|
||||
// Bind any methods
|
||||
General.Actions.BindMethods(this);
|
||||
|
@ -902,18 +904,8 @@ namespace CodeImp.DoomBuilder
|
|||
// Engage new mode
|
||||
if(newmode != null) newmode.OnEngage();
|
||||
|
||||
// Check appropriate button on interface
|
||||
// And show the mode name
|
||||
if(mode != null)
|
||||
{
|
||||
General.MainWindow.CheckEditModeButton(mode.EditModeButtonName);
|
||||
General.MainWindow.DisplayModeName(mode.Attributes.DisplayName);
|
||||
}
|
||||
else
|
||||
{
|
||||
General.MainWindow.CheckEditModeButton("");
|
||||
General.MainWindow.DisplayModeName("");
|
||||
}
|
||||
// Update the interface
|
||||
General.MainWindow.EditModeChanged();
|
||||
|
||||
// Dispose old mode
|
||||
if(oldmode != null) oldmode.Dispose();
|
||||
|
|
|
@ -26,12 +26,14 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using System.Collections.ObjectModel;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
public sealed class Sector : MapElement
|
||||
public sealed class Sector : MapElement, ID3DResource
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -76,6 +78,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private Triangulation triangles;
|
||||
private FlatVertex[] flatvertices;
|
||||
private ReadOnlyCollection<LabelPositionInfo> labels;
|
||||
private VertexBuffer flatceilingbuffer;
|
||||
private VertexBuffer flatfloorbuffer;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -100,6 +104,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public Sector Clone { get { return clone; } set { clone = value; } }
|
||||
public Triangulation Triangles { get { return triangles; } }
|
||||
public FlatVertex[] FlatVertices { get { return flatvertices; } }
|
||||
internal VertexBuffer FlatCeilingBuffer { get { return flatceilingbuffer; } }
|
||||
internal VertexBuffer FlatFloorBuffer { get { return flatfloorbuffer; } }
|
||||
public ReadOnlyCollection<LabelPositionInfo> Labels { get { return labels; } }
|
||||
|
||||
#endregion
|
||||
|
@ -120,7 +126,9 @@ namespace CodeImp.DoomBuilder.Map
|
|||
this.longfloortexname = MapSet.EmptyLongName;
|
||||
this.longceiltexname = MapSet.EmptyLongName;
|
||||
this.triangulationneeded = true;
|
||||
|
||||
|
||||
General.Map.Graphics.RegisterResource(this);
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
@ -144,7 +152,13 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// because a sidedef cannot exist without reference to its sector.
|
||||
foreach(Sidedef sd in sidedefs) sd.Dispose();
|
||||
|
||||
General.Map.Graphics.UnregisterResource(this);
|
||||
|
||||
// Clean up
|
||||
if(flatceilingbuffer != null) flatceilingbuffer.Dispose();
|
||||
if(flatfloorbuffer != null) flatfloorbuffer.Dispose();
|
||||
flatceilingbuffer = null;
|
||||
flatfloorbuffer = null;
|
||||
mainlistitem = null;
|
||||
sidedefs = null;
|
||||
things = null;
|
||||
|
@ -222,6 +236,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
{
|
||||
// Triangulate sector
|
||||
triangles = Triangulation.Create(this);
|
||||
triangulationneeded = false;
|
||||
|
||||
// Make label positions
|
||||
labels = Array.AsReadOnly<LabelPositionInfo>(Tools.FindLabelPositions(this).ToArray());
|
||||
|
@ -248,8 +263,113 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Updated
|
||||
updateneeded = false;
|
||||
|
||||
// Update buffers
|
||||
UpdateFloorSurface();
|
||||
UpdateCeilingSurface();
|
||||
}
|
||||
}
|
||||
|
||||
// This updates the buffer with flat vertices
|
||||
public void UpdateFloorSurface()
|
||||
{
|
||||
// Trash buffer, if any
|
||||
if(flatfloorbuffer != null)
|
||||
{
|
||||
flatfloorbuffer.Dispose();
|
||||
flatfloorbuffer = null;
|
||||
}
|
||||
|
||||
// Not updated?
|
||||
if(updateneeded)
|
||||
{
|
||||
// Make sure the sector is up-to-date
|
||||
// This will automatically call this function again
|
||||
UpdateCache();
|
||||
}
|
||||
// Any vertices?
|
||||
else if(flatvertices.Length > 0)
|
||||
{
|
||||
FlatVertex[] buffervertices = new FlatVertex[triangles.Vertices.Count];
|
||||
flatvertices.CopyTo(buffervertices, 0);
|
||||
|
||||
// Raise event to allow plugins to modify this data
|
||||
General.Plugins.OnSectorFloorSurfaceUpdate(this, ref buffervertices);
|
||||
|
||||
// Make the buffer
|
||||
flatfloorbuffer = new VertexBuffer(General.Map.Graphics.Device, FlatVertex.Stride * buffervertices.Length,
|
||||
Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default);
|
||||
|
||||
// Fill it
|
||||
DataStream bufferstream = flatfloorbuffer.Lock(0, FlatVertex.Stride * buffervertices.Length, LockFlags.Discard);
|
||||
bufferstream.WriteRange<FlatVertex>(buffervertices);
|
||||
flatfloorbuffer.Unlock();
|
||||
bufferstream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// This updates the buffer with flat vertices
|
||||
public void UpdateCeilingSurface()
|
||||
{
|
||||
// Trash buffer, if any
|
||||
if(flatceilingbuffer != null)
|
||||
{
|
||||
flatceilingbuffer.Dispose();
|
||||
flatceilingbuffer = null;
|
||||
}
|
||||
|
||||
// Not updated?
|
||||
if(updateneeded)
|
||||
{
|
||||
// Make sure the sector is up-to-date
|
||||
// This will automatically call this function again
|
||||
UpdateCache();
|
||||
}
|
||||
// Any vertices?
|
||||
else if(flatvertices.Length > 0)
|
||||
{
|
||||
FlatVertex[] buffervertices = new FlatVertex[triangles.Vertices.Count];
|
||||
flatvertices.CopyTo(buffervertices, 0);
|
||||
|
||||
// Raise event to allow plugins to modify this data
|
||||
General.Plugins.OnSectorCeilingSurfaceUpdate(this, ref buffervertices);
|
||||
|
||||
// Make the buffer
|
||||
flatceilingbuffer = new VertexBuffer(General.Map.Graphics.Device, FlatVertex.Stride * buffervertices.Length,
|
||||
Usage.WriteOnly | Usage.Dynamic, VertexFormat.None, Pool.Default);
|
||||
|
||||
// Fill it
|
||||
DataStream bufferstream = flatceilingbuffer.Lock(0, FlatVertex.Stride * buffervertices.Length, LockFlags.Discard);
|
||||
bufferstream.WriteRange<FlatVertex>(buffervertices);
|
||||
flatceilingbuffer.Unlock();
|
||||
bufferstream.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// Unload unstable resources
|
||||
public void UnloadResource()
|
||||
{
|
||||
// Trash buffer, if any
|
||||
if(flatfloorbuffer != null)
|
||||
{
|
||||
flatfloorbuffer.Dispose();
|
||||
flatfloorbuffer = null;
|
||||
}
|
||||
|
||||
// Trash buffer, if any
|
||||
if(flatceilingbuffer != null)
|
||||
{
|
||||
flatceilingbuffer.Dispose();
|
||||
flatceilingbuffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Reload unstable resources
|
||||
public void ReloadResource()
|
||||
{
|
||||
UpdateFloorSurface();
|
||||
UpdateCeilingSurface();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -7,6 +7,9 @@ using System.Globalization;
|
|||
using System.Text;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -99,6 +102,22 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
|
||||
#region ================== Events
|
||||
|
||||
/// <summary>
|
||||
/// This iscalled when the ceiling surface buffer is updated for a sector. The plugin can
|
||||
/// modify the vertices to change how the surface is presented to the user.
|
||||
/// </summary>
|
||||
public virtual void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This iscalled when the floor surface buffer is updated for a sector. The plugin can
|
||||
/// modify the vertices to change how the surface is presented to the user.
|
||||
/// </summary>
|
||||
public virtual void OnSectorFloorSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before a map is opened.
|
||||
/// </summary>
|
||||
|
|
|
@ -24,6 +24,8 @@ using System.Text;
|
|||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using System.Reflection;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -307,6 +309,18 @@ namespace CodeImp.DoomBuilder.Plugins
|
|||
foreach(Plugin p in plugins) p.Plug.OnMapNewEnd();
|
||||
}
|
||||
|
||||
|
||||
public void OnSectorCeilingSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
|
||||
{
|
||||
foreach(Plugin p in plugins) p.Plug.OnSectorCeilingSurfaceUpdate(s, ref vertices);
|
||||
}
|
||||
|
||||
|
||||
public void OnSectorFloorSurfaceUpdate(Sector s, ref FlatVertex[] vertices)
|
||||
{
|
||||
foreach(Plugin p in plugins) p.Plug.OnSectorFloorSurfaceUpdate(s, ref vertices);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
30
Source/Properties/Resources.Designer.cs
generated
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.832
|
||||
// Runtime Version:2.0.50727.1433
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
@ -284,6 +284,34 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ViewBrightness {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ViewBrightness", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ViewNormal {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ViewNormal", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ViewTextureCeiling {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ViewTextureCeiling", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ViewTextureFloor {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ViewTextureFloor", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Warning {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Warning", resourceCulture);
|
||||
|
|
|
@ -127,8 +127,11 @@
|
|||
<data name="UnknownImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\UnknownImage.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="Hourglass" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Hourglass.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ViewNormal" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ViewNormal.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Status1" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Status1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
@ -142,9 +145,18 @@
|
|||
<data name="Status2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Status2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="KnownTextureSet" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\KnownTextureSet.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Splash3_trans" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Splash3_trans.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ViewTextureFloor" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ViewTextureFloor.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Zoom_arrowup" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Zoom_arrowup.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -154,12 +166,12 @@
|
|||
<data name="Monster2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Monster2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Hourglass" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Hourglass.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="File" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Copy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="mergegeometry" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mergegeometry.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -175,18 +187,15 @@
|
|||
<data name="Undo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Undo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Paste" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Paste.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Failed" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Failed.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="MissingTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Zoom" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Zoom.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ViewBrightness" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ViewBrightness.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Test" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Test.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -196,12 +205,12 @@
|
|||
<data name="SlimDX_small" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SlimDX_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Paste" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Paste.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="WarningOff" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\WarningOff.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Splash3_small" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Splash3_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="mergegeometry2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\mergegeometry2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -211,19 +220,22 @@
|
|||
<data name="Filter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Filter.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Splash3_small" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Splash3_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Folder" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Folder.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Grid4" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Grid4.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="MissingTexture" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\MissingTexture.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Warning" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Warning.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="KnownTextureSet" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\KnownTextureSet.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="ViewTextureCeiling" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ViewTextureCeiling.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
|
@ -59,7 +59,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private Capabilities devicecaps;
|
||||
private Device device;
|
||||
private Viewport viewport;
|
||||
private List<ID3DResource> resources;
|
||||
private Dictionary<ID3DResource, ID3DResource> resources;
|
||||
private ShaderManager shaders;
|
||||
private Surface backbuffer;
|
||||
private Surface depthbuffer;
|
||||
|
@ -94,7 +94,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
this.rendertarget = rendertarget;
|
||||
|
||||
// Create resources list
|
||||
resources = new List<ID3DResource>();
|
||||
resources = new Dictionary<ID3DResource, ID3DResource>();
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
|
@ -107,7 +107,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
foreach(ID3DResource res in resources) res.UnloadResource();
|
||||
foreach(ID3DResource res in resources.Values) res.UnloadResource();
|
||||
if(shaders != null) shaders.Dispose();
|
||||
rendertarget = null;
|
||||
if(backbuffer != null) backbuffer.Dispose();
|
||||
|
@ -342,7 +342,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
internal void RegisterResource(ID3DResource res)
|
||||
{
|
||||
// Add resource
|
||||
resources.Add(res);
|
||||
resources.Add(res, res);
|
||||
}
|
||||
|
||||
// This unregisters a resource
|
||||
|
@ -364,7 +364,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
//if(coopresult.Name != "D3DERR_DEVICENOTRESET")
|
||||
{
|
||||
// Unload all Direct3D resources
|
||||
foreach(ID3DResource res in resources) res.UnloadResource();
|
||||
foreach(ID3DResource res in resources.Values) res.UnloadResource();
|
||||
|
||||
// Lose backbuffers
|
||||
if(backbuffer != null) backbuffer.Dispose();
|
||||
|
@ -397,7 +397,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
SetupSettings();
|
||||
|
||||
// Reload all Direct3D resources
|
||||
foreach(ID3DResource res in resources) res.ReloadResource();
|
||||
foreach(ID3DResource res in resources.Values) res.ReloadResource();
|
||||
|
||||
// Success
|
||||
return true;
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
float TranslateY { get; }
|
||||
float Scale { get; }
|
||||
int VertexSize { get; }
|
||||
ViewMode ViewMode { get; }
|
||||
|
||||
// Color methods
|
||||
PixelColor DetermineLinedefColor(Linedef l);
|
||||
|
@ -77,5 +78,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
void RenderLine(Vector2D start, Vector2D end, float thickness, PixelColor c, bool transformcoords);
|
||||
void RenderText(TextLabel text);
|
||||
void RenderGeometry(FlatVertex[] vertices, ImageData texture, bool transformcoords);
|
||||
void RedrawSurface();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Standard classic mode
|
||||
standard = new Presentation();
|
||||
standard.layers.Add(new PresentLayer(RendererLayer.Background, BlendingMode.Mask));
|
||||
standard.layers.Add(new PresentLayer(RendererLayer.Surface, BlendingMode.Mask));
|
||||
standard.layers.Add(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, THINGS_BACK_ALPHA));
|
||||
standard.layers.Add(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
|
||||
standard.layers.Add(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
|
||||
|
@ -73,6 +74,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Things classic mode
|
||||
things = new Presentation();
|
||||
things.layers.Add(new PresentLayer(RendererLayer.Background, BlendingMode.Mask));
|
||||
things.layers.Add(new PresentLayer(RendererLayer.Surface, BlendingMode.Mask));
|
||||
things.layers.Add(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
|
||||
things.layers.Add(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
|
||||
things.layers.Add(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, 1f, false));
|
||||
|
@ -143,7 +145,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
Grid,
|
||||
Things,
|
||||
Geometry,
|
||||
Overlay
|
||||
Overlay,
|
||||
Surface
|
||||
}
|
||||
|
||||
// Blending modes
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
Background = 1,
|
||||
Plotter = 2,
|
||||
Things = 3,
|
||||
Overlay = 4
|
||||
Overlay = 4,
|
||||
Surface = 5
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private const int THING_SHINY = 1;
|
||||
private const int THING_SQUARE = 2;
|
||||
private const int NUM_THING_TEXTURES = 4;
|
||||
internal const int NUM_VIEW_MODES = 4;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -74,6 +75,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private Texture plottertex;
|
||||
private Texture thingstex;
|
||||
private Texture overlaytex;
|
||||
private Texture surfacetex;
|
||||
|
||||
// Locking data
|
||||
private DataRectangle plotlocked;
|
||||
|
@ -110,6 +112,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private ResourceImage[] thingtexture;
|
||||
|
||||
// View settings (world coordinates)
|
||||
private ViewMode viewmode;
|
||||
private float scale;
|
||||
private float scaleinv;
|
||||
private float offsetx;
|
||||
|
@ -135,6 +138,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public float TranslateY { get { return translatey; } }
|
||||
public float Scale { get { return scale; } }
|
||||
public int VertexSize { get { return vertexsize; } }
|
||||
public ViewMode ViewMode { get { return viewmode; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -294,7 +298,17 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
case RendererLayer.Overlay:
|
||||
graphics.Device.SetTexture(0, overlaytex);
|
||||
graphics.Shaders.Display2D.Texture1 = overlaytex;
|
||||
graphics.Shaders.Display2D.SetSettings(1f / thingssize.Width, 1f / thingssize.Height, FSAA_FACTOR, layer.alpha);
|
||||
graphics.Shaders.Display2D.SetSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha);
|
||||
graphics.Shaders.Display2D.BeginPass(aapass);
|
||||
graphics.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
|
||||
graphics.Shaders.Display2D.EndPass();
|
||||
break;
|
||||
|
||||
// SURFACE
|
||||
case RendererLayer.Surface:
|
||||
graphics.Device.SetTexture(0, surfacetex);
|
||||
graphics.Shaders.Display2D.Texture1 = surfacetex;
|
||||
graphics.Shaders.Display2D.SetSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha);
|
||||
graphics.Shaders.Display2D.BeginPass(aapass);
|
||||
graphics.Device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
|
||||
graphics.Shaders.Display2D.EndPass();
|
||||
|
@ -353,6 +367,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
if(plottertex != null) plottertex.Dispose();
|
||||
if(thingstex != null) thingstex.Dispose();
|
||||
if(overlaytex != null) overlaytex.Dispose();
|
||||
if(surfacetex != null) surfacetex.Dispose();
|
||||
if(backtex != null) backtex.Dispose();
|
||||
if(screenverts != null) screenverts.Dispose();
|
||||
plottertex = null;
|
||||
|
@ -360,6 +375,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
backtex = null;
|
||||
screenverts = null;
|
||||
overlaytex = null;
|
||||
surfacetex = null;
|
||||
|
||||
// Trash things batch buffer
|
||||
if(thingsvertices != null) thingsvertices.Dispose();
|
||||
|
@ -393,6 +409,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
thingstex = new Texture(graphics.Device, windowsize.Width, windowsize.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
|
||||
backtex = new Texture(graphics.Device, windowsize.Width, windowsize.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
|
||||
overlaytex = new Texture(graphics.Device, windowsize.Width, windowsize.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
|
||||
surfacetex = new Texture(graphics.Device, windowsize.Width, windowsize.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
|
||||
|
||||
// Get the real surface sizes
|
||||
sd = plottertex.GetLevelDescription(0);
|
||||
|
@ -456,8 +473,14 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Coordination
|
||||
#region ================== View
|
||||
|
||||
// This changes view mode
|
||||
public void SetViewMode(ViewMode mode)
|
||||
{
|
||||
viewmode = mode;
|
||||
}
|
||||
|
||||
// This changes view position
|
||||
public void PositionView(float x, float y)
|
||||
{
|
||||
|
@ -679,7 +702,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
// Clean up things / overlay
|
||||
if((renderlayer == RenderLayers.Things) || (renderlayer == RenderLayers.Overlay))
|
||||
if((renderlayer == RenderLayers.Things) || (renderlayer == RenderLayers.Overlay) || (renderlayer == RenderLayers.Surface))
|
||||
{
|
||||
// Stop rendering
|
||||
graphics.FinishRendering();
|
||||
|
@ -1067,6 +1090,131 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Surface
|
||||
|
||||
// This redraws the surface
|
||||
public void RedrawSurface()
|
||||
{
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidOperationException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
renderlayer = RenderLayers.Surface;
|
||||
|
||||
// Rendertargets available?
|
||||
if(surfacetex != null)
|
||||
{
|
||||
// Set the rendertarget to the surface texture
|
||||
targetsurface = surfacetex.GetSurfaceLevel(0);
|
||||
if(graphics.StartRendering(true, General.Colors.Background.WithAlpha(0).ToColorValue(), targetsurface, null))
|
||||
{
|
||||
// Set transformations
|
||||
UpdateTransformations();
|
||||
|
||||
// Render what must be rendered
|
||||
switch(viewmode)
|
||||
{
|
||||
case ViewMode.Brightness: RenderSectorBrightness(General.Map.Map.Sectors); break;
|
||||
case ViewMode.FloorTextures: RenderSectorFloors(General.Map.Map.Sectors); break;
|
||||
case ViewMode.CeilingTextures: RenderSectorCeilings(General.Map.Map.Sectors); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Done
|
||||
Finish();
|
||||
}
|
||||
|
||||
// This renders all sector floors
|
||||
private void RenderSectorFloors(ICollection<Sector> sectors)
|
||||
{
|
||||
// Set states
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
graphics.Device.SetRenderState(RenderState.ZEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
SetWorldTransformation(true);
|
||||
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f);
|
||||
|
||||
// Render all sectors
|
||||
foreach(Sector s in sectors)
|
||||
RenderSectorSurface(s, s.FlatFloorBuffer, s.LongFloorTexture);
|
||||
}
|
||||
|
||||
// This renders all sector ceilings
|
||||
private void RenderSectorCeilings(ICollection<Sector> sectors)
|
||||
{
|
||||
// Set states
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
graphics.Device.SetRenderState(RenderState.ZEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
SetWorldTransformation(true);
|
||||
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f);
|
||||
|
||||
// Render all sectors
|
||||
foreach(Sector s in sectors)
|
||||
RenderSectorSurface(s, s.FlatCeilingBuffer, s.LongCeilTexture);
|
||||
}
|
||||
|
||||
// This renders all sector brightness levels
|
||||
private void RenderSectorBrightness(ICollection<Sector> sectors)
|
||||
{
|
||||
// Set states
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
graphics.Device.SetRenderState(RenderState.ZEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaBlendEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.AlphaTestEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
SetWorldTransformation(true);
|
||||
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f);
|
||||
|
||||
// Render all sectors
|
||||
foreach(Sector s in sectors)
|
||||
RenderSectorSurface(s, s.FlatFloorBuffer, 0);
|
||||
}
|
||||
|
||||
// This renders the geometry and tecture of the sector
|
||||
private void RenderSectorSurface(Sector s, VertexBuffer buffer, long longimagename)
|
||||
{
|
||||
Texture t = null;
|
||||
|
||||
if((buffer != null) && (s.FlatVertices != null) && (s.FlatVertices.Length > 0))
|
||||
{
|
||||
ImageData img = General.Map.Data.GetFlatImage(longimagename);
|
||||
if(img != null)
|
||||
{
|
||||
// Is the texture loaded?
|
||||
if(img.IsImageLoaded)
|
||||
{
|
||||
if(img.Texture == null) img.CreateTexture();
|
||||
t = img.Texture;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = whitetexture.Texture;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t = whitetexture.Texture;
|
||||
}
|
||||
|
||||
// Set renderstates for rendering
|
||||
graphics.Shaders.Display2D.Texture1 = t;
|
||||
graphics.Device.SetTexture(0, t);
|
||||
graphics.Device.SetStreamSource(0, buffer, 0, FlatVertex.Stride);
|
||||
|
||||
// Draw
|
||||
graphics.Shaders.Display2D.Begin();
|
||||
graphics.Shaders.Display2D.BeginPass(1);
|
||||
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, s.FlatVertices.Length / 3);
|
||||
graphics.Shaders.Display2D.EndPass();
|
||||
graphics.Shaders.Display2D.End();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Overlay
|
||||
|
||||
// This renders geometry
|
||||
|
@ -1099,7 +1247,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetTexture(0, t);
|
||||
SetWorldTransformation(transformcoords);
|
||||
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f);
|
||||
|
||||
|
||||
// Draw
|
||||
graphics.Shaders.Display2D.Begin();
|
||||
graphics.Shaders.Display2D.BeginPass(1);
|
||||
|
|
48
Source/Rendering/ViewMode.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
|
||||
#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 System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using SlimDX.Direct3D9;
|
||||
using SlimDX;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using System.Drawing.Imaging;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Rendering
|
||||
{
|
||||
public enum ViewMode : int
|
||||
{
|
||||
Normal = 0,
|
||||
Brightness = 1,
|
||||
FloorTextures = 2,
|
||||
CeilingTextures = 3
|
||||
}
|
||||
}
|
BIN
Source/Resources/ViewBrightness.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
Source/Resources/ViewNormal.png
Normal file
After Width: | Height: | Size: 239 B |
BIN
Source/Resources/ViewTextureCeiling.png
Normal file
After Width: | Height: | Size: 559 B |
BIN
Source/Resources/ViewTextureFloor.png
Normal file
After Width: | Height: | Size: 562 B |
1223
Source/Windows/MainForm.Designer.cs
generated
|
@ -36,6 +36,7 @@ using CodeImp.DoomBuilder.Controls;
|
|||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Properties;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -62,7 +63,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
#region ================== Delegates
|
||||
|
||||
private delegate void CallUpdateStatusIcon();
|
||||
|
||||
private delegate void CallImageDataLoaded(ImageData img);
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
@ -88,6 +90,9 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Recent files
|
||||
private ToolStripMenuItem[] recentitems;
|
||||
|
||||
// View mode buttons
|
||||
private ToolStripButton[] viewmodes;
|
||||
|
||||
// Edit modes
|
||||
private List<ToolStripItem> editmodeitems;
|
||||
|
||||
|
@ -123,6 +128,13 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Setup controls
|
||||
InitializeComponent();
|
||||
editmodeitems = new List<ToolStripItem>();
|
||||
|
||||
// Make array from view mode buttons
|
||||
viewmodes = new ToolStripButton[Renderer2D.NUM_VIEW_MODES];
|
||||
viewmodes[(int)ViewMode.Normal] = buttonviewnormal;
|
||||
viewmodes[(int)ViewMode.Brightness] = buttonviewbrightness;
|
||||
viewmodes[(int)ViewMode.FloorTextures] = buttonviewfloors;
|
||||
viewmodes[(int)ViewMode.CeilingTextures] = buttonviewceilings;
|
||||
|
||||
// Visual Studio IDE doesn't let me set these in the designer :(
|
||||
buttonzoom.Font = menufile.Font;
|
||||
|
@ -154,6 +166,26 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
#region ================== General
|
||||
|
||||
// Editing mode changed!
|
||||
internal void EditModeChanged()
|
||||
{
|
||||
// Check appropriate button on interface
|
||||
// And show the mode name
|
||||
if(General.Map.Mode != null)
|
||||
{
|
||||
General.MainWindow.CheckEditModeButton(General.Map.Mode.EditModeButtonName);
|
||||
General.MainWindow.DisplayModeName(General.Map.Mode.Attributes.DisplayName);
|
||||
}
|
||||
else
|
||||
{
|
||||
General.MainWindow.CheckEditModeButton("");
|
||||
General.MainWindow.DisplayModeName("");
|
||||
}
|
||||
|
||||
// View mode only matters in classic editing modes
|
||||
for(int i = 0; i < Renderer2D.NUM_VIEW_MODES; i++) viewmodes[i].Enabled = (General.Map.Mode is ClassicMode);
|
||||
}
|
||||
|
||||
// This makes a beep sound
|
||||
public void MessageBeep(MessageBeepType type)
|
||||
{
|
||||
|
@ -1219,6 +1251,12 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Update buttons
|
||||
buttontestmonsters.Enabled = (General.Map != null);
|
||||
buttontestmonsters.Checked = General.Settings.TestMonsters;
|
||||
|
||||
// Only disable view mode buttons
|
||||
if(General.Map == null)
|
||||
{
|
||||
for(int i = 0; i < Renderer2D.NUM_VIEW_MODES; i++) viewmodes[i].Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// This checks one of the edit mode items (and unchecks all others)
|
||||
|
@ -1302,9 +1340,30 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
General.Actions[modeinfo.SwitchAction.GetFullActionName(modeinfo.Plugin.Assembly)].Begin();
|
||||
this.Update();
|
||||
}
|
||||
|
||||
|
||||
// This changes view mode
|
||||
private void ViewModeButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
int mode = 0;
|
||||
|
||||
if((sender is ToolStripButton) && (General.Map != null))
|
||||
{
|
||||
ToolStripButton button = sender as ToolStripButton;
|
||||
int.TryParse(button.Tag.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out mode);
|
||||
|
||||
// Update all view buttons
|
||||
for(int i = 0; i < Renderer2D.NUM_VIEW_MODES; i++) viewmodes[i].Checked = (i == mode);
|
||||
|
||||
// Apply view mode
|
||||
General.Map.CRenderer2D.SetViewMode((ViewMode)mode);
|
||||
|
||||
// Redraw
|
||||
RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ================== Menus
|
||||
|
||||
// This adds a menu to the menus bar
|
||||
|
@ -1851,7 +1910,48 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Processor
|
||||
#region ================== Processing
|
||||
|
||||
// This is called from the background thread when images are loaded
|
||||
// but only when first loaded or when dimensions were changed
|
||||
internal void ImageDataLoaded(ImageData img)
|
||||
{
|
||||
// From different thread?
|
||||
if(this.InvokeRequired)
|
||||
{
|
||||
// Pass the call on to the application thread
|
||||
CallImageDataLoaded call = new CallImageDataLoaded(ImageDataLoaded);
|
||||
this.Invoke(call, img);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Image is used in the map?
|
||||
if(img.UsedInMap && !img.IsDisposed && (General.Map != null))
|
||||
{
|
||||
// Go for all setors
|
||||
bool updated = false;
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
// Update floor buffer if needed
|
||||
if(s.LongFloorTexture == img.LongName)
|
||||
{
|
||||
s.UpdateFloorSurface();
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// Update ceiling buffer if needed
|
||||
if(s.LongCeilTexture == img.LongName)
|
||||
{
|
||||
s.UpdateCeilingSurface();
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If we made updates, redraw the screen
|
||||
if(updated) RedrawDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This toggles the processor
|
||||
public void SetProcessorState(bool on)
|
||||
|
|
|
@ -156,12 +156,6 @@
|
|||
<metadata name="toolStripSeparator12.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="toolStripMenuItem4.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="toolStripSeparator2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="menumain.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
@ -180,6 +174,12 @@
|
|||
<metadata name="statusbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>207, 17</value>
|
||||
</metadata>
|
||||
<metadata name="toolStripMenuItem4.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="toolStripSeparator2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<metadata name="panelinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
|