Added Import Terrain mode (Create -> Terrain from Wavefront .obj)

Draw Settings panel: added "All" buttons to "Fill Selection with Textures" and "Remove Textures form Selection" groups
Export to .obj: fixed a crash when trying to export an unsaved map.
Texture preview are now created ~25% faster.
This commit is contained in:
MaxED 2014-01-30 14:52:08 +00:00
parent cd75b4e30e
commit 79dcaca457
22 changed files with 1383 additions and 434 deletions

View file

@ -512,7 +512,7 @@ namespace CodeImp.DoomBuilder.Data
// Start a low priority thread to load images in background
General.WriteLogLine("Starting background resource loading...");
backgroundloader = new Thread(new ThreadStart(BackgroundLoad));
backgroundloader = new Thread(BackgroundLoad);
backgroundloader.Name = "Background Loader";
backgroundloader.Priority = ThreadPriority.Lowest;
backgroundloader.IsBackground = true;

View file

@ -35,7 +35,7 @@ namespace CodeImp.DoomBuilder.Data
private const PixelFormat IMAGE_FORMAT = PixelFormat.Format32bppArgb;
// Dimensions of a single preview image
public static readonly int[] PREVIEW_SIZES = new int[] { 48, 64, 80, 96, 112, 128 };
public static readonly int[] PREVIEW_SIZES = new[] { 48, 64, 80, 96, 112, 128 };
#endregion
@ -113,11 +113,8 @@ namespace CodeImp.DoomBuilder.Data
// This makes a preview for the given image and updates the image settings
private void MakeImagePreview(ImageData img)
{
int previewwidth, previewheight;
int imagewidth, imageheight;
Bitmap preview;
Graphics g;
lock(img)
{
// Load image if needed
@ -129,28 +126,29 @@ namespace CodeImp.DoomBuilder.Data
}
else
{
imagewidth = img.GetBitmap().Size.Width;
imageheight = img.GetBitmap().Size.Height;
Size size = img.GetBitmap().Size; //mxd
imagewidth = size.Width;
imageheight = size.Height;
}
// Determine preview size
float scalex = (img.Width > maxpreviewwidth) ? (maxpreviewwidth / (float)imagewidth) : 1.0f;
float scaley = (img.Height > maxpreviewheight) ? (maxpreviewheight / (float)imageheight) : 1.0f;
float scale = Math.Min(scalex, scaley);
previewwidth = (int)(imagewidth * scale);
previewheight = (int)(imageheight * scale);
int previewwidth = (int)(imagewidth * scale);
int previewheight = (int)(imageheight * scale);
if(previewwidth < 1) previewwidth = 1;
if(previewheight < 1) previewheight = 1;
// Make new image
preview = new Bitmap(previewwidth, previewheight, IMAGE_FORMAT);
g = Graphics.FromImage(preview);
Bitmap preview = new Bitmap(previewwidth, previewheight, IMAGE_FORMAT);
Graphics g = Graphics.FromImage(preview);
g.PageUnit = GraphicsUnit.Pixel;
g.CompositingQuality = CompositingQuality.HighQuality;
//g.CompositingQuality = CompositingQuality.HighQuality; //mxd
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = SmoothingMode.HighQuality;
//g.SmoothingMode = SmoothingMode.HighQuality; //mxd
g.PixelOffsetMode = PixelOffsetMode.None;
g.Clear(Color.Transparent);
//g.Clear(Color.Transparent); //mxd
// Draw image onto atlas
Rectangle atlasrect = new Rectangle(0, 0, previewwidth, previewheight);

View file

@ -1848,14 +1848,14 @@ namespace CodeImp.DoomBuilder
// This calculates the new rectangle when one is scaled into another keeping aspect ratio
public static RectangleF MakeZoomedRect(Size source, RectangleF target)
{
return MakeZoomedRect(new SizeF((int)source.Width, (int)source.Height), target);
return MakeZoomedRect(new SizeF(source.Width, source.Height), target);
}
// This calculates the new rectangle when one is scaled into another keeping aspect ratio
public static RectangleF MakeZoomedRect(Size source, Rectangle target)
{
return MakeZoomedRect(new SizeF((int)source.Width, (int)source.Height),
new RectangleF((int)target.Left, (int)target.Top, (int)target.Width, (int)target.Height));
return MakeZoomedRect(new SizeF(source.Width, source.Height),
new RectangleF(target.Left, target.Top, target.Width, target.Height));
}
// This calculates the new rectangle when one is scaled into another keeping aspect ratio

View file

@ -88,6 +88,13 @@
<Compile Include="Interface\MenusForm.Designer.cs">
<DependentUpon>MenusForm.cs</DependentUpon>
</Compile>
<Compile Include="Interface\ObjImportSettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Interface\ObjImportSettingsForm.Designer.cs">
<DependentUpon>ObjImportSettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="Modes\ImportObjAsTerrainMode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
@ -113,6 +120,9 @@
<EmbeddedResource Include="Interface\JitterVerticesForm.resx">
<DependentUpon>JitterVerticesForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Interface\ObjImportSettingsForm.resx">
<DependentUpon>ObjImportSettingsForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -125,6 +135,9 @@
<ItemGroup>
<None Include="Resources\Jitter.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Terrain.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -28,13 +28,16 @@
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.transformToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.jitterItem = new System.Windows.Forms.ToolStripMenuItem();
this.createStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
//
// menuStrip
//
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.transformToolStripMenuItem});
this.transformToolStripMenuItem,
this.createStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(452, 24);
@ -44,7 +47,7 @@
// transformToolStripMenuItem
//
this.transformToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.jitterItem});
this.jitterItem});
this.transformToolStripMenuItem.Name = "transformToolStripMenuItem";
this.transformToolStripMenuItem.Size = new System.Drawing.Size(74, 20);
this.transformToolStripMenuItem.Text = "Transform";
@ -53,11 +56,28 @@
//
this.jitterItem.Image = global::CodeImp.DoomBuilder.BuilderEffects.Properties.Resources.Jitter;
this.jitterItem.Name = "jitterItem";
this.jitterItem.Size = new System.Drawing.Size(152, 22);
this.jitterItem.Size = new System.Drawing.Size(108, 22);
this.jitterItem.Tag = "applyjitter";
this.jitterItem.Text = "&Jitter...";
this.jitterItem.Click += new System.EventHandler(this.InvokeTaggedAction);
//
// createStripMenuItem
//
this.createStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.createStripMenuItem.Name = "createStripMenuItem";
this.createStripMenuItem.Size = new System.Drawing.Size(53, 20);
this.createStripMenuItem.Text = "Create";
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Image = global::CodeImp.DoomBuilder.BuilderEffects.Properties.Resources.Terrain;
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(230, 22);
this.toolStripMenuItem1.Tag = "importobjasterrain";
this.toolStripMenuItem1.Text = "Terrain from Wavefront .obj...";
this.toolStripMenuItem1.Click += new System.EventHandler(this.InvokeTaggedAction);
//
// MenusForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -79,5 +99,7 @@
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.ToolStripMenuItem transformToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem jitterItem;
private System.Windows.Forms.ToolStripMenuItem createStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
}
}

View file

@ -1,123 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
<value>17, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,230 @@
namespace CodeImp.DoomBuilder.BuilderEffects
{
partial class ObjImportSettingsForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if(disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.label2 = new System.Windows.Forms.Label();
this.nudScale = new System.Windows.Forms.NumericUpDown();
this.cancel = new System.Windows.Forms.Button();
this.import = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.browse = new System.Windows.Forms.Button();
this.tbImportPath = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.axisx = new System.Windows.Forms.RadioButton();
this.axisy = new System.Windows.Forms.RadioButton();
this.axisz = new System.Windows.Forms.RadioButton();
this.panel1 = new System.Windows.Forms.Panel();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
((System.ComponentModel.ISupportInitialize)(this.nudScale)).BeginInit();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(37, 13);
this.label2.TabIndex = 16;
this.label2.Text = "Scale:";
//
// nudScale
//
this.nudScale.DecimalPlaces = 4;
this.nudScale.Location = new System.Drawing.Point(55, 38);
this.nudScale.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
this.nudScale.Minimum = new decimal(new int[] {
2048,
0,
0,
-2147483648});
this.nudScale.Name = "nudScale";
this.nudScale.Size = new System.Drawing.Size(94, 20);
this.nudScale.TabIndex = 15;
this.nudScale.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// cancel
//
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancel.Location = new System.Drawing.Point(279, 82);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(75, 23);
this.cancel.TabIndex = 14;
this.cancel.Text = "Cancel";
this.cancel.UseVisualStyleBackColor = true;
this.cancel.Click += new System.EventHandler(this.cancel_Click);
//
// import
//
this.import.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.import.Location = new System.Drawing.Point(360, 82);
this.import.Name = "import";
this.import.Size = new System.Drawing.Size(75, 23);
this.import.TabIndex = 13;
this.import.Text = "Import";
this.import.UseVisualStyleBackColor = true;
this.import.Click += new System.EventHandler(this.import_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(18, 14);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 13);
this.label1.TabIndex = 12;
this.label1.Text = "Path:";
//
// browse
//
this.browse.Location = new System.Drawing.Point(360, 10);
this.browse.Name = "browse";
this.browse.Size = new System.Drawing.Size(75, 23);
this.browse.TabIndex = 11;
this.browse.Text = "Browse...";
this.browse.UseVisualStyleBackColor = true;
this.browse.Click += new System.EventHandler(this.browse_Click);
//
// tbImportPath
//
this.tbImportPath.Location = new System.Drawing.Point(55, 12);
this.tbImportPath.Name = "tbImportPath";
this.tbImportPath.Size = new System.Drawing.Size(299, 20);
this.tbImportPath.TabIndex = 10;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(183, 40);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(45, 13);
this.label3.TabIndex = 17;
this.label3.Text = "Up axis:";
//
// axisx
//
this.axisx.AutoSize = true;
this.axisx.Location = new System.Drawing.Point(3, 3);
this.axisx.Name = "axisx";
this.axisx.Size = new System.Drawing.Size(32, 17);
this.axisx.TabIndex = 18;
this.axisx.TabStop = true;
this.axisx.Text = "X";
this.axisx.UseVisualStyleBackColor = true;
//
// axisy
//
this.axisy.AutoSize = true;
this.axisy.Location = new System.Drawing.Point(41, 3);
this.axisy.Name = "axisy";
this.axisy.Size = new System.Drawing.Size(32, 17);
this.axisy.TabIndex = 19;
this.axisy.TabStop = true;
this.axisy.Text = "Y";
this.axisy.UseVisualStyleBackColor = true;
//
// axisz
//
this.axisz.AutoSize = true;
this.axisz.Location = new System.Drawing.Point(79, 3);
this.axisz.Name = "axisz";
this.axisz.Size = new System.Drawing.Size(32, 17);
this.axisz.TabIndex = 20;
this.axisz.TabStop = true;
this.axisz.Text = "Z";
this.axisz.UseVisualStyleBackColor = true;
//
// panel1
//
this.panel1.Controls.Add(this.axisx);
this.panel1.Controls.Add(this.axisz);
this.panel1.Controls.Add(this.axisy);
this.panel1.Location = new System.Drawing.Point(234, 36);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(133, 24);
this.panel1.TabIndex = 21;
//
// openFileDialog
//
this.openFileDialog.DefaultExt = "obj";
this.openFileDialog.FileName = "openFileDialog1";
this.openFileDialog.Filter = "Wavefront obj files|*.obj";
this.openFileDialog.Title = "Choose .obj file to import:";
//
// ObjImportSettingsForm
//
this.AcceptButton = this.import;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(447, 109);
this.Controls.Add(this.panel1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.nudScale);
this.Controls.Add(this.cancel);
this.Controls.Add(this.import);
this.Controls.Add(this.label1);
this.Controls.Add(this.browse);
this.Controls.Add(this.tbImportPath);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "ObjImportSettingsForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "Import Wavefront .obj";
((System.ComponentModel.ISupportInitialize)(this.nudScale)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown nudScale;
private System.Windows.Forms.Button cancel;
private System.Windows.Forms.Button import;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button browse;
private System.Windows.Forms.TextBox tbImportPath;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RadioButton axisx;
private System.Windows.Forms.RadioButton axisy;
private System.Windows.Forms.RadioButton axisz;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.OpenFileDialog openFileDialog;
}
}

View file

@ -0,0 +1,78 @@
#region ================== Namespaces
using System;
using System.IO;
using System.Windows.Forms;
#endregion
namespace CodeImp.DoomBuilder.BuilderEffects
{
public partial class ObjImportSettingsForm : Form
{
#region ================== Variables
private ImportObjAsTerrainMode.UpAxis axis;
#endregion
#region ================== Properties
internal string FilePath { get { return tbImportPath.Text.Trim(); } }
internal ImportObjAsTerrainMode.UpAxis UpAxis { get { return axis; } }
internal float ObjScale { get { return (float)nudScale.Value; } }
//todo: floor/ceiling textures? height offsets? ceiling extra height?
#endregion
public ObjImportSettingsForm() {
InitializeComponent();
//restore settings
axis = (ImportObjAsTerrainMode.UpAxis)General.Settings.ReadPluginSetting("objexportupaxis", 0);
nudScale.Value = (decimal)General.Settings.ReadPluginSetting("objexportscale", 1.0f);
switch(axis) {
case ImportObjAsTerrainMode.UpAxis.X: axisx.Checked = true; break;
case ImportObjAsTerrainMode.UpAxis.Y: axisy.Checked = true; break;
case ImportObjAsTerrainMode.UpAxis.Z: axisz.Checked = true; break;
default: axisy.Checked = true; break;
}
}
#region ================== Events
private void browse_Click(object sender, EventArgs e) {
if(openFileDialog.ShowDialog() == DialogResult.OK) {
tbImportPath.Text = openFileDialog.FileName;
}
}
private void import_Click(object sender, EventArgs e) {
if(nudScale.Value == 0) {
MessageBox.Show("Scale should not be zero!");
return;
}
if(!File.Exists(tbImportPath.Text)) {
MessageBox.Show("Selected path does not exist!");
return;
}
axis = (axisy.Checked ? ImportObjAsTerrainMode.UpAxis.Y : (axisz.Checked ? ImportObjAsTerrainMode.UpAxis.Z : ImportObjAsTerrainMode.UpAxis.X));
//save settings
General.Settings.WritePluginSetting("objexportupaxis", (int)axis);
General.Settings.WritePluginSetting("objexportscale", (float)nudScale.Value);
this.DialogResult = DialogResult.OK;
this.Close();
}
private void cancel_Click(object sender, EventArgs e) {
this.Close();
}
#endregion
}
}

View file

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,304 @@
#region ================== Namespaces
using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Editing;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Geometry;
using System.IO;
using System.Globalization;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderEffects
{
[EditMode(DisplayName = "Terrain Importer",
SwitchAction = "importobjasterrain",
Volatile = true,
UseByDefault = true,
AllowCopyPaste = false)]
public class ImportObjAsTerrainMode : ClassicMode
{
#region ================== Constants
private readonly static char[] space = { ' ' };
private const string slash = "/";
#endregion
#region ================== Variables
private struct Face
{
public readonly Vector3D V1;
public readonly Vector3D V2;
public readonly Vector3D V3;
public Face(Vector3D v1, Vector3D v2, Vector3D v3) {
V1 = v1;
V2 = v2;
V3 = v3;
}
}
private readonly ObjImportSettingsForm form;
#endregion
#region ================== Properties
internal enum UpAxis
{
Y,
Z,
X
}
#endregion
#region ================== Constructor
public ImportObjAsTerrainMode() {
form = new ObjImportSettingsForm();
}
#endregion
#region ================== Methods
public override void OnEngage() {
if(!General.Map.UDMF) {
General.Interface.DisplayStatus(StatusType.Warning, "Terrain importer works only in UDMF map format!");
OnCancel();
}
base.OnEngage();
General.Map.Map.ClearAllSelected();
//show interface
if(form.ShowDialog() == DialogResult.OK && File.Exists(form.FilePath)) {
OnAccept();
} else {
OnCancel();
}
}
public override void OnAccept() {
Cursor.Current = Cursors.AppStarting;
General.Interface.DisplayStatus(StatusType.Busy, "Creating geometry...");
// Collections! Everyone loves them!
List<Vector3D> verts = new List<Vector3D>(12);
List<Face> faces = new List<Face>(4);
int minZ = int.MaxValue;
int maxZ = int.MinValue;
// Read .obj, create and select sectors
if(!readGeometry(form.FilePath, form.ObjScale, form.UpAxis, verts, faces, ref minZ, ref maxZ) || !createGeometry(verts, faces, minZ, maxZ + (maxZ - minZ)/2)) {
// Fial!
Cursor.Current = Cursors.Default;
// Return to base mode
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
// Update caches
General.Map.Map.Update();
General.Map.IsChanged = true;
// Done
Cursor.Current = Cursors.Default;
// Switch to Edit Selection mode
General.Editing.ChangeMode("EditSelectionMode", true);
}
public override void OnCancel() {
// Cancel base class
base.OnCancel();
// Return to base mode
General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
}
#endregion
#region ================== Geometry creation
private bool createGeometry(List<Vector3D> verts, List<Face> faces, int minZ, int maxZ) {
//make undo
General.Map.UndoRedo.CreateUndo("Import Terrain");
//prepare mapset
List<Linedef> newlines = new List<Linedef>();
MapSet map = General.Map.Map;
map.BeginAddRemove();
map.SetCapacity(map.Vertices.Count + verts.Count, map.Linedefs.Count + faces.Count * 3, map.Sidedefs.Count + faces.Count * 3, map.Sectors.Count + faces.Count, 0);
//terrain has many faces... let's create them
Dictionary<Vector3D, Vertex> newverts = new Dictionary<Vector3D, Vertex>();
foreach(Face face in faces){
Sector s = map.CreateSector();
s.Selected = true;
s.FloorHeight = minZ;
s.CeilHeight = maxZ;
s.Brightness = General.Settings.DefaultBrightness; //todo: allow user to change this
s.SetCeilTexture(General.Map.Config.SkyFlatName);
s.SetFloorTexture(General.Map.Options.DefaultFloorTexture); //todo: allow user to change this
Linedef newline = getLine(newverts, s, face.V1, face.V2);
if(newline != null) newlines.Add(newline);
newline = getLine(newverts, s, face.V2, face.V3);
if(newline != null) newlines.Add(newline);
newline = getLine(newverts, s, face.V3, face.V1);
if(newline != null) newlines.Add(newline);
s.UpdateCache();
}
//update new lines
foreach(Linedef l in newlines){
l.ApplySidedFlags();
}
map.EndAddRemove();
return true;
}
private Linedef getLine(Dictionary<Vector3D, Vertex> verts, Sector sector, Vector3D v1, Vector3D v2) {
Linedef line = null;
//get start and end verts
Vertex start = getVertex(verts, v1);
Vertex end = getVertex(verts, v2);
//check if the line is already created
foreach(Linedef l in start.Linedefs){
if(l.End == end || l.Start == end) {
line = l;
break;
}
}
//create a new line?
if(line == null) {
line = General.Map.Map.CreateLinedef(start, end);
//create front sidedef and attach sector to it
General.Map.Map.CreateSidedef(line, true, sector);
} else {
//create back sidedef and attach sector to it
General.Map.Map.CreateSidedef(line, false, sector);
}
line.Selected = true;
return line;
}
private Vertex getVertex(Dictionary<Vector3D, Vertex> verts, Vector3D pos) {
//already there?
if(verts.ContainsKey(pos)) return verts[pos];
//make a new one
Vertex v = General.Map.Map.CreateVertex(pos);
v.ZFloor = pos.z;
verts.Add(pos, v);
return v;
}
#endregion
#region ================== .obj import
private static bool readGeometry(string path, float scale, UpAxis axis, List<Vector3D> verts, List<Face> faces, ref int minZ, ref int maxZ) {
using(StreamReader reader = File.OpenText(path)) {
string line;
float x, y, z;
int px, py, pz;
int counter = 0;
while((line = reader.ReadLine()) != null) {
counter++;
if(line.StartsWith("v ")) {
string[] parts = line.Split(space);
if(parts.Length != 4 || !float.TryParse(parts[1], NumberStyles.Float, CultureInfo.InvariantCulture, out x) ||
!float.TryParse(parts[2], NumberStyles.Float, CultureInfo.InvariantCulture, out y) ||
!float.TryParse(parts[3], NumberStyles.Float, CultureInfo.InvariantCulture, out z)) {
MessageBox.Show("Failed to parse vertex definition at line " + counter + "!", "Terrain Importer", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
//apply up axis
switch (axis) {
case UpAxis.Y:
px = (int)Math.Round(x * scale);
py = (int)Math.Round(-z * scale);
pz = (int)Math.Round(y * scale);
break;
case UpAxis.Z:
px = (int)Math.Round(x * scale);
py = (int)Math.Round(-y * scale);
pz = (int)Math.Round(z * scale);
break;
case UpAxis.X:
px = (int)Math.Round(y * scale);
py = (int)Math.Round(-z * scale);
pz = (int)Math.Round(x * scale);
break;
default: //same as UpAxis.Y
px = (int)Math.Round(x * scale);
py = (int)Math.Round(-z * scale);
pz = (int)Math.Round(y * scale);
break;
}
if(maxZ < pz) maxZ = pz;
if(minZ > pz) minZ = pz;
verts.Add(new Vector3D(px, py, pz));
} else if(line.StartsWith("f ")) {
string[] parts = line.Split(space);
if(parts.Length != 4) {
MessageBox.Show("Failed to parse face definition at line " + counter + ": only triangle faces are supported!", "Terrain Importer", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
//.obj vertex indices are 1-based
int v1 = readVertexIndex(parts[1]) - 1;
int v2 = readVertexIndex(parts[2]) - 1;
int v3 = readVertexIndex(parts[3]) - 1;
if(verts[v1] == verts[v2] || verts[v1] == verts[v3] || verts[v2] == verts[v3]) continue;
if (axis == UpAxis.X) {
faces.Add(new Face(verts[v1], verts[v2], verts[v3]));
} else {
faces.Add(new Face(verts[v3], verts[v2], verts[v1]));
}
}
}
}
return true;
}
private static int readVertexIndex(string def) {
int slashpos = def.IndexOf(slash);
if(slashpos != -1) def = def.Substring(0, slashpos);
return int.Parse(def);
}
#endregion
}
}

View file

@ -67,6 +67,13 @@ namespace CodeImp.DoomBuilder.BuilderEffects.Properties {
}
}
internal static System.Drawing.Bitmap Terrain {
get {
object obj = ResourceManager.GetObject("Terrain", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Update {
get {
object obj = ResourceManager.GetObject("Update", resourceCulture);

View file

@ -1,127 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Update.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Jitter" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Jitter.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<value>..\Resources\Jitter.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Update.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Terrain" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Terrain.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View file

@ -13,4 +13,14 @@ applyjitter
allowmouse = false;
allowscroll = false;
default = 131146; //Ctrl-J
}
importobjasterrain
{
title = "Import Wavefront .obj as terrain";
category = "transform";
description = "Creates sectors using given model (UDMF only)";
allowkeys = true;
allowmouse = false;
allowscroll = false;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

View file

@ -156,6 +156,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode = ModifyMode.None;
}
//mxd. Another constructor
public EditSelectionMode(bool pasting) {
// Initialize
this.pasting = pasting;
this.mode = ModifyMode.None;
}
// Disposer
public override void Dispose()
{

View file

@ -118,9 +118,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
private bool autoDrawOnEdit; //mxd
private bool marqueSelectTouching; //mxd. Select elements partially/fully inside of marque selection?
private bool syncSelection; //mxd. Sync selection between Visual and Classic modes.
private bool objExportTextures; //mxd
private bool objGZDoomScale; //mxd
private float objScale; //mxd
private bool lockSectorTextureOffsetsWhileDragging; //mxd
#endregion
@ -181,9 +178,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
public bool DontMoveGeometryOutsideMapBoundary { get { return dontMoveGeometryOutsideMapBoundary; } set { DontMoveGeometryOutsideMapBoundary = value; } } //mxd
public bool MarqueSelectTouching { get { return marqueSelectTouching; } set { marqueSelectTouching = value; } } //mxd
public bool SyncSelection { get { return syncSelection; } set { syncSelection = value; } } //mxd
public bool ObjExportTextures { get { return objExportTextures; } internal set { objExportTextures = value; } } //mxd
public bool ObjGZDoomScale { get { return objGZDoomScale; } internal set { objGZDoomScale = value; } } //mxd
public float ObjScale { get { return objScale; } internal set { objScale = value; } } //mxd
public bool LockSectorTextureOffsetsWhileDragging { get { return lockSectorTextureOffsetsWhileDragging; } internal set { lockSectorTextureOffsetsWhileDragging = value; } } //mxd
#endregion
@ -224,14 +218,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Export to .obj
exportToObjMenuItem = new ToolStripMenuItem("Export to .obj...");
exportToObjMenuItem.Tag = "exporttoobj";
exportToObjMenuItem.Click += new EventHandler(InvokeTaggedAction);
exportToObjMenuItem.Click += InvokeTaggedAction;
exportToObjMenuItem.Enabled = false;
General.Interface.AddMenu(exportToObjMenuItem, MenuSection.FileNewOpenClose);
//mxd. add "Snap Vertices" menu button
snapModeMenuItem = new ToolStripMenuItem("Snap selected map elements to grid");
snapModeMenuItem.Tag = "snapvertstogrid";
snapModeMenuItem.Click += new EventHandler(InvokeTaggedAction);
snapModeMenuItem.Click += InvokeTaggedAction;
snapModeMenuItem.Image = Properties.Resources.SnapVerts;
snapModeMenuItem.Enabled = false;
General.Interface.AddMenu(snapModeMenuItem, MenuSection.EditGeometry);
@ -240,7 +234,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//draw ellipse
drawEllipseModeMenuItem = new ToolStripMenuItem("Draw Ellipse");
drawEllipseModeMenuItem.Tag = "drawellipsemode";
drawEllipseModeMenuItem.Click += new EventHandler(InvokeTaggedAction);
drawEllipseModeMenuItem.Click += InvokeTaggedAction;
drawEllipseModeMenuItem.Image = Properties.Resources.DrawEllipseMode;
drawEllipseModeMenuItem.Enabled = false;
General.Interface.AddMenu(drawEllipseModeMenuItem, MenuSection.ModeDrawModes);
@ -248,7 +242,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//draw grid
drawGridModeMenuItem = new ToolStripMenuItem("Draw Grid");
drawGridModeMenuItem.Tag = "drawgridmode";
drawGridModeMenuItem.Click += new EventHandler(InvokeTaggedAction);
drawGridModeMenuItem.Click += InvokeTaggedAction;
drawGridModeMenuItem.Image = Properties.Resources.DrawGridMode;
drawGridModeMenuItem.Enabled = false;
General.Interface.AddMenu(drawGridModeMenuItem, MenuSection.ModeDrawModes);
@ -256,7 +250,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//draw rectangle
drawRectModeMenuItem = new ToolStripMenuItem("Draw Rectangle");
drawRectModeMenuItem.Tag = "drawrectanglemode";
drawRectModeMenuItem.Click += new EventHandler(InvokeTaggedAction);
drawRectModeMenuItem.Click += InvokeTaggedAction;
drawRectModeMenuItem.Image = Properties.Resources.DrawRectMode;
drawRectModeMenuItem.Enabled = false;
General.Interface.AddMenu(drawRectModeMenuItem, MenuSection.ModeDrawModes);
@ -264,7 +258,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//draw curve
drawCurveModeMenuItem = new ToolStripMenuItem("Draw Curve");
drawCurveModeMenuItem.Tag = "drawcurvemode";
drawCurveModeMenuItem.Click += new EventHandler(InvokeTaggedAction);
drawCurveModeMenuItem.Click += InvokeTaggedAction;
drawCurveModeMenuItem.Image = Properties.Resources.DrawCurveMode;
drawCurveModeMenuItem.Enabled = false;
General.Interface.AddMenu(drawCurveModeMenuItem, MenuSection.ModeDrawModes);
@ -272,7 +266,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//draw lines
drawLinesModeMenuItem = new ToolStripMenuItem("Draw Lines");
drawLinesModeMenuItem.Tag = "drawlinesmode";
drawLinesModeMenuItem.Click += new EventHandler(InvokeTaggedAction);
drawLinesModeMenuItem.Click += InvokeTaggedAction;
drawLinesModeMenuItem.Image = Properties.Resources.DrawLinesMode;
drawLinesModeMenuItem.Enabled = false;
General.Interface.AddMenu(drawLinesModeMenuItem, MenuSection.ModeDrawModes);
@ -341,9 +335,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
autoAlignTextureOffsetsOnCreate = General.Settings.ReadPluginSetting("autoaligntextureoffsetsoncreate", false); //mxd
dontMoveGeometryOutsideMapBoundary = General.Settings.ReadPluginSetting("dontmovegeometryoutsidemapboundary", false); //mxd
syncSelection = General.Settings.ReadPluginSetting("syncselection", false); //mxd
objExportTextures = General.Settings.ReadPluginSetting("objexporttextures", false); //mxd
objGZDoomScale = General.Settings.ReadPluginSetting("objgzdoomscale", false); //mxd
objScale = General.Settings.ReadPluginSetting("objscale", 1.0f); //mxd
lockSectorTextureOffsetsWhileDragging = General.Settings.ReadPluginSetting("locktextureoffsets", false); //mxd
}
@ -922,7 +913,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//show settings form
WavefrontSettingsForm form = new WavefrontSettingsForm(General.Map.Map.SelectedSectorsCount == 0 ? -1 : sectors.Count);
if(form.ShowDialog() == DialogResult.OK) {
WavefrontExportSettings data = new WavefrontExportSettings(Path.GetFileNameWithoutExtension(form.FilePath), Path.GetDirectoryName(form.FilePath), BuilderPlug.Me.ObjScale, BuilderPlug.Me.ObjGZDoomScale, BuilderPlug.Me.ObjExportTextures);
WavefrontExportSettings data = new WavefrontExportSettings(Path.GetFileNameWithoutExtension(form.FilePath), Path.GetDirectoryName(form.FilePath), form.ObjScale, form.UseGZDoomScale, form.ExportTextures);
WavefrontExporter e = new WavefrontExporter();
e.Export(sectors, data);
}

View file

@ -27,6 +27,8 @@
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.ceiling = new CodeImp.DoomBuilder.Controls.FlatSelectorControl();
this.floor = new CodeImp.DoomBuilder.Controls.FlatSelectorControl();
this.cbOverrideFloorTexture = new System.Windows.Forms.CheckBox();
this.cbOverrideCeilingTexture = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
@ -58,8 +60,8 @@
this.clearfloor = new System.Windows.Forms.Button();
this.clearceiling = new System.Windows.Forms.Button();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.floor = new CodeImp.DoomBuilder.Controls.FlatSelectorControl();
this.ceiling = new CodeImp.DoomBuilder.Controls.FlatSelectorControl();
this.fillall = new System.Windows.Forms.Button();
this.clearall = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@ -82,6 +84,24 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Sector texture overrides:";
//
// ceiling
//
this.ceiling.Location = new System.Drawing.Point(6, 41);
this.ceiling.Name = "ceiling";
this.ceiling.Size = new System.Drawing.Size(68, 90);
this.ceiling.TabIndex = 30;
this.ceiling.TextureName = "";
this.ceiling.OnValueChanged += new System.EventHandler(this.ceiling_OnValueChanged);
//
// floor
//
this.floor.Location = new System.Drawing.Point(87, 41);
this.floor.Name = "floor";
this.floor.Size = new System.Drawing.Size(68, 90);
this.floor.TabIndex = 29;
this.floor.TextureName = "";
this.floor.OnValueChanged += new System.EventHandler(this.floor_OnValueChanged);
//
// cbOverrideFloorTexture
//
this.cbOverrideFloorTexture.AutoSize = true;
@ -300,6 +320,7 @@
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox4.Controls.Add(this.fillall);
this.groupBox4.Controls.Add(this.filllower);
this.groupBox4.Controls.Add(this.fillmiddle);
this.groupBox4.Controls.Add(this.fillupper);
@ -314,7 +335,7 @@
//
// filllower
//
this.filllower.Location = new System.Drawing.Point(133, 19);
this.filllower.Location = new System.Drawing.Point(171, 19);
this.filllower.Name = "filllower";
this.filllower.Size = new System.Drawing.Size(26, 23);
this.filllower.TabIndex = 4;
@ -325,7 +346,7 @@
//
// fillmiddle
//
this.fillmiddle.Location = new System.Drawing.Point(101, 19);
this.fillmiddle.Location = new System.Drawing.Point(139, 19);
this.fillmiddle.Name = "fillmiddle";
this.fillmiddle.Size = new System.Drawing.Size(26, 23);
this.fillmiddle.TabIndex = 3;
@ -336,7 +357,7 @@
//
// fillupper
//
this.fillupper.Location = new System.Drawing.Point(69, 19);
this.fillupper.Location = new System.Drawing.Point(107, 19);
this.fillupper.Name = "fillupper";
this.fillupper.Size = new System.Drawing.Size(26, 23);
this.fillupper.TabIndex = 2;
@ -347,7 +368,7 @@
//
// fillfloor
//
this.fillfloor.Location = new System.Drawing.Point(38, 19);
this.fillfloor.Location = new System.Drawing.Point(76, 19);
this.fillfloor.Name = "fillfloor";
this.fillfloor.Size = new System.Drawing.Size(26, 23);
this.fillfloor.TabIndex = 1;
@ -358,7 +379,7 @@
//
// fillceiling
//
this.fillceiling.Location = new System.Drawing.Point(6, 19);
this.fillceiling.Location = new System.Drawing.Point(44, 19);
this.fillceiling.Name = "fillceiling";
this.fillceiling.Size = new System.Drawing.Size(26, 23);
this.fillceiling.TabIndex = 0;
@ -370,7 +391,7 @@
//
// clearlower
//
this.clearlower.Location = new System.Drawing.Point(133, 19);
this.clearlower.Location = new System.Drawing.Point(171, 19);
this.clearlower.Name = "clearlower";
this.clearlower.Size = new System.Drawing.Size(26, 23);
this.clearlower.TabIndex = 4;
@ -381,7 +402,7 @@
//
// clearmiddle
//
this.clearmiddle.Location = new System.Drawing.Point(101, 19);
this.clearmiddle.Location = new System.Drawing.Point(139, 19);
this.clearmiddle.Name = "clearmiddle";
this.clearmiddle.Size = new System.Drawing.Size(26, 23);
this.clearmiddle.TabIndex = 3;
@ -392,7 +413,7 @@
//
// clearupper
//
this.clearupper.Location = new System.Drawing.Point(69, 19);
this.clearupper.Location = new System.Drawing.Point(107, 19);
this.clearupper.Name = "clearupper";
this.clearupper.Size = new System.Drawing.Size(26, 23);
this.clearupper.TabIndex = 2;
@ -403,7 +424,7 @@
//
// clearfloor
//
this.clearfloor.Location = new System.Drawing.Point(38, 19);
this.clearfloor.Location = new System.Drawing.Point(76, 19);
this.clearfloor.Name = "clearfloor";
this.clearfloor.Size = new System.Drawing.Size(26, 23);
this.clearfloor.TabIndex = 1;
@ -414,7 +435,7 @@
//
// clearceiling
//
this.clearceiling.Location = new System.Drawing.Point(6, 19);
this.clearceiling.Location = new System.Drawing.Point(44, 19);
this.clearceiling.Name = "clearceiling";
this.clearceiling.Size = new System.Drawing.Size(26, 23);
this.clearceiling.TabIndex = 0;
@ -427,6 +448,7 @@
//
this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox5.Controls.Add(this.clearall);
this.groupBox5.Controls.Add(this.clearlower);
this.groupBox5.Controls.Add(this.clearmiddle);
this.groupBox5.Controls.Add(this.clearupper);
@ -439,23 +461,27 @@
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Remove Textures form Selection:";
//
// floor
// fillall
//
this.floor.Location = new System.Drawing.Point(87, 41);
this.floor.Name = "floor";
this.floor.Size = new System.Drawing.Size(68, 90);
this.floor.TabIndex = 29;
this.floor.TextureName = "";
this.floor.OnValueChanged += new System.EventHandler(this.floor_OnValueChanged);
this.fillall.Location = new System.Drawing.Point(6, 19);
this.fillall.Name = "fillall";
this.fillall.Size = new System.Drawing.Size(32, 23);
this.fillall.TabIndex = 5;
this.fillall.Text = "All";
this.toolTip1.SetToolTip(this.fillall, "Replace all textures with currently enabled overrides");
this.fillall.UseVisualStyleBackColor = true;
this.fillall.Click += new System.EventHandler(this.fillall_Click);
//
// ceiling
// clearall
//
this.ceiling.Location = new System.Drawing.Point(6, 41);
this.ceiling.Name = "ceiling";
this.ceiling.Size = new System.Drawing.Size(68, 90);
this.ceiling.TabIndex = 30;
this.ceiling.TextureName = "";
this.ceiling.OnValueChanged += new System.EventHandler(this.ceiling_OnValueChanged);
this.clearall.Location = new System.Drawing.Point(6, 19);
this.clearall.Name = "clearall";
this.clearall.Size = new System.Drawing.Size(32, 23);
this.clearall.TabIndex = 6;
this.clearall.Text = "All";
this.toolTip1.SetToolTip(this.clearall, "Remove all textures from selected map elements");
this.clearall.UseVisualStyleBackColor = true;
this.clearall.Click += new System.EventHandler(this.clearall_Click);
//
// SectorDrawingOptionsPanel
//
@ -516,5 +542,7 @@
private System.Windows.Forms.Button clearceiling;
private CodeImp.DoomBuilder.Controls.FlatSelectorControl floor;
private CodeImp.DoomBuilder.Controls.FlatSelectorControl ceiling;
private System.Windows.Forms.Button fillall;
private System.Windows.Forms.Button clearall;
}
}

View file

@ -147,7 +147,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
General.Map.Data.UpdateUsedTextures();
General.Map.IsChanged = true;
if(General.Map.Renderer2D.ViewMode == CodeImp.DoomBuilder.Rendering.ViewMode.CeilingTextures)
if(General.Map.Renderer2D.ViewMode == Rendering.ViewMode.CeilingTextures)
General.Interface.RedrawDisplay();
}
@ -167,7 +167,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
General.Map.Data.UpdateUsedTextures();
General.Map.IsChanged = true;
if(General.Map.Renderer2D.ViewMode == CodeImp.DoomBuilder.Rendering.ViewMode.FloorTextures)
if(General.Map.Renderer2D.ViewMode == Rendering.ViewMode.FloorTextures)
General.Interface.RedrawDisplay();
}
@ -225,6 +225,59 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
General.Map.IsChanged = true;
}
private void fillall_Click(object sender, EventArgs e) {
ICollection<Sector> sectors = General.Map.Map.GetSelectedSectors(true);
//if we have selected sectors - fill their textures
if (sectors.Count > 0) {
//make undo
General.Map.UndoRedo.CreateUndo("Fill all texturs for " + sectors.Count + (sectors.Count > 1 ? " sectors" : " sector"));
foreach (Sector s in sectors) {
//fill sidedefs
foreach(Sidedef side in s.Sidedefs) {
if(top.Enabled && side.HighRequired()) side.SetTextureHigh(top.TextureName);
if(middle.Enabled && side.MiddleRequired()) side.SetTextureMid(middle.TextureName);
if(bottom.Enabled && side.LowRequired()) side.SetTextureLow(bottom.TextureName);
}
//fill flats
if(floor.Enabled) s.SetFloorTexture(floor.TextureName);
if(ceiling.Enabled) s.SetCeilTexture(ceiling.TextureName);
}
} else { //if we don't - fill linedef textures
ICollection<Linedef> lines = General.Map.Map.GetSelectedLinedefs(true);
if(lines.Count == 0) return;
//make undo
General.Map.UndoRedo.CreateUndo("Fill all texturs for " + lines.Count + (lines.Count > 1 ? " linedefs" : " linedef"));
//fill textures
foreach (Linedef l in lines) {
if(top.Enabled) {
if(l.Front != null && l.Front.HighRequired()) l.Front.SetTextureHigh(top.TextureName);
if(l.Back != null && l.Back.HighRequired()) l.Back.SetTextureHigh(top.TextureName);
}
if(middle.Enabled) {
if(l.Front != null && l.Front.MiddleRequired()) l.Front.SetTextureMid(middle.TextureName);
if(l.Back != null && l.Back.MiddleRequired()) l.Back.SetTextureMid(middle.TextureName);
}
if(bottom.Enabled) {
if(l.Front != null && l.Front.LowRequired()) l.Front.SetTextureLow(bottom.TextureName);
if(l.Back != null && l.Back.LowRequired()) l.Back.SetTextureLow(bottom.TextureName);
}
}
}
// Update the used textures
General.Map.Data.UpdateUsedTextures();
General.Map.IsChanged = true;
// Update entire display
General.Map.Map.Update();
General.Interface.RedrawDisplay();
}
#endregion
#region Clear Textures
@ -247,7 +300,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
// Update entire display
General.Map.Map.Update();
if(General.Map.Renderer2D.ViewMode == CodeImp.DoomBuilder.Rendering.ViewMode.CeilingTextures)
if(General.Map.Renderer2D.ViewMode == Rendering.ViewMode.CeilingTextures)
General.Interface.RedrawDisplay();
}
@ -269,7 +322,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
// Update entire display
General.Map.Map.Update();
if(General.Map.Renderer2D.ViewMode == CodeImp.DoomBuilder.Rendering.ViewMode.FloorTextures)
if(General.Map.Renderer2D.ViewMode == Rendering.ViewMode.FloorTextures)
General.Interface.RedrawDisplay();
}
@ -327,6 +380,61 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
General.Map.IsChanged = true;
}
private void clearall_Click(object sender, EventArgs e) {
//if we have selected sectors - clear their textures
ICollection<Sector> sectors = General.Map.Map.GetSelectedSectors(true);
if (sectors.Count > 0) {
//make undo
string undodesc = "sector";
if(sectors.Count > 1) undodesc = sectors.Count + " sectors";
General.Map.UndoRedo.CreateUndo("Clear all texture from " + undodesc);
foreach(Sector s in sectors) {
//clear side textures
foreach (Sidedef side in s.Sidedefs) {
if(side.HighTexture != "-") side.SetTextureHigh("-");
if(side.MiddleTexture != "-") side.SetTextureMid("-");
if(side.LowTexture != "-") side.SetTextureLow("-");
}
//clear flats
s.SetCeilTexture("-");
s.SetFloorTexture("-");
}
} else { //if we don't - clear linedef textures
ICollection<Linedef> lines = General.Map.Map.GetSelectedLinedefs(true);
if(lines.Count == 0) return;
//make undo
string undodesc = "linedef";
if(lines.Count > 1) undodesc = lines.Count + " linedefs";
General.Map.UndoRedo.CreateUndo("Clear all texture from " + undodesc);
//clear textures
foreach(Linedef l in lines) {
if(l.Front != null) {
if(l.Front.HighTexture != "-") l.Front.SetTextureHigh("-");
if(l.Front.MiddleTexture != "-") l.Front.SetTextureMid("-");
if(l.Front.LowTexture != "-") l.Front.SetTextureLow("-");
}
if (l.Back != null) {
if(l.Back.HighTexture != "-") l.Back.SetTextureHigh("-");
if(l.Back.MiddleTexture != "-") l.Back.SetTextureMid("-");
if(l.Back.LowTexture != "-") l.Back.SetTextureLow("-");
}
}
}
// Update the used textures
General.Map.Data.UpdateUsedTextures();
General.Map.IsChanged = true;
// Update entire display
General.Map.Map.Update();
General.Interface.RedrawDisplay();
}
#endregion
}

View file

@ -120,4 +120,7 @@
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -40,9 +40,9 @@
//
// tbExportPath
//
this.tbExportPath.Location = new System.Drawing.Point(82, 12);
this.tbExportPath.Location = new System.Drawing.Point(55, 12);
this.tbExportPath.Name = "tbExportPath";
this.tbExportPath.Size = new System.Drawing.Size(272, 20);
this.tbExportPath.Size = new System.Drawing.Size(299, 20);
this.tbExportPath.TabIndex = 0;
//
// browse
@ -58,11 +58,11 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 15);
this.label1.Location = new System.Drawing.Point(18, 14);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 14);
this.label1.Size = new System.Drawing.Size(31, 14);
this.label1.TabIndex = 2;
this.label1.Text = "Export path:";
this.label1.Text = "Path:";
//
// cbFixScale
//
@ -116,30 +116,30 @@
// nudScale
//
this.nudScale.DecimalPlaces = 4;
this.nudScale.Location = new System.Drawing.Point(82, 38);
this.nudScale.Location = new System.Drawing.Point(55, 38);
this.nudScale.Maximum = new decimal(new int[] {
2048,
0,
0,
0});
2048,
0,
0,
0});
this.nudScale.Minimum = new decimal(new int[] {
2048,
0,
0,
-2147483648});
2048,
0,
0,
-2147483648});
this.nudScale.Name = "nudScale";
this.nudScale.Size = new System.Drawing.Size(94, 20);
this.nudScale.TabIndex = 8;
this.nudScale.Value = new decimal(new int[] {
1,
0,
0,
0});
1,
0,
0,
0});
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(39, 40);
this.label2.Location = new System.Drawing.Point(12, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(37, 14);
this.label2.TabIndex = 9;

View file

@ -1,27 +1,46 @@
using System;
#region ================== Namespaces
using System;
using System.Windows.Forms;
using System.IO;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes.Interface
{
public partial class WavefrontSettingsForm : Form
{
public string FilePath { get { return filePath; } }
private string filePath;
#region ================== Properties
public string FilePath { get { return tbExportPath.Text.Trim(); } }
public bool ExportTextures { get { return cbExportTextures.Checked; } }
public bool UseGZDoomScale { get { return cbFixScale.Checked; } }
public float ObjScale { get { return (float)nudScale.Value; } }
#endregion
public WavefrontSettingsForm(int sectorsCount) {
InitializeComponent();
saveFileDialog.InitialDirectory = General.Map.FilePathName;
saveFileDialog.FileName = Path.GetDirectoryName(General.Map.FilePathName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(General.Map.FileTitle) + "_" + General.Map.Options.LevelName + ".obj";
tbExportPath.Text = saveFileDialog.FileName;
cbExportTextures.Checked = BuilderPlug.Me.ObjExportTextures;
cbFixScale.Checked = BuilderPlug.Me.ObjGZDoomScale;
nudScale.Value = (decimal)BuilderPlug.Me.ObjScale;
string name = Path.GetFileNameWithoutExtension(General.Map.FileTitle) + "_" + General.Map.Options.LevelName + ".obj";
if(string.IsNullOrEmpty(General.Map.FilePathName)) {
saveFileDialog.FileName = name;
} else {
saveFileDialog.InitialDirectory = General.Map.FilePathName;
saveFileDialog.FileName = Path.GetDirectoryName(General.Map.FilePathName) + Path.DirectorySeparatorChar + name;
tbExportPath.Text = saveFileDialog.FileName;
}
//restore settings
cbExportTextures.Checked = General.Settings.ReadPluginSetting("objexporttextures", false);//BuilderPlug.Me.ObjExportTextures;
cbFixScale.Checked = General.Settings.ReadPluginSetting("objgzdoomscale", false);//BuilderPlug.Me.ObjGZDoomScale;
nudScale.Value = (decimal)General.Settings.ReadPluginSetting("objscale", 1.0f);//(decimal)BuilderPlug.Me.ObjScale;
this.Text = "Export " + (sectorsCount == -1 ? "whole map" : sectorsCount + (sectorsCount > 1 ? "sectors" : "sector")) + " to Wavefront .obj";
}
#region ================== Events
private void browse_Click(object sender, EventArgs e) {
if(saveFileDialog.ShowDialog() == DialogResult.OK) {
tbExportPath.Text = saveFileDialog.FileName;
@ -29,29 +48,34 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
}
private void export_Click(object sender, EventArgs e) {
filePath = tbExportPath.Text.Trim();
//BuilderPlug.Me.ObjExportTextures = cbExportTextures.Checked;
//BuilderPlug.Me.ObjGZDoomScale = cbFixScale.Checked;
//BuilderPlug.Me.ObjScale = (float)nudScale.Value;
BuilderPlug.Me.ObjExportTextures = cbExportTextures.Checked;
BuilderPlug.Me.ObjGZDoomScale = cbFixScale.Checked;
BuilderPlug.Me.ObjScale = (float)nudScale.Value;
if(nudScale.Value == 0) {
MessageBox.Show("Scale should not be zero!");
return;
}
if(!Directory.Exists(Path.GetDirectoryName(tbExportPath.Text))) {
MessageBox.Show("Selected path does not exist!");
return;
}
//save settings
General.Settings.WritePluginSetting("objexporttextures", cbExportTextures.Checked);//mxd
General.Settings.WritePluginSetting("objgzdoomscale", cbFixScale.Checked);//mxd
General.Settings.WritePluginSetting("objscale", (float)nudScale.Value);//mxd
//verify path
if(Directory.Exists(Path.GetDirectoryName(filePath))) {
filePath = tbExportPath.Text;
this.DialogResult = DialogResult.OK;
this.Close();
} else {
MessageBox.Show("Selected path does not exist!");
}
General.Settings.WritePluginSetting("objexporttextures", cbExportTextures.Checked);
General.Settings.WritePluginSetting("objgzdoomscale", cbFixScale.Checked);
General.Settings.WritePluginSetting("objscale", (float)nudScale.Value);
//filePath = tbExportPath.Text;
this.DialogResult = DialogResult.OK;
this.Close();
}
private void cancel_Click(object sender, EventArgs e) {
this.Close();
}
#endregion
}
}

View file

@ -1,123 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
<value>17, 17</value>
</metadata>
</root>