Added, Visual mode, DECORATE: "Alpha" and "DefaultAlpha" properties are now supported.

Added, Visual mode, DECORATE: "RenderStyle" property is now partially supported.
Added, Visual mode, DECORATE: +BRIGHT flag is now supported.
Added, Visual mode, UDMF: "Alpha" thing property is now supported.
Added, Visual mode, UDMF: "RenderStyle" thing property is now partially supported.
Added, Visual mode, Hexen map format and UDMF: "Translucent" and "Invisible" thing flags are now supported.
Added, Game Configurations: added "alpha" and "renderstyle" Thing and Thing Category properties.
Fixed, Visual mode: blockmap was not updated when moving things using "Move Thing Left/Right/Forward/Backward" and "Move Thing to Cursor Location" actions.
DECORATE parser: added a warning when unable to find actor's parent class.
Internal: current map format can now be checked using "General.Map.UDMF", "General.Map.HEXEN" and "General.Map.DOOM" properties.
Updated documentation ("Game Configuration - Things Settings" page).
This commit is contained in:
MaxED 2015-09-28 14:57:48 +00:00
parent f729c811f5
commit 07b4a7a9cd
20 changed files with 569 additions and 152 deletions

View file

@ -31,7 +31,7 @@ thingflags
1 = "Easy";
2 = "Medium";
4 = "Hard";
8 = "Deaf";
8 = "Ambush players";
16 = "Multiplayer only";
}

View file

@ -112,6 +112,8 @@ monsters
58
{
title = "Spectre";
renderstyle = "translucent";
alpha = 0.25f;
width = 30;
sprite = "SARGF1";
class = "Spectre";

View file

@ -35,10 +35,10 @@ mapformat_doom
1 = "Easy";
2 = "Medium";
4 = "Hard";
8 = "Standing";
8 = "Stand still";
16 = "Multiplayer only";
32 = "Ambush";
64 = "Ally";
32 = "Ambush players";
64 = "Friendly (Strife logic)";
256 = "Translucent (25%)";
512 = "Invisible";
}

View file

@ -1,7 +1,5 @@
// Basic UDMF stuff.
thingflags
{
skill1 = "Skill 1";
@ -12,15 +10,15 @@ thingflags
skill6 = "Skill 6";
skill7 = "Skill 7";
skill8 = "Skill 8";
ambush = "Deaf";
single = "Singleplayer";
dm = "Deathmatch";
coop = "Cooperative";
friend = "Friendly";
dm = "Deathmatch";
friend = "Friendly (MBF logic)";
strifeally = "Friendly (Strife logic)";
ambush = "Ambush players";
standing = "Stand still";
dormant = "Dormant";
standing = "Standing";
strifeally = "Ally";
translucent = "Translucent";
translucent = "Translucent (25%)";
invisible = "Invisible";
}

View file

@ -78,8 +78,8 @@ thingflags
{
2048 = "Translucent (25%)";
4096 = "Invisible";
8192 = "Friendly";
16384 = "Standing";
8192 = "Friendly (Strife logic)";
16384 = "Stand still";
}

View file

@ -1271,6 +1271,8 @@ doom
9050
{
title = "Arachnotron (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
width = 64;
height = 64;
sprite = "BSPIA2A8";
@ -1280,6 +1282,8 @@ doom
9051
{
title = "Archvile (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
width = 20;
sprite = "VILEA2D8";
class = "StealthArchvile";
@ -1288,6 +1292,8 @@ doom
9052
{
title = "Baron of Hell (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
width = 24;
height = 64;
sprite = "BOSSA2A8";
@ -1297,6 +1303,8 @@ doom
9053
{
title = "Cacodemon (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
width = 31;
sprite = "HEADA2A8";
class = "StealthCacodemon";
@ -1305,6 +1313,8 @@ doom
9054
{
title = "Chaingunner (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
sprite = "CPOSA2";
class = "StealthChaingunGuy";
}
@ -1312,6 +1322,8 @@ doom
9055
{
title = "Demon (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
width = 30;
sprite = "SARGA2A8";
class = "StealthDemon";
@ -1320,6 +1332,8 @@ doom
9056
{
title = "Hell Knight (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
width = 24;
height = 64;
sprite = "BOS2A2C8";
@ -1329,6 +1343,8 @@ doom
9057
{
title = "Imp (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
sprite = "TROOA2A8";
class = "StealthDoomImp";
}
@ -1336,6 +1352,8 @@ doom
9058
{
title = "Mancubus (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
width = 48;
height = 64;
sprite = "FATTC2C8";
@ -1345,6 +1363,8 @@ doom
9059
{
title = "Revenant (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
sprite = "SKELA2D8";
class = "StealthRevenant";
}
@ -1352,6 +1372,8 @@ doom
9060
{
title = "Former Sergeant (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
sprite = "SPOSA2A8";
class = "StealthShotgunGuy";
}
@ -1359,6 +1381,8 @@ doom
9061
{
title = "Former Human (stealth)";
renderstyle = "translucent";
alpha = 0.25f;
sprite = "POSSA2A8";
class = "StealthZombieMan";
}

View file

@ -102,6 +102,14 @@ thingrenderstyles
<p><b class="fat">arrow</b> (integer) [0 .. 1]<br />
When set to 1, thing angle will be shown as an arrow in Classic and Visual modes.<br />
<br />
<b class="fat">renderstyle</b> (string)<br />
Sets the renderstyle of this category or thing. See <a href="http://www.zdoom.org/wiki/Actor_properties#RenderStyle">zdoom.org/wiki/Actor_properties#RenderStyle</a>.<br />
Default value is<strong> &quot;Normal&quot;</strong>.<br />
<br />
<b class="fat">alpha</b> (decimal) [0.0f .. 1.0f]<br />
Sets alpha of this category or thing.<br />
Default value is<strong> &quot;1.0f&quot;</strong>.<br />
<br />
<b class="fat">title</b> (string)<br />
Sets the title of this category or thing.<br />
<br />
@ -149,7 +157,7 @@ thingrenderstyles
<br />
<b class="fat">spritescale</b> (decimal)<br />
Can be used to modify the rendered sprite scale in Visual mode.<br />
Default value is<strong> &quot;1.0&quot;</strong>.<br />
Default value is<strong> &quot;1.0f&quot;</strong>.<br />
<br />
<span class="big">Thing definitions:</span><br />
These settings can be used inside of thing definitions.<br />

View file

@ -88,6 +88,11 @@ namespace CodeImp.DoomBuilder.Config
// Map lumps
private readonly Dictionary<string, MapLumpInfo> maplumps;
//mxd. Map format
private bool doommapformat;
private bool hexenmapformat;
private bool universalmapformat;
// Texture/flat/voxel sources
private readonly IDictionary textureranges;
@ -196,6 +201,11 @@ namespace CodeImp.DoomBuilder.Config
// Map lumps
public Dictionary<string, MapLumpInfo> MapLumps { get { return maplumps; } }
//mxd. Map format
public bool UDMF { get { return universalmapformat; } }
public bool HEXEN { get { return hexenmapformat; } }
public bool DOOM { get { return doommapformat; } }
// Texture/flat/voxel sources
public IDictionary TextureRanges { get { return textureranges; } }
public IDictionary FlatRanges { get { return flatranges; } }
@ -328,6 +338,11 @@ namespace CodeImp.DoomBuilder.Config
defaultLinedefActivation = cfg.ReadSetting("defaultlinedefactivation", ""); //mxd
for(int i = 0; i < Linedef.NUM_ARGS; i++) makedoorargs[i] = cfg.ReadSetting("makedoorarg" + i.ToString(CultureInfo.InvariantCulture), 0);
//mxd. Update map format flags
universalmapformat = (formatinterface == "UniversalMapSetIO");
hexenmapformat = (formatinterface == "HexenMapSetIO");
doommapformat = (formatinterface == "DoomMapSetIO");
//mxd. Texture names length
longtexturenames = cfg.ReadSetting("longtexturenames", false);
maxtexturenamelength = (longtexturenames ? short.MaxValue : DataManager.CLASIC_IMAGE_NAME_LENGTH);

View file

@ -46,6 +46,8 @@ namespace CodeImp.DoomBuilder.Config
// Thing properties for inheritance
private readonly string sprite;
private readonly int color;
private readonly float alpha; //mxd
private readonly string renderstyle; //mxd
private readonly int arrow;
private readonly float radius;
private readonly float height;
@ -70,6 +72,8 @@ namespace CodeImp.DoomBuilder.Config
public bool Sorted { get { return sorted; } }
public List<ThingCategory> Children { get { return children; } } //mxd
public int Color { get { return color; } }
public float Alpha { get { return alpha; } } //mxd
public string RenderStyle { get { return renderstyle; } } //mxd
public int Arrow { get { return arrow; } }
public float Radius { get { return radius; } }
public float Height { get { return height; } }
@ -102,6 +106,8 @@ namespace CodeImp.DoomBuilder.Config
this.sprite = parent.sprite;
this.sorted = parent.sorted;
this.color = parent.color;
this.alpha = parent.alpha;
this.renderstyle = parent.renderstyle;
this.arrow = parent.arrow;
this.radius = parent.radius;
this.height = parent.height;
@ -119,6 +125,8 @@ namespace CodeImp.DoomBuilder.Config
this.sprite = "";
this.sorted = true;
this.color = 18;
this.alpha = 1f; //mxd
this.renderstyle = "normal"; //mxd
this.arrow = 1;
this.radius = 10;
this.height = 20;
@ -153,6 +161,8 @@ namespace CodeImp.DoomBuilder.Config
this.sprite = cfg.ReadSetting("thingtypes." + name + ".sprite", parent.sprite);
this.sorted = (cfg.ReadSetting("thingtypes." + name + ".sort", (parent.sorted ? 1 : 0)) != 0);
this.color = cfg.ReadSetting("thingtypes." + name + ".color", parent.color);
this.alpha = cfg.ReadSetting("thingtypes." + name + ".alpha", parent.alpha);
this.renderstyle = cfg.ReadSetting("thingtypes." + name + ".renderstyle", parent.renderstyle).ToLower();
this.arrow = cfg.ReadSetting("thingtypes." + name + ".arrow", parent.arrow);
this.radius = cfg.ReadSetting("thingtypes." + name + ".width", parent.radius);
this.height = cfg.ReadSetting("thingtypes." + name + ".height", parent.height);
@ -160,7 +170,7 @@ namespace CodeImp.DoomBuilder.Config
this.blocking = cfg.ReadSetting("thingtypes." + name + ".blocking", parent.blocking);
this.errorcheck = cfg.ReadSetting("thingtypes." + name + ".error", parent.errorcheck);
this.fixedsize = cfg.ReadSetting("thingtypes." + name + ".fixedsize", parent.fixedsize);
this.fixedrotation = cfg.ReadSetting("thingtypes." + name + ".fixedrotation", parent.fixedrotation); //mxd
this.fixedrotation = cfg.ReadSetting("thingtypes." + name + ".fixedrotation", parent.fixedrotation);
this.absolutez = cfg.ReadSetting("thingtypes." + name + ".absolutez", parent.absolutez);
this.spritescale = cfg.ReadSetting("thingtypes." + name + ".spritescale", parent.spritescale);
}
@ -169,6 +179,8 @@ namespace CodeImp.DoomBuilder.Config
this.sprite = cfg.ReadSetting("thingtypes." + name + ".sprite", "");
this.sorted = (cfg.ReadSetting("thingtypes." + name + ".sort", 0) != 0);
this.color = cfg.ReadSetting("thingtypes." + name + ".color", 0);
this.alpha = General.Clamp(cfg.ReadSetting("thingtypes." + name + ".alpha", 1f), 0f, 1f);
this.renderstyle = cfg.ReadSetting("thingtypes." + name + ".renderstyle", "normal").ToLower();
this.arrow = cfg.ReadSetting("thingtypes." + name + ".arrow", 0);
this.radius = cfg.ReadSetting("thingtypes." + name + ".width", 10);
this.height = cfg.ReadSetting("thingtypes." + name + ".height", 20);

View file

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using CodeImp.DoomBuilder.GZBuilder.Data;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.ZDoom;
@ -52,6 +53,10 @@ namespace CodeImp.DoomBuilder.Config
private string classname; //mxd
private long spritelongname;
private int color;
private float alpha; //mxd
private byte alphabyte; //mxd
private string renderstyle; //mxd
private bool bright; //mxd
private bool arrow;
private float radius;
private float height;
@ -83,6 +88,10 @@ namespace CodeImp.DoomBuilder.Config
public ActorStructure Actor { get { return actor; } }
public long SpriteLongName { get { return spritelongname; } }
public int Color { get { return color; } }
public float Alpha { get { return alpha; } } //mxd
public byte AlphaByte { get { return alphabyte; } } //mxd
public string RenderStyle { get { return renderstyle; } } //mxd
public bool Bright { get { return bright; } } //mxd
public bool Arrow { get { return arrow; } }
public float Radius { get { return radius; } }
public float Height { get { return height; } }
@ -120,6 +129,10 @@ namespace CodeImp.DoomBuilder.Config
this.sprite = DataManager.INTERNAL_PREFIX + "unknownthing";
this.classname = string.Empty; //mxd
this.color = 0;
this.alpha = 1f; //mxd
this.alphabyte = 255; //mxd
this.renderstyle = "normal"; //mxd
this.bright = false; //mxd
this.arrow = true;
this.radius = 10f;
this.height = 20f;
@ -151,11 +164,15 @@ namespace CodeImp.DoomBuilder.Config
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
this.isknown = true;
this.actor = null;
this.bright = false; //mxd
// Read properties
this.title = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".title", "<" + key + ">");
this.sprite = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".sprite", cat.Sprite);
this.color = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".color", cat.Color);
this.alpha = General.Clamp(cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".alpha", cat.Alpha), 0f, 1f); //mxd
this.alphabyte = (byte)(this.alpha * 255); //mxd
this.renderstyle = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".renderstyle", cat.RenderStyle).ToLower(); //mxd
this.arrow = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".arrow", cat.Arrow) != 0);
this.radius = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".width", cat.Radius);
this.height = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".height", cat.Height);
@ -198,6 +215,7 @@ namespace CodeImp.DoomBuilder.Config
this.actor = null;
this.classname = string.Empty; //mxd
this.isknown = true;
this.bright = false; //mxd
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);
@ -205,6 +223,9 @@ namespace CodeImp.DoomBuilder.Config
this.sprite = cat.Sprite;
this.color = cat.Color;
this.arrow = (cat.Arrow != 0);
this.alpha = cat.Alpha; //mxd
this.alphabyte = (byte)(this.alpha * 255); //mxd
this.renderstyle = cat.RenderStyle; //mxd
this.radius = cat.Radius;
this.height = cat.Height;
this.hangs = (cat.Hangs != 0);
@ -240,12 +261,16 @@ namespace CodeImp.DoomBuilder.Config
this.actor = actor;
this.classname = actor.ClassName; //mxd
this.isknown = true;
this.bright = false; //mxd
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);
// Read properties
this.sprite = cat.Sprite;
this.color = cat.Color;
this.alpha = cat.Alpha; //mxd
this.alphabyte = (byte)(this.alpha * 255); //mxd
this.renderstyle = cat.RenderStyle; //mxd
this.arrow = (cat.Arrow != 0);
this.radius = cat.Radius;
this.height = cat.Height;
@ -278,12 +303,16 @@ namespace CodeImp.DoomBuilder.Config
this.actor = actor;
this.classname = actor.ClassName; //mxd
this.isknown = true;
this.bright = false; //mxd
this.args = new ArgumentInfo[Linedef.NUM_ARGS];
for(int i = 0; i < Linedef.NUM_ARGS; i++) this.args[i] = new ArgumentInfo(i);
// Read properties
this.sprite = cat.Sprite;
this.color = cat.Color;
this.alpha = cat.Alpha; //mxd
this.alphabyte = (byte)(this.alpha * 255); //mxd
this.renderstyle = cat.RenderStyle; //mxd
this.arrow = (cat.Arrow != 0);
this.radius = cat.Radius;
this.height = cat.Height;
@ -323,6 +352,10 @@ namespace CodeImp.DoomBuilder.Config
// Copy properties
this.sprite = other.sprite;
this.color = other.color;
this.alpha = other.alpha; //mxd
this.alphabyte = other.alphabyte; //mxd
this.renderstyle = other.renderstyle; //mxd
this.bright = other.bright; //mxd
this.arrow = other.arrow;
this.radius = other.radius;
this.height = other.height;
@ -399,7 +432,6 @@ namespace CodeImp.DoomBuilder.Config
else if(string.IsNullOrEmpty(sprite))//mxd
sprite = DataManager.INTERNAL_PREFIX + "unknownthing";
if(this.sprite.Length < 9)
this.spritelongname = Lump.MakeLongName(this.sprite);
else
@ -415,6 +447,24 @@ namespace CodeImp.DoomBuilder.Config
// Size
if(actor.HasPropertyWithValue("radius")) radius = actor.GetPropertyValueInt("radius", 0);
if(actor.HasPropertyWithValue("height")) height = actor.GetPropertyValueInt("height", 0);
//mxd. Renderstyle
if(actor.HasPropertyWithValue("renderstyle")) renderstyle = actor.GetPropertyValueString("renderstyle", 0).ToLower();
//mxd. Alpha
if(actor.HasPropertyWithValue("alpha"))
{
this.alpha = General.Clamp(actor.GetPropertyValueFloat("alpha", 0), 0f, 1f);
this.alphabyte = (byte)(this.alpha * 255);
}
else if(actor.HasProperty("defaultalpha"))
{
this.alpha = (General.Map.Config.GameType == GameType.HERETIC ? 0.4f : 0.6f);
this.alphabyte = (byte)(this.alpha * 255);
}
//mxd. BRIGHT
this.bright = actor.GetFlagValue("bright", false);
// Safety
if(this.radius < 4f) this.radius = 8f;

View file

@ -121,12 +121,16 @@ namespace CodeImp.DoomBuilder
public VisualCamera VisualCamera { get { return visualcamera; } set { visualcamera = value; } }
public bool IsScriptsWindowOpen { get { return (scriptwindow != null) && !scriptwindow.IsDisposed; } }
//mxd
public bool UDMF { get { return config.FormatInterface == "UniversalMapSetIO"; } }
//mxd. Map format
public bool UDMF { get { return config.UDMF; } }
public bool HEXEN { get { return config.HEXEN; } }
public bool DOOM { get { return config.DOOM; } }
//mxd. Scripts
internal Dictionary<string, ScriptItem> NamedScripts { get { return namedscripts; } }
internal Dictionary<int, ScriptItem> NumberedScripts { get { return numberedscripts; } }
internal List<string> ScriptIncludes { get { return scriptincludes; } }
public ViewMode ViewMode { get { return renderer2d.ViewMode; } }
#endregion

View file

@ -780,7 +780,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
}
if (sector != null)
if(sector != null)
{
// Determine the shader pass we want to use for this object
int wantedshaderpass = (((g == highlighted) && showhighlight) || (g.Selected && showselection)) ? highshaderpass : shaderpass;
@ -1015,7 +1015,7 @@ namespace CodeImp.DoomBuilder.Rendering
else
{
translucentgeo.Sort((vg1, vg2) => (int)((General.Map.VisualCamera.Position - vg2.BoundingBox[0]).GetLengthSq()
- (General.Map.VisualCamera.Position - vg1.BoundingBox[0]).GetLengthSq()));
- (General.Map.VisualCamera.Position - vg1.BoundingBox[0]).GetLengthSq()));
}
// Begin rendering with this shader
@ -1132,7 +1132,176 @@ namespace CodeImp.DoomBuilder.Rendering
}
}
//TODO: render things
// Get things for this pass
if(thingspass.Count > 0)
{
// Texture addressing
graphics.Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp);
graphics.Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp);
graphics.Device.SetSamplerState(0, SamplerState.AddressW, TextureAddress.Clamp);
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None); //mxd. Disable backside culling, because otherwise sprites with positive ScaleY and negative ScaleX will be facing away from the camera...
// Sort geometry by camera distance. First vertex of the BoundingBox is it's center
thingspass.Sort((vt1, vt2) => (int)((General.Map.VisualCamera.Position - vt2.BoundingBox[0]).GetLengthSq()
- (General.Map.VisualCamera.Position - vt1.BoundingBox[0]).GetLengthSq()));
// Reset vars
currentpass = RenderPass.Solid;
curtexturename = 0;
// Render things collected
foreach(VisualThing t in thingspass)
{
if(t.Texture is UnknownImage) continue;
// Change blend mode?
if(t.RenderPass != currentpass)
{
switch(t.RenderPass)
{
case RenderPass.Additive:
graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.One);
break;
case RenderPass.Alpha:
graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
break;
}
currentpass = t.RenderPass;
}
// Change texture?
if(t.Texture.LongName != curtexturename)
{
// What texture to use?
if(t.Texture.IsImageLoaded && !t.Texture.IsDisposed)
curtexture = t.Texture;
else
curtexture = General.Map.Data.Hourglass3D;
// Create Direct3D texture if still needed
if((curtexture.Texture == null) || curtexture.Texture.Disposed)
curtexture.CreateTexture();
// Apply texture
if(!graphics.Shaders.Enabled)
graphics.Device.SetTexture(0, curtexture.Texture);
graphics.Shaders.World3D.Texture1 = curtexture.Texture;
curtexturename = t.Texture.LongName;
}
//mxd
if(t.Thing.IsModel &&
(General.Settings.GZDrawModelsMode == ModelRenderMode.ALL ||
General.Settings.GZDrawModelsMode == ModelRenderMode.ACTIVE_THINGS_FILTER ||
(General.Settings.GZDrawModelsMode == ModelRenderMode.SELECTION && t.Selected)))
continue;
// Update buffer if needed
t.Update();
// Only do this sector when a vertexbuffer is created
if(t.GeometryBuffer != null)
{
// Determine the shader pass we want to use for this object
int wantedshaderpass = (((t == highlighted) && showhighlight) || (t.Selected && showselection)) ? highshaderpass : shaderpass;
//mxd. if fog is enagled, switch to shader, which calculates it
if(General.Settings.GZDrawFog && !fullbrightness && t.Thing.Sector != null && (t.Thing.Sector.HasFogColor || t.Thing.Sector.Brightness < 248))
wantedshaderpass += 8;
//mxd. if current thing is light - set it's color to light color
Color4 litcolor = new Color4();
if(Array.IndexOf(GZBuilder.GZGeneral.GZ_LIGHTS, t.Thing.Type) != -1 && !fullbrightness)
{
wantedshaderpass += 4; //render using one of passes, which uses World3D.VertexColor
graphics.Shaders.World3D.VertexColor = t.LightColor;
litcolor = t.LightColor;
}
//mxd. check if Thing is affected by dynamic lights and set color accordingly
else if(General.Settings.GZDrawLightsMode != LightRenderMode.NONE && !fullbrightness && lightthings.Count > 0)
{
litcolor = GetLitColorForThing(t);
if(litcolor.ToArgb() != 0)
{
wantedshaderpass += 4; //render using one of passes, which uses World3D.VertexColor
graphics.Shaders.World3D.VertexColor = new Color4(t.VertexColor) + litcolor;
}
}
// Switch shader pass?
if(currentshaderpass != wantedshaderpass)
{
graphics.Shaders.World3D.EndPass();
graphics.Shaders.World3D.BeginPass(wantedshaderpass);
currentshaderpass = wantedshaderpass;
}
// Set the colors to use
if(!graphics.Shaders.Enabled)
{
graphics.Device.SetTexture(2, (t.Selected && showselection) ? selectionimage.Texture : null);
graphics.Device.SetTexture(3, ((t == highlighted) && showhighlight) ? highlightimage.Texture : null);
}
else
{
graphics.Shaders.World3D.SetHighlightColor(CalculateHighlightColor((t == highlighted) && showhighlight, (t.Selected && showselection)).ToArgb());
}
//mxd. Create the matrix for positioning
if(t.Info.RenderMode == Thing.SpriteRenderMode.NORMAL) // Apply billboarding?
{
if(t.Info.XYBillboard)
{
world = Matrix.Translation(0f, 0f, -t.LocalCenterZ)
* Matrix.RotationX(Angle2D.PI - General.Map.VisualCamera.AngleZ)
* Matrix.Translation(0f, 0f, t.LocalCenterZ)
* billboard
* Matrix.Scaling(t.Thing.ScaleX, t.Thing.ScaleX, t.Thing.ScaleY)
* t.Position;
}
else
{
world = billboard
* Matrix.Scaling(t.Thing.ScaleX, t.Thing.ScaleX, t.Thing.ScaleY)
* t.Position;
}
}
else
{
world = Matrix.Scaling(t.Thing.ScaleX, t.Thing.ScaleX, t.Thing.ScaleY)
* t.Position;
}
ApplyMatrices3D();
//mxd. Set variables for fog rendering
if(wantedshaderpass > 7)
{
graphics.Shaders.World3D.World = world;
graphics.Shaders.World3D.LightColor = t.Thing.Sector.FogColor;
float fogdistance = (litcolor.ToArgb() != 0 ? VisualSector.MAXIMUM_FOG_DISTANCE : t.FogDistance);
graphics.Shaders.World3D.CameraPosition = new Vector4(cameraposition.x, cameraposition.y, cameraposition.z, fogdistance);
}
graphics.Shaders.World3D.ApplySettings();
// Apply buffer
graphics.Device.SetStreamSource(0, t.GeometryBuffer, 0, WorldVertex.Stride);
// Render!
graphics.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, t.Triangles);
}
}
// Texture addressing
graphics.Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Wrap);
graphics.Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Wrap);
graphics.Device.SetSamplerState(0, SamplerState.AddressW, TextureAddress.Wrap);
graphics.Device.SetRenderState(RenderState.CullMode, Cull.Counterclockwise); //mxd
}
// Done rendering with this shader
graphics.Shaders.World3D.EndPass();

View file

@ -68,10 +68,12 @@ sampler2D texturesamp = sampler_state
PixelData vs_main(VertexData vd)
{
PixelData pd;
// Fill pixel data input
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
pd.color = vd.color;
pd.uv = vd.uv;
// Return result
return pd;
}
@ -80,11 +82,13 @@ PixelData vs_main(VertexData vd)
PixelData vs_customvertexcolor(VertexData vd)
{
PixelData pd;
// Fill pixel data input
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
pd.color = vertexColor;
pd.color.a = 1.0f;
pd.uv = vd.uv;
// Return result
return pd;
}
@ -92,6 +96,7 @@ PixelData vs_customvertexcolor(VertexData vd)
LitPixelData vs_customvertexcolor_fog(VertexData vd)
{
LitPixelData pd;
// Fill pixel data input
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
pd.pos_w = mul(float4(vd.pos, 1.0f), world);
@ -99,6 +104,7 @@ LitPixelData vs_customvertexcolor_fog(VertexData vd)
pd.color.a = 1.0f;
pd.uv = vd.uv;
pd.normal = vd.normal;
// Return result
return pd;
}
@ -108,7 +114,6 @@ LitPixelData vs_lightpass(VertexData vd)
{
LitPixelData pd;
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
//pd.pos_w = mul(vd.pos, (float3x3)world);
pd.pos_w = mul(float4(vd.pos, 1.0f), world);
pd.color = vd.color;
pd.uv = vd.uv;
@ -137,34 +142,35 @@ float4 ps_fullbright(PixelData pd) : COLOR
float4 ps_main_highlight(PixelData pd) : COLOR
{
float4 tcolor = tex2D(texturesamp, pd.uv);
if(tcolor.a == 0) clip(-1);
// 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);
return float4(highlightcolor.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);
float4 hcolor = float4(highlightcolor.rgb, tcolor.a);
if(tcolor.a == 0) clip(-1);
//return lerp(ncolor, hcolor, highlightcolor.a);
return float4(hcolor.rgb * highlightcolor.a + (tcolor.rgb - 0.4f * highlightcolor.a), tcolor.a + 0.25f);
// Blend texture color and vertex color
float4 ncolor = tcolor * pd.color;
return float4(highlightcolor.rgb * highlightcolor.a + (tcolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f);
}
//mxd. This adds fog color to current pixel color
float4 getFogColor(LitPixelData pd, float4 color)
{
float fogdist = max(16.0f, distance(pd.pos_w, cameraPos.xyz));
float fogfactor = min(1.0f, fogdist / cameraPos.w);
//float fogfactor = exp2(cameraPos.w * fogdist);
if(fogfactor == 1.0f) //texture color completly replaced by fog color
return float4(lightColor.rgb, color.a);
return float4(lightColor.rgb * fogfactor + color.rgb * (1.0f - fogfactor), color.a);
float fogdist = max(16.0f, distance(pd.pos_w, cameraPos.xyz));
float fogfactor = min(1.0f, fogdist / cameraPos.w);
//texture color completly replaced by fog color
if(fogfactor == 1.0f) return float4(lightColor.rgb, color.a);
return float4(lightColor.rgb * fogfactor + color.rgb * (1.0f - fogfactor), color.a);
}
//mxd. Shaders with fog calculation
@ -172,6 +178,8 @@ float4 getFogColor(LitPixelData pd, float4 color)
float4 ps_main_fog(LitPixelData pd) : COLOR
{
float4 tcolor = tex2D(texturesamp, pd.uv);
if(tcolor.a == 0) clip(-1);
return getFogColor(pd, tcolor * pd.color);
}
@ -179,12 +187,12 @@ float4 ps_main_fog(LitPixelData pd) : COLOR
float4 ps_main_highlight_fog(LitPixelData pd) : COLOR
{
float4 tcolor = tex2D(texturesamp, pd.uv);
if(tcolor.a == 0) clip(-1);
// Blend texture color and vertex color
float4 ncolor = getFogColor(pd, tcolor * pd.color);
float4 hcolor = float4(highlightcolor.rgb, ncolor.a);
return float4(hcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f);
return float4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), ncolor.a + 0.25f);
}
//mxd: used to draw bounding boxes
@ -202,33 +210,33 @@ float4 ps_vertex_color(PixelData pd) : COLOR
//mxd. dynamic light pixel shader pass, dood!
float4 ps_lightpass(LitPixelData pd) : COLOR
{
//is face facing away from light source?
if(dot(pd.normal, (lightPosAndRadius.xyz - pd.pos_w)) < -0.1f) // (lightPosAndRadius.xyz - pd.pos_w) == direction from light to current pixel
clip(-1);
//is face facing away from light source?
if(dot(pd.normal, (lightPosAndRadius.xyz - pd.pos_w)) < -0.1f) // (lightPosAndRadius.xyz - pd.pos_w) == direction from light to current pixel
clip(-1);
//is pixel in light range?
float dist = distance(pd.pos_w, lightPosAndRadius.xyz);
if(dist > lightPosAndRadius.w)
clip(-1);
//is pixel tranparent?
float4 tcolor = tex2D(texturesamp, pd.uv);
if(tcolor.a == 0.0f)
clip(-1);
//is pixel in light range?
float dist = distance(pd.pos_w, lightPosAndRadius.xyz);
if(dist > lightPosAndRadius.w)
clip(-1);
//is pixel tranparent?
float4 tcolor = tex2D(texturesamp, pd.uv);
if(tcolor.a == 0.0f)
clip(-1);
//if it is - calculate color at current pixel
float4 lightColorMod = float4(0.0f, 0.0f, 0.0f, 0.0f);
//if it is - calculate color at current pixel
float4 lightColorMod = float4(0.0f, 0.0f, 0.0f, 0.0f);
lightColorMod.rgb = lightColor.rgb * max(lightPosAndRadius.w - dist, 0.0f) / lightPosAndRadius.w;
if(lightColorMod.r > 0.0f || lightColorMod.g > 0.0f || lightColorMod.b > 0.0f)
{
lightColorMod.rgb *= lightColor.a;
if(lightColor.a > 0.4f) //Normal, vavoom or negative light
return tcolor * lightColorMod;
return lightColorMod; //Additive light
}
clip(-1);
return lightColorMod; //should never get here
lightColorMod.rgb = lightColor.rgb * max(lightPosAndRadius.w - dist, 0.0f) / lightPosAndRadius.w;
if(lightColorMod.r > 0.0f || lightColorMod.g > 0.0f || lightColorMod.b > 0.0f)
{
lightColorMod.rgb *= lightColor.a;
if(lightColor.a > 0.4f) //Normal, vavoom or negative light
return tcolor * lightColorMod;
return lightColorMod; //Additive light
}
clip(-1);
return lightColorMod; //should never get here
}
// Technique for shader model 2.0

View file

@ -39,9 +39,6 @@ namespace CodeImp.DoomBuilder.VisualModes
// Vertices
private WorldVertex[] vertices;
private int triangles;
// Desired modulate color
private PixelColor modulatecolor;
// Selected?
protected bool selected;
@ -95,11 +92,6 @@ namespace CodeImp.DoomBuilder.VisualModes
/// </summary>
public ImageData Texture { get { return texture; } set { texture = value; } }
/// <summary>
/// Color to modulate the texture pixels with.
/// </summary>
public PixelColor ModulateColor { get { return modulatecolor; } set { modulatecolor = value; } }
/// <summary>
/// Returns the VisualSector this geometry has been added to.
/// </summary>
@ -125,7 +117,6 @@ namespace CodeImp.DoomBuilder.VisualModes
protected VisualGeometry(VisualSector vs)
{
this.sector = vs;
this.ModulateColor = new PixelColor(255, 255, 255, 255);
this.geometrytype = VisualGeometryType.UNKNOWN; //mxd
}
@ -137,7 +128,6 @@ namespace CodeImp.DoomBuilder.VisualModes
{
this.sector = vs;
this.sidedef = sd;
this.ModulateColor = new PixelColor(255, 255, 255, 255);
this.geometrytype = VisualGeometryType.UNKNOWN; //mxd
}

View file

@ -328,10 +328,10 @@
this.tabproperties.Controls.Add(this.groupBox2);
this.tabproperties.Controls.Add(this.groupBox1);
this.tabproperties.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabproperties.Location = new System.Drawing.Point(4, 23);
this.tabproperties.Location = new System.Drawing.Point(4, 22);
this.tabproperties.Name = "tabproperties";
this.tabproperties.Padding = new System.Windows.Forms.Padding(3);
this.tabproperties.Size = new System.Drawing.Size(627, 402);
this.tabproperties.Size = new System.Drawing.Size(627, 403);
this.tabproperties.TabIndex = 0;
this.tabproperties.Text = "Properties";
this.tabproperties.UseVisualStyleBackColor = true;
@ -537,10 +537,10 @@
this.tabeffects.Controls.Add(this.actiongroup);
this.tabeffects.Controls.Add(this.grouptag);
this.tabeffects.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabeffects.Location = new System.Drawing.Point(4, 23);
this.tabeffects.Location = new System.Drawing.Point(4, 22);
this.tabeffects.Name = "tabeffects";
this.tabeffects.Padding = new System.Windows.Forms.Padding(3);
this.tabeffects.Size = new System.Drawing.Size(627, 402);
this.tabeffects.Size = new System.Drawing.Size(627, 403);
this.tabeffects.TabIndex = 1;
this.tabeffects.Text = "Action / Tag / Misc.";
this.tabeffects.UseVisualStyleBackColor = true;
@ -727,6 +727,7 @@
this.alpha.Size = new System.Drawing.Size(72, 24);
this.alpha.StepValues = null;
this.alpha.TabIndex = 23;
this.alpha.WhenTextChanged += new System.EventHandler(this.alpha_WhenTextChanged);
//
// label8
//
@ -745,6 +746,7 @@
this.renderStyle.Name = "renderStyle";
this.renderStyle.Size = new System.Drawing.Size(156, 21);
this.renderStyle.TabIndex = 24;
this.renderStyle.SelectedIndexChanged += new System.EventHandler(this.renderStyle_SelectedIndexChanged);
//
// labelrenderstyle
//
@ -833,9 +835,9 @@
//
this.tabcomment.Controls.Add(this.commenteditor);
this.tabcomment.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabcomment.Location = new System.Drawing.Point(4, 23);
this.tabcomment.Location = new System.Drawing.Point(4, 22);
this.tabcomment.Name = "tabcomment";
this.tabcomment.Size = new System.Drawing.Size(627, 402);
this.tabcomment.Size = new System.Drawing.Size(627, 403);
this.tabcomment.TabIndex = 3;
this.tabcomment.Text = "Comment";
this.tabcomment.UseVisualStyleBackColor = true;
@ -851,9 +853,9 @@
//
this.tabcustom.Controls.Add(this.fieldslist);
this.tabcustom.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tabcustom.Location = new System.Drawing.Point(4, 23);
this.tabcustom.Location = new System.Drawing.Point(4, 22);
this.tabcustom.Name = "tabcustom";
this.tabcustom.Size = new System.Drawing.Size(627, 402);
this.tabcustom.Size = new System.Drawing.Size(627, 403);
this.tabcustom.TabIndex = 2;
this.tabcustom.Text = "Custom";
this.tabcustom.UseVisualStyleBackColor = true;

View file

@ -67,9 +67,11 @@ namespace CodeImp.DoomBuilder.Windows
public readonly int Roll;
public readonly float ScaleX;
public readonly float ScaleY;
public readonly float Alpha;
public readonly float X;
public readonly float Y;
public readonly float Z;
public readonly Dictionary<string, bool> Flags;
public ThingProperties(Thing t)
{
@ -82,6 +84,8 @@ namespace CodeImp.DoomBuilder.Windows
Roll = t.Roll;
ScaleX = t.ScaleX;
ScaleY = t.ScaleY;
Alpha = UDMFTools.GetFloat(t.Fields, "alpha", 1.0f);
Flags = t.GetFlags();
}
}
@ -268,11 +272,11 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Custom fields
fieldslist.SetValues(t.Fields, false);
commenteditor.SetValues(t.Fields, false); //mxd. Comments
if (t.Fields.GetValue("conversation", 0).ToString() != conversationID.Text) conversationID.Text = "";
if (t.Fields.GetValue("gravity", 1.0f).ToString() != gravity.Text) gravity.Text = "";
if (t.Fields.GetValue("score", 0).ToString() != score.Text) score.Text = "";
if (t.Fields.GetValue("health", 1).ToString() != health.Text) health.Text = "";
if (t.Fields.GetValue("alpha", 1.0f).ToString() != alpha.Text) alpha.Text = "";
if(t.Fields.GetValue("conversation", 0).ToString() != conversationID.Text) conversationID.Text = "";
if(t.Fields.GetValue("gravity", 1.0f).ToString() != gravity.Text) gravity.Text = "";
if(t.Fields.GetValue("score", 0).ToString() != score.Text) score.Text = "";
if(t.Fields.GetValue("health", 1).ToString() != health.Text) health.Text = "";
if(t.Fields.GetValue("alpha", 1.0f).ToString() != alpha.Text) alpha.Text = "";
scale.SetValues(t.ScaleX, t.ScaleY, false);
color.SetValueFrom(t.Fields);
@ -470,16 +474,6 @@ namespace CodeImp.DoomBuilder.Windows
float py = General.Clamp(t.Position.y, General.Map.Config.BottomBoundary, General.Map.Config.TopBoundary);
if(t.Position.x != px || t.Position.y != py) t.Move(new Vector2D(px, py));
// Apply all flags
foreach(CheckBox c in flags.Checkboxes)
{
switch (c.CheckState)
{
case CheckState.Checked: t.SetFlag(c.Tag.ToString(), true); break;
case CheckState.Unchecked: t.SetFlag(c.Tag.ToString(), false); break;
}
}
// Action/tags
t.Tag = General.Clamp(tagSelector.GetSmartTag(t.Tag, tagoffset++), General.Map.FormatInterface.MinTag, General.Map.FormatInterface.MaxTag); //mxd
if(!action.Empty) t.Action = action.Value;
@ -489,18 +483,14 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Custom fields
fieldslist.Apply(t.Fields);
if (!string.IsNullOrEmpty(conversationID.Text))
if(!string.IsNullOrEmpty(conversationID.Text))
UDMFTools.SetInteger(t.Fields, "conversation", conversationID.GetResult(t.Fields.GetValue("conversation", 0)), 0);
if (!string.IsNullOrEmpty(gravity.Text))
if(!string.IsNullOrEmpty(gravity.Text))
UDMFTools.SetFloat(t.Fields, "gravity", gravity.GetResultFloat(t.Fields.GetValue("gravity", 1.0f)), 1.0f);
if (!string.IsNullOrEmpty(health.Text))
if(!string.IsNullOrEmpty(health.Text))
UDMFTools.SetInteger(t.Fields, "health", health.GetResult(t.Fields.GetValue("health", 1)), 1);
if (!string.IsNullOrEmpty(score.Text))
if(!string.IsNullOrEmpty(score.Text))
UDMFTools.SetInteger(t.Fields, "score", score.GetResult(t.Fields.GetValue("score", 0)), 0);
if (!string.IsNullOrEmpty(alpha.Text))
UDMFTools.SetFloat(t.Fields, "alpha", alpha.GetResultFloat(t.Fields.GetValue("alpha", 1.0f)), 1.0f);
if (rskeys != null && renderStyle.SelectedIndex > -1)
UDMFTools.SetString(t.Fields, "renderstyle", rskeys[renderStyle.SelectedIndex], "normal");
color.ApplyTo(t.Fields, t.Fields.GetValue("fillcolor", 0));
@ -778,18 +768,44 @@ namespace CodeImp.DoomBuilder.Windows
private void flags_OnValueChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
// Apply flags
foreach(Thing t in things)
{
// Apply all flags
foreach(CheckBox c in flags.Checkboxes)
{
if(c.CheckState == CheckState.Checked)
t.SetFlag(c.Tag.ToString(), true);
else if(c.CheckState == CheckState.Unchecked)
t.SetFlag(c.Tag.ToString(), false);
else if(thingprops[i].Flags.ContainsKey(c.Tag.ToString()))
t.SetFlag(c.Tag.ToString(), thingprops[i].Flags[c.Tag.ToString()]);
else //things created in the editor have empty Flags by default
t.SetFlag(c.Tag.ToString(), false);
}
i++;
}
// Dispatch event
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
// Validate flags
string warn = ThingFlagsCompare.CheckThingEditFormFlags(flags.Checkboxes);
if(!string.IsNullOrEmpty(warn))
{
//got missing flags
// Got missing flags
tooltip.SetToolTip(missingflags, warn);
missingflags.Visible = true;
settingsgroup.ForeColor = Color.DarkRed;
return;
}
//everything is OK
// Everything is OK
missingflags.Visible = false;
settingsgroup.ForeColor = SystemColors.ControlText;
}
@ -812,6 +828,43 @@ namespace CodeImp.DoomBuilder.Windows
grouproll.Enabled = !cbrandomroll.Checked;
}
private void renderStyle_SelectedIndexChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
//update values
foreach(Thing t in things)
UDMFTools.SetString(t.Fields, "renderstyle", renderstyles[renderStyle.SelectedIndex], "normal");
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
private void alpha_WhenTextChanged(object sender, EventArgs e)
{
if(preventchanges) return;
MakeUndo(); //mxd
int i = 0;
//restore values
if(string.IsNullOrEmpty(alpha.Text))
{
foreach(Thing t in things) UDMFTools.SetFloat(t.Fields, "alpha", thingprops[i++].Alpha, 1.0f);
}
else //update values
{
foreach(Thing t in things)
{
float value = General.Clamp(alpha.GetResultFloat(t.Fields.GetValue("alpha", 1.0f)), 0f, 1.0f);
UDMFTools.SetFloat(t.Fields, "alpha", value, 1.0f);
}
}
General.Map.IsChanged = true;
if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty);
}
#endregion
}

View file

@ -123,6 +123,13 @@ namespace CodeImp.DoomBuilder.ZDoom
// Find the actor to inherit from
baseclass = parser.GetArchivedActorByName(inheritclass);
//mxd. Does it exist?
if(baseclass == null)
{
parser.ReportError("Parent class '" + inheritclass + "' does not exist");
return;
}
break;
case "replaces":

View file

@ -522,25 +522,28 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd
protected override void MoveSelectedThings(Vector2D direction, bool absolutePosition)
protected override void MoveSelectedThings(Vector2D direction, bool absoluteposition)
{
List<VisualThing> visualThings = GetSelectedVisualThings(true);
if (visualThings.Count == 0) return;
List<VisualThing> visualthings = GetSelectedVisualThings(true);
if (visualthings.Count == 0) return;
PreAction(UndoGroup.ThingMove);
Vector3D[] coords = new Vector3D[visualThings.Count];
for (int i = 0; i < visualThings.Count; i++)
coords[i] = visualThings[i].Thing.Position;
Vector3D[] coords = new Vector3D[visualthings.Count];
for(int i = 0; i < visualthings.Count; i++)
coords[i] = visualthings[i].Thing.Position;
//move things...
Vector3D[] translatedCoords = TranslateCoordinates(coords, direction, absolutePosition);
for (int i = 0; i < visualThings.Count; i++)
Vector3D[] translatedcoords = TranslateCoordinates(coords, direction, absoluteposition);
for(int i = 0; i < visualthings.Count; i++)
{
BaseVisualThing t = visualThings[i] as BaseVisualThing;
t.OnMove(translatedCoords[i]);
BaseVisualThing t = visualthings[i] as BaseVisualThing;
t.OnMove(translatedcoords[i]);
}
// Things may've changed sectors...
FillBlockMap();
PostAction();
}

View file

@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Forms;
using CodeImp.DoomBuilder.GZBuilder.Data;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
@ -98,7 +99,72 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This builds the thing geometry. Returns false when nothing was created.
public bool Setup()
{
int sectorcolor = new PixelColor(255, 255, 255, 255).ToInt();
//mxd. Apply DECORATE/UDMF alpha/renderstyle overrides
string renderstyle = info.RenderStyle;
byte alpha = info.AlphaByte;
if(General.Map.UDMF)
{
if(Thing.IsFlagSet("translucent"))
{
renderstyle = "translucent";
alpha = 64;
}
else if(Thing.IsFlagSet("invisible"))
{
renderstyle = "none";
alpha = 0;
}
else if(Thing.Fields.ContainsKey("renderstyle"))
{
renderstyle = Thing.Fields.GetValue("renderstyle", renderstyle);
if(Thing.Fields.ContainsKey("alpha"))
alpha = (byte)(General.Clamp(Thing.Fields.GetValue("alpha", info.Alpha), 0f, 1f) * 255);
}
}
else if(General.Map.HEXEN)
{
if(Thing.IsFlagSet("2048"))
{
renderstyle = "translucent";
alpha = 64;
}
else if(Thing.IsFlagSet("4096"))
{
renderstyle = "none";
alpha = 0;
}
}
// Set appropriate RenderPass
switch(renderstyle)
{
case "translucent":
case "subtract":
case "stencil":
RenderPass = RenderPass.Alpha;
break;
case "add":
RenderPass = RenderPass.Additive;
break;
case "none":
RenderPass = RenderPass.Mask;
alpha = 0;
break;
// Many render styles are not supported yet...
default:
RenderPass = RenderPass.Mask;
alpha = 255;
break;
}
// Don't bother when alpha is unchanged
if(alpha == 255) RenderPass = RenderPass.Mask;
int sectorcolor = new PixelColor(alpha, 255, 255, 255).ToInt();
fogdistance = VisualSector.MAXIMUM_FOG_DISTANCE; //mxd
//mxd. Check thing size
@ -128,41 +194,47 @@ namespace CodeImp.DoomBuilder.BuilderModes
SectorData sd = mode.GetSectorData(Thing.Sector);
floor = sd.Floor.plane; //mxd
ceiling = sd.Ceiling.plane; //mxd
SectorLevel level = sd.GetLevelAboveOrAt(new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position)));
//mxd. Let's use point on floor plane instead of Thing.Sector.FloorHeight;
if(nointeraction && level == null && sd.LightLevels.Count > 0) level = sd.LightLevels[sd.LightLevels.Count - 1];
//mxd. Use the light level of the highest surface when a thing is above highest sector level.
if(level != null)
{
// Use sector brightness for color shading
PixelColor areabrightness = PixelColor.FromInt(mode.CalculateBrightness(level.brightnessbelow));
PixelColor areacolor = PixelColor.Modulate(level.colorbelow, areabrightness);
sectorcolor = areacolor.WithAlpha(255).ToInt();
//mxd. Calculate fogdistance
int brightness = Math.Max((byte)30, areabrightness.r); // R, G and B of areabrightness are the same
if(Thing.Sector.HasFogColor)
if(!info.Bright)
{
SectorLevel level = sd.GetLevelAboveOrAt(new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + sd.Floor.plane.GetZ(Thing.Position)));
//mxd. Let's use point on floor plane instead of Thing.Sector.FloorHeight;
if(nointeraction && level == null && sd.LightLevels.Count > 0) level = sd.LightLevels[sd.LightLevels.Count - 1];
//mxd. Use the light level of the highest surface when a thing is above highest sector level.
if(level != null)
{
if(Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.OutsideFogDensity > 0)
fogdistance = General.Map.Data.MapInfo.OutsideFogDensity;
else if(!Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.FogDensity > 0)
fogdistance = General.Map.Data.MapInfo.FogDensity;
// Use sector brightness for color shading
PixelColor areabrightness = PixelColor.FromInt(mode.CalculateBrightness(level.brightnessbelow));
PixelColor areacolor = PixelColor.Modulate(level.colorbelow, areabrightness);
sectorcolor = areacolor.WithAlpha(alpha).ToInt();
int brightness = Math.Max((byte) 30, areabrightness.r); // R, G and B of areabrightness are the same
//mxd. Calculate fogdistance
if(Thing.Sector.HasFogColor)
{
if(Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.OutsideFogDensity > 0) fogdistance = General.Map.Data.MapInfo.OutsideFogDensity;
else if(!Thing.Sector.UsesOutsideFog && General.Map.Data.MapInfo.FogDensity > 0) fogdistance = General.Map.Data.MapInfo.FogDensity;
else fogdistance = brightness * 11.0f;
}
// Thing is affected by floor glow
else if(level.affectedbyglow)
{
fogdistance = (float) Math.Pow(2.0f, brightness / 9.0f);
}
// Thing is not affected by floor glow
else
fogdistance = brightness * 11.0f;
}
// Thing is affected by floor glow
else if(level.affectedbyglow)
{
fogdistance = (float)Math.Pow(2.0f, brightness / 9.0f);
}
// Thing is not affected by floor glow
else
{
fogdistance = (float)Math.Pow(2.0f, brightness / 9.0f) * 2.0f;
{
fogdistance = (float) Math.Pow(2.0f, brightness / 9.0f) * 2.0f;
}
}
}
else
{
// +BRIGHT things are not affected by fog
fogdistance = float.MaxValue;
}
}
// Check if the texture is loaded
@ -678,18 +750,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd
public void OnMove(Vector3D newPosition)
public void OnMove(Vector3D newposition)
{
if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Move thing");
Thing.Move(newPosition);
Thing.Move(newposition);
mode.SetActionResult("Changed thing position to " + Thing.Position + ".");
// Update what must be updated
ThingData td = mode.GetThingData(this.Thing);
foreach (KeyValuePair<Sector, bool> s in td.UpdateAlso)
foreach(KeyValuePair<Sector, bool> s in td.UpdateAlso)
{
if (mode.VisualSectorExists(s.Key))
if(mode.VisualSectorExists(s.Key))
{
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s.Key);
vs.UpdateSectorGeometry(s.Value);

View file

@ -155,7 +155,7 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
try
{
// Load the map
bool isHexen = (General.Map.Config.FormatInterface == "HexenMapSetIO");
bool isHexen = General.Map.HEXEN;
if(LoadWAD(filename) != 0) throw new Exception("VPO is unable to read this file.");
if(OpenMap(mapname, ref isHexen) != 0) throw new Exception("VPO is unable to open this map.");
OpenDoors(BuilderPlug.InterfaceForm.OpenDoors ? 1 : -1); //mxd