Skip to content

Commit

Permalink
preview 8 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Sep 20, 2018
1 parent ace48fa commit 5449ccf
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 44 deletions.
2 changes: 0 additions & 2 deletions IndustrialPark/ArchiveEditor/ArchiveEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,6 @@ private void importTXDArchiveToolStripMenuItem_Click(object sender, EventArgs e)
if (openTXD.ShowDialog() == DialogResult.OK)
{
archive.AddTextureDictionary(openTXD.FileName);
comboBoxLayers.Items.Add(LayerToString(archive.DICT.LTOC.LHDRList.Count - 1));
comboBoxLayers.SelectedIndex = comboBoxLayers.Items.Count - 1;
}
}

Expand Down
17 changes: 9 additions & 8 deletions IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,14 +606,15 @@ public void MouseMoveY(SharpCamera camera, int distance)
public void AddTextureDictionary(string fileName)
{
// Add a new layer for the textures
int layerIndex = DICT.LTOC.LHDRList.Count;

DICT.LTOC.LHDRList.Add(new Section_LHDR()
{
layerType = LayerType.TEXTURE,
assetIDlist = new List<uint>(),
LDBG = new Section_LDBG(-1)
});
//int layerIndex = DICT.LTOC.LHDRList.Count;
int layerIndex = 2;

//DICT.LTOC.LHDRList.Add(new Section_LHDR()
//{
// layerType = LayerType.TEXTURE,
// assetIDlist = new List<uint>(),
// LDBG = new Section_LDBG(-1)
//});

ReadFileMethods.treatTexturesAsByteArray = true;

Expand Down
2 changes: 1 addition & 1 deletion IndustrialPark/IndustrialPark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<Compile Include="Assets\ObjectAssets\AssetTIMR.cs" />
<Compile Include="Assets\ObjectAssets\ClickableAssets\PlaceableAssets\AssetBOUL.cs" />
<Compile Include="Assets\ObjectAssets\ClickableAssets\PlaceableAssets\AssetDSTR.cs" />
<Compile Include="Other\OBJFunctions.cs" />
<Compile Include="Assets\Shared\Colors\MyColor.cs" />
<Compile Include="Assets\Shared\Colors\MyColorConverter.cs" />
<Compile Include="Assets\Shared\Colors\MyColorEditor.cs" />
Expand Down Expand Up @@ -193,7 +194,6 @@
</Compile>
<Compile Include="Other\ConverterFunctions.cs" />
<Compile Include="Other\ModelConverterData.cs" />
<Compile Include="Other\OBJFunctions.cs" />
<Compile Include="Other\Triangle.cs" />
<Compile Include="Other\Vertex.cs" />
<Compile Include="Program.cs" />
Expand Down
2 changes: 1 addition & 1 deletion IndustrialPark/MainForm/AboutBox.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions IndustrialPark/Other/ModelConverterData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using RenderWareFile;
using SharpDX;

namespace IndustrialPark.Models
Expand All @@ -9,7 +8,7 @@ public struct ModelConverterData
public List<string> MaterialList;
public List<Vertex> VertexList;
public List<Vector2> UVList;
public List<SharpDX.Color> ColorList;
public List<Color> ColorList;
public List<Triangle> TriangleList;
public string MTLLib;
}
Expand Down
54 changes: 27 additions & 27 deletions IndustrialPark/Other/OBJFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace IndustrialPark.Models
{
public class OBJFunctions
public static class OBJFunctions
{
public static bool flipUVs = false;

public static ModelConverterData ReadOBJFile(string InputFile, bool hasUVCoords = true)
{
ModelConverterData objData = new ModelConverterData()
Expand All @@ -34,7 +34,7 @@ public static ModelConverterData ReadOBJFile(string InputFile, bool hasUVCoords
int CurrentMaterial = -1;

List<SharpDX.Color> ColorStream = new List<SharpDX.Color>();

foreach (string j in OBJFile)
{
if (j.Length > 2)
Expand Down Expand Up @@ -89,7 +89,7 @@ public static ModelConverterData ReadOBJFile(string InputFile, bool hasUVCoords

Triangle TempTriangle = new Triangle
{
MaterialIndex = CurrentMaterial,
materialIndex = CurrentMaterial,
vertex1 = Convert.ToInt32(SubStrings[1].Split('/')[0]) - 1,
vertex2 = Convert.ToInt32(SubStrings[2].Split('/')[0]) - 1,
vertex3 = Convert.ToInt32(SubStrings[3].Split('/')[0]) - 1
Expand Down Expand Up @@ -131,7 +131,7 @@ public static ModelConverterData ReadOBJFile(string InputFile, bool hasUVCoords
{
MessageBox.Show("Unable to load material lib. Will use material names as texture names.");
}

return FixUVCoords(objData);
}

Expand Down Expand Up @@ -256,7 +256,7 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)
indexLists.Last().Add(triangleStream2[0].vertex1);
indexLists.Last().Add(triangleStream2[0].vertex2);
indexLists.Last().Add(triangleStream2[0].vertex3);
triangleStream2[0].MaterialIndex = -1;
triangleStream2[0].materialIndex = -1;

bool allAreDone = false;

Expand All @@ -266,15 +266,15 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)

for (int i = 0; i < triangleStream2.Count(); i++)
{
if (triangleStream2[i].MaterialIndex == -1) continue;
if (triangleStream2[i].materialIndex == -1) continue;

if (!inverted)
{
if (indexLists.Last()[indexLists.Last().Count - 2] == triangleStream2[i].vertex1 &
indexLists.Last()[indexLists.Last().Count - 1] == triangleStream2[i].vertex2)
{
indexLists.Last().Add(triangleStream2[i].vertex3);
triangleStream2[i].MaterialIndex = -1;
triangleStream2[i].materialIndex = -1;
inverted = !inverted;
i = 0;
continue;
Expand All @@ -283,7 +283,7 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)
indexLists.Last()[indexLists.Last().Count - 1] == triangleStream2[i].vertex3)
{
indexLists.Last().Add(triangleStream2[i].vertex1);
triangleStream2[i].MaterialIndex = -1;
triangleStream2[i].materialIndex = -1;
inverted = !inverted;
i = 0;
continue;
Expand All @@ -292,7 +292,7 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)
indexLists.Last()[indexLists.Last().Count - 1] == triangleStream2[i].vertex1)
{
indexLists.Last().Add(triangleStream2[i].vertex2);
triangleStream2[i].MaterialIndex = -1;
triangleStream2[i].materialIndex = -1;
inverted = !inverted;
i = 0;
continue;
Expand All @@ -304,7 +304,7 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)
indexLists.Last()[indexLists.Last().Count - 1] == triangleStream2[i].vertex1)
{
indexLists.Last().Add(triangleStream2[i].vertex3);
triangleStream2[i].MaterialIndex = -1;
triangleStream2[i].materialIndex = -1;
inverted = !inverted;
i = 0;
continue;
Expand All @@ -313,7 +313,7 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)
indexLists.Last()[indexLists.Last().Count - 1] == triangleStream2[i].vertex2)
{
indexLists.Last().Add(triangleStream2[i].vertex1);
triangleStream2[i].MaterialIndex = -1;
triangleStream2[i].materialIndex = -1;
inverted = !inverted;
i = 0;
continue;
Expand All @@ -322,7 +322,7 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)
indexLists.Last()[indexLists.Last().Count - 1] == triangleStream2[i].vertex3)
{
indexLists.Last().Add(triangleStream2[i].vertex2);
triangleStream2[i].MaterialIndex = -1;
triangleStream2[i].materialIndex = -1;
inverted = !inverted;
i = 0;
continue;
Expand All @@ -334,15 +334,15 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)

for (int i = 0; i < triangleStream2.Count(); i++)
{
if (triangleStream2[i].MaterialIndex == -1)
if (triangleStream2[i].materialIndex == -1)
continue;
else
{
indexLists.Add(new List<int>());
indexLists.Last().Add(triangleStream2[i].vertex1);
indexLists.Last().Add(triangleStream2[i].vertex2);
indexLists.Last().Add(triangleStream2[i].vertex3);
triangleStream2[i].MaterialIndex = -1;
triangleStream2[i].materialIndex = -1;
allAreDone = false;
break;
}
Expand All @@ -351,7 +351,7 @@ private static List<List<int>> GenerateTristrips(List<Triangle> triangleStream2)

return indexLists;
}

public static void ConvertBSPtoOBJ(string fileName, RenderWareModelFile bspFile)
{
int totalVertexIndices = 0;
Expand Down Expand Up @@ -389,19 +389,19 @@ public static void ConvertBSPtoOBJ(string fileName, RenderWareModelFile bspFile)
if (bspFile.isCollision)
{
foreach (Triangle j in triangleList)
if (j.MaterialIndex == i)
if (j.materialIndex == i)
OBJWriter.WriteLine("f "
+ (j.vertex1 + 1).ToString() + " "
+ (j.vertex2 + 1).ToString() + " "
+ (j.vertex3 + 1).ToString());
}
else
foreach (Triangle j in triangleList)
if (j.MaterialIndex == i)
OBJWriter.WriteLine("f "
+ (j.vertex1 + 1).ToString() + "/" + (j.vertex1 + 1).ToString() + " "
+ (j.vertex2 + 1).ToString() + "/" + (j.vertex2 + 1).ToString() + " "
+ (j.vertex3 + 1).ToString() + "/" + (j.vertex3 + 1).ToString());
foreach (Triangle j in triangleList)
if (j.materialIndex == i)
OBJWriter.WriteLine("f "
+ (j.vertex1 + 1).ToString() + "/" + (j.vertex1 + 1).ToString() + " "
+ (j.vertex2 + 1).ToString() + "/" + (j.vertex2 + 1).ToString() + " "
+ (j.vertex3 + 1).ToString() + "/" + (j.vertex3 + 1).ToString());

OBJWriter.WriteLine();
}
Expand All @@ -418,7 +418,7 @@ private static void GetPlaneTriangleList(StreamWriter OBJWriter, PlaneSector_000
}
else if (PlaneSector.leftSection is PlaneSector_000A p1)
{
GetPlaneTriangleList(OBJWriter, p1, ref triangleList, ref totalVertexIndices);
GetPlaneTriangleList(OBJWriter, p1, ref triangleList, ref totalVertexIndices);
}

if (PlaneSector.rightSection is AtomicSector_0009 a2)
Expand Down Expand Up @@ -455,7 +455,7 @@ private static void GetAtomicTriangleList(StreamWriter OBJWriter, AtomicSector_0
// Write vcolors to obj
if (atomicSection.atomicSectorStruct.colorArray != null)
foreach (RenderWareFile.Color i in atomicSection.atomicSectorStruct.colorArray)
OBJWriter.WriteLine("vc " + i.R.ToString() + " " + i.G.ToString() + " " + i.B.ToString() + " " + i.A.ToString());
OBJWriter.WriteLine("vc " + i.R.ToString() + " " + i.G.ToString() + " " + i.B.ToString() + " " + i.A.ToString());

OBJWriter.WriteLine();

Expand All @@ -464,7 +464,7 @@ private static void GetAtomicTriangleList(StreamWriter OBJWriter, AtomicSector_0
{
triangleList.Add(new Triangle
{
MaterialIndex = i.materialIndex,
materialIndex = i.materialIndex,
vertex1 = i.vertex1 + totalVertexIndices,
vertex2 = i.vertex2 + totalVertexIndices,
vertex3 = i.vertex3 + totalVertexIndices
Expand Down Expand Up @@ -493,7 +493,7 @@ private static void WriteMaterialLib(string[] MaterialStream, string materialLib
MTLWriter.WriteLine();
}

MTLWriter.Close();
MTLWriter.Close();
}
}
}
2 changes: 1 addition & 1 deletion IndustrialPark/Other/Triangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class Triangle
{
public int MaterialIndex;
public int materialIndex;

public int vertex1;
public int vertex2;
Expand Down
2 changes: 0 additions & 2 deletions IndustrialPark/SharpDX/SharpRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using SharpDX.Windows;
using System.Collections.Generic;
using static IndustrialPark.Models.OBJFunctions;
using System;
using System.Drawing;

namespace IndustrialPark
{
Expand Down

0 comments on commit 5449ccf

Please sign in to comment.