mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Added, Visual mode: translucent/additive geometry is now rendered properly.
Fixed: "Open map in current wad" action was accidentally broken in R2403.
This commit is contained in:
parent
dc840605aa
commit
f729c811f5
12 changed files with 597 additions and 421 deletions
|
@ -54,6 +54,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
protected string virtualname; //mxd. Path of this name is used in TextureBrowserForm
|
||||
protected string displayname; //mxd. Name to display in TextureBrowserForm
|
||||
protected bool isFlat; //mxd. if false, it's a texture
|
||||
protected bool istranslucent; //mxd
|
||||
protected bool hasLongName; //mxd. Texture name is longer than DataManager.CLASIC_IMAGE_NAME_LENGTH
|
||||
protected bool hasPatchWithSameName; //mxd
|
||||
protected int level; //mxd. Folder depth of this item
|
||||
|
@ -91,6 +92,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
public string VirtualName { get { return virtualname; } } //mxd
|
||||
public string DisplayName { get { return displayname; } } //mxd
|
||||
public bool IsFlat { get { return isFlat; } } //mxd
|
||||
public bool IsTranslucent { get { return istranslucent; } } //mxd
|
||||
public bool HasPatchWithSameName { get { return hasPatchWithSameName; } } //mxd
|
||||
internal bool HasLongName { get { return hasLongName; } } //mxd
|
||||
public bool UseColorCorrection { get { return usecolorcorrection; } set { usecolorcorrection = value; } }
|
||||
|
@ -289,7 +291,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
// Apply color correction
|
||||
PixelColor* pixels = (PixelColor*)(bmpdata.Scan0.ToPointer());
|
||||
General.Colors.ApplColorCorrection(pixels, bmpdata.Width * bmpdata.Height);
|
||||
General.Colors.ApplyColorCorrection(pixels, bmpdata.Width * bmpdata.Height);
|
||||
bitmap.UnlockBits(bmpdata);
|
||||
}
|
||||
}
|
||||
|
@ -335,15 +337,8 @@ namespace CodeImp.DoomBuilder.Data
|
|||
General.Map.Data.GlowingFlats[longname].CalculateTextureColor)
|
||||
{
|
||||
BitmapData bmpdata = null;
|
||||
|
||||
try
|
||||
{
|
||||
bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Cannot lock image '" + this.fullname + "' for glow color calculationt. " + e.GetType().Name + ": " + e.Message);
|
||||
}
|
||||
try { bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); }
|
||||
catch(Exception e) { General.ErrorLogger.Add(ErrorType.Error, "Cannot lock image '" + this.fullname + "' for glow color calculation. " + e.GetType().Name + ": " + e.Message); }
|
||||
|
||||
if(bmpdata != null)
|
||||
{
|
||||
|
@ -358,6 +353,9 @@ namespace CodeImp.DoomBuilder.Data
|
|||
r += cp->r;
|
||||
g += cp->g;
|
||||
b += cp->b;
|
||||
|
||||
// Also check alpha
|
||||
if(cp->a > 0 && cp->a < 255) istranslucent = true;
|
||||
}
|
||||
|
||||
// Update glow data
|
||||
|
@ -383,6 +381,32 @@ namespace CodeImp.DoomBuilder.Data
|
|||
General.Map.Data.GlowingFlats[longname].CalculateTextureColor = false;
|
||||
}
|
||||
|
||||
// Release the data
|
||||
bitmap.UnlockBits(bmpdata);
|
||||
}
|
||||
}
|
||||
//mxd. Check if the texture is translucent
|
||||
else
|
||||
{
|
||||
BitmapData bmpdata = null;
|
||||
try { bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); }
|
||||
catch(Exception e) { General.ErrorLogger.Add(ErrorType.Error, "Cannot lock image '" + this.fullname + "' for translucency check. " + e.GetType().Name + ": " + e.Message); }
|
||||
|
||||
if(bmpdata != null)
|
||||
{
|
||||
PixelColor* pixels = (PixelColor*)(bmpdata.Scan0.ToPointer());
|
||||
int numpixels = bmpdata.Width * bmpdata.Height;
|
||||
|
||||
for(PixelColor* cp = pixels + numpixels - 1; cp >= pixels; cp--)
|
||||
{
|
||||
// Check alpha
|
||||
if(cp->a > 0 && cp->a < 255)
|
||||
{
|
||||
istranslucent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Release the data
|
||||
bitmap.UnlockBits(bmpdata);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX;
|
||||
|
||||
namespace CodeImp.DoomBuilder.GZBuilder.Data
|
||||
|
@ -23,12 +24,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
|
||||
public static class BoundingBoxTools
|
||||
{
|
||||
public static Vector3[] CalculateBoundingPlane(BoundingBoxSizes bbs)
|
||||
public static Vector3D[] CalculateBoundingPlane(BoundingBoxSizes bbs)
|
||||
{
|
||||
//mxd. looks like I need only these 2 points, so...
|
||||
//center
|
||||
Vector3 v0 = new Vector3(bbs.MinX + (bbs.MaxX - bbs.MinX) / 2, bbs.MinY + (bbs.MaxY - bbs.MinY) / 2, bbs.MinZ + (bbs.MaxZ - bbs.MinZ) / 2);
|
||||
Vector3 v1 = new Vector3(bbs.MinX, bbs.MinY, bbs.MinZ);
|
||||
Vector3D v0 = new Vector3D(bbs.MinX + (bbs.MaxX - bbs.MinX) / 2, bbs.MinY + (bbs.MaxY - bbs.MinY) / 2, bbs.MinZ + (bbs.MaxZ - bbs.MinZ) / 2);
|
||||
Vector3D v1 = new Vector3D(bbs.MinX, bbs.MinY, bbs.MinZ);
|
||||
return new[] { v0, v1 };
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
/*#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
@ -254,4 +254,4 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -593,9 +593,9 @@ namespace CodeImp.DoomBuilder
|
|||
io = MapSetIO.Create(config.FormatInterface, tempwad, this);
|
||||
General.WriteLogLine("Reading map data structures from file...");
|
||||
#if DEBUG
|
||||
newmap = io.Read(map, TEMP_MAP_HEADER);
|
||||
newmap = io.Read(newmap, TEMP_MAP_HEADER);
|
||||
#else
|
||||
try { newmap = io.Read(map, TEMP_MAP_HEADER); } catch(Exception e)
|
||||
try { newmap = io.Read(newmap, TEMP_MAP_HEADER); } catch(Exception e)
|
||||
{
|
||||
General.ErrorLogger.Add(ErrorType.Error, "Unable to read the map data structures with the specified configuration. " + e.GetType().Name + ": " + e.Message);
|
||||
General.ShowErrorMessage("Unable to read the map data structures with the specified configuration.", MessageBoxButtons.OK);
|
||||
|
|
|
@ -208,7 +208,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
// This applies color-correction over a block of pixel data
|
||||
internal unsafe void ApplColorCorrection(PixelColor* pixels, int numpixels)
|
||||
internal unsafe void ApplyColorCorrection(PixelColor* pixels, int numpixels)
|
||||
{
|
||||
for(PixelColor* cp = pixels + numpixels - 1; cp >= pixels; cp--)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,25 +29,24 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
#region ================== Variables
|
||||
|
||||
// Property handlers
|
||||
private EffectHandle texture1;
|
||||
private EffectHandle worldviewproj;
|
||||
private EffectHandle minfiltersettings;
|
||||
private EffectHandle magfiltersettings;
|
||||
private EffectHandle mipfiltersettings;
|
||||
private EffectHandle maxanisotropysetting;
|
||||
private EffectHandle modulatecolor;
|
||||
private EffectHandle highlightcolor;
|
||||
private readonly EffectHandle texture1;
|
||||
private readonly EffectHandle worldviewproj;
|
||||
private readonly EffectHandle minfiltersettings;
|
||||
private readonly EffectHandle magfiltersettings;
|
||||
private readonly EffectHandle mipfiltersettings;
|
||||
private readonly EffectHandle maxanisotropysetting;
|
||||
private readonly EffectHandle highlightcolor;
|
||||
|
||||
//mxd
|
||||
private EffectHandle vertexColorHadle;
|
||||
private readonly EffectHandle vertexColorHadle;
|
||||
//lights
|
||||
private EffectHandle lightPositionAndRadiusHandle;
|
||||
private EffectHandle lightColorHandle;
|
||||
private EffectHandle worldHandle;
|
||||
private readonly EffectHandle lightPositionAndRadiusHandle;
|
||||
private readonly EffectHandle lightColorHandle;
|
||||
private readonly EffectHandle worldHandle;
|
||||
//fog
|
||||
private EffectHandle camPosHandle;
|
||||
private readonly EffectHandle camPosHandle;
|
||||
//used in ModelReader
|
||||
private VertexElement[] vertexElements;
|
||||
private readonly VertexElement[] vertexElements;
|
||||
|
||||
|
||||
#endregion
|
||||
|
@ -87,7 +86,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
minfiltersettings = effect.GetParameter(null, "minfiltersettings");
|
||||
magfiltersettings = effect.GetParameter(null, "magfiltersettings");
|
||||
mipfiltersettings = effect.GetParameter(null, "mipfiltersettings");
|
||||
modulatecolor = effect.GetParameter(null, "modulatecolor");
|
||||
highlightcolor = effect.GetParameter(null, "highlightcolor");
|
||||
maxanisotropysetting = effect.GetParameter(null, "maxanisotropysetting");
|
||||
|
||||
|
@ -142,16 +140,15 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
if(minfiltersettings != null) minfiltersettings.Dispose();
|
||||
if(magfiltersettings != null) magfiltersettings.Dispose();
|
||||
if(mipfiltersettings != null) mipfiltersettings.Dispose();
|
||||
if(modulatecolor != null) modulatecolor.Dispose();
|
||||
if(highlightcolor != null) highlightcolor.Dispose();
|
||||
if(maxanisotropysetting != null) maxanisotropysetting.Dispose();
|
||||
|
||||
//mxd
|
||||
if (vertexColorHadle != null) vertexColorHadle.Dispose();
|
||||
if (lightColorHandle != null) lightColorHandle.Dispose();
|
||||
if (lightPositionAndRadiusHandle != null) lightPositionAndRadiusHandle.Dispose();
|
||||
if (camPosHandle != null) camPosHandle.Dispose();
|
||||
if (worldHandle != null) worldHandle.Dispose();
|
||||
if(vertexColorHadle != null) vertexColorHadle.Dispose();
|
||||
if(lightColorHandle != null) lightColorHandle.Dispose();
|
||||
if(lightPositionAndRadiusHandle != null) lightPositionAndRadiusHandle.Dispose();
|
||||
if(camPosHandle != null) camPosHandle.Dispose();
|
||||
if(worldHandle != null) worldHandle.Dispose();
|
||||
|
||||
|
||||
// Done
|
||||
|
@ -195,15 +192,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
}
|
||||
|
||||
// This sets the modulation color
|
||||
public void SetModulateColor(int modcolor)
|
||||
{
|
||||
if(manager.Enabled)
|
||||
{
|
||||
effect.SetValue(modulatecolor, new Color4(modcolor));
|
||||
}
|
||||
}
|
||||
|
||||
// This sets the highlight color
|
||||
public void SetHighlightColor(int hicolor)
|
||||
{
|
||||
|
|
|
@ -29,9 +29,6 @@ struct LitPixelData
|
|||
float3 normal : TEXCOORD2; //mxd. normal
|
||||
};
|
||||
|
||||
// Modulation color
|
||||
float4 modulatecolor;
|
||||
|
||||
// Highlight color
|
||||
float4 highlightcolor;
|
||||
|
||||
|
@ -125,7 +122,7 @@ LitPixelData vs_lightpass(VertexData vd)
|
|||
float4 ps_main(PixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
return tcolor * pd.color * modulatecolor;
|
||||
return tcolor * pd.color;
|
||||
}
|
||||
|
||||
// Full-bright pixel shader
|
||||
|
@ -133,9 +130,7 @@ float4 ps_fullbright(PixelData pd) : COLOR
|
|||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor.a *= pd.color.a;
|
||||
|
||||
// Blend texture color and modulation color
|
||||
return tcolor * modulatecolor;
|
||||
return tcolor;
|
||||
}
|
||||
|
||||
// Normal pixel shader with highlight
|
||||
|
@ -143,25 +138,22 @@ float4 ps_main_highlight(PixelData pd) : COLOR
|
|||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
|
||||
// Blend texture color, vertex color and modulation color
|
||||
float4 ncolor = tcolor * pd.color * modulatecolor;
|
||||
// Blend texture color and vertex color
|
||||
float4 ncolor = tcolor * pd.color;
|
||||
float4 hcolor = float4(highlightcolor.rgb, ncolor.a);
|
||||
|
||||
//return lerp(ncolor, hcolor, highlightcolor.a);
|
||||
return float4(hcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f); //tcolor.a
|
||||
return float4(hcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f);
|
||||
}
|
||||
|
||||
// Full-bright pixel shader with highlight
|
||||
float4 ps_fullbright_highlight(PixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
|
||||
// Blend texture color and modulation color
|
||||
float4 ncolor = tcolor * modulatecolor;
|
||||
float4 hcolor = float4(highlightcolor.rgb, ncolor.a);
|
||||
float4 hcolor = float4(highlightcolor.rgb, tcolor.a);
|
||||
|
||||
//return lerp(ncolor, hcolor, highlightcolor.a);
|
||||
return float4(hcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f); //tcolor.a
|
||||
return float4(hcolor.rgb * highlightcolor.a + (tcolor.rgb - 0.4f * highlightcolor.a), tcolor.a + 0.25f);
|
||||
}
|
||||
|
||||
//mxd. This adds fog color to current pixel color
|
||||
|
@ -180,7 +172,7 @@ float4 getFogColor(LitPixelData pd, float4 color)
|
|||
float4 ps_main_fog(LitPixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
return getFogColor(pd, tcolor * pd.color * modulatecolor);
|
||||
return getFogColor(pd, tcolor * pd.color);
|
||||
}
|
||||
|
||||
// Normal pixel shader with highlight
|
||||
|
@ -188,10 +180,11 @@ float4 ps_main_highlight_fog(LitPixelData pd) : COLOR
|
|||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
|
||||
// Blend texture color, vertex color and modulation color
|
||||
float4 ncolor = tcolor * pd.color * modulatecolor;
|
||||
// Blend texture color and vertex color
|
||||
float4 ncolor = getFogColor(pd, tcolor * pd.color);
|
||||
float4 hcolor = float4(highlightcolor.rgb, ncolor.a);
|
||||
return getFogColor(pd, float4(hcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f)) * float4(highlightcolor.rgb, 1.0f);
|
||||
|
||||
return float4(hcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f);
|
||||
}
|
||||
|
||||
//mxd: used to draw bounding boxes
|
||||
|
|
|
@ -29,7 +29,7 @@ using SlimDX;
|
|||
|
||||
namespace CodeImp.DoomBuilder.VisualModes
|
||||
{
|
||||
public abstract class VisualGeometry : IVisualPickable, IComparable<VisualGeometry>
|
||||
public abstract class VisualGeometry : IVisualPickable
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
|
@ -62,13 +62,13 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
protected float pickrayu;
|
||||
|
||||
// Rendering
|
||||
private int renderpass = (int)RenderPass.Solid;
|
||||
private RenderPass renderpass = RenderPass.Solid;
|
||||
|
||||
// Sector buffer info
|
||||
private int vertexoffset;
|
||||
|
||||
//mxd
|
||||
private Vector3[] boundingBox;
|
||||
private Vector3D[] boundingBox;
|
||||
protected VisualGeometryType geometrytype;
|
||||
protected string partname; //UDMF part name
|
||||
|
||||
|
@ -80,16 +80,15 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public WorldVertex[] Vertices { get { return vertices; } } //mxd
|
||||
internal int VertexOffset { get { return vertexoffset; } set { vertexoffset = value; } }
|
||||
internal int Triangles { get { return triangles; } }
|
||||
internal int RenderPassInt { get { return renderpass; } }
|
||||
|
||||
//mxd
|
||||
public Vector3[] BoundingBox { get { return boundingBox; } }
|
||||
public Vector3D[] BoundingBox { get { return boundingBox; } }
|
||||
public VisualGeometryType GeometryType { get { return geometrytype; } }
|
||||
|
||||
/// <summary>
|
||||
/// Render pass in which this geometry must be rendered. Default is Solid.
|
||||
/// </summary>
|
||||
public RenderPass RenderPass { get { return (RenderPass)renderpass; } set { renderpass = (int)value; } }
|
||||
public RenderPass RenderPass { get { return renderpass; } set { renderpass = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Image to use as texture on this geometry.
|
||||
|
@ -214,13 +213,6 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
{
|
||||
return sidedef.Line;
|
||||
}
|
||||
|
||||
// This compares for sorting by sector
|
||||
public int CompareTo(VisualGeometry other)
|
||||
{
|
||||
// Compare sectors
|
||||
return this.sector.Sector.FixedIndex - other.sector.Sector.FixedIndex;
|
||||
}
|
||||
|
||||
// This keeps the results for a sidedef intersection
|
||||
internal void SetPickResults(Vector3D intersect, float u)
|
||||
|
|
|
@ -482,16 +482,16 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
delta = delta.GetFixedLength(General.Settings.ViewDistance * 0.98f);
|
||||
VisualPickResult target = PickObject(start, start + delta);
|
||||
|
||||
if (target.picked == null) return new Vector2D(float.NaN, float.NaN);
|
||||
if(target.picked == null) return new Vector2D(float.NaN, float.NaN);
|
||||
|
||||
//now find where exactly did we hit
|
||||
if (target.picked is VisualGeometry)
|
||||
if(target.picked is VisualGeometry)
|
||||
{
|
||||
VisualGeometry vg = target.picked as VisualGeometry;
|
||||
return GetIntersection(start, start + delta, new Vector3D(vg.BoundingBox[0].X, vg.BoundingBox[0].Y, vg.BoundingBox[0].Z), new Vector3D(vg.Vertices[0].nx, vg.Vertices[0].ny, vg.Vertices[0].nz));
|
||||
return GetIntersection(start, start + delta, vg.BoundingBox[0], new Vector3D(vg.Vertices[0].nx, vg.Vertices[0].ny, vg.Vertices[0].nz));
|
||||
}
|
||||
|
||||
if (target.picked is VisualThing)
|
||||
if(target.picked is VisualThing)
|
||||
{
|
||||
VisualThing vt = target.picked as VisualThing;
|
||||
return GetIntersection(start, start + delta, vt.CenterV3D, D3DDevice.V3D(vt.Center - vt.PositionV3));
|
||||
|
|
|
@ -32,7 +32,7 @@ using Plane = CodeImp.DoomBuilder.Geometry.Plane;
|
|||
|
||||
namespace CodeImp.DoomBuilder.VisualModes
|
||||
{
|
||||
public abstract class VisualThing : IVisualPickable, ID3DResource, IComparable<VisualThing>
|
||||
public abstract class VisualThing : IVisualPickable, ID3DResource
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -58,12 +58,11 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
private int triangles;
|
||||
|
||||
// Rendering
|
||||
private int renderpass;
|
||||
private RenderPass renderpass;
|
||||
private Matrix position;
|
||||
private Matrix cagescales;
|
||||
private Vector2D pos2d;
|
||||
private float cameradistance;
|
||||
private int cagecolor;
|
||||
private int cameradistance;
|
||||
private Color4 cagecolor;
|
||||
protected bool sizeless; //mxd. Used to render visual things with 0 width and height
|
||||
protected float fogdistance; //mxd. Distance, at which fog color completely replaces texture color of this thing
|
||||
|
||||
|
@ -74,7 +73,6 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
private bool isdisposed;
|
||||
|
||||
//mxd
|
||||
private int cameraDistance3D;
|
||||
private int thingheight;
|
||||
|
||||
//mxd. light properties
|
||||
|
@ -86,7 +84,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
private float lightSecondaryRadius;
|
||||
private Vector3 position_v3;
|
||||
private float lightDelta; //used in light animation
|
||||
private Vector3[] boundingBox;
|
||||
private Vector3D[] boundingBox;
|
||||
|
||||
//gldefs light
|
||||
private Vector3 lightOffset;
|
||||
|
@ -100,27 +98,28 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
internal VertexBuffer GeometryBuffer { get { return geobuffer; } }
|
||||
internal bool NeedsUpdateGeo { get { return updategeo; } }
|
||||
internal int Triangles { get { return triangles; } }
|
||||
internal int RenderPassInt { get { return renderpass; } }
|
||||
internal Matrix Position { get { return position; } }
|
||||
internal Matrix CageScales { get { return cagescales; } }
|
||||
internal int CageColor { get { return cagecolor; } }
|
||||
internal Color4 CageColor { get { return cagecolor; } }
|
||||
public ThingTypeInfo Info { get { return info; } } //mxd
|
||||
|
||||
//mxd
|
||||
internal int VertexColor { get { return vertices.Length > 0 ? vertices[0].c : 0;} }
|
||||
public int CameraDistance3D { get { return cameraDistance3D; } }
|
||||
public int CameraDistance { get { return cameradistance; } }
|
||||
public bool Sizeless { get { return sizeless; } }
|
||||
public float FogDistance { get { return fogdistance; } }
|
||||
public Vector3 Center {
|
||||
get {
|
||||
if (isGldefsLight) return position_v3 + lightOffset;
|
||||
public Vector3 Center
|
||||
{
|
||||
get
|
||||
{
|
||||
if(isGldefsLight) return position_v3 + lightOffset;
|
||||
return new Vector3(position_v3.X, position_v3.Y, position_v3.Z + thingheight / 2f);
|
||||
}
|
||||
}
|
||||
public Vector3D CenterV3D { get { return D3DDevice.V3D(Center); } }
|
||||
public float LocalCenterZ { get { return thingheight / 2f; } } //mxd
|
||||
public Vector3 PositionV3 { get { return position_v3; } }
|
||||
public Vector3[] BoundingBox { get { return boundingBox; } }
|
||||
public Vector3D[] BoundingBox { get { return boundingBox; } }
|
||||
|
||||
//mxd. light properties
|
||||
public DynamicLightType LightType { get { return lightType; } }
|
||||
|
@ -134,9 +133,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public Thing Thing { get { return thing; } }
|
||||
|
||||
/// <summary>
|
||||
/// Render pass in which this geometry must be rendered. Default is Solid.
|
||||
/// Render pass in which this geometry must be rendered. Default is Mask.
|
||||
/// </summary>
|
||||
public RenderPass RenderPass { get { return (RenderPass)renderpass; } set { renderpass = (int)value; } }
|
||||
public RenderPass RenderPass { get { return renderpass; } set { renderpass = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Image to use as texture on the geometry.
|
||||
|
@ -162,7 +161,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
{
|
||||
// Initialize
|
||||
this.thing = t;
|
||||
this.renderpass = (int)RenderPass.Mask;
|
||||
this.renderpass = RenderPass.Mask;
|
||||
this.position = Matrix.Identity;
|
||||
this.cagescales = Matrix.Identity;
|
||||
|
||||
|
@ -173,7 +172,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
lightSecondaryRadius = -1;
|
||||
lightInterval = -1;
|
||||
lightColor = new Color4();
|
||||
boundingBox = new Vector3[9];
|
||||
boundingBox = new Vector3D[9];
|
||||
|
||||
// Register as resource
|
||||
General.Map.Graphics.RegisterResource(this);
|
||||
|
@ -200,21 +199,14 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This sets the distance from the camera
|
||||
internal void CalculateCameraDistance(Vector2D campos)
|
||||
{
|
||||
cameradistance = Vector2D.DistanceSq(pos2d, campos);
|
||||
}
|
||||
|
||||
//mxd
|
||||
internal void CalculateCameraDistance3D(Vector3 campos)
|
||||
internal void CalculateCameraDistance(Vector3D campos)
|
||||
{
|
||||
cameraDistance3D = (int)Vector3.DistanceSquared(PositionV3, campos);
|
||||
cameradistance = (int)((CenterV3D - campos).GetLengthSq());
|
||||
}
|
||||
|
||||
// This is called before a device is reset
|
||||
// (when resized or display adapter was changed)
|
||||
// This is called before a device is reset (when resized or display adapter was changed)
|
||||
public void UnloadResource()
|
||||
{
|
||||
// Trash geometry buffer
|
||||
|
@ -234,7 +226,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
/// <summary>
|
||||
/// Sets the size of the cage around the thing geometry.
|
||||
/// </summary>
|
||||
public void SetCageSize(float radius, float height)
|
||||
protected void SetCageSize(float radius, float height)
|
||||
{
|
||||
cagescales = Matrix.Scaling(radius, radius, height);
|
||||
thingheight = (int)height; //mxd
|
||||
|
@ -243,9 +235,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
/// <summary>
|
||||
/// Sets the color of the cage around the thing geometry.
|
||||
/// </summary>
|
||||
public void SetCageColor(PixelColor color)
|
||||
protected void SetCageColor(PixelColor color)
|
||||
{
|
||||
cagecolor = color.ToInt();
|
||||
cagecolor = color.ToColorValue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -253,7 +245,6 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
/// </summary>
|
||||
public void SetPosition(Vector3D pos)
|
||||
{
|
||||
pos2d = new Vector2D(pos);
|
||||
position_v3 = D3DDevice.V3(pos); //mxd
|
||||
position = Matrix.Translation(position_v3);
|
||||
|
||||
|
@ -459,7 +450,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
}
|
||||
|
||||
//used in ColorPicker to update light
|
||||
//mxd. Used in ColorPicker to update light
|
||||
public void UpdateLight()
|
||||
{
|
||||
int light_id = Array.IndexOf(GZBuilder.GZGeneral.GZ_LIGHTS, thing.Type);
|
||||
|
@ -470,7 +461,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
}
|
||||
|
||||
//mxd update light info
|
||||
//mxd. Update light info
|
||||
private void UpdateLight(int lightId)
|
||||
{
|
||||
float scaled_intensity = 255.0f / General.Settings.GZDynamicLightIntensity;
|
||||
|
@ -510,7 +501,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
lightPrimaryRadius = (thing.Args[3] * 2) * General.Settings.GZDynamicLightRadius; //works... that.. way in GZDoom
|
||||
if (lightType > 0) lightSecondaryRadius = (thing.Args[4] * 2) * General.Settings.GZDynamicLightRadius;
|
||||
}
|
||||
} else //it's one of vavoom lights
|
||||
}
|
||||
else //it's one of vavoom lights
|
||||
{
|
||||
lightRenderStyle = DynamicLightRenderStyle.VAVOOM;
|
||||
lightType = (DynamicLightType)thing.Type;
|
||||
|
@ -520,6 +512,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
lightColor = new Color4((float)lightRenderStyle / 100.0f, General.Settings.GZDynamicLightIntensity, General.Settings.GZDynamicLightIntensity, General.Settings.GZDynamicLightIntensity);
|
||||
lightPrimaryRadius = (thing.Args[0] * 8) * General.Settings.GZDynamicLightRadius;
|
||||
}
|
||||
|
||||
UpdateLightRadius();
|
||||
}
|
||||
|
||||
|
@ -619,19 +612,19 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
private void UpdateBoundingBox(float width, float height)
|
||||
{
|
||||
boundingBox = new Vector3[9];
|
||||
boundingBox[0] = Center;
|
||||
boundingBox = new Vector3D[9];
|
||||
boundingBox[0] = CenterV3D;
|
||||
float h2 = height / 2.0f;
|
||||
|
||||
boundingBox[1] = new Vector3(position_v3.X - width, position_v3.Y - width, Center.Z - h2);
|
||||
boundingBox[2] = new Vector3(position_v3.X + width, position_v3.Y - width, Center.Z - h2);
|
||||
boundingBox[3] = new Vector3(position_v3.X - width, position_v3.Y + width, Center.Z - h2);
|
||||
boundingBox[4] = new Vector3(position_v3.X + width, position_v3.Y + width, Center.Z - h2);
|
||||
boundingBox[1] = new Vector3D(position_v3.X - width, position_v3.Y - width, Center.Z - h2);
|
||||
boundingBox[2] = new Vector3D(position_v3.X + width, position_v3.Y - width, Center.Z - h2);
|
||||
boundingBox[3] = new Vector3D(position_v3.X - width, position_v3.Y + width, Center.Z - h2);
|
||||
boundingBox[4] = new Vector3D(position_v3.X + width, position_v3.Y + width, Center.Z - h2);
|
||||
|
||||
boundingBox[5] = new Vector3(position_v3.X - width, position_v3.Y - width, Center.Z + h2);
|
||||
boundingBox[6] = new Vector3(position_v3.X + width, position_v3.Y - width, Center.Z + h2);
|
||||
boundingBox[7] = new Vector3(position_v3.X - width, position_v3.Y + width, Center.Z + h2);
|
||||
boundingBox[8] = new Vector3(position_v3.X + width, position_v3.Y + width, Center.Z + h2);
|
||||
boundingBox[5] = new Vector3D(position_v3.X - width, position_v3.Y - width, Center.Z + h2);
|
||||
boundingBox[6] = new Vector3D(position_v3.X + width, position_v3.Y - width, Center.Z + h2);
|
||||
boundingBox[7] = new Vector3D(position_v3.X - width, position_v3.Y + width, Center.Z + h2);
|
||||
boundingBox[8] = new Vector3D(position_v3.X + width, position_v3.Y + width, Center.Z + h2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -652,14 +645,6 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This sorts things by distance from the camera. Farthest first.
|
||||
/// </summary>
|
||||
public int CompareTo(VisualThing other)
|
||||
{
|
||||
return Math.Sign(other.cameradistance - this.cameradistance);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,31 +102,31 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
protected byte SetLinedefRenderstyle(bool solidasmask)
|
||||
{
|
||||
byte alpha;
|
||||
bool canhavealpha = (this is VisualMiddleDouble || this is VisualMiddle3D || this is VisualMiddleBack); //mxd
|
||||
|
||||
// From TranslucentLine action
|
||||
if(Sidedef.Line.Action == 208)
|
||||
{
|
||||
alpha = (byte)General.Clamp(Sidedef.Line.Args[1], 0, 255);
|
||||
|
||||
if(Sidedef.Line.Args[2] == 1)
|
||||
|
||||
if(canhavealpha && Sidedef.Line.Args[2] == 1)
|
||||
this.RenderPass = RenderPass.Additive;
|
||||
else if(alpha < 255)
|
||||
else if(canhavealpha && (alpha < 255 || Texture.IsTranslucent))
|
||||
this.RenderPass = RenderPass.Alpha;
|
||||
else if(solidasmask)
|
||||
this.RenderPass = RenderPass.Mask;
|
||||
else
|
||||
this.RenderPass = RenderPass.Solid;
|
||||
}
|
||||
// From UDMF field
|
||||
else
|
||||
{
|
||||
// From UDMF field
|
||||
string field = Sidedef.Line.Fields.GetValue("renderstyle", "translucent");
|
||||
alpha = (byte)(Sidedef.Line.Fields.GetValue("alpha", 1.0f) * 255.0f);
|
||||
if(alpha == 255 && Sidedef.Line.IsFlagSet("transparent")) alpha = 64; //mxd
|
||||
|
||||
if(field == "add")
|
||||
if(canhavealpha && Sidedef.Line.Fields.GetValue("renderstyle", "translucent") == "add")
|
||||
this.RenderPass = RenderPass.Additive;
|
||||
else if(alpha < 255)
|
||||
else if(canhavealpha && (alpha < 255 || Texture.IsTranslucent))
|
||||
this.RenderPass = RenderPass.Alpha;
|
||||
else if(solidasmask)
|
||||
this.RenderPass = RenderPass.Mask;
|
||||
|
|
Loading…
Reference in a new issue