- Timestamp:
- Aug 14, 2005, 3:48:22 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/Makefile.am
r5009 r5010 46 46 util/loading/load_param.cc \ 47 47 util/state.cc \ 48 48 story_entities/story_entity.cc \ 49 49 story_entities/campaign.cc \ 50 50 story_entities/world.cc \ … … 78 78 lib/util/ini_parser.cc \ 79 79 lib/util/substring.cc \ 80 lib/util/color.cc \ 80 81 lib/math/vector.cc \ 81 82 lib/math/curve.cc \ … … 147 148 lib/util/substring.h \ 148 149 lib/util/list.h \ 150 lib/util/color.h \ 149 151 lib/math/vector.h \ 150 152 lib/math/curve.h \ -
orxonox/trunk/src/Makefile.in
r4976 r5010 78 78 orxonox-render_2d.$(OBJEXT) orxonox-base_object.$(OBJEXT) \ 79 79 orxonox-class_list.$(OBJEXT) orxonox-ini_parser.$(OBJEXT) \ 80 orxonox-substring.$(OBJEXT) orxonox-vector.$(OBJEXT) \ 81 orxonox-curve.$(OBJEXT) orxonox-glmenu_imagescreen.$(OBJEXT) \ 80 orxonox-substring.$(OBJEXT) orxonox-color.$(OBJEXT) \ 81 orxonox-vector.$(OBJEXT) orxonox-curve.$(OBJEXT) \ 82 orxonox-glmenu_imagescreen.$(OBJEXT) \ 82 83 orxonox-benchmark.$(OBJEXT) 83 84 orxonox_OBJECTS = $(am_orxonox_OBJECTS) … … 95 96 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox-character_attributes.Po \ 96 97 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox-class_list.Po \ 98 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox-color.Po \ 97 99 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox-crosshair.Po \ 98 100 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox-curve.Po \ … … 331 333 lib/util/ini_parser.cc \ 332 334 lib/util/substring.cc \ 335 lib/util/color.cc \ 333 336 lib/math/vector.cc \ 334 337 lib/math/curve.cc \ … … 400 403 lib/util/substring.h \ 401 404 lib/util/list.h \ 405 lib/util/color.h \ 402 406 lib/math/vector.h \ 403 407 lib/math/curve.h \ … … 491 495 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-character_attributes.Po@am__quote@ 492 496 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-class_list.Po@am__quote@ 497 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-color.Po@am__quote@ 493 498 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-crosshair.Po@am__quote@ 494 499 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox-curve.Po@am__quote@ … … 1284 1289 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1285 1290 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-substring.obj `if test -f 'lib/util/substring.cc'; then $(CYGPATH_W) 'lib/util/substring.cc'; else $(CYGPATH_W) '$(srcdir)/lib/util/substring.cc'; fi` 1291 1292 orxonox-color.o: lib/util/color.cc 1293 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-color.o -MD -MP -MF "$(DEPDIR)/orxonox-color.Tpo" -c -o orxonox-color.o `test -f 'lib/util/color.cc' || echo '$(srcdir)/'`lib/util/color.cc; \ 1294 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/orxonox-color.Tpo" "$(DEPDIR)/orxonox-color.Po"; else rm -f "$(DEPDIR)/orxonox-color.Tpo"; exit 1; fi 1295 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='lib/util/color.cc' object='orxonox-color.o' libtool=no @AMDEPBACKSLASH@ 1296 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/orxonox-color.Po' tmpdepfile='$(DEPDIR)/orxonox-color.TPo' @AMDEPBACKSLASH@ 1297 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1298 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-color.o `test -f 'lib/util/color.cc' || echo '$(srcdir)/'`lib/util/color.cc 1299 1300 orxonox-color.obj: lib/util/color.cc 1301 @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT orxonox-color.obj -MD -MP -MF "$(DEPDIR)/orxonox-color.Tpo" -c -o orxonox-color.obj `if test -f 'lib/util/color.cc'; then $(CYGPATH_W) 'lib/util/color.cc'; else $(CYGPATH_W) '$(srcdir)/lib/util/color.cc'; fi`; \ 1302 @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/orxonox-color.Tpo" "$(DEPDIR)/orxonox-color.Po"; else rm -f "$(DEPDIR)/orxonox-color.Tpo"; exit 1; fi 1303 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='lib/util/color.cc' object='orxonox-color.obj' libtool=no @AMDEPBACKSLASH@ 1304 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/orxonox-color.Po' tmpdepfile='$(DEPDIR)/orxonox-color.TPo' @AMDEPBACKSLASH@ 1305 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1306 @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(orxonox_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o orxonox-color.obj `if test -f 'lib/util/color.cc'; then $(CYGPATH_W) 'lib/util/color.cc'; else $(CYGPATH_W) '$(srcdir)/lib/util/color.cc'; fi` 1286 1307 1287 1308 orxonox-vector.o: lib/math/vector.cc -
orxonox/trunk/src/lib/coord/p_node.cc
r5008 r5010 653 653 } 654 654 } 655 #include "color.h" 655 656 656 657 /** … … 707 708 tIterator<PNode>* iterator = this->children->getIterator(); 708 709 //PNode* pn = this->children->enumerate (); 709 Vector childColor = color - Vector(.0,.3,.3);710 Vector childColor = Color::RGBtoHSV(color)+Vector(-.3,.3,.2); 710 711 PNode* pn = iterator->nextElement(); 711 712 while( pn != NULL) -
orxonox/trunk/src/lib/util/color.cc
r5009 r5010 20 20 21 21 #include "color.h" 22 #include "vector.h" 22 23 23 24 using namespace std; 24 25 25 Vector Color::RGBtoHSV (Vector RGB) 26 27 28 29 #include <stdio.h> 30 31 // Needed by rgb2hsv() 32 float Color::maxrgb(float r, float g, float b) 26 33 { 27 Vector HSV;34 float max; 28 35 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 32 33 flaot V = var_Max; 34 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; 36 if( r > g) 37 max = r; 38 else 39 max = g; 40 if( b > max ) 41 max = b; 42 return( max ); 59 43 } 60 44 61 45 62 Vector Color::HSVtoRGB (Vector HSV) 46 // Needed by rgb2hsv() 47 float Color::minrgb(float r,float g,float b) 63 48 { 49 float min; 64 50 51 if( r < g) 52 min = r; 53 else 54 min = g; 55 if( b < min ) 56 min = b; 57 return( min ); 65 58 } 59 60 61 /* Taken from "Fund'l of 3D Computer Graphics", Alan Watt (1989) 62 Assumes (r,g,b) range from 0.0 to 1.0 63 Sets h in degrees: 0.0 to 360.; 64 s,v in [0.,1.] 65 */ 66 Vector Color::RGBtoHSV(const Vector& RGB) 67 { 68 float r = RGB.x; 69 float g = RGB.y; 70 float b = RGB.z; 71 72 float h=0,s=1.0,v=1.0; 73 float max_v,min_v,diff,r_dist,g_dist,b_dist; 74 float undefined = 0.0; 75 76 max_v = maxrgb(r,g,b); 77 min_v = minrgb(r,g,b); 78 diff = max_v - min_v; 79 v = max_v; 80 81 if( max_v != 0 ) 82 s = diff/max_v; 83 else 84 s = 0.0; 85 if( s == 0 ) 86 h = undefined; 87 else { 88 r_dist = (max_v - r)/diff; 89 g_dist = (max_v - g)/diff; 90 b_dist = (max_v - b)/diff; 91 if( r == max_v ) 92 h = b_dist - g_dist; 93 else 94 if( g == max_v ) 95 h = 2 + r_dist - b_dist; 96 else 97 if( b == max_v ) 98 h = 4 + g_dist - r_dist; 99 else 100 printf("rgb2hsv::How did I get here?\n"); 101 h *= 60; 102 if( h < 0) 103 h += 360.0; 104 } 105 return Vector(h, s, v); 106 } 107 108 /* Taken from "Fund'l of 3D Computer Graphics", Alan Watt (1989) 109 Assumes H in degrees, s,v in [0.,1.0]; 110 (r,g,b) range from 0.0 to 1.0 111 */ 112 Vector Color::HSVtoRGB(const Vector& HSV) 113 { 114 float h = HSV.x; 115 float s = HSV.y; 116 float v = HSV.z; 117 float r=0, g=0, b=0; 118 float f,p,q,t; 119 int i; 120 121 if( s == 0 ) { 122 r = v; 123 g = v; 124 b = v; 125 } 126 else { 127 if(h == 360.) 128 h = 0.0; 129 h /= 60.; 130 i = (int) h; 131 f = h - i; 132 p = v*(1-s); 133 q = v*(1-(s*f)); 134 t = v*(1-s*(1-f)); 135 switch(i) { 136 case 0: 137 r = v; 138 g = t; 139 b = p; 140 break; 141 case 1: 142 r = q; 143 g = v; 144 b = p; 145 break; 146 case 2: 147 r = p; 148 g = v; 149 b = t; 150 break; 151 case 3: 152 r = p; 153 g = q; 154 b = v; 155 break; 156 case 4: 157 r = t; 158 g = p; 159 b = v; 160 break; 161 case 5: 162 r = v; 163 g = p; 164 b = q; 165 break; 166 default: 167 r = 1.0; 168 g = 1.0; 169 b = 1.0; 170 //printf("hsv2rgb::How did I get here?\n"); 171 // printf("h: %f, s: %f, v: %f; i: %d\n",hin,s,v,i); 172 break; 173 } 174 } 175 return Vector(r,g,b); 176 } -
orxonox/trunk/src/lib/util/color.h
r5009 r5010 15 15 class Color 16 16 { 17 Vector RGBtoHSV (Vector RGB); 18 Vector HSVtoRGB (Vector HSV); 17 public: 18 static Vector RGBtoHSV (const Vector& RGB); 19 static Vector HSVtoRGB (const Vector& HSV); 20 21 static float minrgb(float r, float g, float b); 22 static float maxrgb(float r, float g, float b); 19 23 }; 20 24 -
orxonox/trunk/src/world_entities/camera.cc
r5007 r5010 192 192 void Camera::apply () 193 193 { 194 this->target->getParent()->debugDraw(0, 2 );194 this->target->getParent()->debugDraw(0, 2, Vector(1,0,0)); 195 195 // switching to Projection Matrix 196 196 glMatrixMode (GL_PROJECTION);
Note: See TracChangeset
for help on using the changeset viewer.