Exemple #1
0
		internal static void CheckMeshFaces(Mesh mesh, ErrorLogger logger) {
			for (int f = 0; f < mesh.Faces.Length; f++) {
				if (mesh.Faces[f].Vertices.Length <= 2) {
					logger.Add("Face " + (f + 1).ToString() + " has less than 3 vertices.");
				} else {
					int ai = mesh.Faces[f].Vertices[0];
					int bi = mesh.Faces[f].Vertices[1];
					int ci = mesh.Faces[f].Vertices[2];
					Vector3f a = mesh.Vertices[ai].Position;
					Vector3f b = mesh.Vertices[bi].Position;
					Vector3f c = mesh.Vertices[ci].Position;
					Vector3f ab = b - a;
					Vector3f ac = c - a;
					Vector3f dx = Vector3f.Normalize(ab);
					Vector3f dy = Vector3f.Normalize(Vector3f.Cross(Vector3f.Cross(ab, ac), ab));
					Vector2f[] projection = new Vector2f[mesh.Faces[f].Vertices.Length];
					for (int i = 0; i < mesh.Faces[f].Vertices.Length; i++) {
						int v = mesh.Faces[f].Vertices[i];
						float x = Vector3f.Dot(mesh.Vertices[v].Position - a, dx);
						float y = Vector3f.Dot(mesh.Vertices[v].Position - a, dy);
						projection[i] = new Vector2f(x, y);
					}
					int winding = Math.Sign(GetWinding(projection, 0));
					for (int i = 1; i < mesh.Faces[f].Vertices.Length; i++) {
						int value = Math.Sign(GetWinding(projection, i));
						if (value != winding) {
							logger.Add("Face " + (f + 1).ToString() + " has an incorrect winding. This usually indicates coinciding vertices, a concave or complex polygon, or a non-planar face. Line number: " + mesh.Faces[f].LineNumber.ToString());
							break;
						}
					}
				}
			}
		}
		public MeshDecodingOptions(TextureManager manager, ErrorLogger logger) {
			this.Manager = manager;
			this.Logger = logger;
		}
		// --- constructors ---
		
		public MeshDecodingOptions() {
			this.Manager = null;
			this.Logger = null;
		}
		// --- constructors ---
		
		internal FileInformation(bool isB3d, string file, bool strictParsing, ErrorLogger logger) {
			this.IsB3d = isB3d;
			this.File = file;
			this.StrictParsing = strictParsing;
			this.Logger = logger;
		}