/[gzz]/gzz/gfx/libtexture/irregu.texture
ViewVC logotype

Diff of /gzz/gfx/libtexture/irregu.texture

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

revision 1.12 by jvk, Mon Oct 28 09:54:56 2002 UTC revision 1.13 by jvk, Tue Oct 29 11:53:53 2002 UTC
# Line 30  void GENERATE(TextureParam *params, int Line 30  void GENERATE(TextureParam *params, int
30      FPARAM(eps, .25);      FPARAM(eps, .25);
31      FPARAM(invert, 0);      FPARAM(invert, 0);
32      FPARAM(quantize, 255);      FPARAM(quantize, 255);
33        int angles = (int)params->getFloat("angles", 0);
34            
35      // Note: radius is specified in texels      // Note: radius is specified in texels
36      FPARAM(radius, 2);      FPARAM(radius, 2);
# Line 38  void GENERATE(TextureParam *params, int Line 39  void GENERATE(TextureParam *params, int
39      FPARAM(ripple_scale, 0.25);      FPARAM(ripple_scale, 0.25);
40    
41      float *origdata = data;      float *origdata = data;
42      if(components != 4) {      data = new float[width * height * depth * 4];
         data = new float[width * height * depth * 4];  
     }  
43    
44      if(depth != 1) return;      if(depth != 1) return;
45      if(width != height) return;      if(width != height) return;
# Line 89  void GENERATE(TextureParam *params, int Line 88  void GENERATE(TextureParam *params, int
88          data[i] = f * scale + bias;          data[i] = f * scale + bias;
89    
90          // Add outer edge to quantized inner edge          // Add outer edge to quantized inner edge
91          if (components == 4)          if (angles)
92              data[i] = floor(data[i] * quantize + 0.5) / quantize;              data[i] = floor(data[i] * quantize + 0.5) / quantize;
93      }      }
94            
95      if (components == 4)      for (int comp = 0; comp < angles && comp < components; comp++) {
96      for (int comp = 0; comp < 3; comp++) {  
97          float dx = cos(comp * 2*M_PI / 3);          float dx = cos(comp * M_PI / angles);
98          float dy = sin(comp * 2*M_PI / 3);          float dy = sin(comp * M_PI / angles);
99                    
100          ind = 0;          ind = 0;
101          for (j = 0, y = 0; j < height; j++, y += ystep) {                for (j = 0, y = 0; j < height; j++, y += ystep) {      
# Line 114  void GENERATE(TextureParam *params, int Line 113  void GENERATE(TextureParam *params, int
113                      if (h > maxh) maxh = h;                      if (h > maxh) maxh = h;
114                  }                  }
115    
116                  data[ind + comp] = maxh;                  origdata[ind + comp] = maxh;
117                  ind += 4;  
118                    ind += components;
119              }              }
120          }          }
121    
# Line 131  void GENERATE(TextureParam *params, int Line 131  void GENERATE(TextureParam *params, int
131      }      }
132  #endif  #endif
133    
134      if (components < 4) {      for (int i = 0; i < width * height * depth; i++)
135          for (int i = 0; i < width * height * depth; i++)          for (int c = angles; c < components; c++)
136              for (int c = 0; c < components; c++)              origdata[i * components + c] = data[4 * i + 3 - (c - angles)];
137                  origdata[i * components + c] = data[4 * i + 3 - c];  
138          delete[] data;      delete[] data;
     }  
139  }  }
140    
141    

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