Changeset 5009 in orxonox.OLD for orxonox/trunk/src/util
- Timestamp:
- Aug 14, 2005, 3:03:02 AM (19 years ago)
- Location:
- orxonox/trunk/src/util
- Files:
-
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/color.cc
r5000 r5009 10 10 11 11 ### File Specific: 12 main-programmer: ...12 main-programmer: Benjamin Grauer 13 13 co-programmer: ... 14 15 this code has been borrowed from: 16 http://www.easyrgb.com/math.php 14 17 */ 15 18 16 19 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ 17 20 18 #include " proto_class.h"21 #include "color.h" 19 22 20 23 using namespace std; 21 24 25 Vector Color::RGBtoHSV (Vector RGB) 26 { 27 Vector HSV; 22 28 23 /** 24 * standard constructor 25 * @todo this constructor is not jet implemented - do it 26 */ 27 ProtoClass::ProtoClass () 28 { 29 this->setClassID(CL_PROTO_ID, "ProtoClass"); 29 float var_Min = min( RGB.x, RGB.y, RGB.z ); //Min. value of RGB 30 float var_Max = max( RGB.x, RGB.y, RGB.z ); //Max. value of RGB 31 float del_Max = var_Max - var_Min; //Delta RGB value 30 32 31 /* If you make a new class, what is most probably the case when you write this file 32 don't forget to: 33 1. Add the new file new_class.cc to the ./src/Makefile.am 34 2. Add the class identifier to ./src/class_id.h eg. CL_NEW_CLASS 33 flaot V = var_Max; 35 34 36 Advanced Topics: 37 - if you want to let your object be managed via the ObjectManager make sure to read 38 the object_manager.h header comments. You will use this most certanly only if you 39 make many objects of your class, like a weapon bullet. 40 */ 35 if ( del_Max == 0 ) //This is a gray, no chroma... 36 { 37 HSV.x = 0 //HSV results = 0 ÷ 1 38 HSV.y = 0 39 } 40 else //Chromatic data... 41 { 42 HSV.y = del_Max / var_Max; 43 44 float del_R = ( ( ( var_Max - RGB.x ) / 6 ) + ( del_Max / 2 ) ) / del_Max; 45 float del_G = ( ( ( var_Max - RGB.y ) / 6 ) + ( del_Max / 2 ) ) / del_Max; 46 float del_B = ( ( ( var_Max - RGB.z ) / 6 ) + ( del_Max / 2 ) ) / del_Max; 47 48 if ( RGB.x == var_Max ) 49 HSV.x = del_B - del_G; 50 else if ( var_G == var_Max ) 51 HSV.x = ( 1 / 3 ) + del_R - del_B; 52 else if ( var_B == var_Max ) 53 HSV.z = ( 2 / 3 ) + del_G - del_R; 54 55 if ( HSV.x < 0 ) ; HSV.x += 1; 56 if ( HSV.x > 1 ) ; HSV.x -= 1; 57 } 58 return HSV; 41 59 } 42 60 43 61 44 /** 45 * standard deconstructor 46 */ 47 ProtoClass::~ProtoClass () 62 Vector Color::HSVtoRGB (Vector HSV) 48 63 { 49 // delete what has to be deleted here 64 50 65 } -
orxonox/trunk/src/util/color.h
r5000 r5009 1 1 /*! 2 * @file proto_class.h 3 * @brief Definition of ... 2 * @file color.h 3 * @brief Definition of color-calculations 4 * 5 * code borrowed from: 6 * http://www.easyrgb.com/math.php 4 7 */ 5 8 6 #ifndef _ PROTO_CLASS_H7 #define _ PROTO_CLASS_H9 #ifndef _COLOR_H 10 #define _COLOR_H 8 11 9 #include "base_object.h" 12 //#include "vector.h" 13 class Vector; 10 14 11 // FORWARD DECLARATION 12 13 14 15 //! A class for ... 16 class ProtoClass : public BaseObject { 17 18 public: 19 ProtoClass(); 20 virtual ~ProtoClass(); 21 22 23 private: 24 15 class Color 16 { 17 Vector RGBtoHSV (Vector RGB); 18 Vector HSVtoRGB (Vector HSV); 25 19 }; 26 20 27 #endif /* _ PROTO_CLASS_H */21 #endif /* _COLOR_H */
Note: See TracChangeset
for help on using the changeset viewer.