[3261] | 1 | #ifndef _OBJCONVERTER2_H
|
---|
| 2 | #define _OBJCONVERTER2_H
|
---|
| 3 |
|
---|
| 4 | #include "SimpleVec.h"
|
---|
| 5 | #include <string>
|
---|
| 6 | #include <vector>
|
---|
| 7 | #include <map>
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | struct Material
|
---|
| 11 | {
|
---|
| 12 | float rgb[3];
|
---|
| 13 | int texture;
|
---|
| 14 | };
|
---|
| 15 |
|
---|
| 16 | class Geometry;
|
---|
| 17 |
|
---|
| 18 | static std::string model_path("data/city/model/procedural_pompeii_area6_hires/");
|
---|
| 19 |
|
---|
| 20 |
|
---|
| 21 | typedef std::vector<SimpleVec> VertexArray;
|
---|
| 22 | typedef std::pair<float, float> Texcoord;
|
---|
| 23 | typedef std::map<std::string, Material *> MaterialTable;
|
---|
| 24 | typedef std::map<std::string, int> TextureTable;
|
---|
| 25 |
|
---|
| 26 | typedef std::vector<std::string> TextureArray;
|
---|
| 27 |
|
---|
| 28 | class ogzstream;
|
---|
| 29 |
|
---|
| 30 | /** Converts obj format into objects readable by our format
|
---|
| 31 | */
|
---|
| 32 | class ObjConverter2
|
---|
| 33 | {
|
---|
| 34 | public:
|
---|
| 35 |
|
---|
| 36 | ObjConverter2();
|
---|
| 37 |
|
---|
| 38 | bool Convert(const std::string &inputFilename,
|
---|
| 39 | const std::string &outputFilename);
|
---|
| 40 |
|
---|
| 41 | bool Convert2(const std::vector<std::string> &filenames,
|
---|
| 42 | const std::string &outputFilename);
|
---|
| 43 |
|
---|
| 44 | bool LoadMaterials(const std::string &mtlFilename);
|
---|
| 45 |
|
---|
| 46 | ~ObjConverter2();
|
---|
| 47 |
|
---|
| 48 | protected:
|
---|
| 49 |
|
---|
| 50 | struct Geometry
|
---|
| 51 | {
|
---|
| 52 | Geometry():
|
---|
| 53 | mVertices(NULL),
|
---|
| 54 | mNormals(NULL),
|
---|
| 55 | mTexcoords(NULL),
|
---|
| 56 | mMaterial(NULL),
|
---|
| 57 | mVertexCount(0),
|
---|
| 58 | mTexcoordCount(0)
|
---|
| 59 | {}
|
---|
| 60 |
|
---|
| 61 | ~Geometry()
|
---|
| 62 | {
|
---|
| 63 | delete [] mVertices;
|
---|
| 64 | delete [] mNormals;
|
---|
| 65 | delete [] mTexcoords;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | SimpleVec *mVertices;
|
---|
| 69 | SimpleVec *mNormals;
|
---|
| 70 | Texcoord *mTexcoords;
|
---|
| 71 | Material *mMaterial;
|
---|
| 72 |
|
---|
| 73 | int mVertexCount;
|
---|
| 74 | int mTexcoordCount;
|
---|
| 75 | };
|
---|
| 76 |
|
---|
| 77 | typedef std::vector<Geometry *> GeometryArray;
|
---|
| 78 |
|
---|
| 79 | void LoadShape(const VertexArray &faceVertices,
|
---|
| 80 | const VertexArray &faceNormals,
|
---|
| 81 | const std::vector<Texcoord> &faceTexcoords,
|
---|
| 82 | Material *mat);
|
---|
| 83 |
|
---|
| 84 | void WriteGeometry(ogzstream &str, Geometry *geom);
|
---|
| 85 |
|
---|
| 86 | bool ReadFile(const std::string &inputFilename);
|
---|
| 87 | bool WriteFile(const std::string &outputFilename);
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 | MaterialTable mMaterialTable;
|
---|
| 91 | TextureTable mTextureTable;
|
---|
| 92 |
|
---|
| 93 | TextureArray mTextures;
|
---|
| 94 | GeometryArray mGeometry;
|
---|
| 95 |
|
---|
| 96 | int mNumShapes;
|
---|
| 97 | };
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 | #endif
|
---|