/home/tetron/hack/vos/libs/vos/metaobjects/a3dl/material.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MATERIAL_HH_
00024 #define _MATERIAL_HH_
00025
00026
00027 #include "a3dldefs.hh"
00028 #include <vos/vos/vos.hh>
00029
00030 #ifndef A3DL_EXPORTS
00031 IMPORT_METAOBJECT_FACTORIES(A3DL_Material)
00032 #endif
00033
00034 namespace A3DL
00035 {
00036 class TextureIterator;
00037 class Texture;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class A3DL_API Material : public VOS::MetaObject
00051 {
00052 public:
00053
00054
00055 enum BlendMode {BLEND_ADD, BLEND_MULTIPLY, BLEND_DOUBLE_MULTIPLY, BLEND_NORMAL};
00056
00057
00058 public:
00059 Material(VOS::VobjectBase* superobject);
00060 virtual ~Material();
00061
00062 static VOS::MetaObject* new_Material(VOS::VobjectBase* superobject, const std::string& type);
00063 virtual const std::string getVOSType();
00064
00065
00066 virtual TextureIterator getTextureLayers();
00067
00068
00069
00070
00071 virtual VUtil::vRef<Texture> getTextureLayer(int idx);
00072
00073
00074
00075
00076 virtual void insertTextureLayer(int idx, Texture& t);
00077
00078
00079
00080
00081
00082
00083 virtual VUtil::vRef<Texture> insertTextureLayerFromFile(int idx, const std::string& filename,
00084 const std::string& datatype);
00085
00086
00087
00088
00089
00090 virtual VUtil::vRef<Texture> insertTextureLayer(int idx, const std::string& data, const std::string& datatype, double alpha = 1.0, BlendMode blendMode = BLEND_NORMAL);
00091
00092 virtual void replaceTextureLayer(int idx, Texture& t);
00093 virtual void replaceTextureLayer(int idx, Texture* t) {
00094 assert(t);
00095 replaceTextureLayer(idx, *t);
00096 }
00097 virtual void removeTextureLayer(int idx);
00098
00099
00100
00101
00102 virtual void setColor(float r, float g, float b);
00103
00104
00105
00106
00107 virtual void getColor(float& r, float& g, float& b);
00108
00109
00110
00111
00112
00113 static void hexStringToFloats(const std::string& str, float& r, float& g, float& b);
00114
00115
00116
00117
00118
00119
00120
00121 static void floatsToHexString(float r, float g, float b, std::string& str);
00122
00123
00124
00125
00126
00127
00128
00129
00130 virtual void setAlpha(double t);
00131
00132
00133
00134
00135
00136 virtual double getAlpha();
00137
00138
00139 virtual VUtil::vRef<VOS::Property> getAlphaObj();
00140
00141
00142 virtual void setAlphaObj(VOS::Property* obj);
00143
00144
00145
00146
00147
00148 virtual void setBlendMode(BlendMode mode);
00149
00150
00151
00152
00153
00154
00155
00156 virtual BlendMode getBlendMode();
00157
00158
00159 virtual VUtil::vRef<VOS::Property> getBlendModeObj();
00160
00161
00162 virtual void setBlendModeObj(VOS::Property* obj);
00163
00164
00165
00166
00167
00168 virtual void setBlendColor(float r, float g, float b);
00169
00170
00171
00172
00173
00174 virtual void getBlendColor(float& r, float& g, float& b);
00175
00176
00177
00178 virtual void setBlendColorObj(VOS::Property* obj);
00179
00180
00181 virtual VUtil::vRef<VOS::Property> getBlendColorObj();
00182 };
00183 }
00184
00185 namespace VUtil {
00186 template<> inline void iteratorReleaseItem(A3DL::Material** v)
00187 {
00188 (*v)->release();
00189 }
00190 }
00191
00192 namespace A3DL {
00193 class MaterialIterator : public VUtil::Iterator<Material*>
00194 {
00195 public:
00196 MaterialIterator() : VUtil::Iterator<Material*>() { }
00197 MaterialIterator(const MaterialIterator& i) : VUtil::Iterator<Material*>(i) { }
00198 MaterialIterator(std::vector<Material*>& vec) {
00199 items->resize(vec.size());
00200 int c = 0;
00201 for(std::vector<Material*>::const_iterator i = vec.begin();
00202 i != vec.end();
00203 i++)
00204 {
00205 (*i)->acquire();
00206 (*items)[c] = (*i);
00207 c++;
00208 }
00209 }
00210 VUtil::vRef<Material> operator*() {
00211 if(pos < items->size()) return VUtil::vRef<Material>((*items)[pos], true);
00212 else return VUtil::vRef<Material>();
00213 }
00214 };
00215 }
00216
00217 #endif