FMath/FMColor.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005-2007 Feeling Software Inc.
00003     Portions of the code are:
00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
00005     
00006     MIT License: http://www.opensource.org/licenses/mit-license.php
00007 */
00008 
00014 #ifndef _FM_COLOR_H_
00015 #define _FM_COLOR_H_
00016 
00023 class FCOLLADA_EXPORT FMColor
00024 {
00025 public:
00026     uint8 r;    
00027     uint8 g;    
00028     uint8 b;    
00029     uint8 a;    
00033     FMColor() {}
00034 
00043     FMColor(uint8 _r, uint8 _g, uint8 _b, uint8 _a = 255) { r = _r; g = _g; b = _b; a = _a; }
00044 
00050     FMColor(uint32 hex) { r = uint8((hex & 0xFF000000) >> 24); g = uint8((hex & 0xFF0000) >> 16); b = uint8((hex & 0xFF00) >> 8); a = uint8(hex & 0xFF); }
00051 
00062     FMColor(const float* components, uint32 componentCount);
00063 
00067     FMColor(const FMVector3& v);
00068 
00071     FMColor(const FMVector4& v);
00072 
00078     void ToFloats(float* components, uint32 componentCount);
00079 
00082     inline uint8 ComponentAverage() { return uint8((uint32(r) + uint32(g) + uint32(b)) / 3); }
00083 
00086     operator uint8*() { return &r; }
00087 };
00088 
00093 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)); }
00094 
00095 #endif // _FM_COLOR_H_

Generated on Thu Feb 14 16:58:35 2008 for FCollada by  doxygen 1.4.6-NO