00001
00002
00003
00004
00005
00011 #ifndef _FM_COLOR_H_
00012 #define _FM_COLOR_H_
00013
00020 class FCOLLADA_EXPORT FMColor
00021 {
00022 public:
00023 uint8 r;
00024 uint8 g;
00025 uint8 b;
00026 uint8 a;
00033 FMColor() {}
00034
00048 FMColor(uint8 _r, uint8 _g, uint8 _b, uint8 _a) { r = _r; g = _g; b = _b; a = _a; }
00049
00059 FMColor(uint32 hex) { r = uint8((hex & 0xFF000000) >> 24); g = uint8((hex & 0xFF0000) >> 16); b = uint8((hex & 0xFF00) >> 8); a = uint8(hex & 0xFF); }
00060
00076 FMColor(const float* components, uint32 componentCount);
00077
00087 void ToFloats(float* components, uint32 componentCount);
00088
00094 inline uint8 ComponentAverage() { return uint8((uint32(r) + uint32(g) + uint32(b)) / 3); }
00095
00101 operator uint8*() { return &b; }
00102 };
00103
00111 inline FMColor operator*(float s, const FMColor& c) { return FMColor(uint8(c.r * s), uint8(c.g * s), uint8(c.b * s), uint8(c.a * s)); }
00112
00113 #endif // _FM_COLOR_H_