00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef BASIC_MATERIAL_H_
00026 #define BASIC_MATERIAL_H_
00027
00028 #include <Graphics/Material/Material.h>
00029
00030 namespace Lamp{
00031
00032
00033
00034
00035
00036 class BasicMaterial : public Material{
00037 friend class MaterialManager;
00038 public:
00039
00040
00041
00042
00043 virtual bool isBasicMaterial() const{ return true; }
00044
00045
00046
00047
00048
00049
00050
00051 virtual Material* copy(u_int copyMask = 0) const{
00052 return copyBasicMaterial(copyMask);
00053 }
00054
00055
00056
00057
00058
00059
00060 virtual BasicMaterial* copyBasicMaterial(u_int copyMask = 0) const;
00061
00062
00063
00064
00065
00066
00067
00068
00069 virtual void draw(DrawRequest* request);
00070
00071
00072
00073
00074
00075
00076
00077
00078 virtual void setBaseTexture(Texture* baseTexture){
00079 baseTexture_ = setTextureReferense(baseTexture_, baseTexture);
00080 }
00081
00082
00083
00084
00085
00086 virtual Texture* getBaseTexture() const{ return baseTexture_; }
00087
00088
00089
00090
00091 virtual void removeBaseTexture(){ setBaseTexture(NULL); }
00092
00093
00094
00095
00096
00097
00098 virtual void setBaseUVIndex(int baseUVIndex){
00099 Assert((baseUVIndex >= 0) && (baseUVIndex < 8));
00100 baseUVIndex_ = baseUVIndex;
00101 }
00102
00103
00104
00105
00106
00107 virtual int getBaseUVIndex() const{ return baseUVIndex_; }
00108
00109
00110
00111
00112
00113
00114
00115
00116 virtual void setGlossTexture(Texture* glossTexture){
00117 glossTexture_ = setTextureReferense(glossTexture_, glossTexture);
00118 }
00119
00120
00121
00122
00123
00124 virtual Texture* getGlossTexture() const{ return glossTexture_; }
00125
00126
00127
00128
00129 virtual void removeGlossTexture(){ setGlossTexture(NULL); }
00130
00131
00132
00133
00134
00135
00136 virtual void setGlossUVIndex(int glossUVIndex){
00137 Assert((glossUVIndex >= 0) && (glossUVIndex < 8));
00138 glossUVIndex_ = glossUVIndex;
00139 }
00140
00141
00142
00143
00144
00145 virtual int getGlossUVIndex() const{ return glossUVIndex_; }
00146
00147
00148
00149
00150
00151
00152
00153
00154 virtual void setLightTexture(Texture* lightTexture){
00155 lightTexture_ = setTextureReferense(lightTexture_, lightTexture);
00156 }
00157
00158
00159
00160
00161
00162 virtual Texture* getLightTexture() const{ return lightTexture_; }
00163
00164
00165
00166
00167 virtual void removeLightTexture(){ setLightTexture(NULL); }
00168
00169
00170
00171
00172
00173
00174 virtual void setLightUVIndex(int lightUVIndex){
00175 Assert((lightUVIndex >= 0) && (lightUVIndex < 8));
00176 lightUVIndex_ = lightUVIndex;
00177 }
00178
00179
00180
00181
00182
00183 virtual int getLightUVIndex() const{ return lightUVIndex_; }
00184
00185
00186
00187
00188
00189
00190
00191
00192 virtual void setStainTexture(Texture* stainTexture){
00193 stainTexture_ = setTextureReferense(stainTexture_, stainTexture);
00194 }
00195
00196
00197
00198
00199
00200 virtual Texture* getStainTexture() const{ return stainTexture_; }
00201
00202
00203
00204
00205 virtual void removeStainTexture(){ setStainTexture(NULL); }
00206
00207
00208
00209
00210
00211
00212 virtual void setStainUVIndex(int stainUVIndex){
00213 Assert((stainUVIndex >= 0) && (stainUVIndex < 8));
00214 stainUVIndex_ = stainUVIndex;
00215 }
00216
00217
00218
00219
00220
00221 virtual int getStainUVIndex() const{ return stainUVIndex_; }
00222
00223
00224
00225
00226
00227
00228
00229
00230 virtual void setDiffuseColor(const Color3f& diffuseColor){
00231 diffuseColor_ = diffuseColor;
00232 stateChanged();
00233 }
00234
00235
00236
00237
00238
00239 virtual const Color3f& getDiffuseColor() const{ return diffuseColor_; }
00240
00241
00242
00243
00244
00245
00246
00247
00248 virtual void setSpecularColor(const Color3f& specularColor){
00249 specularColor_ = specularColor;
00250 stateChanged();
00251 }
00252
00253
00254
00255
00256
00257 virtual const Color3f& getSpecularColor() const{ return specularColor_; }
00258
00259
00260
00261
00262
00263
00264 virtual void setSpecularPower(float specularPower){
00265 specularPower_ = specularPower;
00266 stateChanged();
00267 }
00268
00269
00270
00271
00272
00273 virtual float getSpecularPower() const{ return specularPower_; }
00274
00275
00276
00277
00278
00279
00280 virtual bool isSpecularEnabled() const{
00281 return (specularColor_ != Color3f::black);
00282 }
00283
00284
00285
00286
00287
00288
00289
00290
00291 virtual void setAmbientColor(const Color3f& ambientColor){
00292 ambientColor_ = ambientColor;
00293 stateChanged();
00294 }
00295
00296
00297
00298
00299
00300 virtual const Color3f& getAmbientColor() const{ return ambientColor_; }
00301
00302
00303
00304
00305
00306
00307
00308
00309 virtual void setEmissiveColor(const Color3f& emissiveColor){
00310 emissiveColor_ = emissiveColor;
00311 stateChanged();
00312 }
00313
00314
00315
00316
00317
00318 virtual const Color3f& getEmissiveColor() const{ return emissiveColor_; }
00319
00320
00321 protected:
00322
00323
00324
00325
00326
00327 BasicMaterial(const String& name, Scene* scene);
00328
00329
00330
00331
00332 virtual ~BasicMaterial();
00333
00334
00335
00336
00337
00338
00339 virtual int destroyChildren();
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349 virtual void buildStateBlock(
00350 Direct3DStateBlock** startBlock, Direct3DStateBlock** endBlock);
00351
00352
00353 private:
00354
00355 Texture* baseTexture_;
00356
00357 Texture* glossTexture_;
00358
00359 Texture* lightTexture_;
00360
00361 Texture* stainTexture_;
00362
00363 Color3f diffuseColor_;
00364
00365 Color3f specularColor_;
00366
00367 Color3f ambientColor_;
00368
00369 Color3f emissiveColor_;
00370
00371 float specularPower_;
00372
00373 int baseUVIndex_;
00374
00375 int glossUVIndex_;
00376
00377 int lightUVIndex_;
00378
00379 int stainUVIndex_;
00380
00381 };
00382
00383
00384 }
00385 #endif // End of BASIC_MATERIAL_H_
00386