/[hegemonie]/hegemonie/Map/Display/MapColors.m
ViewVC logotype

Diff of /hegemonie/Map/Display/MapColors.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by dam, Thu Sep 4 11:58:39 2003 UTC revision 1.13 by gabby, Thu Sep 4 22:15:59 2003 UTC
# Line 155  Line 155 
155  - (coord_t) normalAtPosition: (map_coord_t)position  - (coord_t) normalAtPosition: (map_coord_t)position
156  {  {
157    if (_normalsData)    if (_normalsData)
158      {      return ((const coord_t *)[_normalsData bytes])
159        const unsigned width = [self width];                                [position.x + position.z * _xLength];
       const unsigned height = [self height];  
   
       return ((const coord_t *)[_normalsData bytes])  
               [MOD(position.x, width) + MOD(position.z, height) * width];  
     }  
160    else    else
161      {      {
162        const real_t h1 = [self heightAtPosition: MakeMapCoord (position.x + 1,        const real_t h1 = [self heightAtPosition: MakeMapCoord (position.x + 1,
# Line 181  Line 176 
176  }  }
177    
178  /**  /**
179   * Returns the color for a given height.   * Returns the color of the given position with a given height.
180   */   */
181  - (color_t) colorForHeight: (int)height  - (color_t) colorAtPosition: (map_coord_t)position
182                     withHeight: (int)height
183  {  {
184    NSParameterAssert (height >= 0);    NSParameterAssert (height >= 0);
185    NSParameterAssert (height < COLORS_SIZE);    NSParameterAssert (height < COLORS_SIZE);
186      
187      color_t color =  _colors[height];
188    
189    return _colors[height];    if (_shadows)
190  }      {
191          float shadow = (float) ([_shadows shadowAtPoint: position] >> 3);
 #define SHADOW_FACTOR 2.2f  
192    
193  /**        if (shadow > 1.0)
194   * Returns the color of the given position.          return MakeColor
195   */            (color.red / shadow, color.green / shadow, color.blue / shadow);
196  - (color_t) colorAtPosition: (map_coord_t)position        else
197  {          return MakeColor (color.red, color.green, color.blue);
198    u_int8_t height = [self heightAtPosition: position];      }
     
   clamp_t r = _colors[height].red;  
   clamp_t g = _colors[height].green;  
   clamp_t b = _colors[height].blue;  
     
   if (_shadows && [_shadows shadowAtPoint: position])  
     return MakeColor (r / SHADOW_FACTOR, g / SHADOW_FACTOR, b / SHADOW_FACTOR);  
199    else    else
200      return MakeColor (r, g, b);      return MakeColor (color.red, color.green, color.blue);
201  }  }
202    
203  /**  /**
# Line 218  Line 208 
208  - (void) setShadows: (NSString *)shadows  - (void) setShadows: (NSString *)shadows
209  {  {
210    NSParameterAssert (shadows);    NSParameterAssert (shadows);
   NSParameterAssert ([shadows length] != 0);  
211    
212      TEST_RELEASE (_shadows);
213    _shadows = [[MapShadows alloc] initWithShadowsImageName: shadows];    _shadows = [[MapShadows alloc] initWithShadowsImageName: shadows];
214  }  }
215    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26