Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed May 7, 2020
1 parent 93dfb54 commit b603ddd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 12 additions & 9 deletions IndustrialPark/Models/Model_IO_Assimp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static RWSection[] CreateDFFFromAssimp(string fileName, bool flipUVs, boo
(flipUVs ? PostProcessSteps.FlipUVs : 0);

Scene scene = new AssimpContext().ImportFile(fileName, pps);

int vertexCount = scene.Meshes.Sum(m => m.VertexCount);
int triangleCount = scene.Meshes.Sum(m => m.FaceCount);

Expand All @@ -117,7 +117,7 @@ public static RWSection[] CreateDFFFromAssimp(string fileName, bool flipUVs, boo
materialStruct = new MaterialStruct_0001()
{
unusedFlags = 0,
color = ignoreMeshColors ?
color = ignoreMeshColors ?
new RenderWareFile.Color(255, 255, 255, 255) :
new RenderWareFile.Color(
(byte)(m.ColorDiffuse.R * 255),
Expand Down Expand Up @@ -154,27 +154,27 @@ public static RWSection[] CreateDFFFromAssimp(string fileName, bool flipUVs, boo
} : null,
materialExtension = new Extension_0003(),
});

List<Vertex3> vertices = new List<Vertex3>();
List<Vertex3> normals = new List<Vertex3>();
List<Vertex2> textCoords = new List<Vertex2>();
List<RenderWareFile.Color> vertexColors = new List<RenderWareFile.Color>();
List<RenderWareFile.Triangle> triangles = new List<RenderWareFile.Triangle>();

foreach (var m in scene.Meshes)
{
int totalVertices = vertices.Count;

foreach (Vector3D v in m.Vertices)
vertices.Add(new Vertex3(v.X, v.Y, v.Z));

foreach (Vector3D v in m.Normals)
normals.Add(new Vertex3(v.X, v.Y, v.Z));

if (m.HasTextureCoords(0))
foreach (Vector3D v in m.TextureCoordinateChannels[0])
textCoords.Add(new Vertex2(v.X, v.Y));
else
else
for (int i = 0; i < m.VertexCount; i++)
textCoords.Add(new Vertex2(0, 0));

Expand Down Expand Up @@ -391,7 +391,7 @@ public static RWSection[] CreateDFFFromAssimp(string fileName, bool flipUVs, boo

clumpExtension = new Extension_0003()
};

return new RWSection[] { clump };
}

Expand Down Expand Up @@ -428,7 +428,7 @@ public static void ExportAssimp(string fileName, RWSection[] bspFile, bool flipU
PostProcessSteps.PreTransformVertices |
PostProcessSteps.RemoveRedundantMaterials |
PostProcessSteps.Triangulate |
PostProcessSteps.ValidateDataStructure|
PostProcessSteps.ValidateDataStructure |
(flipUVs ? PostProcessSteps.FlipUVs : 0));
}

Expand All @@ -453,7 +453,10 @@ private static void WorldToScene(Scene scene, World_000B world, string textureEx
Name = mat.materialStruct.isTextured != 0 ? "mat_" + mat.texture.diffuseTextureName.stringString : default,
});

scene.Meshes.Add(new Mesh(PrimitiveType.Triangle) { MaterialIndex = i, Name = "mesh_" +
scene.Meshes.Add(new Mesh(PrimitiveType.Triangle)
{
MaterialIndex = i,
Name = "mesh_" +
(mat.materialStruct.isTextured != 0 ? mat.texture.diffuseTextureName.stringString : ("default_" + i.ToString()))
});
}
Expand Down
1 change: 1 addition & 0 deletions IndustrialPark/SharpDX/SharpRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ public void RunMainLoop(Panel Panel)
tintedShader.Dispose();

foreach (SharpMesh mesh in RenderWareModelFile.completeMeshList)
if (mesh != null)
mesh.Dispose();

device.Dispose();
Expand Down

0 comments on commit b603ddd

Please sign in to comment.