testing built in obj to mesh conversion
This commit is contained in:
parent
637bb1f4a5
commit
e27b073ceb
|
|
@ -0,0 +1,84 @@
|
||||||
|
#region Usings
|
||||||
|
using ObjLoader.Loader.Data.VertexData;
|
||||||
|
using ObjLoader.Loader.Loaders;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Icon Loader
|
||||||
|
|
||||||
|
public class OBJConverter
|
||||||
|
{
|
||||||
|
private OpenFileDialog openFileDialog1;
|
||||||
|
private string installOutcome = "";
|
||||||
|
|
||||||
|
public OBJConverter()
|
||||||
|
{
|
||||||
|
openFileDialog1 = new OpenFileDialog()
|
||||||
|
{
|
||||||
|
FileName = "Select an .obj file",
|
||||||
|
Filter = "Wavefront OBJ file (*.obj)|*.obj",
|
||||||
|
Title = "Open .obj"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstallOutcome(string text)
|
||||||
|
{
|
||||||
|
installOutcome = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string getInstallOutcome()
|
||||||
|
{
|
||||||
|
return installOutcome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConvertOBJ()
|
||||||
|
{
|
||||||
|
if (openFileDialog1.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
using (Stream str = openFileDialog1.OpenFile())
|
||||||
|
{
|
||||||
|
Directory.SetCurrentDirectory(Path.GetDirectoryName(openFileDialog1.FileName));
|
||||||
|
var materialStreamProvider = new MaterialStreamProvider();
|
||||||
|
var objLoaderFactory = new ObjLoaderFactory();
|
||||||
|
var objLoader = objLoaderFactory.Create(materialStreamProvider);
|
||||||
|
var fileStream = materialStreamProvider.Open(openFileDialog1.FileName);
|
||||||
|
var result = objLoader.Load(fileStream);
|
||||||
|
|
||||||
|
string testString = "";
|
||||||
|
testString += "version 1.00\n";
|
||||||
|
testString += result.Groups.First().Faces.Count + "\n";
|
||||||
|
foreach (Vertex vert in result.Vertices)
|
||||||
|
{
|
||||||
|
testString += "[" + (vert.X * 0.5) + "," + (vert.Y * 0.5) + "," + (vert.Z * 0.5) + "]";
|
||||||
|
foreach (Normal norm in result.Normals)
|
||||||
|
{
|
||||||
|
testString += "[" + norm.X + "," + norm.Y + "," + norm.Z + "]";
|
||||||
|
|
||||||
|
//this is dumb
|
||||||
|
if (result.Textures.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (Texture tex in result.Textures)
|
||||||
|
{
|
||||||
|
testString += "[" + tex.X + "," + tex.Y + ",0]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
testString += "[0,0,0]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show(testString);
|
||||||
|
Clipboard.SetText(testString);
|
||||||
|
|
||||||
|
Directory.SetCurrentDirectory(GlobalPaths.RootPath);
|
||||||
|
str.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
Binary file not shown.
|
|
@ -53,6 +53,7 @@
|
||||||
this.listView1 = new System.Windows.Forms.ListView();
|
this.listView1 = new System.Windows.Forms.ListView();
|
||||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||||
|
this.TestButton = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
|
|
@ -120,12 +121,23 @@
|
||||||
this.imageList1.Images.SetKeyName(8, "splash.png");
|
this.imageList1.Images.SetKeyName(8, "splash.png");
|
||||||
this.imageList1.Images.SetKeyName(9, "XMLContentEditor.png");
|
this.imageList1.Images.SetKeyName(9, "XMLContentEditor.png");
|
||||||
//
|
//
|
||||||
|
// TestButton
|
||||||
|
//
|
||||||
|
this.TestButton.Location = new System.Drawing.Point(15, 364);
|
||||||
|
this.TestButton.Name = "TestButton";
|
||||||
|
this.TestButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.TestButton.TabIndex = 16;
|
||||||
|
this.TestButton.Text = "OBJStats";
|
||||||
|
this.TestButton.UseVisualStyleBackColor = true;
|
||||||
|
this.TestButton.Click += new System.EventHandler(this.TestButton_Click);
|
||||||
|
//
|
||||||
// NovetusSDK
|
// NovetusSDK
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
this.BackColor = System.Drawing.SystemColors.ControlLightLight;
|
||||||
this.ClientSize = new System.Drawing.Size(438, 354);
|
this.ClientSize = new System.Drawing.Size(438, 399);
|
||||||
|
this.Controls.Add(this.TestButton);
|
||||||
this.Controls.Add(this.listView1);
|
this.Controls.Add(this.listView1);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
this.Controls.Add(this.pictureBox2);
|
this.Controls.Add(this.pictureBox2);
|
||||||
|
|
@ -149,4 +161,5 @@
|
||||||
private System.Windows.Forms.ListView listView1;
|
private System.Windows.Forms.ListView listView1;
|
||||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||||
private System.Windows.Forms.ImageList imageList1;
|
private System.Windows.Forms.ImageList imageList1;
|
||||||
|
private System.Windows.Forms.Button TestButton;
|
||||||
}
|
}
|
||||||
|
|
@ -123,5 +123,12 @@ public partial class NovetusSDK : Form
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
//remove upon test finish
|
||||||
|
private void TestButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OBJConverter objconv = new OBJConverter();
|
||||||
|
objconv.ConvertOBJ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@
|
||||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAU
|
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAU
|
||||||
EwAAAk1TRnQBSQFMAgEBCgEAARgBAAEYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
EwAAAk1TRnQBSQFMAgEBCgEAASABAAEgAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||||
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,9 @@
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="CjClutter.ObjLoader.LoaderNet4">
|
||||||
|
<HintPath>Dependencies\CjClutter.ObjLoader.LoaderNet4.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="DotNetZip, Version=1.11.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
|
<Reference Include="DotNetZip, Version=1.11.0.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath>
|
<HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
@ -95,6 +98,12 @@
|
||||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\NLog.4.7.2\lib\net40-client\NLog.dll</HintPath>
|
<HintPath>..\packages\NLog.4.7.2\lib\net40-client\NLog.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="SharpGL, Version=3.1.1.0, Culture=neutral, PublicKeyToken=27fc851303210b27, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SharpGL.3.1.1\lib\net40\SharpGL.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SharpGL.SceneGraph, Version=3.1.1.0, Culture=neutral, PublicKeyToken=27fc851303210b27, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SharpGL.SceneGraph.3.1.1\lib\net40\SharpGL.SceneGraph.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
|
|
@ -153,6 +162,7 @@
|
||||||
<Compile Include="Classes\Launcher\SplashLoader.cs" />
|
<Compile Include="Classes\Launcher\SplashLoader.cs" />
|
||||||
<Compile Include="Classes\LocalVars.cs" />
|
<Compile Include="Classes\LocalVars.cs" />
|
||||||
<Compile Include="Classes\SDK\Downloader.cs" />
|
<Compile Include="Classes\SDK\Downloader.cs" />
|
||||||
|
<Compile Include="Classes\SDK\OBJConverter.cs" />
|
||||||
<Compile Include="Classes\SDK\ROBLOXFileTypes.cs" />
|
<Compile Include="Classes\SDK\ROBLOXFileTypes.cs" />
|
||||||
<Compile Include="Forms\Decoder.cs">
|
<Compile Include="Forms\Decoder.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,6 @@
|
||||||
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
|
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
|
||||||
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net40" />
|
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net40" />
|
||||||
<package id="NLog" version="4.7.2" targetFramework="net40" />
|
<package id="NLog" version="4.7.2" targetFramework="net40" />
|
||||||
|
<package id="SharpGL" version="3.1.1" targetFramework="net40" />
|
||||||
|
<package id="SharpGL.SceneGraph" version="3.1.1" targetFramework="net40" />
|
||||||
</packages>
|
</packages>
|
||||||
Loading…
Reference in New Issue