#ifndef _OBJCONVERTER2_H #define _OBJCONVERTER2_H #include "SimpleVec.h" #include #include #include struct Material { float rgb[3]; int texture; }; class Geometry; static std::string model_path("data/city/model/procedural_pompeii_area6_hires/"); 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 ObjConverter2 { public: ObjConverter2(); bool Convert(const std::string &inputFilename, const std::string &outputFilename); bool Convert2(const std::vector &filenames, const std::string &outputFilename); bool LoadMaterials(const std::string &mtlFilename); ~ObjConverter2(); 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