SO3Engine
ALMaterial.h
Go to the documentation of this file.
1#ifndef ALMATERIAL_H
2#define ALMATERIAL_H
3
4#include "ALObject.h"
5
6// boost
7#include <boost/filesystem.hpp>
8
9namespace SO3
10{
11 class ALScene;
12
14 struct ALColors
15 {
16 aiColor4D diffuse;
17 aiColor4D specular;
18 aiColor4D ambient;
19 aiColor4D emissive;
20 aiColor4D transparence;
21 };
22
24 struct ALMatInfo
25 {
26 std::string name;
27
28 float opacity;
29 float shininess;
31
33 bool isWire;
35 };
36
39 {
40 std::string path;
41 std::string embname;
43 aiTextureType type;
44 aiTextureMapping mapping;
45 unsigned int uvindex;
46 float blend;
48 aiTextureOp op;
49 aiTextureMapMode mapmode[3];
50 };
51
54 {
55 // Colors textures;
61
62 // Relief related textures.
66
67 // Light related textures.
74 };
75
81 {
82 public:
92 ALMaterial(ALScene* alscene, aiMaterial* srcMaterial, bool useVertexColor = false);
93
95
100 std::string convertToScol(bool clearFile=true);
101
102 std::string convert(boost::filesystem::path expPath, bool clearFile=false);
103 SMaterial* load();
104
105 private:
107 void getColorInfo();
108
110 void getMatInfo();
111
113 void getTexturesInfo();
114
116 void getTexturesCount();
117
119 void manageTexturePath(ALTextureData* texData, boost::filesystem::path expPath);
120
122 void buildData(int count, aiTextureType type, std::vector<ALTextureData>& datas);
123
125 void buildSTexture();
126
128 void writeOgreScript(std::ostream& script, boost::filesystem::path expPath);
129
131 void writeTechnique(std::ostream& script, boost::filesystem::path expPath, bool extended = false, bool basicscheme = false);
132
134 void writePass(std::ostream& script, boost::filesystem::path expPath, bool extended = false);
135
137 void writeTextureUnit(std::ostream& script, boost::filesystem::path expPath, bool extended = false);
138
140 std::string getTextureName(ALTextureData texData, bool full, bool& createTex);
141
143 STexture* createOrRetrieveTexture(std::string name, std::string path, bool create);
144
145 STexture* createOrRetrieveTexture(std::string name, Ogre::Image image, bool create);
146
147 STexture* loadTexture(ALTextureData* texData, std::string tname, bool createTex, bool &isCubic);
148
149 ALColors mColors;
150 aiMaterial* mMat;
151 ALScene* mScene;
152 bool mUseVertexColor;
153 bool mCutout;
154 bool mUseAlpha;
155 bool mHaveAlphaDetails;
156
157 std::vector<ALTextureData> texInfo;
158 ALTexturesCount texCount;
159 ALMatInfo matInfo;
160
161 std::vector<STexture*> scolTex;
162 SMaterial* scolMat;
163 };
164};
165
166#endif // ALMATERIAL_H
SMaterial * load()
std::string convert(boost::filesystem::path expPath, bool clearFile=false)
std::string convertToScol(bool clearFile=true)
Contain the colors information of a material.
Definition ALMaterial.h:15
aiColor4D specular
Definition ALMaterial.h:17
aiColor4D emissive
Definition ALMaterial.h:19
aiColor4D transparence
Definition ALMaterial.h:20
aiColor4D ambient
Definition ALMaterial.h:18
aiColor4D diffuse
Definition ALMaterial.h:16
Contain basic information about a material.
Definition ALMaterial.h:25
std::string name
Definition ALMaterial.h:26
float reflectivity
Definition ALMaterial.h:30
Contain the texture's meta-data.
Definition ALMaterial.h:39
std::string embname
Definition ALMaterial.h:41
aiTextureType type
Definition ALMaterial.h:43
aiTextureMapping mapping
Definition ALMaterial.h:44
aiTextureMapMode mapmode[3]
Definition ALMaterial.h:49
aiTextureOp op
Definition ALMaterial.h:48
std::string path
Definition ALMaterial.h:40
unsigned int uvindex
Definition ALMaterial.h:45
Contain the number of each type of texture possible.
Definition ALMaterial.h:54