Skip to content

Commit 06f96af

Browse files
author
theawesomecoder61
committed
Version 1.5
1 parent a8c8ca6 commit 06f96af

File tree

85 files changed

+3366
-620625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+3366
-620625
lines changed
5.5 KB
Binary file not shown.

Blacksmith/Blacksmith.csproj

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,17 @@
118118
</Reference>
119119
</ItemGroup>
120120
<ItemGroup>
121+
<Compile Include="Forms\ConvertDialog.cs">
122+
<SubType>Form</SubType>
123+
</Compile>
124+
<Compile Include="Forms\ConvertDialog.Designer.cs">
125+
<DependentUpon>ConvertDialog.cs</DependentUpon>
126+
</Compile>
127+
<Compile Include="Three\Cube.cs" />
121128
<Compile Include="Enums\EntryTreeNodeType.cs" />
122129
<Compile Include="Enums\FindType.cs" />
130+
<Compile Include="FileTypes\SMD.cs" />
131+
<Compile Include="FileTypes\STL.cs" />
123132
<Compile Include="Forms\ResourceViewer.cs">
124133
<SubType>Form</SubType>
125134
</Compile>
@@ -152,16 +161,21 @@
152161
<Compile Include="Forms\SoundpackBrowser.Designer.cs">
153162
<DependentUpon>SoundpackBrowser.cs</DependentUpon>
154163
</Compile>
155-
<Compile Include="Three\DAEWriter.cs" />
156-
<Compile Include="Three\IO_DAE.cs" />
164+
<Compile Include="FileTypes\DAEWriter.cs" />
165+
<Compile Include="FileTypes\DAE.cs" />
157166
<Compile Include="Three\Mesh.cs" />
158-
<Compile Include="Three\RenderMode.cs" />
167+
<Compile Include="Three\Model.cs" />
168+
<Compile Include="Enums\RenderMode.cs" />
159169
<Compile Include="Three\ShaderProgram.cs" />
160170
<Compile Include="Three\TextRenderer.cs" />
171+
<Content Include="Binaries\x86\texconv.exe">
172+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
173+
</Content>
161174
<Content Include="Form1 backup.cs">
162175
<SubType>Form</SubType>
163176
</Content>
164177
<None Include="Resources\arrow_in.png" />
178+
<Content Include="Games\Origins backup.txt" />
165179
<Content Include="Three\D3DScene.txt" />
166180
<Compile Include="Enums\DXT.cs" />
167181
<Compile Include="Enums\ResourceType.cs" />
@@ -186,9 +200,9 @@
186200
</Compile>
187201
<Compile Include="Three\Camera.cs" />
188202
<Compile Include="Three\GLViewer.cs" />
189-
<Compile Include="Three\OBJModel.cs" />
203+
<Compile Include="FileTypes\OBJ.cs" />
190204
<Content Include="Three\ThreeViewer.txt" />
191-
<Compile Include="Three\Model.cs" />
205+
<Compile Include="Three\GLMesh.cs" />
192206
<Content Include="Three\GLViewer backup.txt" />
193207
<Content Include="Shaders\fs.glsl">
194208
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -205,6 +219,9 @@
205219
<EmbeddedResource Include="Form1.resx">
206220
<DependentUpon>Form1.cs</DependentUpon>
207221
</EmbeddedResource>
222+
<EmbeddedResource Include="Forms\ConvertDialog.resx">
223+
<DependentUpon>ConvertDialog.cs</DependentUpon>
224+
</EmbeddedResource>
208225
<EmbeddedResource Include="Forms\FindDialog.resx">
209226
<DependentUpon>FindDialog.cs</DependentUpon>
210227
</EmbeddedResource>
@@ -279,9 +296,6 @@
279296
<Content Include="Binaries\x86\revorb.exe">
280297
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
281298
</Content>
282-
<Content Include="Binaries\x86\texconv.exe">
283-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
284-
</Content>
285299
<Content Include="Binaries\x86\ww2ogg.exe">
286300
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
287301
</Content>

Blacksmith/EntryTreeNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public Forge GetForge()
3535
else if (Type == EntryTreeNodeType.SUBENTRY)
3636
return ((EntryTreeNode)Parent.Parent).Forge;
3737
else
38-
return null;
38+
return Forge;
3939
}
4040
}
4141
}
Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23

34
// adapted from: https://github.com/Ploaj/SSBHLib/blob/fe395033f4/CrossMod/IO/IO_DAE.cs
45

56
namespace Blacksmith.Three
67
{
7-
public class IO_DAE
8+
public class DAE
89
{
9-
public static void ExportModelAsDAE(string FileName, List<Mesh> Meshes, bool Optimize, bool ExportMaterials)
10+
public static void Export(string fileName, Model model, bool optimize, bool exportMaterials)
1011
{
11-
using (DAEWriter writer = new DAEWriter(FileName, Optimize))
12+
using (DAEWriter writer = new DAEWriter(fileName, optimize))
1213
{
1314
writer.WriteAsset();
1415

@@ -58,7 +59,7 @@ public static void ExportModelAsDAE(string FileName, List<Mesh> Meshes, bool Opt
5859
}*/
5960

6061
writer.StartGeometrySection();
61-
foreach (var mesh in Meshes)
62+
foreach (Mesh mesh in model.Meshes)
6263
{
6364
writer.StartGeometryMesh("Mesh " + mesh.ID);
6465

@@ -92,12 +93,12 @@ public static void ExportModelAsDAE(string FileName, List<Mesh> Meshes, bool Opt
9293
UV0.Add(vertex.TextureCoordinate.Y);
9394
/*UV1.Add(vertex.UV1.X);
9495
UV1.Add(vertex.UV1.Y);
95-
UV2.Add(vertex.UV2.X);
96+
UV2.Add(vertex.UV2.X);-
9697
UV2.Add(vertex.UV2.Y);
9798
UV3.Add(vertex.UV3.X);
9899
UV3.Add(vertex.UV3.Y);*/
99100

100-
/*Color.AddRange(new float[] { vertex.Color.X, vertex.Color.Y, vertex.Color.Z, vertex.Color.W });*/
101+
//Color.AddRange(new float[] { vertex.Color.X, vertex.Color.Y, vertex.Color.Z, vertex.Color.W });
101102

102103
List<int> bIndices = new List<int>();
103104
List<float> bWeights = new List<float>();
@@ -126,21 +127,24 @@ public static void ExportModelAsDAE(string FileName, List<Mesh> Meshes, bool Opt
126127
}
127128

128129
// ?
129-
uint[] faces = new uint[mesh.Faces.Length * 3];
130-
for (uint i = 0; i < mesh.Faces.Length; i++)
130+
/*uint[] faces = new uint[mesh.Faces.Count * 3];
131+
for (int i = 0; i < mesh.Faces.Count; i++)
131132
{
132133
faces[i] = (uint)mesh.Faces[i].X;
133134
faces[i + 1] = (uint)mesh.Faces[i].Y;
134135
faces[i + 2] = (uint)mesh.Faces[i].Z;
135-
}
136+
}*/
136137
// ?
137138

139+
string name = string.Format("mesh{0}", mesh.ID);
140+
138141
// write sources
139-
//if (mesh.Vertices.Length > 0)
140-
writer.WriteGeometrySource(mesh.Name, DAEWriter.VERTEX_SEMANTIC.POSITION, Position.ToArray(), faces); // ToDo: fix ii
142+
if (mesh.Vertices.Count > 0)
143+
writer.WriteGeometrySource(name, DAEWriter.VERTEX_SEMANTIC.POSITION, Position.ToArray(), mesh.Indices.Cast<uint>().ToArray());
141144

142-
//if (mesh.HasNormals)
143-
//writer.WriteGeometrySource(mesh.Name, DAEWriter.VERTEX_SEMANTIC.NORMAL, Normal.ToArray(), ii); // ToDo: fix ii
145+
#warning needs fixing
146+
if (mesh.Normals.Count > 0)
147+
writer.WriteGeometrySource(name, DAEWriter.VERTEX_SEMANTIC.NORMAL, Normal.ToArray(), new uint[0]);
144148

145149
/*if (mesh.HasColor)
146150
writer.WriteGeometrySource(mesh.Name, DAEWriter.VERTEX_SEMANTIC.COLOR, Color.ToArray(), mesh.Indices.ToArray());*/
@@ -157,10 +161,8 @@ public static void ExportModelAsDAE(string FileName, List<Mesh> Meshes, bool Opt
157161
if (mesh.HasUV3)
158162
writer.WriteGeometrySource(mesh.Name, DAEWriter.VERTEX_SEMANTIC.TEXCOORD, UV3.ToArray(), mesh.Indices.ToArray(), 3);*/
159163

160-
if (mesh.Vertices[0].BoneWeights.Length() > 0)
161-
{
164+
if (mesh.Vertices[0].BoneWeights.Length > 0)
162165
writer.AttachGeometryController(BoneIndices, BoneWeights);
163-
}
164166

165167
writer.EndGeometryMesh();
166168
}

Blacksmith/FileTypes/Forge.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Blacksmith.Enums;
12
using System;
23
using System.IO;
34
using System.Linq;
@@ -10,6 +11,7 @@ public class Forge
1011
{
1112
public string Path { get; private set; }
1213
public string Name { get; private set; }
14+
public Game Game;
1315
public HeaderBlock Header { get; private set; }
1416
public DataHeader1Block DataHeader1 { get; private set; }
1517
public DataHeader2Block DataHeader2 { get; private set; }
@@ -265,17 +267,15 @@ public string CreateFilelist()
265267
if (FileEntries != null && FileEntries.Length > 0)
266268
{
267269
sb.Append("Name\tOffset\tSize\tFile ID from Index Table\n");
268-
foreach (FileEntry entry in FileEntries)
270+
FileEntries.ToList().ForEach(x =>
269271
{
270272
if (Properties.Settings.Default.useCSV)
271-
sb.AppendFormat("{0},{1},{2},{3}\n", entry.NameTable.Name, entry.IndexTable.OffsetToRawDataTable, entry.IndexTable.RawDataSize, entry.IndexTable.FileDataID);
273+
sb.AppendFormat("{0},{1},{2},{3}\n", x.NameTable.Name, x.IndexTable.OffsetToRawDataTable, x.IndexTable.RawDataSize, x.IndexTable.FileDataID);
272274
else
273-
sb.AppendFormat("{0}\t{1}\t{2}\t{3}\n", entry.NameTable.Name, entry.IndexTable.OffsetToRawDataTable, entry.IndexTable.RawDataSize, entry.IndexTable.FileDataID);
274-
}
275-
return sb.ToString();
275+
sb.AppendFormat("{0}\t{1}\t{2}\t{3}\n", x.NameTable.Name, x.IndexTable.OffsetToRawDataTable, x.IndexTable.RawDataSize, x.IndexTable.FileDataID);
276+
});
276277
}
277-
else
278-
return "";
278+
return sb.ToString();
279279
}
280280

281281
public bool IsFullyRead() => isFullyRead;

0 commit comments

Comments
 (0)