diff --git a/WFObj.cc b/WFObj.cc index 744066b..d827759 100644 --- a/WFObj.cc +++ b/WFObj.cc @@ -110,6 +110,9 @@ GLuint WFObj::render() vector vertices[VERTEX_TYPES]; int numVertsLast = 0; bool inFace = false; + bool inMaterial = false; + string currentMaterialName; + WFMtl material; for (int i = 0; i < len; i++) { string type = m_data[i][0]; @@ -227,9 +230,24 @@ GLuint WFObj::render() glEnd(); inFace = false; } + if (inMaterial) + { + material.renderEnd(currentMaterialName); + inMaterial = false; + } + if (m_data[i].size() >= 2) + { + currentMaterialName = m_data[i][1]; + material.renderBegin(currentMaterialName); + inMaterial = true; + } } else if (type == "mtllib") { + if (m_data[i].size() >= 2) + { + material.load(m_data[i][1]); + } } } if (inFace)