cstool/gentrtex.h
00001 /* 00002 Copyright (C) 2001 by W.C.A. Wijngaards 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_GENTERTEX_H__ 00020 #define __CS_GENTERTEX_H__ 00021 00022 #include "csutil/scf.h" 00023 #include "csutil/cscolor.h" 00024 #include "csgeom/vector2.h" 00025 #include "csgfx/rgbpixel.h" 00026 00027 struct iImage; 00028 class csGenerateImageValue; 00029 class csGenerateImageTexture; 00030 00035 class csGenerateImageValue 00036 { 00037 public: 00039 virtual ~csGenerateImageValue() {} 00041 virtual float GetValue (float x, float y) = 0; 00042 }; 00043 00048 class csGenerateImageTexture 00049 { 00050 public: 00052 virtual ~csGenerateImageTexture() {} 00054 virtual void GetColor(csColor& col, float x, float y) = 0; 00055 }; 00056 00057 00068 class csGenerateImage 00069 { 00070 private: 00072 csGenerateImageTexture *tex; 00073 00074 public: 00076 csGenerateImage(); 00078 ~csGenerateImage(); 00079 00084 void SetTexture(csGenerateImageTexture *t) {tex = t;} 00085 00093 iImage *Generate(int totalw, int totalh, int startx, int starty, 00094 int partw, int parth); 00095 }; 00096 00101 class csGenerateImageLayer 00102 { 00103 public: 00105 float value; 00107 csGenerateImageTexture *tex; 00109 csGenerateImageLayer *next; 00110 }; 00111 00115 class csGenerateImageTextureSolid : public csGenerateImageTexture 00116 { 00117 public: 00119 csColor color; 00121 virtual ~csGenerateImageTextureSolid() {} 00123 virtual void GetColor(csColor& col, float, float) {col = color;} 00124 }; 00125 00129 class csGenerateImageTextureSingle : public csGenerateImageTexture 00130 { 00131 public: 00133 csRef<iImage> image; 00135 csVector2 scale; 00137 csVector2 offset; 00138 00140 virtual ~csGenerateImageTextureSingle(); 00142 void SetImage(iImage *im); 00144 virtual void GetColor(csColor& col, float x, float y); 00146 void GetImagePixel(iImage *image, int x, int y, csRGBpixel& res); 00148 void ComputeLayerColor(const csVector2& pos, csColor& col); 00149 }; 00150 00155 class csGenerateImageTextureBlend : public csGenerateImageTexture 00156 { 00157 public: 00159 csGenerateImageLayer *layers; 00161 csGenerateImageValue *valuefunc; 00163 csGenerateImageTextureBlend(); 00165 virtual ~csGenerateImageTextureBlend(); 00167 virtual void GetColor(csColor& col, float x, float y); 00169 void AddLayer(float value, csGenerateImageTexture *tex); 00170 }; 00171 00172 SCF_VERSION (iGenerateImageFunction, 0, 0, 1); 00173 00178 struct iGenerateImageFunction : public iBase 00179 { 00181 virtual float GetValue (float dx, float dy) = 0; 00182 }; 00183 00184 00189 class csGenerateImageValueFunc : public csGenerateImageValue 00190 { 00191 private: 00193 csRef<iGenerateImageFunction> heightfunc; 00194 00195 public: 00196 csGenerateImageValueFunc () { } 00197 virtual ~csGenerateImageValueFunc () 00198 { 00199 } 00200 00202 virtual float GetValue(float x, float y) 00203 { 00204 return heightfunc->GetValue (x, y); 00205 } 00207 void SetFunction (iGenerateImageFunction* func) 00208 { 00209 heightfunc = func; 00210 } 00211 }; 00212 00216 class csGenerateImageValueFuncConst : public csGenerateImageValue 00217 { 00218 public: 00220 float constant; 00222 virtual float GetValue(float, float){return constant;} 00223 }; 00224 00229 class csGenerateImageValueFuncTex : public csGenerateImageValue 00230 { 00231 public: 00233 csGenerateImageTexture *tex; 00235 virtual ~csGenerateImageValueFuncTex(); 00237 virtual float GetValue(float x, float y); 00238 }; 00239 00240 00241 #endif // __CS_GENTERTEX_H__ 00242
Generated for Crystal Space by doxygen 1.2.18