Compare commits
2 Commits
6db4d75a37
...
eaf20f7f4a
Author | SHA1 | Date |
---|---|---|
Jarrod Doyle | eaf20f7f4a | |
Jarrod Doyle | dbabe1527c |
|
@ -62,7 +62,7 @@ public partial class Model : Node3D
|
|||
}
|
||||
}
|
||||
|
||||
var mesh = new ArrayMesh();
|
||||
var surfaceDataMap = new Dictionary<int, MeshSurfaceData>();
|
||||
foreach (var poly in modelFile.Polygons)
|
||||
{
|
||||
var vertices = new List<Vector3>();
|
||||
|
@ -83,17 +83,26 @@ public partial class Model : Node3D
|
|||
}
|
||||
}
|
||||
|
||||
var surfaceData = new MeshSurfaceData();
|
||||
surfaceData.AddPolygon(vertices, normal, uvs, uvs);
|
||||
var array = surfaceData.BuildSurfaceArray();
|
||||
mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, array);
|
||||
if (!surfaceDataMap.ContainsKey(poly.Data))
|
||||
{
|
||||
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 surfaceIdx = mesh.GetSurfaceCount();
|
||||
mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, array);
|
||||
for (var i = 0; i < materials.Count; i++)
|
||||
{
|
||||
var m = modelFile.Materials[i];
|
||||
if (m.Slot == poly.Data)
|
||||
if (m.Slot == materialId)
|
||||
{
|
||||
mesh.SurfaceSetMaterial(poly.Index, materials[i]);
|
||||
mesh.SurfaceSetMaterial(surfaceIdx, materials[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,8 @@ public partial class MissionSelector : Control
|
|||
_LoadButton.Disabled = true;
|
||||
|
||||
_Campaigns.AddItem("Original Missions");
|
||||
foreach (var c in Directory.GetDirectories(_installPaths.fmsPath))
|
||||
var paths = Directory.GetDirectories(_installPaths.fmsPath);
|
||||
foreach (var c in paths.OrderBy(s => s))
|
||||
{
|
||||
_Campaigns.AddItem(c.TrimPrefix(_installPaths.fmsPath));
|
||||
}
|
||||
|
@ -82,8 +83,8 @@ public partial class MissionSelector : Control
|
|||
}
|
||||
|
||||
string[] extensions = { "mis", "cow" };
|
||||
campaignPath = idx == 0 ? _installPaths.omsPath : _installPaths.fmsPath + _Campaigns.GetItemText((int)idx);
|
||||
foreach (var f in Directory.GetFiles(campaignPath))
|
||||
var paths = Directory.GetFiles(campaignPath);
|
||||
foreach (var f in paths.OrderBy(s => s))
|
||||
{
|
||||
if (extensions.Contains(f.GetExtension().ToLower()))
|
||||
{
|
||||
|
|
|
@ -59,7 +59,8 @@ public partial class ModelSelector : Control
|
|||
_Models.Clear();
|
||||
_LoadButton.Disabled = true;
|
||||
|
||||
foreach (var m in Directory.GetFiles(_extractedObjectsPath, "*.bin", SearchOption.AllDirectories))
|
||||
var paths = Directory.GetFiles(_extractedObjectsPath, "*.bin", SearchOption.AllDirectories);
|
||||
foreach (var m in paths.OrderBy(s => s))
|
||||
{
|
||||
_Models.AddItem(m.TrimPrefix(_extractedObjectsPath));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue