#ifndef _OBJCONVERTER_H #define _OBJCONVERTER_H #include "SimpleVec.h" #include #include #include struct Material { float rgb[3]; int texture; }; class Geometry; static std::string model_path("data/city/model/"); typedef std::vector VertexArray; typedef std::pair Texcoord; typedef std::map MaterialTable; typedef std::map TextureTable; typedef std::vector TextureArray; class ogzstream; /** Converts obj format into objects readable by our format */ class ObjConverter { public: ObjConverter(); bool Convert(const std::string &inputFilename, const std::string &outputFilename); // const std::string textureFilename) const; bool LoadMaterials(const std::string &mtlFilename); ~ObjConverter(); protected: struct Geometry { Geometry(): mVertices(NULL), mNormals(NULL), mTexcoords(NULL), mMaterial(NULL), mVertexCount(0), mTexcoordCount(0) {} ~Geometry() { delete [] mVertices; delete [] mNormals; delete [] mTexcoords; } SimpleVec *mVertices; SimpleVec *mNormals; Texcoord *mTexcoords; Material *mMaterial; int mVertexCount; int mTexcoordCount; }; typedef std::vector GeometryArray; void LoadShape(const VertexArray &faceVertices, const VertexArray &faceNormals, const std::vector &faceTexcoords, Material *mat); void WriteGeometry(ogzstream &str, Geometry *geom); bool ReadFile(const std::string &inputFilename); bool WriteFile(const std::string &outputFilename); MaterialTable mMaterialTable; TextureTable mTextureTable; TextureArray mTextures; GeometryArray mGeometry; int mNumShapes; }; #endif