## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# cstool/gentrtex.h

Go to the documentation of this file.

    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
    00026 #include "csextern.h"
    00027
    00028 #include "csgeom/vector2.h"
    00029 #include "csutil/cscolor.h"
    00030 #include "csutil/scf.h"
    00031
    00032 struct iImage;
    00033
    00034 struct csRGBpixel;
    00035
    00040 class CS_CRYSTALSPACE_EXPORT csGenerateImageValue
    00041 {
    00042 public:
    00044   virtual ~csGenerateImageValue() {}
    00046   virtual float GetValue (float x, float y) = 0;
    00047 };
    00048
    00053 class CS_CRYSTALSPACE_EXPORT csGenerateImageTexture
    00054 {
    00055 public:
    00057   virtual ~csGenerateImageTexture() {}
    00059   virtual void GetColor(csColor& col, float x, float y) = 0;
    00060 };
    00061
    00062
    00073 class CS_CRYSTALSPACE_EXPORT csGenerateImage
    00074 {
    00075 private:
    00077   csGenerateImageTexture *tex;
    00078
    00079 public:
    00081   csGenerateImage();
    00083   ~csGenerateImage();
    00084
    00089   void SetTexture(csGenerateImageTexture *t) {tex = t;}
    00090
    00098   iImage *Generate(int totalw, int totalh, int startx, int starty,
    00099     int partw, int parth);
    00100 };
    00101
    00106 class CS_CRYSTALSPACE_EXPORT csGenerateImageLayer
    00107 {
    00108 public:
    00110   float value;
    00112   csGenerateImageTexture *tex;
    00114   csGenerateImageLayer *next;
    00115 };
    00116
    00120 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureSolid :
    00121   public csGenerateImageTexture
    00122 {
    00123 public:
    00125   csColor color;
    00127   virtual ~csGenerateImageTextureSolid() {}
    00129   virtual void GetColor(csColor& col, float, float) {col = color;}
    00130 };
    00131
    00135 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureSingle :
    00136   public csGenerateImageTexture
    00137 {
    00138 public:
    00140   csRef<iImage> image;
    00142   csVector2 scale;
    00144   csVector2 offset;
    00145
    00147   virtual ~csGenerateImageTextureSingle();
    00149   void SetImage(iImage *im);
    00151   virtual void GetColor(csColor& col, float x, float y);
    00153   void GetImagePixel(iImage *image, int x, int y, csRGBpixel& res);
    00155   void ComputeLayerColor(const csVector2& pos, csColor& col);
    00156 };
    00157
    00162 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureBlend :
    00163   public csGenerateImageTexture
    00164 {
    00165 public:
    00167   csGenerateImageLayer *layers;
    00169   csGenerateImageValue *valuefunc;
    00171   csGenerateImageTextureBlend();
    00173   virtual ~csGenerateImageTextureBlend();
    00175   virtual void GetColor(csColor& col, float x, float y);
    00177   void AddLayer(float value, csGenerateImageTexture *tex);
    00178 };
    00179
    00180 SCF_VERSION (iGenerateImageFunction, 0, 0, 1);
    00181
    00186 struct iGenerateImageFunction : public iBase
    00187 {
    00189   virtual float GetValue (float dx, float dy) = 0;
    00190 };
    00191
    00192
    00197 class CS_CRYSTALSPACE_EXPORT csGenerateImageValueFunc
    00198         : public csGenerateImageValue
    00199 {
    00200 private:
    00202   csRef<iGenerateImageFunction> heightfunc;
    00203
    00204 public:
    00205   csGenerateImageValueFunc () { }
    00206   virtual ~csGenerateImageValueFunc ()
    00207   {
    00208   }
    00209
    00211   virtual float GetValue(float x, float y)
    00212   {
    00213     return heightfunc->GetValue (x, y);
    00214   }
    00216   void SetFunction (iGenerateImageFunction* func)
    00217   {
    00218     heightfunc = func;
    00219   }
    00220 };
    00221
    00225 class CS_CRYSTALSPACE_EXPORT csGenerateImageValueFuncConst :
    00226   public csGenerateImageValue
    00227 {
    00228 public:
    00230   float constant;
    00232   virtual float GetValue(float, float){return constant;}
    00233 };
    00234
    00239 class CS_CRYSTALSPACE_EXPORT csGenerateImageValueFuncTex :
    00240   public csGenerateImageValue
    00241 {
    00242 public:
    00244   csGenerateImageTexture *tex;
    00246   virtual ~csGenerateImageValueFuncTex();
    00248   virtual float GetValue(float x, float y);
    00249 };
    00250
    00251
    00252 #endif // __CS_GENTERTEX_H__
    00253