source: GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.h @ 3261

Revision 3261, 1.8 KB checked in by mattausch, 16 years ago (diff)

worked on powerplant loading

Line 
1#ifndef _OBJCONVERTER_H
2#define _OBJCONVERTER_H
3
4#include "SimpleVec.h"
5#include <string>
6#include <vector>
7#include <map>
8
9
10struct Material
11{
12        float rgb[3];
13        int texture;
14};
15
16class Geometry;
17
18static std::string model_path("data/city/model/");
19
20
21typedef std::vector<SimpleVec> VertexArray;
22typedef std::pair<float, float> Texcoord;
23typedef std::map<std::string, Material *> MaterialTable;
24typedef std::map<std::string, int> TextureTable;
25
26typedef std::vector<std::string> TextureArray;
27
28class ogzstream;
29
30/** Converts obj format into objects readable by our format
31*/
32class ObjConverter
33{
34public:
35
36        ObjConverter();
37
38        bool Convert(const std::string &inputFilename,
39                         const std::string &outputFilename);
40                     // const std::string textureFilename) const;
41
42        bool LoadMaterials(const std::string &mtlFilename);
43
44        ~ObjConverter();
45
46protected:
47
48        struct Geometry
49        {
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
66                SimpleVec *mVertices;
67                SimpleVec *mNormals;
68                Texcoord *mTexcoords;
69                Material *mMaterial;
70
71                int mVertexCount;
72                int mTexcoordCount;
73        };
74
75typedef std::vector<Geometry *> GeometryArray;
76
77        void LoadShape(const VertexArray &faceVertices,
78                           const VertexArray &faceNormals,
79                                   const std::vector<Texcoord> &faceTexcoords,
80                                   Material *mat);
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
88        MaterialTable mMaterialTable;
89        TextureTable mTextureTable;
90       
91        TextureArray mTextures;
92        GeometryArray mGeometry;
93
94        int mNumShapes;
95};
96
97
98
99#endif
Note: See TracBrowser for help on using the repository browser.