public WavefrontModel(string name, string filename, string textureFilename, string normalsFilename) { Name = name; TintColor = new Vector4(1, 1, 0, 0); // alpha is intensity // load model if (WavefrontLoader.Load(this, filename)) { Log.WriteLine(Log.LOG_INFO, "WavefrontModel '" + name + "' loaded " + vertices.Length + " vertices, " + normals.Length + " normals, " + texCoords.Length + " texture coords, " + indices.Length + " indices, " + "using " + PolygonType.ToString() + " -> " + (indices.Length / (PolygonType == PrimitiveType.Quads ? 4 : 3)) + " polygons"); } else { Log.WriteLine(Log.LOG_ERROR, "WavefrontModel '" + name + "' failed loading '" + filename + "' - might be incompatible"); return; } // load material material = new TextureMaterial(textureFilename, normalsFilename, normals.Length > 0, true); if (!material.Ready) { Log.WriteLine(Log.LOG_ERROR, "failed to load WavefrontModel material"); return; } // sanity check for normal information /* * if (!material.UseNormalMap && normals.Length == 0) * { * Log.WriteLine(Log.LOG_ERROR, "WavefrontModel '" + name + "' is not using a normal map and does not have vertex normals"); * return; * }*/ // create GL objects createVBOs(); createVAOs(); ready = true; }
public static Model ReadModel(string filename) => WavefrontLoader.Read(Encoding.ASCII.GetString(ReadAllBytes(filename)));