diff --git a/WFObj.cc b/WFObj.cc index f9afc5d..e6ac16c 100644 --- a/WFObj.cc +++ b/WFObj.cc @@ -123,6 +123,7 @@ void WFObj::clear() for (int i = 0; i < sizeof(m_vertices)/sizeof(m_vertices[0]); i++) m_vertices[i].clear(); m_faces.clear(); + m_face_indices.clear(); m_materials.clear(); m_valid = false; m_path = ""; @@ -451,6 +452,8 @@ bool WFObj::buildVBO() it != m_faces.end(); it++) { + int first = vid; + int num = 0; for (vector::iterator fit = it->second.begin(); fit != it->second.end(); fit++) @@ -473,9 +476,13 @@ bool WFObj::buildVBO() if (vf.texture != 0) texture_ref_count++; if (flat_vertices.find(vf) == flat_vertices.end()) + { flat_vertices[vf] = vid++; + num++; + } } } + m_face_indices[it->first] = make_pair(first, num); } if (texture_ref_count == 0) do_textures = false; diff --git a/WFObj.h b/WFObj.h index a5d4379..5e218ad 100644 --- a/WFObj.h +++ b/WFObj.h @@ -104,6 +104,7 @@ protected: /* variables */ std::vector m_vertices[VERTEX_TYPES]; std::map< std::string, std::vector< Face > > m_faces; + std::map< std::string, std::pair > m_face_indices; std::map< std::string, Material > m_materials; float m_aabb[6]; std::string m_path;