Material.h
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
00024 #ifndef APP_MATERIAL_H
00025 #define APP_MATERIAL_H
00026
00027 #ifdef __GNUC__
00028 # include <stdint.h>
00029 #endif
00030
00031 namespace App
00032 {
00033
00036 class AppExport Color
00037 {
00038 public:
00043 explicit Color(float R=0.0,float G=0.0, float B=0.0, float A=0.0)
00044 :r(R),g(G),b(B),a(A){}
00049 Color(uint32_t rgba)
00050 { setPackedValue( rgba ); }
00052 Color(const Color& c)
00053 :r(c.r),g(c.g),b(c.b),a(c.a){}
00055 bool operator==(const Color& c) const
00056 {
00057 return getPackedValue() == c.getPackedValue();
00058
00059 }
00060 bool operator!=(const Color& c) const
00061 {
00062 return !operator==(c);
00063 }
00068 void set(float R,float G, float B, float A=0.0)
00069 {
00070 r=R;g=G;b=B;a=A;
00071 }
00072 Color& operator=(const Color& c)
00073 {
00074 r=c.r;g=c.g;b=c.b;a=c.a;
00075 return *this;
00076 }
00084 Color& setPackedValue(uint32_t rgba)
00085 {
00086 this->set((rgba >> 24)/255.0f,
00087 ((rgba >> 16)&0xff)/255.0f,
00088 ((rgba >> 8)&0xff)/255.0f,
00089 (rgba&0xff)/255.0f);
00090 return *this;
00091 }
00097 uint32_t getPackedValue() const
00098 {
00099 return ((uint32_t)(r*255.0f + 0.5f) << 24 |
00100 (uint32_t)(g*255.0f + 0.5f) << 16 |
00101 (uint32_t)(b*255.0f + 0.5f) << 8 |
00102 (uint32_t)(a*255.0f + 0.5f));
00103 }
00104
00106 float r,g,b,a;
00107 };
00108
00111 class AppExport Material
00112 {
00113 public:
00114 enum MaterialType {
00115 BRASS,
00116 BRONZE,
00117 COPPER,
00118 GOLD,
00119 PEWTER,
00120 PLASTER,
00121 PLASTIC,
00122 SILVER,
00123 STEEL,
00124 STONE,
00125 SHINY_PLASTIC,
00126 SATIN,
00127 METALIZED,
00128 NEON_GNC,
00129 CHROME,
00130 ALUMINIUM,
00131 OBSIDIAN,
00132 NEON_PHC,
00133 JADE,
00134 RUBY,
00135 EMERALD,
00136 DEFAULT,
00137 USER_DEFINED
00138 };
00139
00140 public:
00145 Material(void);
00149 Material(const char* MatName);
00151 Material(const MaterialType MatType);
00153 ~Material();
00154
00183 void set(const char* MatName);
00188 void setType(const MaterialType MatType);
00192 MaterialType getType() const
00193 { return _matType; }
00194
00197 Color ambientColor;
00198 Color diffuseColor;
00199 Color specularColor;
00200 Color emissiveColor;
00201 float shininess;
00202 float transparency;
00204
00205 private:
00206 MaterialType _matType;
00207 };
00208
00209 }
00210
00211 #endif // APP_MATERIAL_H