#ifndef WFOBJ_H #define WFOBJ_H #include #include #include #include class WFObj { public: typedef GLuint (*loadTextureFunc_t)(const char * texture); typedef void * (*loadFileFunc_t)(const char * filename, unsigned int * length); bool load(const std::string & filename, loadTextureFunc_t loadTexture = NULL, loadFileFunc_t loadFile = NULL); GLuint render(bool doTextureInfo = true); const float * const getAABB() { return m_aabb; } protected: /* types */ class Vertex { public: float operator[](int idx) const { return data[idx]; } float & operator[](int idx) { return data[idx]; } float * getData() { return data; } private: float data[4]; }; /* methods */ void clear(); int filesize(const char * filename); void processInputLine(const std::string & input); Vertex readVertex(const std::vector & parts); void parseVertexIndices(const std::string & vtxref, int * ret); void updateAABB(const float * const vertex); bool load(std::istream & istr, unsigned int size); /* variables */ std::vector< std::vector > m_data; loadTextureFunc_t m_loadTexture; loadFileFunc_t m_loadFile; std::string m_fileName; float m_aabb[6]; bool m_loadedVertex; }; class WFMtl { public: bool load(const std::string & filename, WFObj::loadTextureFunc_t loadTexture = NULL, WFObj::loadFileFunc_t loadFile = NULL); void renderBegin(const std::string & mtlname, bool doTextureInfo = true); void renderEnd(const std::string & mtlname, bool doTextureInfo = true); protected: /* methods */ void clear(); int filesize(const char * filename); void processInputLine(const std::string & input); void pushAttributes(); bool load(std::istream & istr, unsigned int size); /* variables */ std::map< std::string, std::vector< std::vector > > m_data; std::string m_currentMaterialName; bool m_attributesPushed; WFObj::loadTextureFunc_t m_loadTexture; std::string m_fileName; }; #endif