From 51c0ded005ad323ef0c3eead5a998d99816276a0 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 19 Apr 2011 17:05:17 -0400 Subject: [PATCH] fix compilation errors; compiling! --- WFObj.cc | 27 +++++++++++++++++++++------ WFObj.h | 15 ++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/WFObj.cc b/WFObj.cc index 60dd298..9dd8c6b 100644 --- a/WFObj.cc +++ b/WFObj.cc @@ -3,8 +3,9 @@ #include #include #include -#include // isspace() -#include // strlen() +#include /* isspace() */ +#include /* strlen() */ +#include /* atoi */ #include #include #include @@ -125,9 +126,9 @@ bool WFObj::load(const WFObj::Buffer &buff) { string buildup; size_t idx = 0; - while (idx < buff.size) + while (idx < buff.length) { - string line = getLine(buff, idx, &idx) + string line = getLine(buff, idx, &idx); string input = trimString(line); int sz = input.size(); if (sz == 0 || input[0] == '#') @@ -148,7 +149,7 @@ bool WFObj::load(const WFObj::Buffer &buff) return true; } -string WFObj::getLine(const Buff & buff, size_t idx, size_t *update_idx) +string WFObj::getLine(const Buffer & buff, size_t idx, size_t *update_idx) { size_t len = 0; while (idx + len < buff.length) @@ -198,7 +199,9 @@ void WFObj::processInputLine(const std::string & input) { if (m_faces.find(m_current_material_name) == m_faces.end()) m_faces[m_current_material_name] = vector(); - m_faces[m_current_material_name].push_back(readFace(tokens)); + vector faces = readFaces(tokens); + for (vector::iterator it = faces.begin(); it != faces.end(); it++) + m_faces[m_current_material_name].push_back(*it); } else if (type == "usemtl") { @@ -226,6 +229,7 @@ void WFObj::processInputLine(const std::string & input) void WFObj::updateAABB(const float * const vertex) { +#ifdef TODO if (m_loadedVertex) { if (vertex[0] < m_aabb[0]) @@ -248,6 +252,7 @@ void WFObj::updateAABB(const float * const vertex) m_aabb[2] = m_aabb[5] = vertex[2]; m_loadedVertex = true; } +#endif } WFObj::Vertex WFObj::readVertex(const vector & parts) @@ -308,3 +313,13 @@ WFObj::VertexRef WFObj::readVertexRef(const std::string ref) } return fr; } + +void WFObj::loadMaterial(const std::string & name) +{ + /* TODO */ +} + +bool WFObj::loadfile(const char *path, Buffer *buff) +{ + /* TODO */ +} diff --git a/WFObj.h b/WFObj.h index bfc0d74..9e5cae5 100644 --- a/WFObj.h +++ b/WFObj.h @@ -11,9 +11,6 @@ class WFObj { public: /* types */ - typedef bool (*loadfile_t)(const char *fname, Buffer *buff); - typedef GLuint (*loadtexture_t)(const char *fname); - class Buffer { public: @@ -21,6 +18,9 @@ public: size_t length; }; + typedef bool (*loadfile_t)(const char *fname, Buffer *buff); + typedef GLuint (*loadtexture_t)(const char *fname); + enum { VERTEX, VERTEX_TEXTURE, VERTEX_NORMAL, VERTEX_TYPES }; /* constructors */ @@ -66,14 +66,15 @@ protected: std::vector readFaces(const std::vector & parts); VertexRef readVertexRef(const std::string ref); void updateAABB(const float * const vertex); - static Buffer loadfile(const char *path); - std::string getLine(const Buff & buff, size_t idx, size_t *update_idx); + static bool loadfile(const char *path, Buffer *buff); + std::string getLine(const Buffer & buff, size_t idx, size_t *update_idx); + void loadMaterial(const std::string & name); /* variables */ - std::vector m_vertices[VERTEX_TYPES]; + std::vector m_vertices[VERTEX_TYPES]; std::map< std::string, std::vector< Face > > m_faces; - FileLoader::Path m_path; float m_aabb[6]; + std::string m_path; loadfile_t m_loadfile; loadtexture_t m_loadtexture; std::string m_current_material_name;