Blender V2.61 - r43446
|
00001 00006 #ifndef __BL_MATERIAL_H__ 00007 #define __BL_MATERIAL_H__ 00008 00009 #include "STR_String.h" 00010 #include "MT_Point2.h" 00011 00012 #ifdef WITH_CXX_GUARDEDALLOC 00013 #include "MEM_guardedalloc.h" 00014 #endif 00015 00016 // -- 00017 struct MTex; 00018 struct Material; 00019 struct Image; 00020 struct MTFace; 00021 struct MTex; 00022 struct Material; 00023 struct EnvMap; 00024 // -- 00025 00032 #define MAXTEX 8 //match in RAS_TexVert & RAS_OpenGLRasterizer 00033 00034 // different mapping modes 00035 class BL_Mapping 00036 { 00037 public: 00038 int mapping; 00039 float scale[3]; 00040 float offsets[3]; 00041 int projplane[3]; 00042 STR_String objconame; 00043 STR_String uvCoName; 00044 }; 00045 00046 // base material struct 00047 class BL_Material 00048 { 00049 private: 00050 int num_users; 00051 bool share; 00052 00053 public: 00054 // ----------------------------------- 00055 BL_Material(); 00056 void Initialize(); 00057 00058 int IdMode; 00059 unsigned int ras_mode; 00060 bool glslmat; 00061 00062 STR_String texname[MAXTEX]; 00063 unsigned int flag[MAXTEX]; 00064 int tile,tilexrep[MAXTEX],tileyrep[MAXTEX]; 00065 STR_String matname; 00066 STR_String mtexname[MAXTEX]; 00067 int materialindex; 00068 00069 float matcolor[4]; 00070 float speccolor[3]; 00071 short alphablend, pad; 00072 00073 float hard, spec_f; 00074 float alpha, emit, color_blend[MAXTEX], ref; 00075 float amb; 00076 00077 int blend_mode[MAXTEX]; 00078 00079 int num_enabled; 00080 00081 BL_Mapping mapping[MAXTEX]; 00082 STR_String imageId[MAXTEX]; 00083 00084 00085 Material* material; 00086 MTFace* tface; 00087 Image* img[MAXTEX]; 00088 EnvMap* cubemap[MAXTEX]; 00089 00090 unsigned int rgb[4]; 00091 MT_Point2 uv[4]; 00092 MT_Point2 uv2[4]; 00093 00094 STR_String uvName; 00095 STR_String uv2Name; 00096 00097 void SetConversionRGB(unsigned int *rgb); 00098 void GetConversionRGB(unsigned int *rgb); 00099 00100 void SetConversionUV(const STR_String& name, MT_Point2 *uv); 00101 void GetConversionUV(MT_Point2 *uv); 00102 00103 void SetConversionUV2(const STR_String& name, MT_Point2 *uv); 00104 void GetConversionUV2(MT_Point2 *uv); 00105 00106 void SetSharedMaterial(bool v); 00107 bool IsShared(); 00108 void SetUsers(int num); 00109 00110 00111 #ifdef WITH_CXX_GUARDEDALLOC 00112 public: 00113 void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_Material"); } 00114 void operator delete( void *mem ) { MEM_freeN(mem); } 00115 #endif 00116 }; 00117 00118 // BL_Material::IdMode 00119 enum BL_IdMode { 00120 DEFAULT_BLENDER=-1, 00121 TEXFACE, 00122 ONETEX, 00123 TWOTEX, 00124 GREATERTHAN2 00125 }; 00126 00127 // BL_Material::blend_mode[index] 00128 enum BL_BlendMode 00129 { 00130 BLEND_MIX=1, 00131 BLEND_ADD, 00132 BLEND_SUB, 00133 BLEND_MUL, 00134 BLEND_SCR 00135 }; 00136 00137 // ------------------------------------- 00138 // BL_Material::flag[index] 00139 enum BL_flag 00140 { 00141 MIPMAP=1, // set to use mipmaps 00142 CALCALPHA=2, // additive 00143 USEALPHA=4, // use actual alpha channel 00144 TEXALPHA=8, // use alpha combiner functions 00145 TEXNEG=16, // negate blending 00146 /*HASIPO=32,*/ // unused, commeted for now. 00147 USENEGALPHA=64 00148 }; 00149 00150 // BL_Material::ras_mode 00151 enum BL_ras_mode 00152 { 00153 // POLY_VIS=1, 00154 COLLIDER=2, 00155 ZSORT=4, 00156 ALPHA=8, 00157 // TRIANGLE=16, 00158 USE_LIGHT=32, 00159 WIRE=64, 00160 CAST_SHADOW=128, 00161 TEX=256, 00162 TWOSIDED=512 00163 }; 00164 00165 // ------------------------------------- 00166 // BL_Material::mapping[index]::mapping 00167 enum BL_MappingFlag 00168 { 00169 USEENV =1, 00170 // -- 00171 USEREFL =2, 00172 USEOBJ =4, 00173 USENORM =8, 00174 USEORCO =16, 00175 USEUV =32, 00176 USETANG =64, 00177 DISABLE =128, 00178 USECUSTOMUV=256 00179 }; 00180 00181 // BL_Material::BL_Mapping::projplane 00182 enum BL_MappingProj 00183 { 00184 PROJN=0, 00185 PROJX, 00186 PROJY, 00187 PROJZ 00188 }; 00189 00190 // ------------------------------------ 00191 //extern void initBL_Material(BL_Material* mat); 00192 extern MTex* getImageFromMaterial(Material *mat, int index); 00193 extern int getNumTexChannels( Material *mat ); 00194 // ------------------------------------ 00195 00196 #endif 00197 00198