public GenericMesh(MeshExportOptions options) { ExportOptions = options; Vertices = new List<Vector3>(); Normals = new List<Vector3>(); TexCoords = new List<Vector3>(); Faces = new List<GenericFace>(); }
public void ApplyExportOptions(MeshExportOptions options) { if (!exportOptionsApplied || !options.Equals(ExportOptions)) { // If these settings haven't already been applied if (options.NormalExportMode == MeshNormalExportMode.CalculateNormalsFlatShaded) { RecalculateNormalsFlatShaded(); } else if (options.NormalExportMode == MeshNormalExportMode.CalculateNormalsSmoothShaded) { RecalculateNormalsSmoothShaded(); } else { // Use already set up normals } Vertices = Vertices.Select(vertex => Vector3.Transform(vertex, options.Matrix)).ToList(); Normals = Normals .Select(normal => Vector3.Normalize(Vector3.TransformNormal(normal, options.Matrix) * (options.InvertNormals ? -1.0f : 1.0f))) .ToList(); if (options.ReverseFaceWinding) { Faces = Faces.Select(face => GenericFace.ReverseWinding(face)).ToList(); } exportOptionsApplied = true; } }