mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-16 17:11:28 +00:00
Sectors mode: added "Light and Fade" brightness gradient mode.
Sectors mode: "Gradient Interpolation Mode" toolbar menu. Internal: extracted easing functions from Bridge Mode into InterpolationTools class. +a couple of cosmetic changes.
This commit is contained in:
parent
290231070a
commit
b8c871916b
9 changed files with 273 additions and 184 deletions
|
@ -466,7 +466,7 @@ gzdoom_lights
|
|||
|
||||
gzdoom
|
||||
{
|
||||
zdoom
|
||||
zdoom
|
||||
{
|
||||
blocking = 2;
|
||||
5004 = "Map Spot (FraggleScript)";
|
||||
|
|
|
@ -763,6 +763,7 @@
|
|||
<Compile Include="General\MurmurHash2.cs" />
|
||||
<Compile Include="General\SavePurpose.cs" />
|
||||
<Compile Include="Geometry\CurveTools.cs" />
|
||||
<Compile Include="Geometry\InterpolationTools.cs" />
|
||||
<Compile Include="GZBuilder\Controls\AngleControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
|
75
Source/Core/Geometry/InterpolationTools.cs
Normal file
75
Source/Core/Geometry/InterpolationTools.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
|
||||
|
||||
public static class InterpolationTools
|
||||
{
|
||||
public enum Mode
|
||||
{
|
||||
Linear,
|
||||
EaseInOutSine,
|
||||
EaseInSine,
|
||||
EaseOutSine,
|
||||
}
|
||||
|
||||
public static int Interpolate(int val1, int val2, float delta, Mode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case Mode.Linear: return Linear(val1, val2, delta);
|
||||
case Mode.EaseInSine: return EaseInSine(val1, val2, delta);
|
||||
case Mode.EaseOutSine: return EaseOutSine(val1, val2, delta);
|
||||
case Mode.EaseInOutSine: return EaseInOutSine(val1, val2, delta);
|
||||
default: throw new NotImplementedException("InterpolationTools.Interpolate: '" + mode + "' mode is not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
//Based on Robert Penner's original easing equations (http://www.robertpenner.com/easing/)
|
||||
public static int Linear(int val1, int val2, float delta)
|
||||
{
|
||||
return (int)(delta * val2 + (1.0f - delta) * val1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
|
||||
*/
|
||||
public static int EaseInSine(int val1, int val2, float delta)
|
||||
{
|
||||
float f_val1 = val1;
|
||||
float f_val2 = val2 - f_val1;
|
||||
return (int)(-f_val2 * Math.Cos(delta * Angle2D.PIHALF) + f_val2 + f_val1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
|
||||
*/
|
||||
public static int EaseOutSine(int val1, int val2, float delta)
|
||||
{
|
||||
float f_val1 = val1;
|
||||
float f_val2 = val2;
|
||||
return (int)((f_val2 - f_val1) * Math.Sin(delta * Angle2D.PIHALF) + f_val1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
|
||||
*/
|
||||
public static int EaseInOutSine(int val1, int val2, float delta)
|
||||
{
|
||||
float f_val1, f_val2;
|
||||
if(val1 > val2)
|
||||
{
|
||||
f_val1 = val2;
|
||||
f_val2 = val1;
|
||||
delta = 1.0f - delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
f_val1 = val1;
|
||||
f_val2 = val2;
|
||||
}
|
||||
return (int)(-f_val2 / 2.0f * (Math.Cos(Angle2D.PI * delta) - 1.0f) + f_val1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -39,51 +39,51 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private readonly ListViewGroup availgroup;
|
||||
private TreeNode selectedset; //mxd
|
||||
private string selecttextureonfill;
|
||||
private readonly bool browseFlats;
|
||||
private readonly bool browseflats; //mxd
|
||||
|
||||
// Properties
|
||||
public string SelectedName { get { return selectedname; } }
|
||||
|
||||
// Constructor
|
||||
public TextureBrowserForm(string selecttexture, bool browseFlats)
|
||||
public TextureBrowserForm(string selecttexture, bool browseflats)
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
TreeNode item; //mxd
|
||||
long longname = Lump.MakeLongName(selecttexture ?? "");
|
||||
longname = (browseFlats ? General.Map.Data.GetFullLongFlatName(longname) : General.Map.Data.GetFullLongTextureName(longname)); //mxd
|
||||
longname = (browseflats ? General.Map.Data.GetFullLongFlatName(longname) : General.Map.Data.GetFullLongTextureName(longname)); //mxd
|
||||
int count; //mxd
|
||||
selectedset = null; //mxd
|
||||
this.browseFlats = browseFlats;
|
||||
this.browseflats = browseflats; //mxd
|
||||
|
||||
// Initialize
|
||||
InitializeComponent();
|
||||
|
||||
//mxd. Set title
|
||||
string imgType = (browseFlats ? "flats" : "textures");
|
||||
this.Text = "Browse " + imgType;
|
||||
string imagetype = (browseflats ? "flats" : "textures");
|
||||
this.Text = "Browse " + imagetype;
|
||||
|
||||
// Setup texture browser
|
||||
ImageBrowserControl.ShowTextureSizes = General.Settings.ReadSetting("browserwindow.showtexturesizes", General.Settings.ShowTextureSizes);
|
||||
ImageBrowserControl.UseLongTextureNames = General.Map.Config.UseLongTextureNames && General.Settings.ReadSetting("browserwindow.uselongtexturenames", true);
|
||||
browser.BrowseFlats = browseFlats;
|
||||
browser.BrowseFlats = browseflats;
|
||||
browser.ApplySettings();
|
||||
|
||||
// Update the used textures
|
||||
General.Map.Data.UpdateUsedTextures();
|
||||
|
||||
tvTextureSets.BeginUpdate();//mxd
|
||||
tvTextureSets.BeginUpdate(); //mxd
|
||||
|
||||
// Texture to select when list is filled
|
||||
selecttextureonfill = selecttexture;
|
||||
|
||||
// Make groups
|
||||
usedgroup = browser.AddGroup("Used " + imgType + ":");
|
||||
availgroup = browser.AddGroup("Available " + imgType + ":");
|
||||
usedgroup = browser.AddGroup("Used " + imagetype + ":");
|
||||
availgroup = browser.AddGroup("Available " + imagetype + ":");
|
||||
|
||||
//mxd. Fill texture sets list with normal texture sets
|
||||
foreach(IFilledTextureSet ts in General.Map.Data.TextureSets)
|
||||
{
|
||||
count = (browseFlats ? ts.Flats.Count : ts.Textures.Count);
|
||||
count = (browseflats ? ts.Flats.Count : ts.Textures.Count);
|
||||
if((count == 0 && !General.Map.Config.MixTexturesFlats) || (ts.Flats.Count == 0 && ts.Textures.Count == 0))
|
||||
continue;
|
||||
|
||||
|
@ -96,7 +96,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//mxd. Add container-specific texture sets
|
||||
foreach(ResourceTextureSet ts in General.Map.Data.ResourceTextureSets)
|
||||
{
|
||||
count = (browseFlats ? ts.Flats.Count : ts.Textures.Count);
|
||||
count = (browseflats ? ts.Flats.Count : ts.Textures.Count);
|
||||
if((count == 0 && !General.Map.Config.MixTexturesFlats) || (ts.Flats.Count == 0 && ts.Textures.Count == 0))
|
||||
continue;
|
||||
|
||||
|
@ -113,20 +113,20 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
}
|
||||
}
|
||||
|
||||
//mxd. Add All textures set
|
||||
count = (browseFlats ? General.Map.Data.AllTextureSet.Flats.Count : General.Map.Data.AllTextureSet.Textures.Count);
|
||||
//mxd. Add "All" texture set
|
||||
count = (browseflats ? General.Map.Data.AllTextureSet.Flats.Count : General.Map.Data.AllTextureSet.Textures.Count);
|
||||
item = tvTextureSets.Nodes.Add(General.Map.Data.AllTextureSet.Name + " [" + count + "]");
|
||||
item.Name = General.Map.Data.AllTextureSet.Name;
|
||||
item.Tag = General.Map.Data.AllTextureSet;
|
||||
item.ImageIndex = 1;
|
||||
item.SelectedImageIndex = item.ImageIndex;
|
||||
|
||||
//mxd. Select the last one that was selected
|
||||
//mxd. Get the previously selected texture set
|
||||
string selectname = General.Settings.ReadSetting("browserwindow.textureset", "");
|
||||
TreeNode match;
|
||||
// When texture name is empty, select "All" texture set
|
||||
if(string.IsNullOrEmpty(selectname) || selectname == "-")
|
||||
{
|
||||
// When texture name is empty, select "All" texture set
|
||||
match = tvTextureSets.Nodes[tvTextureSets.Nodes.Count - 1];
|
||||
}
|
||||
else
|
||||
|
@ -157,11 +157,11 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
}
|
||||
}
|
||||
|
||||
//mxd. Texture still now found? Then just select the last used set
|
||||
//mxd. Texture still not found? Then just select the last used set
|
||||
if (selectedset == null && match != null)
|
||||
selectedset = match;
|
||||
|
||||
//mxd. Select found node or "All" node, if none were found
|
||||
//mxd. Select the found set or "All", if none were found
|
||||
if (tvTextureSets.Nodes.Count > 0)
|
||||
{
|
||||
if (selectedset == null) selectedset = tvTextureSets.Nodes[tvTextureSets.Nodes.Count - 1];
|
||||
|
@ -219,7 +219,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//then - in current node
|
||||
IFilledTextureSet set = (node.Tag as IFilledTextureSet);
|
||||
|
||||
if (browseFlats)
|
||||
if (browseflats)
|
||||
{
|
||||
foreach(ImageData img in set.Flats)
|
||||
if(img.LongName == longname) return node;
|
||||
|
@ -260,7 +260,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
char[] separator = new[] { Path.AltDirectorySeparatorChar };
|
||||
|
||||
ImageData[] images;
|
||||
if (browseFlats)
|
||||
if (browseflats)
|
||||
{
|
||||
images = new ImageData[set.Flats.Count];
|
||||
set.Flats.CopyTo(images, 0);
|
||||
|
@ -342,7 +342,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
}
|
||||
else
|
||||
{
|
||||
node.Text += " [" + (browseFlats ? ts.Flats.Count : ts.Textures.Count) + "]";
|
||||
node.Text += " [" + (browseflats ? ts.Flats.Count : ts.Textures.Count) + "]";
|
||||
}
|
||||
|
||||
foreach (TreeNode child in node.Nodes) SetItemsCount(child);
|
||||
|
@ -479,7 +479,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Start adding
|
||||
browser.BeginAdding(false);
|
||||
|
||||
if (browseFlats)
|
||||
if (browseflats)
|
||||
{
|
||||
// Add all available flats
|
||||
foreach(ImageData img in set.Flats)
|
||||
|
|
|
@ -716,36 +716,6 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes
|
|||
#endregion
|
||||
|
||||
#region ================== Easing functions
|
||||
//Based on Robert Penner's original easing equations (http://www.robertpenner.com/easing/)
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing in: accelerating from zero velocity.
|
||||
*/
|
||||
private static int EaseInSine(int val1, int val2, float delta)
|
||||
{
|
||||
float f_val1 = val1;
|
||||
float f_val2 = val2 - f_val1;
|
||||
return (int)(-f_val2 * Math.Cos(delta * Angle2D.PIHALF) + f_val2 + f_val1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing out: decelerating from zero velocity.
|
||||
*/
|
||||
private static int EaseOutSine(int val1, int val2, float delta)
|
||||
{
|
||||
float f_val1 = val1;
|
||||
float f_val2 = val2;
|
||||
return (int)((f_val2 - f_val1) * Math.Sin(delta * Angle2D.PIHALF) + f_val1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easing equation function for a sinusoidal (sin(t)) easing in/out: acceleration until halfway, then deceleration.
|
||||
*/
|
||||
private static int EaseInOutSine(int val1, int val2, float delta)
|
||||
{
|
||||
float f_val1 = val1;
|
||||
float f_val2 = val2;
|
||||
return (int)(-f_val2 / 2.0f * (Math.Cos(Angle2D.PI * delta) - 1.0f) + f_val1);
|
||||
}
|
||||
|
||||
private static int IntepolateValue(int val1, int val2, float delta, string mode)
|
||||
{
|
||||
|
@ -760,19 +730,19 @@ namespace CodeImp.DoomBuilder.BuilderModes.ClassicModes
|
|||
return Math.Min(val1, val2);
|
||||
|
||||
case BridgeInterpolationMode.LINEAR:
|
||||
return (int)(delta * val2 + (1.0f - delta) * val1);
|
||||
return InterpolationTools.Linear(val1, val2, delta);
|
||||
|
||||
case BridgeInterpolationMode.IN_SINE:
|
||||
return EaseInSine(val1, val2, delta);
|
||||
return InterpolationTools.EaseInSine(val1, val2, delta);
|
||||
|
||||
case BridgeInterpolationMode.OUT_SINE:
|
||||
return EaseOutSine(val1, val2, delta);
|
||||
return InterpolationTools.EaseOutSine(val1, val2, delta);
|
||||
|
||||
case BridgeInterpolationMode.IN_OUT_SINE:
|
||||
return EaseInOutSine(val1, val2, delta);
|
||||
return InterpolationTools.EaseInOutSine(val1, val2, delta);
|
||||
|
||||
default:
|
||||
throw new Exception("DrawBezierPathMode.intepolateValue: got unknown mode: '" + mode + "'");
|
||||
throw new Exception("DrawBezierPathMode.IntepolateValue: '" + mode + "' mode is not supported!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -637,10 +637,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects);
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors1);
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeDoor); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors2); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
|
||||
if(General.Map.UDMF) General.Interface.AddButton(BuilderPlug.Me.MenusForm.BrightnessGradientMode); //mxd
|
||||
if(General.Map.UDMF) General.Interface.AddButton(BuilderPlug.Me.MenusForm.GradientModeMenu); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.GradientInterpolationMenu); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeGradientFloors);
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeGradientCeilings);
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors3); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MarqueSelectTouching); //mxd
|
||||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.DragThingsInSelectedSectors); //mxd
|
||||
if(General.Map.UDMF) General.Interface.AddButton(BuilderPlug.Me.MenusForm.TextureOffsetLock, ToolbarSection.Geometry); //mxd
|
||||
|
@ -672,10 +675,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects);
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorSectors1);
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeDoor); //mxd
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorSectors2); //mxd
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
|
||||
if(General.Map.UDMF) General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.BrightnessGradientMode); //mxd
|
||||
if(General.Map.UDMF) General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.GradientModeMenu); //mxd
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.GradientInterpolationMenu); //mxd
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientFloors);
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientCeilings);
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorSectors3); //mxd
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MarqueSelectTouching); //mxd
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.DragThingsInSelectedSectors); //mxd
|
||||
if(General.Map.UDMF) General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.TextureOffsetLock); //mxd
|
||||
|
@ -1691,118 +1697,85 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Sector end = General.GetByIndex(orderedselection, orderedselection.Count - 1);
|
||||
|
||||
//mxd. Use UDMF light?
|
||||
string mode = (string)BuilderPlug.Me.MenusForm.BrightnessGradientMode.SelectedItem;
|
||||
if(General.Map.UDMF && (mode == MenusForm.BrightnessGradientModes.Ceilings || mode == MenusForm.BrightnessGradientModes.Floors))
|
||||
string mode = (string)BuilderPlug.Me.MenusForm.GradientModeMenu.SelectedItem;
|
||||
InterpolationTools.Mode interpolationmode = (InterpolationTools.Mode) BuilderPlug.Me.MenusForm.GradientInterpolationMenu.SelectedIndex;
|
||||
if(General.Map.UDMF)
|
||||
{
|
||||
string lightKey;
|
||||
string lightAbsKey;
|
||||
float startbrightness, endbrightness;
|
||||
|
||||
if(mode == MenusForm.BrightnessGradientModes.Ceilings)
|
||||
if(mode == MenusForm.BrightnessGradientModes.Ceilings || mode == MenusForm.BrightnessGradientModes.Floors)
|
||||
{
|
||||
lightKey = "lightceiling";
|
||||
lightAbsKey = "lightceilingabsolute";
|
||||
}
|
||||
else //should be floors...
|
||||
{
|
||||
lightKey = "lightfloor";
|
||||
lightAbsKey = "lightfloorabsolute";
|
||||
}
|
||||
string lightKey;
|
||||
string lightAbsKey;
|
||||
int startbrightness, endbrightness;
|
||||
|
||||
//get total brightness of start sector
|
||||
if(start.Fields.GetValue(lightAbsKey, false))
|
||||
startbrightness = start.Fields.GetValue(lightKey, 0);
|
||||
else
|
||||
startbrightness = Math.Min(255, Math.Max(0, (float)start.Brightness + start.Fields.GetValue(lightKey, 0)));
|
||||
|
||||
//get total brightness of end sector
|
||||
if(end.Fields.GetValue(lightAbsKey, false))
|
||||
endbrightness = end.Fields.GetValue(lightKey, 0);
|
||||
else
|
||||
endbrightness = Math.Min(255, Math.Max(0, (float)end.Brightness + end.Fields.GetValue(lightKey, 0)));
|
||||
|
||||
float delta = endbrightness - startbrightness;
|
||||
|
||||
// Go for all sectors in between first and last
|
||||
int index = 0;
|
||||
foreach(Sector s in orderedselection)
|
||||
{
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float u = index / (float)(orderedselection.Count - 1);
|
||||
float b = startbrightness + delta * u;
|
||||
|
||||
//absolute flag set?
|
||||
if(s.Fields.GetValue(lightAbsKey, false))
|
||||
if(mode == MenusForm.BrightnessGradientModes.Ceilings)
|
||||
{
|
||||
if(s.Fields.ContainsKey(lightKey))
|
||||
s.Fields[lightKey].Value = (int)b;
|
||||
else
|
||||
s.Fields.Add(lightKey, new UniValue(UniversalType.Integer, (int)b));
|
||||
}
|
||||
else
|
||||
lightKey = "lightceiling";
|
||||
lightAbsKey = "lightceilingabsolute";
|
||||
}
|
||||
else //should be floors...
|
||||
{
|
||||
UDMFTools.SetInteger(s.Fields, lightKey, (int)b - s.Brightness, 0);
|
||||
lightKey = "lightfloor";
|
||||
lightAbsKey = "lightfloorabsolute";
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
//mxd. Use UDMF light/fade color?
|
||||
else if(General.Map.UDMF && (mode == MenusForm.BrightnessGradientModes.Fade || mode == MenusForm.BrightnessGradientModes.Light))
|
||||
{
|
||||
string key;
|
||||
int defaultValue = 0;
|
||||
//get total brightness of start sector
|
||||
if(start.Fields.GetValue(lightAbsKey, false))
|
||||
startbrightness = start.Fields.GetValue(lightKey, 0);
|
||||
else
|
||||
startbrightness = Math.Min(255, Math.Max(0, start.Brightness + start.Fields.GetValue(lightKey, 0)));
|
||||
|
||||
if(mode == MenusForm.BrightnessGradientModes.Light)
|
||||
{
|
||||
key = "lightcolor";
|
||||
defaultValue = 0xFFFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = "fadecolor";
|
||||
}
|
||||
|
||||
if(!start.Fields.ContainsKey(key) && !end.Fields.ContainsKey(key))
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "First or last sector must have " + key + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Color startColor = PixelColor.FromInt(start.Fields.GetValue(key, defaultValue)).ToColor();
|
||||
Color endColor = PixelColor.FromInt(end.Fields.GetValue(key, defaultValue)).ToColor();
|
||||
int dr = endColor.R - startColor.R;
|
||||
int dg = endColor.G - startColor.G;
|
||||
int db = endColor.B - startColor.B;
|
||||
//get total brightness of end sector
|
||||
if(end.Fields.GetValue(lightAbsKey, false))
|
||||
endbrightness = end.Fields.GetValue(lightKey, 0);
|
||||
else
|
||||
endbrightness = Math.Min(255, Math.Max(0, end.Brightness + end.Fields.GetValue(lightKey, 0)));
|
||||
|
||||
// Go for all sectors in between first and last
|
||||
int index = 0;
|
||||
foreach(Sector s in orderedselection)
|
||||
{
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float u = index / (float)(orderedselection.Count - 1);
|
||||
Color c = Color.FromArgb(0, General.Clamp((int)(startColor.R + dr * u), 0, 255), General.Clamp((int)(startColor.G + dg * u), 0, 255), General.Clamp((int)(startColor.B + db * u), 0, 255));
|
||||
|
||||
UDMFTools.SetInteger(s.Fields, key, c.ToArgb(), defaultValue);
|
||||
s.UpdateNeeded = true;
|
||||
float u = index / (float) (orderedselection.Count - 1);
|
||||
float b = InterpolationTools.Interpolate(startbrightness, endbrightness, u, interpolationmode);
|
||||
|
||||
//absolute flag set?
|
||||
if(s.Fields.GetValue(lightAbsKey, false))
|
||||
{
|
||||
if(s.Fields.ContainsKey(lightKey))
|
||||
s.Fields[lightKey].Value = (int) b;
|
||||
else
|
||||
s.Fields.Add(lightKey, new UniValue(UniversalType.Integer, (int) b));
|
||||
}
|
||||
else
|
||||
{
|
||||
UDMFTools.SetInteger(s.Fields, lightKey, (int) b - s.Brightness, 0);
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
else if(mode == MenusForm.BrightnessGradientModes.Fade)
|
||||
{
|
||||
ApplyColorGradient(orderedselection, start, end, interpolationmode, "fadecolor", 0);
|
||||
}
|
||||
else if(mode == MenusForm.BrightnessGradientModes.Light)
|
||||
{
|
||||
ApplyColorGradient(orderedselection, start, end, interpolationmode, "lightcolor", 0xFFFFFF);
|
||||
}
|
||||
else if(mode == MenusForm.BrightnessGradientModes.LightAndFade)
|
||||
{
|
||||
ApplyColorGradient(orderedselection, start, end, interpolationmode, "fadecolor", 0);
|
||||
ApplyColorGradient(orderedselection, start, end, interpolationmode, "lightcolor", 0xFFFFFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float startbrightness = start.Brightness;
|
||||
float endbrightness = end.Brightness;
|
||||
float delta = endbrightness - startbrightness;
|
||||
|
||||
// Go for all sectors in between first and last
|
||||
int index = 0;
|
||||
foreach(Sector s in orderedselection)
|
||||
{
|
||||
float u = index / (float)(orderedselection.Count - 1);
|
||||
float b = startbrightness + delta * u;
|
||||
s.Brightness = (int)b;
|
||||
s.Brightness = InterpolationTools.Interpolate(start.Brightness, end.Brightness, u, interpolationmode); //mxd
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
@ -1821,6 +1794,35 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
private void ApplyColorGradient(ICollection<Sector> orderedselection, Sector start, Sector end, InterpolationTools.Mode interpolationmode, string key, int defaultvalue)
|
||||
{
|
||||
if(!start.Fields.ContainsKey(key) && !end.Fields.ContainsKey(key))
|
||||
{
|
||||
General.Interface.DisplayStatus(StatusType.Warning, "First or last selected sector must have the '" + key + "' property!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Color startColor = PixelColor.FromInt(start.Fields.GetValue(key, defaultvalue)).ToColor();
|
||||
Color endColor = PixelColor.FromInt(end.Fields.GetValue(key, defaultvalue)).ToColor();
|
||||
|
||||
// Go for all sectors in between first and last
|
||||
int index = 0;
|
||||
foreach(Sector s in orderedselection)
|
||||
{
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float u = index / (float)(orderedselection.Count - 1);
|
||||
Color c = Color.FromArgb(0, General.Clamp(InterpolationTools.Interpolate(startColor.R, endColor.R, u, interpolationmode), 0, 255),
|
||||
General.Clamp(InterpolationTools.Interpolate(startColor.G, endColor.G, u, interpolationmode), 0, 255),
|
||||
General.Clamp(InterpolationTools.Interpolate(startColor.B, endColor.B, u, interpolationmode), 0, 255));
|
||||
|
||||
UDMFTools.SetInteger(s.Fields, key, c.ToArgb(), defaultvalue);
|
||||
s.UpdateNeeded = true;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make gradient floors
|
||||
[BeginAction("gradientfloors")]
|
||||
public void MakeGradientFloors()
|
||||
|
@ -1833,17 +1835,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.DisplayStatus(StatusType.Action, "Created gradient floor heights over selected sectors.");
|
||||
General.Map.UndoRedo.CreateUndo("Gradient floor heights");
|
||||
|
||||
float startlevel = General.GetByIndex(orderedselection, 0).FloorHeight;
|
||||
float endlevel = General.GetByIndex(orderedselection, orderedselection.Count - 1).FloorHeight;
|
||||
float delta = endlevel - startlevel;
|
||||
int startlevel = General.GetByIndex(orderedselection, 0).FloorHeight;
|
||||
int endlevel = General.GetByIndex(orderedselection, orderedselection.Count - 1).FloorHeight;
|
||||
InterpolationTools.Mode interpolationmode = (InterpolationTools.Mode)BuilderPlug.Me.MenusForm.GradientInterpolationMenu.SelectedIndex; //mxd
|
||||
|
||||
// Go for all sectors in between first and last
|
||||
int index = 0;
|
||||
foreach(Sector s in orderedselection)
|
||||
{
|
||||
float u = index / (float)(orderedselection.Count - 1);
|
||||
float b = startlevel + delta * u;
|
||||
s.FloorHeight = (int)b;
|
||||
s.FloorHeight = InterpolationTools.Interpolate(startlevel, endlevel, u, interpolationmode); //mxd
|
||||
index++;
|
||||
}
|
||||
|
||||
|
@ -1869,17 +1870,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.DisplayStatus(StatusType.Action, "Created gradient ceiling heights over selected sectors.");
|
||||
General.Map.UndoRedo.CreateUndo("Gradient ceiling heights");
|
||||
|
||||
float startlevel = General.GetByIndex(orderedselection, 0).CeilHeight;
|
||||
float endlevel = General.GetByIndex(orderedselection, orderedselection.Count - 1).CeilHeight;
|
||||
float delta = endlevel - startlevel;
|
||||
int startlevel = General.GetByIndex(orderedselection, 0).CeilHeight;
|
||||
int endlevel = General.GetByIndex(orderedselection, orderedselection.Count - 1).CeilHeight;
|
||||
InterpolationTools.Mode interpolationmode = (InterpolationTools.Mode)BuilderPlug.Me.MenusForm.GradientInterpolationMenu.SelectedIndex; //mxd
|
||||
|
||||
// Go for all sectors in between first and last
|
||||
int index = 0;
|
||||
foreach(Sector s in orderedselection)
|
||||
{
|
||||
float u = (float)index / (orderedselection.Count - 1);
|
||||
float b = startlevel + delta * u;
|
||||
s.CeilHeight = (int)b;
|
||||
s.CeilHeight = InterpolationTools.Interpolate(startlevel, endlevel, u, interpolationmode);
|
||||
index++;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.buttonflipselectionh = new System.Windows.Forms.ToolStripButton();
|
||||
this.buttonflipselectionv = new System.Windows.Forms.ToolStripButton();
|
||||
this.buttoncurvelinedefs = new System.Windows.Forms.ToolStripButton();
|
||||
this.brightnessGradientMode = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.gradientModeMenu = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.gradientInterpolationMenu = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.buttonMarqueSelectTouching = new System.Windows.Forms.ToolStripButton();
|
||||
this.buttonDragThingsInSelectedSectors = new System.Windows.Forms.ToolStripButton();
|
||||
this.buttonAlignThingsToWall = new System.Windows.Forms.ToolStripButton();
|
||||
|
@ -97,6 +98,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.fileMenuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.exportStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.separatorsectors2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.separatorsectors3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.menustrip.SuspendLayout();
|
||||
this.manualstrip.SuspendLayout();
|
||||
this.fileMenuStrip.SuspendLayout();
|
||||
|
@ -111,7 +114,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.vertsmenu});
|
||||
this.menustrip.Location = new System.Drawing.Point(0, 24);
|
||||
this.menustrip.Name = "menustrip";
|
||||
this.menustrip.Size = new System.Drawing.Size(588, 24);
|
||||
this.menustrip.Size = new System.Drawing.Size(694, 24);
|
||||
this.menustrip.TabIndex = 0;
|
||||
this.menustrip.Text = "menustrip";
|
||||
//
|
||||
|
@ -482,7 +485,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//
|
||||
this.globalstrip.Location = new System.Drawing.Point(0, 48);
|
||||
this.globalstrip.Name = "globalstrip";
|
||||
this.globalstrip.Size = new System.Drawing.Size(588, 25);
|
||||
this.globalstrip.Size = new System.Drawing.Size(694, 25);
|
||||
this.globalstrip.TabIndex = 1;
|
||||
this.globalstrip.Text = "toolstrip";
|
||||
//
|
||||
|
@ -496,21 +499,24 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.buttonselectionnumbers,
|
||||
this.buttonselectioneffects,
|
||||
this.separatorsectors1,
|
||||
this.buttonMakeDoor,
|
||||
this.separatorsectors2,
|
||||
this.buttonbrightnessgradient,
|
||||
this.buttonfloorgradient,
|
||||
this.buttonceilinggradient,
|
||||
this.buttonflipselectionh,
|
||||
this.buttonflipselectionv,
|
||||
this.buttoncurvelinedefs,
|
||||
this.brightnessGradientMode,
|
||||
this.gradientModeMenu,
|
||||
this.gradientInterpolationMenu,
|
||||
this.separatorsectors3,
|
||||
this.buttonMarqueSelectTouching,
|
||||
this.buttonDragThingsInSelectedSectors,
|
||||
this.buttonAlignThingsToWall,
|
||||
this.buttonTextureOffsetLock,
|
||||
this.buttonMakeDoor});
|
||||
this.buttonTextureOffsetLock});
|
||||
this.manualstrip.Location = new System.Drawing.Point(0, 73);
|
||||
this.manualstrip.Name = "manualstrip";
|
||||
this.manualstrip.Size = new System.Drawing.Size(588, 25);
|
||||
this.manualstrip.Size = new System.Drawing.Size(694, 25);
|
||||
this.manualstrip.TabIndex = 2;
|
||||
this.manualstrip.Text = "toolStrip1";
|
||||
//
|
||||
|
@ -648,13 +654,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.buttoncurvelinedefs.Text = "Curve Linedefs";
|
||||
this.buttoncurvelinedefs.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// brightnessGradientMode
|
||||
// gradientModeMenu
|
||||
//
|
||||
this.brightnessGradientMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.brightnessGradientMode.Name = "brightnessGradientMode";
|
||||
this.brightnessGradientMode.Size = new System.Drawing.Size(75, 25);
|
||||
this.brightnessGradientMode.ToolTipText = "Brightness Gradient affects:";
|
||||
this.brightnessGradientMode.DropDownClosed += new System.EventHandler(this.brightnessGradientMode_DropDownClosed);
|
||||
this.gradientModeMenu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.gradientModeMenu.Name = "gradientModeMenu";
|
||||
this.gradientModeMenu.Size = new System.Drawing.Size(108, 25);
|
||||
this.gradientModeMenu.ToolTipText = "Brightness Gradient Target";
|
||||
this.gradientModeMenu.DropDownClosed += new System.EventHandler(this.brightnessGradientMode_DropDownClosed);
|
||||
//
|
||||
// gradientInterpolationMenu
|
||||
//
|
||||
this.gradientInterpolationMenu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.gradientInterpolationMenu.Name = "gradientInterpolationMenu";
|
||||
this.gradientInterpolationMenu.Size = new System.Drawing.Size(108, 25);
|
||||
this.gradientInterpolationMenu.ToolTipText = "Brightness and Height Gradient Interpolation Mode";
|
||||
//
|
||||
// buttonMarqueSelectTouching
|
||||
//
|
||||
|
@ -722,7 +735,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.exportStripMenuItem});
|
||||
this.fileMenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.fileMenuStrip.Name = "fileMenuStrip";
|
||||
this.fileMenuStrip.Size = new System.Drawing.Size(588, 24);
|
||||
this.fileMenuStrip.Size = new System.Drawing.Size(694, 24);
|
||||
this.fileMenuStrip.TabIndex = 3;
|
||||
this.fileMenuStrip.Text = "menuStrip1";
|
||||
//
|
||||
|
@ -742,11 +755,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.toolStripMenuItem5.Text = "Selection to Wavefront .obj...";
|
||||
this.toolStripMenuItem5.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// separatorsectors2
|
||||
//
|
||||
this.separatorsectors2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.separatorsectors2.Name = "separatorsectors2";
|
||||
this.separatorsectors2.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// separatorsectors3
|
||||
//
|
||||
this.separatorsectors3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.separatorsectors3.Name = "separatorsectors3";
|
||||
this.separatorsectors3.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// MenusForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(588, 100);
|
||||
this.ClientSize = new System.Drawing.Size(694, 100);
|
||||
this.Controls.Add(this.manualstrip);
|
||||
this.Controls.Add(this.globalstrip);
|
||||
this.Controls.Add(this.menustrip);
|
||||
|
@ -800,7 +825,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private System.Windows.Forms.ToolStripButton buttoncopyproperties;
|
||||
private System.Windows.Forms.ToolStripButton buttonpasteproperties;
|
||||
private System.Windows.Forms.ToolStripSeparator seperatorcopypaste;
|
||||
private System.Windows.Forms.ToolStripComboBox brightnessGradientMode;
|
||||
private System.Windows.Forms.ToolStripComboBox gradientModeMenu;
|
||||
private System.Windows.Forms.ToolStripButton buttonMarqueSelectTouching;
|
||||
private System.Windows.Forms.ToolStripMenuItem thingsmenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem alignToWallItem;
|
||||
|
@ -841,5 +866,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private System.Windows.Forms.ToolStripMenuItem flipsectorlinedefsitem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
|
||||
private System.Windows.Forms.ToolStripButton buttonDragThingsInSelectedSectors;
|
||||
private System.Windows.Forms.ToolStripComboBox gradientInterpolationMenu;
|
||||
private System.Windows.Forms.ToolStripSeparator separatorsectors2;
|
||||
private System.Windows.Forms.ToolStripSeparator separatorsectors3;
|
||||
}
|
||||
}
|
|
@ -41,11 +41,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//mxd
|
||||
public struct BrightnessGradientModes
|
||||
{
|
||||
public static string Sectors = "Sectors";
|
||||
public static string Light = "Light";
|
||||
public static string Fade = "Fade";
|
||||
public static string Floors = "Floors";
|
||||
public static string Ceilings = "Ceilings";
|
||||
public const string Sectors = "Sectors";
|
||||
public const string Light = "Light";
|
||||
public const string Fade = "Fade";
|
||||
public const string LightAndFade = "Light and Fade";
|
||||
public const string Floors = "Floors";
|
||||
public const string Ceilings = "Ceilings";
|
||||
}
|
||||
|
||||
//mxd
|
||||
private struct GradientInterpolationModes
|
||||
{
|
||||
public const string Linear = "Linear";
|
||||
public const string EaseInOutSine = "EaseInOutSine";
|
||||
public const string EaseInSine = "EaseInSine";
|
||||
public const string EaseOutSine = "EaseOutSine";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -57,6 +67,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public ToolStripButton ViewSelectionNumbers { get { return buttonselectionnumbers; } }
|
||||
public ToolStripButton ViewSelectionEffects { get { return buttonselectioneffects; } }
|
||||
public ToolStripSeparator SeparatorSectors1 { get { return separatorsectors1; } }
|
||||
public ToolStripSeparator SeparatorSectors2 { get { return separatorsectors2; } } //mxd
|
||||
public ToolStripSeparator SeparatorSectors3 { get { return separatorsectors3; } } //mxd
|
||||
public ToolStripButton MakeGradientBrightness { get { return buttonbrightnessgradient; } }
|
||||
public ToolStripButton MakeGradientFloors { get { return buttonfloorgradient; } }
|
||||
public ToolStripButton MakeGradientCeilings { get { return buttonceilinggradient; } }
|
||||
|
@ -67,7 +79,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public ToolStripButton PasteProperties { get { return buttonpasteproperties; } }
|
||||
public ToolStripButton PastePropertiesOptions { get { return buttonpastepropertiesoptions; } } //mxd
|
||||
public ToolStripSeparator SeparatorCopyPaste { get { return seperatorcopypaste; } }
|
||||
public ToolStripComboBox BrightnessGradientMode { get { return brightnessGradientMode; } } //mxd
|
||||
public ToolStripComboBox GradientModeMenu { get { return gradientModeMenu; } } //mxd
|
||||
public ToolStripComboBox GradientInterpolationMenu { get { return gradientInterpolationMenu; } } //mxd
|
||||
public ToolStripButton MarqueSelectTouching { get { return buttonMarqueSelectTouching; } } //mxd
|
||||
public ToolStripButton AlignThingsToWall { get { return buttonAlignThingsToWall; } } //mxd
|
||||
public ToolStripButton TextureOffsetLock { get { return buttonTextureOffsetLock; } } //mxd
|
||||
|
@ -89,8 +102,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
buttonselectioneffects.Checked = BuilderPlug.Me.ViewSelectionEffects; //mxd
|
||||
|
||||
//mxd
|
||||
brightnessGradientMode.Items.AddRange(new[] { BrightnessGradientModes.Sectors, BrightnessGradientModes.Light, BrightnessGradientModes.Fade, BrightnessGradientModes.Ceilings, BrightnessGradientModes.Floors });
|
||||
brightnessGradientMode.SelectedIndex = 0;
|
||||
gradientModeMenu.Items.AddRange(new[] { BrightnessGradientModes.Sectors, BrightnessGradientModes.Light, BrightnessGradientModes.Fade, BrightnessGradientModes.LightAndFade, BrightnessGradientModes.Ceilings, BrightnessGradientModes.Floors });
|
||||
gradientModeMenu.SelectedIndex = 0;
|
||||
gradientInterpolationMenu.Items.AddRange(new[] { GradientInterpolationModes.Linear, GradientInterpolationModes.EaseInOutSine, GradientInterpolationModes.EaseInSine, GradientInterpolationModes.EaseOutSine });
|
||||
gradientInterpolationMenu.SelectedIndex = 0;
|
||||
|
||||
// List all menus
|
||||
menus = new ToolStripItem[menustrip.Items.Count];
|
||||
|
|
4
Source/Plugins/TagRange/ToolsForm.Designer.cs
generated
4
Source/Plugins/TagRange/ToolsForm.Designer.cs
generated
|
@ -49,7 +49,7 @@ namespace CodeImp.DoomBuilder.TagRange
|
|||
//
|
||||
// seperator1
|
||||
//
|
||||
this.seperator1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.seperator1.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.seperator1.Name = "seperator1";
|
||||
this.seperator1.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
|
@ -66,7 +66,7 @@ namespace CodeImp.DoomBuilder.TagRange
|
|||
//
|
||||
// seperator2
|
||||
//
|
||||
this.seperator2.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.seperator2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
|
||||
this.seperator2.Name = "seperator2";
|
||||
this.seperator2.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue