1 | #if !defined(__OGRE_MAX_CONFIG_H__) |
---|
2 | #define __OGRE_MAX_CONFIG_H__ |
---|
3 | |
---|
4 | #include <string> |
---|
5 | #include "tchar.h" |
---|
6 | |
---|
7 | namespace OgreMax { |
---|
8 | |
---|
9 | const int NAME_MAX_LEN = 256; |
---|
10 | const int MAX_PATH = 260; // same as Windows -- no point in including windows.h for that |
---|
11 | const unsigned int CURRENTVERSION = 2; |
---|
12 | |
---|
13 | typedef enum { |
---|
14 | DIRECT3D = 0, |
---|
15 | OPENGL |
---|
16 | } VertexColourFormat; |
---|
17 | |
---|
18 | typedef enum { |
---|
19 | NATIVE = 0, |
---|
20 | BIG, |
---|
21 | LITTLE |
---|
22 | } Endian; |
---|
23 | |
---|
24 | typedef enum { |
---|
25 | UV, |
---|
26 | VW, |
---|
27 | WU |
---|
28 | } Tex2D; |
---|
29 | |
---|
30 | |
---|
31 | // class for managing exporter configuration data |
---|
32 | class Config |
---|
33 | { |
---|
34 | public: |
---|
35 | Config(); |
---|
36 | Config(const Config& config); // copy c'tor |
---|
37 | virtual ~Config(); |
---|
38 | |
---|
39 | // serialization |
---|
40 | void save(); |
---|
41 | void load(); |
---|
42 | |
---|
43 | // assignment operator |
---|
44 | Config& operator=(const Config& rhs); |
---|
45 | |
---|
46 | // |
---|
47 | // General Exporter Settings |
---|
48 | // |
---|
49 | // exporting one file per object or putting all objects as submeshes in a single file |
---|
50 | void setExportMultipleFiles(bool exportMultipleFiles); |
---|
51 | bool getExportMultipleFiles() const { return m_exportMultipleFiles; } |
---|
52 | |
---|
53 | // exporting one file per object or putting all objects as submeshes in a single file |
---|
54 | void setUseSingleSkeleton(bool singleSkeleton); |
---|
55 | bool getUseSingleSkeleton() const { return m_useSingleSkeleton; } |
---|
56 | |
---|
57 | // enable skeleton file export |
---|
58 | void setExportSkeleton(bool useSkeleton); |
---|
59 | bool getExportSkeleton() const { return m_exportSkeleton; } |
---|
60 | |
---|
61 | // enable material file export |
---|
62 | void setExportMaterial(bool exportMaterial); |
---|
63 | bool getExportMaterial() const { return m_exportMaterial; } |
---|
64 | |
---|
65 | // enable mesh binary file export |
---|
66 | void setExportBinaryMesh(bool export); |
---|
67 | bool getExportBinaryMesh() const { return m_exportBinaryMesh; } |
---|
68 | |
---|
69 | // enable mesh XML file export |
---|
70 | void setExportXMLMesh(bool export); |
---|
71 | bool getExportXMLMesh() const { return m_exportXMLMesh; } |
---|
72 | |
---|
73 | // enable vertex color export |
---|
74 | void setExportVertexColours(bool exportVC); |
---|
75 | bool getExportVertexColours() const { return m_exportVertexColors; } |
---|
76 | |
---|
77 | // rebuild normals on export |
---|
78 | void setRebuildNormals(bool rebuild); |
---|
79 | bool getRebuildNormals() const { return m_rebuildNormals; } |
---|
80 | |
---|
81 | // invert normals on export |
---|
82 | void setInvertNormals(bool invert); |
---|
83 | bool getInvertNormals() const { return m_invertNormals; } |
---|
84 | |
---|
85 | // invert Y and Z on export (rotate 90 in other words) |
---|
86 | void setInvertYZ(bool invert); |
---|
87 | bool getInvertYZ() const { return m_flipYZ; } |
---|
88 | |
---|
89 | // default material name to use when none is provided for a mesh |
---|
90 | void setDefaultMaterialName(const std::string& materialName); |
---|
91 | const std::string& getDefaultMaterialName() const { return m_defaultMaterialName; } |
---|
92 | |
---|
93 | // set scale to use when exporting |
---|
94 | void setScale(float scale); |
---|
95 | float getScale() const { return m_scale; } |
---|
96 | |
---|
97 | // set fps to use when sampling keyframes |
---|
98 | void setFPS(float fps); |
---|
99 | float getFPS() const { return m_fps; } |
---|
100 | |
---|
101 | // set fps to use when sampling keyframes |
---|
102 | void setTexCoord2D(Tex2D texCoord); |
---|
103 | Tex2D getTexCoord2D() const { return m_2DTexCoord; } |
---|
104 | |
---|
105 | // export directory |
---|
106 | void setExportPath(const std::string& path); |
---|
107 | const std::string& getExportPath() const { return m_exportPath; } |
---|
108 | |
---|
109 | // export filename |
---|
110 | void setExportFilename(const std::string& name); |
---|
111 | const std::string& getExportFilename() const { return m_exportFilename; } |
---|
112 | |
---|
113 | // export basename -- this is read-only, based on the filename the user set coming in |
---|
114 | const std::string& getExportBasename() const { return m_exportBasename; } |
---|
115 | |
---|
116 | // material filename |
---|
117 | void setMaterialFilename(const std::string& filename); |
---|
118 | const std::string& getMaterialFilename() const { return m_materialFilename; } |
---|
119 | |
---|
120 | // skeleton filename |
---|
121 | void setSkeletonFilename(const std::string& filename); |
---|
122 | const std::string& getSkeletonFilename() const { return m_skeletonFilename; } |
---|
123 | |
---|
124 | // |
---|
125 | // Binary mesh export settings |
---|
126 | // |
---|
127 | // tangent vector generation |
---|
128 | void setGenerateTangents(bool generateTangents); |
---|
129 | bool getGenerateTangents() const { return m_generateTangents; } |
---|
130 | |
---|
131 | // automatic LoD generation |
---|
132 | void setGenerateLod(bool generateLod); |
---|
133 | bool getGenerateLod() const { return m_generateLod; } |
---|
134 | |
---|
135 | // edge lists |
---|
136 | void setBuildEdgeLists(bool buildEdgeLists); |
---|
137 | bool getBuildEdgeLists() const { return m_edgeLists; } |
---|
138 | |
---|
139 | // optimize layout |
---|
140 | void setOptmizeBinaryMesh(bool optimize); |
---|
141 | bool getOptmizeBinaryMesh() const { return m_optimizeBinaryLayout; } |
---|
142 | |
---|
143 | // vertex colour format |
---|
144 | void setVertexColourFormat(VertexColourFormat format); |
---|
145 | VertexColourFormat getVertexColourFormat() const { return m_colourFormat; } |
---|
146 | |
---|
147 | // endianness |
---|
148 | void setEndian(Endian endian); |
---|
149 | Endian getEndian() const { return m_endian; } |
---|
150 | |
---|
151 | // number of LoD levels |
---|
152 | void setNumLodLevels(unsigned int levels); |
---|
153 | unsigned int getNumLodLevels() const { return m_numLodLevels; } |
---|
154 | |
---|
155 | // LoD distance |
---|
156 | void setLodDistance(float distance); |
---|
157 | float getLodDistance() const { return m_lodDistance; } |
---|
158 | |
---|
159 | // LoD percent reduction |
---|
160 | void setLodPercentReduction(float percent); |
---|
161 | float getLodPercentReduction() const { return m_lodPercent; } |
---|
162 | |
---|
163 | // LoD vertex reduction |
---|
164 | void setLodVertexReduction(int count); |
---|
165 | int getLodVertexReduction() const { return m_lodVertexCount; } |
---|
166 | |
---|
167 | // export only selected or all objects |
---|
168 | void setExportSelected(bool selected); |
---|
169 | bool getExportSelected() const { return m_exportSelectedObjects; } |
---|
170 | |
---|
171 | // |
---|
172 | // version 2 |
---|
173 | // |
---|
174 | // merge meshes based on material likeness |
---|
175 | void setMergeMeshes(bool merge); |
---|
176 | bool getMergeMeshes() const { return m_mergeMeshes; } |
---|
177 | |
---|
178 | private: |
---|
179 | |
---|
180 | // config file version number -- use this to tell if new features are saved in the file or not. |
---|
181 | // Version 1 was a basic XML exporter (mesh, material and Biped animation skeleton) |
---|
182 | unsigned int m_version; |
---|
183 | |
---|
184 | // general exporter settings |
---|
185 | bool m_exportMultipleFiles; // export subobjects to multiple mesh or XML files |
---|
186 | bool m_useSingleSkeleton; // use a single skeleton file when exporting multiple mesh files |
---|
187 | bool m_exportSkeleton; // export skeleton file for skeletal animation |
---|
188 | bool m_rebuildNormals; // rebuild mesh normals prior to export |
---|
189 | bool m_exportMaterial; // alernate is to use default material |
---|
190 | bool m_invertNormals; // flip normals in the mesh on export |
---|
191 | bool m_flipYZ; // flip the "up" axis to/from Z and Y |
---|
192 | bool m_exportVertexColors; // export vertex colors |
---|
193 | float m_scale; // scale to use when exporting |
---|
194 | float m_fps; // default keyframe sampling rate |
---|
195 | Tex2D m_2DTexCoord; // interpretation of 2D texture coordinates (UV, VW, WU) |
---|
196 | |
---|
197 | // XML mesh settings |
---|
198 | bool m_exportXMLMesh; |
---|
199 | |
---|
200 | // binary mesh settings |
---|
201 | bool m_exportBinaryMesh; // enable binary mesh export |
---|
202 | bool m_optimizeBinaryLayout; // enable binary mesh layout optimization |
---|
203 | bool m_generateTangents; // generate tangents (normal/offset mapping) |
---|
204 | bool m_generateLod; // generate LoD meshes automatically |
---|
205 | bool m_edgeLists; // build edge lists (shadow volumes) |
---|
206 | float m_lodDistance; // distance increment per LoD level |
---|
207 | unsigned int m_numLodLevels; // number of LoD meshes to generate |
---|
208 | float m_lodPercent; // if > 0.0, decimate on a percentage reduction basis |
---|
209 | int m_lodVertexCount; // if > 0, decimate on a vertex count reduction basis |
---|
210 | VertexColourFormat m_colourFormat; // Direct3D or OpenGL |
---|
211 | Endian m_endian; // Native, Big or Little |
---|
212 | |
---|
213 | |
---|
214 | TCHAR m_bufDefaultMaterialName[NAME_MAX_LEN]; // actual buffer written when config saved to disk |
---|
215 | TCHAR m_bufExportPath[MAX_PATH]; // actual buffer written when config saved to disk |
---|
216 | TCHAR m_bufExportBasename[NAME_MAX_LEN]; // actual buffer written when config saved to disk |
---|
217 | TCHAR m_bufExportFilename[NAME_MAX_LEN]; // actual buffer written when config saved to disk |
---|
218 | TCHAR m_bufMaterialFilename[NAME_MAX_LEN]; // actual buffer written when config saved to disk |
---|
219 | TCHAR m_bufSkeletonFilename[NAME_MAX_LEN]; // actual buffer written when config saved to disk |
---|
220 | |
---|
221 | |
---|
222 | // add new version data after this point |
---|
223 | |
---|
224 | // version 2 -- added mesh merge capability |
---|
225 | bool m_mergeMeshes; // merge submeshes into single mesh based on material likeness |
---|
226 | |
---|
227 | |
---|
228 | // since we are doing a new-in-place type of config save/load (because I'm lazy) we can't write these to disk, and |
---|
229 | // instead have to "fix" them up on config load and write them out to the buffers above on save. These are used, however, |
---|
230 | // for the convenience of the setter/getters in the class. |
---|
231 | std::string m_defaultMaterialName; // default material name to use when none is provided for a mesh |
---|
232 | std::string m_exportPath; // path to contain exported files |
---|
233 | std::string m_exportFilename; // exported base filename |
---|
234 | std::string m_exportBasename; // exported base filename, sans extension |
---|
235 | std::string m_materialFilename; // exported material filename |
---|
236 | std::string m_skeletonFilename; // exported skeleton filename (for shared skeleton export) |
---|
237 | |
---|
238 | // we can also track temporary info that we do not want to save in the config file, but want to pass around in |
---|
239 | // the config object |
---|
240 | bool m_exportSelectedObjects; // true = export only selected objects, false = export all objects |
---|
241 | |
---|
242 | }; |
---|
243 | } |
---|
244 | |
---|
245 | |
---|
246 | #endif |
---|