00001 // starcolors.cpp 00002 // 00003 // Copyright (C) 2004, Chris Laurel <claurel@shatters.net> 00004 // 00005 // Tables of star colors, indexed by temperature. 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 00012 #ifndef _CELENGINE_STARCOLORS_H_ 00013 #define _CELENGINE_STARCOLORS_H_ 00014 00015 #include <celutil/color.h> 00016 00017 00018 class ColorTemperatureTable 00019 { 00020 public: 00021 ColorTemperatureTable(Color* _colors, 00022 unsigned int _nColors, 00023 float maxTemp) : 00024 colors(_colors), 00025 nColors(_nColors), 00026 tempScale((float) (_nColors - 1) / maxTemp) 00027 {}; 00028 00029 Color lookupColor(float temp) const 00030 { 00031 unsigned int colorTableIndex = (unsigned int) (temp * tempScale); 00032 if (colorTableIndex >= nColors) 00033 return colors[nColors - 1]; 00034 else 00035 return colors[colorTableIndex]; 00036 } 00037 00038 private: 00039 const Color* colors; 00040 unsigned nColors; 00041 float tempScale; 00042 }; 00043 00044 enum ColorTableType 00045 { 00046 ColorTable_Enhanced, 00047 ColorTable_Blackbody_D65, 00048 }; 00049 00050 extern ColorTemperatureTable* GetStarColorTable(ColorTableType); 00051 00052 00053 #endif // _CELENGINE_STARCOLORS_H_
1.4.1