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