CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 "csgeom/vector2.h"
00025 #include "csutil/cscolor.h"
00026 #include "csutil/scf.h"
00027 
00028 struct iImage;
00029 
00030 struct csRGBpixel;
00031 
00036 class CS_CRYSTALSPACE_EXPORT csGenerateImageValue
00037 {
00038 public:
00040   virtual ~csGenerateImageValue() {}
00042   virtual float GetValue (float x, float y) = 0;
00043 };
00044 
00049 class CS_CRYSTALSPACE_EXPORT csGenerateImageTexture
00050 {
00051 public:
00053   virtual ~csGenerateImageTexture() {}
00055   virtual void GetColor(csColor& col, float x, float y) = 0;
00056 };
00057 
00058 
00069 class CS_CRYSTALSPACE_EXPORT csGenerateImage
00070 {
00071 private:
00073   csGenerateImageTexture *tex;
00074 
00075 public:
00077   csGenerateImage();
00079   ~csGenerateImage();
00080 
00085   void SetTexture(csGenerateImageTexture *t) {tex = t;}
00086 
00094   iImage *Generate(int totalw, int totalh, int startx, int starty,
00095     int partw, int parth);
00096 };
00097 
00102 class CS_CRYSTALSPACE_EXPORT csGenerateImageLayer
00103 {
00104 public:
00106   float value;
00108   csGenerateImageTexture *tex;
00110   csGenerateImageLayer *next;
00111 };
00112 
00116 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureSolid : 
00117   public csGenerateImageTexture
00118 {
00119 public:
00121   csColor color;
00123   virtual ~csGenerateImageTextureSolid() {}
00125   virtual void GetColor(csColor& col, float, float) {col = color;}
00126 };
00127 
00131 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureSingle : 
00132   public csGenerateImageTexture
00133 {
00134 public:
00136   csRef<iImage> image;
00138   csVector2 scale;
00140   csVector2 offset;
00141 
00143   virtual ~csGenerateImageTextureSingle();
00145   void SetImage(iImage *im);
00147   virtual void GetColor(csColor& col, float x, float y);
00149   void GetImagePixel(iImage *image, int x, int y, csRGBpixel& res);
00151   void ComputeLayerColor(const csVector2& pos, csColor& col);
00152 };
00153 
00158 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureBlend : 
00159   public csGenerateImageTexture
00160 {
00161 public:
00163   csGenerateImageLayer *layers;
00165   csGenerateImageValue *valuefunc;
00167   csGenerateImageTextureBlend();
00169   virtual ~csGenerateImageTextureBlend();
00171   virtual void GetColor(csColor& col, float x, float y);
00173   void AddLayer(float value, csGenerateImageTexture *tex);
00174 };
00175 
00176 SCF_VERSION (iGenerateImageFunction, 0, 0, 1);
00177 
00182 struct iGenerateImageFunction : public iBase
00183 {
00185   virtual float GetValue (float dx, float dy) = 0;
00186 };
00187 
00188 
00193 class CS_CRYSTALSPACE_EXPORT csGenerateImageValueFunc : public csGenerateImageValue
00194 {
00195 private:
00197   csRef<iGenerateImageFunction> heightfunc;
00198 
00199 public:
00200   csGenerateImageValueFunc () { }
00201   virtual ~csGenerateImageValueFunc ()
00202   {
00203   }
00204 
00206   virtual float GetValue(float x, float y)
00207   {
00208     return heightfunc->GetValue (x, y);
00209   }
00211   void SetFunction (iGenerateImageFunction* func)
00212   {
00213     heightfunc = func;
00214   }
00215 };
00216 
00220 class CS_CRYSTALSPACE_EXPORT csGenerateImageValueFuncConst : 
00221   public csGenerateImageValue
00222 {
00223 public:
00225   float constant;
00227   virtual float GetValue(float, float){return constant;}
00228 };
00229 
00234 class CS_CRYSTALSPACE_EXPORT csGenerateImageValueFuncTex : 
00235   public csGenerateImageValue
00236 {
00237 public:
00239   csGenerateImageTexture *tex;
00241   virtual ~csGenerateImageValueFuncTex();
00243   virtual float GetValue(float x, float y);
00244 };
00245 
00246 
00247 #endif // __CS_GENTERTEX_H__
00248 

Generated for Crystal Space by doxygen 1.4.4