Compare commits

..

No commits in common. "eaf20f7f4a7bd88dd5ea9b1fd2670ed232893ebd" and "6db4d75a37e974aad5883769ef6a3d78c8ae1901" have entirely different histories.

3 changed files with 10 additions and 21 deletions

View File

@ -62,7 +62,7 @@ public partial class Model : Node3D
} }
} }
var surfaceDataMap = new Dictionary<int, MeshSurfaceData>(); var mesh = new ArrayMesh();
foreach (var poly in modelFile.Polygons) foreach (var poly in modelFile.Polygons)
{ {
var vertices = new List<Vector3>(); var vertices = new List<Vector3>();
@ -83,26 +83,17 @@ public partial class Model : Node3D
} }
} }
if (!surfaceDataMap.ContainsKey(poly.Data)) var surfaceData = new MeshSurfaceData();
{ surfaceData.AddPolygon(vertices, normal, uvs, uvs);
surfaceDataMap.Add(poly.Data, new MeshSurfaceData());
}
surfaceDataMap[poly.Data].AddPolygon(vertices, normal, uvs, uvs);
}
var mesh = new ArrayMesh();
foreach (var (materialId, surfaceData) in surfaceDataMap)
{
var array = surfaceData.BuildSurfaceArray(); var array = surfaceData.BuildSurfaceArray();
var surfaceIdx = mesh.GetSurfaceCount();
mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, array); mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, array);
for (var i = 0; i < materials.Count; i++) for (var i = 0; i < materials.Count; i++)
{ {
var m = modelFile.Materials[i]; var m = modelFile.Materials[i];
if (m.Slot == materialId) if (m.Slot == poly.Data)
{ {
mesh.SurfaceSetMaterial(surfaceIdx, materials[i]); mesh.SurfaceSetMaterial(poly.Index, materials[i]);
break; break;
} }
} }

View File

@ -60,8 +60,7 @@ public partial class MissionSelector : Control
_LoadButton.Disabled = true; _LoadButton.Disabled = true;
_Campaigns.AddItem("Original Missions"); _Campaigns.AddItem("Original Missions");
var paths = Directory.GetDirectories(_installPaths.fmsPath); foreach (var c in Directory.GetDirectories(_installPaths.fmsPath))
foreach (var c in paths.OrderBy(s => s))
{ {
_Campaigns.AddItem(c.TrimPrefix(_installPaths.fmsPath)); _Campaigns.AddItem(c.TrimPrefix(_installPaths.fmsPath));
} }
@ -83,8 +82,8 @@ public partial class MissionSelector : Control
} }
string[] extensions = { "mis", "cow" }; string[] extensions = { "mis", "cow" };
var paths = Directory.GetFiles(campaignPath); campaignPath = idx == 0 ? _installPaths.omsPath : _installPaths.fmsPath + _Campaigns.GetItemText((int)idx);
foreach (var f in paths.OrderBy(s => s)) foreach (var f in Directory.GetFiles(campaignPath))
{ {
if (extensions.Contains(f.GetExtension().ToLower())) if (extensions.Contains(f.GetExtension().ToLower()))
{ {

View File

@ -59,8 +59,7 @@ public partial class ModelSelector : Control
_Models.Clear(); _Models.Clear();
_LoadButton.Disabled = true; _LoadButton.Disabled = true;
var paths = Directory.GetFiles(_extractedObjectsPath, "*.bin", SearchOption.AllDirectories); foreach (var m in Directory.GetFiles(_extractedObjectsPath, "*.bin", SearchOption.AllDirectories))
foreach (var m in paths.OrderBy(s => s))
{ {
_Models.AddItem(m.TrimPrefix(_extractedObjectsPath)); _Models.AddItem(m.TrimPrefix(_extractedObjectsPath));
} }