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 "csextern.h" 00023 00024 #include "csutil/scf.h" 00025 #include "csutil/cscolor.h" 00026 #include "csgeom/vector2.h" 00027 #include "csgfx/rgbpixel.h" 00028 00029 struct iImage; 00030 class csGenerateImageValue; 00031 class csGenerateImageTexture; 00032 00037 class CS_CSTOOL_EXPORT csGenerateImageValue 00038 { 00039 public: 00041 virtual ~csGenerateImageValue() {} 00043 virtual float GetValue (float x, float y) = 0; 00044 }; 00045 00050 class CS_CSTOOL_EXPORT csGenerateImageTexture 00051 { 00052 public: 00054 virtual ~csGenerateImageTexture() {} 00056 virtual void GetColor(csColor& col, float x, float y) = 0; 00057 }; 00058 00059 00070 class CS_CSTOOL_EXPORT csGenerateImage 00071 { 00072 private: 00074 csGenerateImageTexture *tex; 00075 00076 public: 00078 csGenerateImage(); 00080 ~csGenerateImage(); 00081 00086 void SetTexture(csGenerateImageTexture *t) {tex = t;} 00087 00095 iImage *Generate(int totalw, int totalh, int startx, int starty, 00096 int partw, int parth); 00097 }; 00098 00103 class CS_CSTOOL_EXPORT csGenerateImageLayer 00104 { 00105 public: 00107 float value; 00109 csGenerateImageTexture *tex; 00111 csGenerateImageLayer *next; 00112 }; 00113 00117 class CS_CSTOOL_EXPORT csGenerateImageTextureSolid : 00118 public csGenerateImageTexture 00119 { 00120 public: 00122 csColor color; 00124 virtual ~csGenerateImageTextureSolid() {} 00126 virtual void GetColor(csColor& col, float, float) {col = color;} 00127 }; 00128 00132 class CS_CSTOOL_EXPORT csGenerateImageTextureSingle : 00133 public csGenerateImageTexture 00134 { 00135 public: 00137 csRef<iImage> image; 00139 csVector2 scale; 00141 csVector2 offset; 00142 00144 virtual ~csGenerateImageTextureSingle(); 00146 void SetImage(iImage *im); 00148 virtual void GetColor(csColor& col, float x, float y); 00150 void GetImagePixel(iImage *image, int x, int y, csRGBpixel& res); 00152 void ComputeLayerColor(const csVector2& pos, csColor& col); 00153 }; 00154 00159 class CS_CSTOOL_EXPORT csGenerateImageTextureBlend : 00160 public csGenerateImageTexture 00161 { 00162 public: 00164 csGenerateImageLayer *layers; 00166 csGenerateImageValue *valuefunc; 00168 csGenerateImageTextureBlend(); 00170 virtual ~csGenerateImageTextureBlend(); 00172 virtual void GetColor(csColor& col, float x, float y); 00174 void AddLayer(float value, csGenerateImageTexture *tex); 00175 }; 00176 00177 SCF_VERSION (iGenerateImageFunction, 0, 0, 1); 00178 00183 struct iGenerateImageFunction : public iBase 00184 { 00186 virtual float GetValue (float dx, float dy) = 0; 00187 }; 00188 00189 00194 class CS_CSTOOL_EXPORT csGenerateImageValueFunc : public csGenerateImageValue 00195 { 00196 private: 00198 csRef<iGenerateImageFunction> heightfunc; 00199 00200 public: 00201 csGenerateImageValueFunc () { } 00202 virtual ~csGenerateImageValueFunc () 00203 { 00204 } 00205 00207 virtual float GetValue(float x, float y) 00208 { 00209 return heightfunc->GetValue (x, y); 00210 } 00212 void SetFunction (iGenerateImageFunction* func) 00213 { 00214 heightfunc = func; 00215 } 00216 }; 00217 00221 class CS_CSTOOL_EXPORT csGenerateImageValueFuncConst : 00222 public csGenerateImageValue 00223 { 00224 public: 00226 float constant; 00228 virtual float GetValue(float, float){return constant;} 00229 }; 00230 00235 class CS_CSTOOL_EXPORT csGenerateImageValueFuncTex : 00236 public csGenerateImageValue 00237 { 00238 public: 00240 csGenerateImageTexture *tex; 00242 virtual ~csGenerateImageValueFuncTex(); 00244 virtual float GetValue(float x, float y); 00245 }; 00246 00247 00248 #endif // __CS_GENTERTEX_H__ 00249
Generated for Crystal Space by doxygen 1.2.18