diff --git a/Build/Configurations/Includes/Doom2_things.cfg b/Build/Configurations/Includes/Doom2_things.cfg index 859f292f..bfb26d31 100644 --- a/Build/Configurations/Includes/Doom2_things.cfg +++ b/Build/Configurations/Includes/Doom2_things.cfg @@ -207,7 +207,7 @@ decoration sort = 1; height = 16; hangs = 0; - blocking = 1; + blocking = 0; 79 { @@ -236,6 +236,7 @@ decoration sprite = "HDB1A0"; height = 88; hangs = 1; + blocking = 1; class = "HangNoGuts"; } @@ -245,6 +246,7 @@ decoration sprite = "HDB2A0"; height = 88; hangs = 1; + blocking = 1; class = "HangBNoBrain"; } @@ -254,6 +256,7 @@ decoration sprite = "HDB3A0"; height = 64; hangs = 1; + blocking = 1; class = "HangTLookingDown"; } diff --git a/Build/Scripting/GZDoom_MODELDEF.cfg b/Build/Scripting/GZDoom_MODELDEF.cfg index b98e855d..d9fc2d2d 100644 --- a/Build/Scripting/GZDoom_MODELDEF.cfg +++ b/Build/Scripting/GZDoom_MODELDEF.cfg @@ -23,6 +23,9 @@ keywords Rotation-Vector = "Rotation-Vector "; Rotation-Center = "Rotation-Center "; ZOffset = "ZOffset "; + AngleOffset = "AngleOffset "; + PitchOffset = "PitchOffset "; + RollOffset = "RollOffset "; } constants @@ -32,4 +35,6 @@ constants INTERPOLATEDOUBLEDFRAMES; ROTATING; NOINTERPOLATION; + INHERITACTORPITCH; + INHERITACTORROLL; } \ No newline at end of file diff --git a/Source/Core/Builder.sln b/Source/Core/Builder.sln index a681d591..4c148dbc 100644 --- a/Source/Core/Builder.sln +++ b/Source/Core/Builder.sln @@ -7,13 +7,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuilderModes", "..\Plugins\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GZDoomEditing", "..\Plugins\GZDoomEditing\GZDoomEditing.csproj", "{760A9BC7-CB73-4C36-858B-994C14996FCD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagExplorer", "..\Plugins\TagExplorer\TagExplorer.csproj", "{BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UDMFControls", "..\Plugins\UMDFControls\UDMFControls.csproj", "{2D11C828-295C-463A-8545-CA1AD6D51518}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorPicker", "..\Plugins\ColorPicker\ColorPicker.csproj", "{A4761900-0EA3-4FE4-A919-847FD5080EFC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisplaneExplorer", "..\Plugins\VisplaneExplorer\VisplaneExplorer.csproj", "{CF670175-7099-4090-A330-EE25C7230139}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagExplorer", "..\Plugins\TagExplorer\TagExplorer.csproj", "{BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -55,46 +51,28 @@ Global {760A9BC7-CB73-4C36-858B-994C14996FCD}.Release|Mixed Platforms.Build.0 = Release|x86 {760A9BC7-CB73-4C36-858B-994C14996FCD}.Release|x86.ActiveCfg = Release|x86 {760A9BC7-CB73-4C36-858B-994C14996FCD}.Release|x86.Build.0 = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|x86.ActiveCfg = Debug|Any CPU - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Any CPU.Build.0 = Release|Any CPU - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Mixed Platforms.Build.0 = Release|x86 - {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|x86.ActiveCfg = Release|Any CPU {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|x86.ActiveCfg = Debug|Any CPU + {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|x86.ActiveCfg = Debug|x86 + {2D11C828-295C-463A-8545-CA1AD6D51518}.Debug|x86.Build.0 = Debug|x86 {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Any CPU.Build.0 = Release|Any CPU {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Mixed Platforms.ActiveCfg = Release|x86 {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|Mixed Platforms.Build.0 = Release|x86 - {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|x86.ActiveCfg = Release|Any CPU - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Debug|Any CPU.ActiveCfg = Debug|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Debug|x86.ActiveCfg = Debug|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Debug|x86.Build.0 = Debug|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Release|Any CPU.ActiveCfg = Release|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Release|Mixed Platforms.Build.0 = Release|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Release|x86.ActiveCfg = Release|x86 - {A4761900-0EA3-4FE4-A919-847FD5080EFC}.Release|x86.Build.0 = Release|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Debug|Any CPU.ActiveCfg = Debug|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Debug|Mixed Platforms.Build.0 = Debug|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Debug|x86.ActiveCfg = Debug|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Debug|x86.Build.0 = Debug|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Release|Any CPU.ActiveCfg = Release|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Release|Mixed Platforms.ActiveCfg = Release|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Release|Mixed Platforms.Build.0 = Release|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Release|x86.ActiveCfg = Release|x86 - {CF670175-7099-4090-A330-EE25C7230139}.Release|x86.Build.0 = Release|x86 + {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|x86.ActiveCfg = Release|x86 + {2D11C828-295C-463A-8545-CA1AD6D51518}.Release|x86.Build.0 = Release|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Any CPU.ActiveCfg = Debug|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|x86.ActiveCfg = Debug|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Debug|x86.Build.0 = Debug|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Any CPU.ActiveCfg = Release|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|Mixed Platforms.Build.0 = Release|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|x86.ActiveCfg = Release|x86 + {BE7917F3-E6FE-4D5B-8FA9-B8E7668AC731}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source/Core/Config/ThingTypeInfo.cs b/Source/Core/Config/ThingTypeInfo.cs index 94375425..3aa0829a 100644 --- a/Source/Core/Config/ThingTypeInfo.cs +++ b/Source/Core/Config/ThingTypeInfo.cs @@ -284,7 +284,11 @@ namespace CodeImp.DoomBuilder.Config // Set sprite string suitablesprite = actor.FindSuitableSprite(); - if(!string.IsNullOrEmpty(suitablesprite)) sprite = suitablesprite; + if(!string.IsNullOrEmpty(suitablesprite)) + sprite = suitablesprite; + else//mxd + sprite = DataManager.INTERNAL_PREFIX + "unknownthing"; + if(this.sprite.Length <= 8) this.spritelongname = Lump.MakeLongName(this.sprite); diff --git a/Source/Core/Controls/ImageSelectorControl.cs b/Source/Core/Controls/ImageSelectorControl.cs index dca40652..d357fe96 100644 --- a/Source/Core/Controls/ImageSelectorControl.cs +++ b/Source/Core/Controls/ImageSelectorControl.cs @@ -45,7 +45,7 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Variables private Bitmap bmp; - private bool ispressed; + //private bool ispressed; private bool ismouseinside; private MouseButtons button; protected bool allowclear; @@ -97,7 +97,7 @@ namespace CodeImp.DoomBuilder.Controls // Image clicked private void preview_Click(object sender, EventArgs e) { - ispressed = false; + //ispressed = false; preview.BackColor = SystemColors.Highlight; ShowPreview(FindImage(name.Text)); if(button == MouseButtons.Right) @@ -123,7 +123,7 @@ namespace CodeImp.DoomBuilder.Controls button = e.Button; if((button == MouseButtons.Left) || ((button == MouseButtons.Right) && allowclear)) { - ispressed = true; + //ispressed = true; preview.BackColor = AdjustedColor(SystemColors.Highlight, 0.2f); ShowPreview(FindImage(name.Text)); } @@ -132,14 +132,14 @@ namespace CodeImp.DoomBuilder.Controls // Mouse released private void preview_MouseUp(object sender, MouseEventArgs e) { - ispressed = false; + //ispressed = false; ShowPreview(FindImage(name.Text)); } // Mouse leaves private void preview_MouseLeave(object sender, EventArgs e) { - ispressed = false; + //ispressed = false; ismouseinside = false; preview.BackColor = SystemColors.AppWorkspace; } diff --git a/Source/Core/Controls/ScintillaControl.cs b/Source/Core/Controls/ScintillaControl.cs index 85863d19..ee53be1e 100644 --- a/Source/Core/Controls/ScintillaControl.cs +++ b/Source/Core/Controls/ScintillaControl.cs @@ -108,8 +108,8 @@ namespace CodeImp.DoomBuilder.Controls public event MarginClickHandler MarginClick; public event NeedShownHandler NeedShown; public event PaintedHandler Painted; - public event UserListSelectionHandler UserListSelection; - public event URIDroppedHandler URIDropped; + //public event UserListSelectionHandler UserListSelection; + //public event URIDroppedHandler URIDropped; public event DwellStartHandler DwellStart; public event DwellEndHandler DwellEnd; public event ZoomHandler Zoom; diff --git a/Source/Core/Controls/ThingBrowserControl.cs b/Source/Core/Controls/ThingBrowserControl.cs index fea8b830..dd85b6c6 100644 --- a/Source/Core/Controls/ThingBrowserControl.cs +++ b/Source/Core/Controls/ThingBrowserControl.cs @@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Controls #region ================== Variables - private ICollection things; + //private ICollection things; private List nodes; private ThingTypeInfo thinginfo; private bool doupdatenode; diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index 744a36de..26e34aca 100644 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -1458,6 +1458,7 @@ namespace CodeImp.DoomBuilder.Data } General.MainWindow.DisplayStatus(StatusType.Busy, "Reloading model definitions..."); loadModeldefs(createActorsByClassList()); + LoadModels(); //rebuild geometry if in Visual mode if (General.Editing.Mode != null && General.Editing.Mode.GetType().Name == "BaseVisualMode") { diff --git a/Source/Core/Editing/UndoSnapshot.cs b/Source/Core/Editing/UndoSnapshot.cs index 9f1b1042..7b2f40df 100644 --- a/Source/Core/Editing/UndoSnapshot.cs +++ b/Source/Core/Editing/UndoSnapshot.cs @@ -47,7 +47,7 @@ namespace CodeImp.DoomBuilder.Editing private volatile bool storeondisk; private volatile bool isondisk; private bool isdisposed; - private Dictionary customdata; + //private Dictionary customdata; #endregion diff --git a/Source/Core/GZBuilder/Data/ModelDefEntry.cs b/Source/Core/GZBuilder/Data/ModelDefEntry.cs index 4fc97387..8b44c87c 100644 --- a/Source/Core/GZBuilder/Data/ModelDefEntry.cs +++ b/Source/Core/GZBuilder/Data/ModelDefEntry.cs @@ -22,6 +22,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data internal Vector3 Scale; internal float zOffset; + internal float AngleOffset; //in radians + internal float PitchOffset; //in radians + internal float RollOffset; //in radians + internal ModeldefEntry() { ModelNames = new List(); TextureNames = new List(); diff --git a/Source/Core/GZBuilder/GZDoom/ModeldefStructure.cs b/Source/Core/GZBuilder/GZDoom/ModeldefStructure.cs index c32ca513..c0f23021 100644 --- a/Source/Core/GZBuilder/GZDoom/ModeldefStructure.cs +++ b/Source/Core/GZBuilder/GZDoom/ModeldefStructure.cs @@ -19,6 +19,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { string path = ""; Vector3 scale = new Vector3(1, 1, 1); float zOffset = 0; + float angleOffset = 0; + float pitchOffset = 0; + float rollOffset = 0; + string token; bool gotErrors = false; @@ -28,7 +32,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { if (!string.IsNullOrEmpty(token)) { token = parser.StripTokenQuotes(token).ToLowerInvariant(); //ANYTHING can be quoted... - //path +//path if (token == "path") { parser.SkipWhitespace(true); path = parser.StripTokenQuotes(parser.ReadToken()).Replace("/", "\\"); @@ -38,7 +42,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { gotErrors = true; break; } - //model +//model } else if (token == "model") { parser.SkipWhitespace(true); @@ -57,7 +61,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { break; } - //model path +//model path token = parser.StripTokenQuotes(parser.ReadToken()).ToLowerInvariant(); if (string.IsNullOrEmpty(token)) { GZBuilder.GZGeneral.LogAndTraceWarning("Error in " + parser.Source + " at line " + parser.GetCurrentLineNumber() + ": expected model name, but got '" + token + "'"); @@ -76,7 +80,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { //GZDoom allows models with identical modelIndex, it uses the last one encountered modelNames[modelIndex] = token; } - //skin +//skin } else if (token == "skin") { parser.SkipWhitespace(true); @@ -95,7 +99,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { break; } - //skin path +//skin path token = parser.StripTokenQuotes(parser.ReadToken()).ToLowerInvariant(); if (string.IsNullOrEmpty(token)) { GZBuilder.GZGeneral.LogAndTraceWarning("Error in " + parser.Source + " at line " + parser.GetCurrentLineNumber() + ": expected skin name, but got '" + token + "'"); @@ -111,7 +115,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { //GZDoom allows skins with identical modelIndex, it uses the last one encountered textureNames[skinIndex] = token; } - //scale +//scale } else if (token == "scale") { parser.SkipWhitespace(true); @@ -142,7 +146,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { gotErrors = true; break; } - //zoffset +//zoffset } else if (token == "zoffset") { parser.SkipWhitespace(true); @@ -153,7 +157,40 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { gotErrors = true; break; } - //frameindex +//angleoffset + } else if (token == "angleoffset") { + parser.SkipWhitespace(true); + + token = parser.StripTokenQuotes(parser.ReadToken()); + if (!parser.ReadSignedFloat(token, ref angleOffset)) { + // Not numeric! + GZBuilder.GZGeneral.LogAndTraceWarning("Error in " + parser.Source + " at line " + parser.GetCurrentLineNumber() + ": expected AngleOffset value, but got '" + token + "'"); + gotErrors = true; + break; + } +//pitchoffset + } else if (token == "pitchoffset") { + parser.SkipWhitespace(true); + + token = parser.StripTokenQuotes(parser.ReadToken()); + if (!parser.ReadSignedFloat(token, ref pitchOffset)) { + // Not numeric! + GZBuilder.GZGeneral.LogAndTraceWarning("Error in " + parser.Source + " at line " + parser.GetCurrentLineNumber() + ": expected PitchOffset value, but got '" + token + "'"); + gotErrors = true; + break; + } +//rolloffset + } else if (token == "rolloffset") { + parser.SkipWhitespace(true); + + token = parser.StripTokenQuotes(parser.ReadToken()); + if (!parser.ReadSignedFloat(token, ref rollOffset)) { + // Not numeric! + GZBuilder.GZGeneral.LogAndTraceWarning("Error in " + parser.Source + " at line " + parser.GetCurrentLineNumber() + ": expected RollOffset value, but got '" + token + "'"); + gotErrors = true; + break; + } +//frameindex } else if (token == "frameindex") { //parsed all required fields. if got more than one model - find which one(s) should be displayed int len = modelNames.GetLength(0); @@ -262,14 +299,16 @@ namespace CodeImp.DoomBuilder.GZBuilder.GZDoom { break; } - if (gotErrors) - return null; + if (gotErrors) return null; //classname is set in ModeldefParser ModeldefEntry mde = new ModeldefEntry(); mde.Path = path; mde.Scale = scale; mde.zOffset = zOffset; + mde.AngleOffset = angleOffset * (float)Math.PI / 180.0f; + mde.RollOffset = rollOffset * (float)Math.PI / 180.0f; + mde.PitchOffset = pitchOffset * (float)Math.PI / 180.0f; for (int i = 0; i < textureNames.Length; i++) { if (textureNames[i] != null && modelNames[i] != null) { diff --git a/Source/Core/GZBuilder/GZGeneral.cs b/Source/Core/GZBuilder/GZGeneral.cs index 4c6b4173..5f858638 100644 --- a/Source/Core/GZBuilder/GZGeneral.cs +++ b/Source/Core/GZBuilder/GZGeneral.cs @@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.GZBuilder //version public const float Version = 1.12f; - public const char Revision = ' '; + public const char Revision = 'a'; //debug console #if DEBUG diff --git a/Source/Core/GZBuilder/md3/GZModel.cs b/Source/Core/GZBuilder/md3/GZModel.cs index 30b3da61..ea1de1b0 100644 --- a/Source/Core/GZBuilder/md3/GZModel.cs +++ b/Source/Core/GZBuilder/md3/GZModel.cs @@ -6,16 +6,15 @@ using CodeImp.DoomBuilder.Geometry; namespace CodeImp.DoomBuilder.GZBuilder.MD3 { - public class GZModel { - public List Meshes; - public List Textures; - public byte NUM_MESHES; //can't be greater than 255, can it? - public Vector3[] BoundingBox; - public List Indeces2D; - public List NumIndeces2D; - public float Angle = 0; //crappy way to set rotation to md2 models... + internal class GZModel { + internal List Meshes; + internal List Textures; + internal byte NUM_MESHES; //can't be greater than 255, can it? + internal Vector3[] BoundingBox; + internal List Indeces2D; + internal List NumIndeces2D; - public GZModel() { + internal GZModel() { Meshes = new List(); Textures = new List(); Indeces2D = new List(); diff --git a/Source/Core/GZBuilder/md3/ModelReader.cs b/Source/Core/GZBuilder/md3/ModelReader.cs index 9a22d12c..485188bf 100644 --- a/Source/Core/GZBuilder/md3/ModelReader.cs +++ b/Source/Core/GZBuilder/md3/ModelReader.cs @@ -195,12 +195,49 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 if (start + ofsNormal != br.BaseStream.Position) br.BaseStream.Position = start + ofsNormal; + //rotation angles + float angleOfsetCos = (float)Math.Cos(mde.AngleOffset); + float angleOfsetSin = (float)Math.Sin(mde.AngleOffset); + float pitchOfsetCos = (float)Math.Cos(-mde.PitchOffset); + float pitchOfsetSin = (float)Math.Sin(-mde.PitchOffset); + float rollOfsetCos = (float)Math.Cos(mde.RollOffset); + float rollOfsetSin = (float)Math.Sin(mde.RollOffset); + for (int i = vertexOffset; i < vertexOffset + numVerts; i++) { WorldVertex v = vertList[i]; - v.y = -(float)br.ReadInt16() / 64 * mde.Scale.X; - v.x = (float)br.ReadInt16() / 64 * mde.Scale.Y; - v.z = (float)br.ReadInt16() / 64 * mde.Scale.Z + mde.zOffset; + //read vertex + v.y = -(float)br.ReadInt16() / 64; + v.x = (float)br.ReadInt16() / 64; + v.z = (float)br.ReadInt16() / 64; + + //rotate it + if (mde.AngleOffset != 0) { + float rx = angleOfsetCos * v.x - angleOfsetSin * v.y; + float ry = angleOfsetSin * v.x + angleOfsetCos * v.y; + v.y = ry; + v.x = rx; + } + if (mde.PitchOffset != 0) { + float ry = pitchOfsetCos * v.y - pitchOfsetSin * v.z; + float rz = pitchOfsetSin * v.y + pitchOfsetCos * v.z; + v.z = rz; + v.y = ry; + } + if (mde.RollOffset != 0) { + float rx = rollOfsetCos * v.x - rollOfsetSin * v.z; + float rz = rollOfsetSin * v.x + rollOfsetCos * v.z; + v.z = rz; + v.x = rx; + } + + //scale it + v.y *= mde.Scale.X; + v.x *= mde.Scale.Y; + v.z *= mde.Scale.Z; + + //add zOffset + v.z += mde.zOffset; //bounding box BoundingBoxTools.UpdateBoundingBoxSizes(ref bbs, v); @@ -286,14 +323,49 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 s.Position += 16; //frame name + //rotation angles + float angle = mde.AngleOffset - 0.5f * (float)Math.PI; //subtract 90 degrees to get correct rotation + float angleOfsetCos = (float)Math.Cos(angle); + float angleOfsetSin = (float)Math.Sin(angle); + float pitchOfsetCos = (float)Math.Cos(-mde.PitchOffset); + float pitchOfsetSin = (float)Math.Sin(-mde.PitchOffset); + float rollOfsetCos = (float)Math.Cos(mde.RollOffset); + float rollOfsetSin = (float)Math.Sin(mde.RollOffset); + //verts for (int i = 0; i < num_verts; i++) { - //pos WorldVertex v = new WorldVertex(); - v.x = ((float)br.ReadByte() * scale.X + translate.X) * mde.Scale.X; - v.y = ((float)br.ReadByte() * scale.Y + translate.Y) * mde.Scale.Y; - v.z = ((float)br.ReadByte() * scale.Z + translate.Z) * mde.Scale.Z + mde.zOffset; + v.x = ((float)br.ReadByte() * scale.X + translate.X); + v.y = ((float)br.ReadByte() * scale.Y + translate.Y); + v.z = ((float)br.ReadByte() * scale.Z + translate.Z); + + //rotate it + float rx = angleOfsetCos * v.x - angleOfsetSin * v.y; + float ry = angleOfsetSin * v.x + angleOfsetCos * v.y; + v.y = ry; + v.x = rx; + + if (mde.PitchOffset != 0) { + ry = pitchOfsetCos * v.y - pitchOfsetSin * v.z; + float rz = pitchOfsetSin * v.y + pitchOfsetCos * v.z; + v.z = rz; + v.y = ry; + } + if (mde.RollOffset != 0) { + rx = rollOfsetCos * v.x - rollOfsetSin * v.z; + float rz = rollOfsetSin * v.x + rollOfsetCos * v.z; + v.z = rz; + v.x = rx; + } + + //scale it + v.x *= mde.Scale.X; + v.y *= mde.Scale.Y; + v.z *= mde.Scale.Z; + + //add zOffset + v.z += mde.zOffset; vertList.Add(v); @@ -340,7 +412,6 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 mde.Model.Indeces2D.Add(indeces2d); mde.Model.NumIndeces2D.Add((short)polyIndecesList.Count); - mde.Model.Angle = -90.0f * (float)Math.PI / 180.0f; } return ""; } diff --git a/Source/Core/Rendering/Renderer2D.cs b/Source/Core/Rendering/Renderer2D.cs index a5f7bf32..f8a03723 100644 --- a/Source/Core/Rendering/Renderer2D.cs +++ b/Source/Core/Rendering/Renderer2D.cs @@ -1132,10 +1132,23 @@ namespace CodeImp.DoomBuilder.Rendering foreach(KeyValuePair group in thingsWithModel){ ModeldefEntry mde = General.Map.Data.ModeldefEntries[group.Value.Type]; - if (mde.Model != null) - RenderModel(mde.Model, group.Key, group.Value.Angle + mde.Model.Angle, group.Value.Selected); - else + if (mde.Model != null) {//render model + //wire color + graphics.Shaders.Things2D.FillColor = group.Value.Selected ? General.Colors.Selection.ToColorValue() : General.Colors.ModelWireframe.ToColorValue(); + + for (int i = 0; i < mde.Model.NUM_MESHES; i++) { + graphics.Shaders.Things2D.SetTransformSettings(group.Key, group.Value.Angle, scale); + graphics.Shaders.Things2D.ApplySettings(); + + // Draw + graphics.Device.SetStreamSource(0, mde.Model.Meshes[i].VertexBuffer, 0, WorldVertex.Stride); + graphics.Device.Indices = mde.Model.Indeces2D[i]; + graphics.Device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, mde.Model.Meshes[i].VertexCount, 0, mde.Model.NumIndeces2D[i]); + } + + } else { group.Value.IsModel = General.Map.Data.LoadModelForThing(group.Value); + } } graphics.Shaders.Things2D.EndPass(); } @@ -1157,22 +1170,6 @@ namespace CodeImp.DoomBuilder.Rendering { RenderThingsBatch(things, alpha, false, new PixelColor()); } - - //mxd - public void RenderModel(GZModel model, Vector2D modelPos, float modelAngle, bool selected) { - //wire color - graphics.Shaders.Things2D.FillColor = selected ? General.Colors.Selection.ToColorValue() : General.Colors.ModelWireframe.ToColorValue(); - - for (int i = 0; i < model.NUM_MESHES; i++) { - graphics.Shaders.Things2D.SetTransformSettings(modelPos, modelAngle, scale); - graphics.Shaders.Things2D.ApplySettings(); - - // Draw - graphics.Device.SetStreamSource(0, model.Meshes[i].VertexBuffer, 0, WorldVertex.Stride); - graphics.Device.Indices = model.Indeces2D[i]; - graphics.Device.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, model.Meshes[i].VertexCount, 0, model.NumIndeces2D[i]); - } - } #endregion diff --git a/Source/Core/Rendering/Renderer3D.cs b/Source/Core/Rendering/Renderer3D.cs index 74852d5f..c35158f2 100644 --- a/Source/Core/Rendering/Renderer3D.cs +++ b/Source/Core/Rendering/Renderer3D.cs @@ -1031,7 +1031,7 @@ namespace CodeImp.DoomBuilder.Rendering } // Create the matrix for positioning / rotation - world = Matrix.Multiply(t.Orientation, Matrix.RotationZ(t.Thing.Angle + group.Key.Model.Angle)); + world = Matrix.Multiply(t.Orientation, Matrix.RotationZ(t.Thing.Angle)); world = Matrix.Multiply(world, t.Position); ApplyMatrices3D(); diff --git a/Source/Core/Windows/AngleForm.cs b/Source/Core/Windows/AngleForm.cs index f2d323b5..153ecad8 100644 --- a/Source/Core/Windows/AngleForm.cs +++ b/Source/Core/Windows/AngleForm.cs @@ -38,7 +38,7 @@ namespace CodeImp.DoomBuilder.Windows { #region ================== Variables - private bool setup; + //private bool setup; private int value; #endregion @@ -86,10 +86,10 @@ namespace CodeImp.DoomBuilder.Windows // Setup from EnumList public void Setup(int value) { - setup = true; + //setup = true; this.value = value; angle.Value = value; - setup = false; + //setup = false; } // This shows the dialog diff --git a/Source/Core/Windows/ErrorsForm.Designer.cs b/Source/Core/Windows/ErrorsForm.Designer.cs index 181b4790..cc68cabe 100644 --- a/Source/Core/Windows/ErrorsForm.Designer.cs +++ b/Source/Core/Windows/ErrorsForm.Designer.cs @@ -29,7 +29,7 @@ namespace CodeImp.DoomBuilder.Windows private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.copyselected = new System.Windows.Forms.Button(); this.clearlist = new System.Windows.Forms.Button(); this.close = new System.Windows.Forms.Button(); @@ -44,6 +44,7 @@ namespace CodeImp.DoomBuilder.Windows // copyselected // this.copyselected.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.copyselected.Enabled = false; this.copyselected.Location = new System.Drawing.Point(12, 416); this.copyselected.Name = "copyselected"; this.copyselected.Size = new System.Drawing.Size(122, 25); @@ -116,9 +117,9 @@ namespace CodeImp.DoomBuilder.Windows this.grid.Name = "grid"; this.grid.ReadOnly = true; this.grid.RowHeadersVisible = false; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft; - dataGridViewCellStyle1.Padding = new System.Windows.Forms.Padding(2, 4, 2, 5); - this.grid.RowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopLeft; + dataGridViewCellStyle2.Padding = new System.Windows.Forms.Padding(2, 4, 2, 5); + this.grid.RowsDefaultCellStyle = dataGridViewCellStyle2; this.grid.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.grid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.grid.ShowCellErrors = false; @@ -128,6 +129,7 @@ namespace CodeImp.DoomBuilder.Windows this.grid.Size = new System.Drawing.Size(732, 395); this.grid.StandardTab = true; this.grid.TabIndex = 5; + this.grid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.grid_CellContentClick); // // iconcolumn // diff --git a/Source/Core/Windows/ErrorsForm.cs b/Source/Core/Windows/ErrorsForm.cs index 3118481e..62eba0b4 100644 --- a/Source/Core/Windows/ErrorsForm.cs +++ b/Source/Core/Windows/ErrorsForm.cs @@ -146,5 +146,9 @@ namespace CodeImp.DoomBuilder.Windows grid.Rows[0].Selected = false; } + + private void grid_CellContentClick(object sender, DataGridViewCellEventArgs e) { + copyselected.Enabled = true; + } } } \ No newline at end of file diff --git a/Source/Plugins/UMDFControls/BuilderPlug.cs b/Source/Plugins/UMDFControls/BuilderPlug.cs index 5ec1ea6c..7dd4d769 100644 --- a/Source/Plugins/UMDFControls/BuilderPlug.cs +++ b/Source/Plugins/UMDFControls/BuilderPlug.cs @@ -17,8 +17,11 @@ namespace CodeImp.DoomBuilder.UDMFControls public override string Name { get { return "UDMF Controls"; } } - private UDMFControlsForm form; + //settings + private int scaleReange; + public int ScaleReange { get { return scaleReange; } } + private UDMFControlsForm form; private Point formLocation; //used to keep form's location constant public override void OnInitialize() { @@ -31,27 +34,12 @@ namespace CodeImp.DoomBuilder.UDMFControls me = this; General.Actions.BindMethods(this); - } - /*public override void OnEditKeyDown(KeyEventArgs e) { - //dbg - GZBuilder.GZGeneral.Trace("OnEditKeyDown"); - - base.OnEditKeyDown(e); - if(form != null){ - form.FineMovement = General.Interface.ShiftState; - form.FastMovement = General.Interface.CtrlState; - } + scaleReange = General.Settings.ReadPluginSetting("scalerange", 2); + if (scaleReange < 1) scaleReange = 2; + General.Settings.WritePluginSetting("scalerange", scaleReange); //not working when called from Dispose()... } - public override void OnEditKeyUp(KeyEventArgs e) { - base.OnEditKeyUp(e); - if (form != null) { - form.FineMovement = General.Interface.ShiftState; - form.FastMovement = General.Interface.CtrlState; - } - }*/ - public override void Dispose() { base.Dispose(); General.Actions.UnbindMethods(this); diff --git a/Source/Plugins/UMDFControls/Controls/FloatSlider.cs b/Source/Plugins/UMDFControls/Controls/FloatSlider.cs index 5b6c5f21..a1a35c08 100644 --- a/Source/Plugins/UMDFControls/Controls/FloatSlider.cs +++ b/Source/Plugins/UMDFControls/Controls/FloatSlider.cs @@ -17,7 +17,7 @@ namespace CodeImp.DoomBuilder.UDMFControls public float Value { get { - return (float)trackBar1.Value / 10f; + return (float)Math.Round(numericUpDown1.Value, 1); } set { blockEvents = true; @@ -28,9 +28,9 @@ namespace CodeImp.DoomBuilder.UDMFControls } } - private int previousValue; - private int delta; - public float Delta { get { return (float)delta / 10f; } } + private float previousValue; + private float delta; + public float Delta { get { return delta; } } private bool showLabels = true; public bool ShowLabels { @@ -43,14 +43,14 @@ namespace CodeImp.DoomBuilder.UDMFControls labelMax.Visible = showLabels; } } - + public FloatSlider() { InitializeComponent(); ShowLabels = showLabels; numericUpDown1.DecimalPlaces = 1; } - public void SetLimits(float min, float max, bool doubledLimits) { + public void SetLimits(float min, float max, bool extendedLimits) { blockEvents = true; trackBar1.Value = General.Clamp(trackBar1.Value, (int)(min * 10), (int)(max * 10)); @@ -62,9 +62,9 @@ namespace CodeImp.DoomBuilder.UDMFControls numericUpDown1.Value = (decimal)General.Clamp((float)numericUpDown1.Value, min, max); - if (doubledLimits) { - numericUpDown1.Minimum = (decimal)(min * 10); - numericUpDown1.Maximum = (decimal)(max * 10); + if (extendedLimits) { + numericUpDown1.Minimum = (decimal)(min * 32); + numericUpDown1.Maximum = (decimal)(max * 32); } else { numericUpDown1.Minimum = (decimal)min; numericUpDown1.Maximum = (decimal)max; @@ -75,21 +75,19 @@ namespace CodeImp.DoomBuilder.UDMFControls //events private void trackBar1_ValueChanged(object sender, EventArgs e) { - int value = ((TrackBar)sender).Value; - delta = value - previousValue; - previousValue = value; - - numericUpDown1.Value = Math.Round((decimal)(value / 10.0), 1); + if (!blockEvents) numericUpDown1.Value = Math.Round((decimal)(trackBar1.Value / 10.0), 1); } private void numericUpDown1_ValueChanged(object sender, EventArgs e) { - float val = (float)((NumericUpDown)sender).Value; + float value = (float)Math.Round(numericUpDown1.Value, 1); + delta = (float)Math.Round(value - previousValue, 1); + previousValue = value; if (!blockEvents && OnValueChanged != null) OnValueChanged(this, EventArgs.Empty); blockEvents = true; - trackBar1.Value = General.Clamp((int)(val * 10), trackBar1.Minimum, trackBar1.Maximum); + trackBar1.Value = General.Clamp((int)(value * 10), trackBar1.Minimum, trackBar1.Maximum); blockEvents = false; } } diff --git a/Source/Plugins/UMDFControls/Controls/IntSlider.cs b/Source/Plugins/UMDFControls/Controls/IntSlider.cs index da5d6008..dc59c4cc 100644 --- a/Source/Plugins/UMDFControls/Controls/IntSlider.cs +++ b/Source/Plugins/UMDFControls/Controls/IntSlider.cs @@ -10,19 +10,18 @@ using System.Globalization; namespace CodeImp.DoomBuilder.UDMFControls { - public partial class IntSlider : UserControl { + public partial class IntSlider : UserControl + { private bool blockEvents; public event EventHandler OnValueChanged; private int previousValue; - public int Value { - get - { - return (int)numericUpDown1.Value; + public int Value { + get { + return (int)numericUpDown1.Value; } - set - { + set { blockEvents = true; previousValue = General.Clamp(value, (int)numericUpDown1.Minimum, (int)numericUpDown1.Maximum); @@ -31,7 +30,8 @@ namespace CodeImp.DoomBuilder.UDMFControls } } - public int Delta { get { return trackBar1.Value - previousValue; }} + private int delta; + public int Delta { get { return delta; } } private bool showLabels; public bool ShowLabels { @@ -44,13 +44,12 @@ namespace CodeImp.DoomBuilder.UDMFControls labelMax.Visible = showLabels; } } - + public IntSlider() { InitializeComponent(); } public void SetLimits(int min, int max) { - //bool blockEventsStatus = blockEvents; blockEvents = true; trackBar1.Value = General.Clamp(trackBar1.Value, min, max); @@ -64,24 +63,24 @@ namespace CodeImp.DoomBuilder.UDMFControls numericUpDown1.Minimum = min; numericUpDown1.Maximum = max; - //blockEvents = blockEventsStatus; blockEvents = false; } -//events + //events private void trackBar1_ValueChanged(object sender, EventArgs e) { - numericUpDown1.Value = ((TrackBar)sender).Value; + if (!blockEvents) numericUpDown1.Value = ((TrackBar)sender).Value; } private void numericUpDown1_ValueChanged(object sender, EventArgs e) { - int val = (int)((NumericUpDown)sender).Value; + int value = (int)((NumericUpDown)sender).Value; + delta = value - previousValue; + previousValue = value; if (!blockEvents && OnValueChanged != null) OnValueChanged(this, EventArgs.Empty); - previousValue = trackBar1.Value; blockEvents = true; - trackBar1.Value = General.Clamp(val, trackBar1.Minimum, trackBar1.Maximum); //clamp it! + trackBar1.Value = General.Clamp(value, trackBar1.Minimum, trackBar1.Maximum); blockEvents = false; } } diff --git a/Source/Plugins/UMDFControls/Controls/ScaleControl.cs b/Source/Plugins/UMDFControls/Controls/ScaleControl.cs index 1c11db4a..d6a69dbc 100644 --- a/Source/Plugins/UMDFControls/Controls/ScaleControl.cs +++ b/Source/Plugins/UMDFControls/Controls/ScaleControl.cs @@ -62,9 +62,10 @@ namespace CodeImp.DoomBuilder.UDMFControls floatSlider2.Value = val; } - if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty); delta.x = (float)Math.Round(val - prevValues.x, 1); prevValues.x = val; + + if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty); } private void floatSlider2_OnValueChanged(object sender, EventArgs e) { @@ -76,9 +77,10 @@ namespace CodeImp.DoomBuilder.UDMFControls floatSlider1.Value = val; } - if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty); delta.y = (float)Math.Round(val - prevValues.y, 1); prevValues.y = val; + + if (OnValueChanged != null) OnValueChanged(this, EventArgs.Empty); } private void button1_Click(object sender, EventArgs e) { diff --git a/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs b/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs index a1446c4d..43c94415 100644 --- a/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs +++ b/Source/Plugins/UMDFControls/Windows/UDMFControlsForm.cs @@ -142,7 +142,8 @@ namespace CodeImp.DoomBuilder.UDMFControls //set sliders limits sliderDesaturation.SetLimits(0f, 1f, false); sliderAlpha.SetLimits(0f, 1f, false); - scaleControl.SetLimits(-2f, 2f); + float scaleRange = BuilderPlug.Me.ScaleReange; + scaleControl.SetLimits(-scaleRange, scaleRange); cbRenderStyle.Items.AddRange(new object[] { "Translucent", "Add" }); cbRenderStyle.SelectedIndex = 0;