| ## 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/ref.h"
    00031 #include "csutil/scf_interface.h"
    00032
    00033 struct iImage;
    00034
    00035 struct csRGBpixel;
    00036
    00041 class CS_CRYSTALSPACE_EXPORT csGenerateImageValue
    00042 {
    00043 public:
    00045   virtual ~csGenerateImageValue() {}
    00047   virtual float GetValue (float x, float y) = 0;
    00048 };
    00049
    00054 class CS_CRYSTALSPACE_EXPORT csGenerateImageTexture
    00055 {
    00056 public:
    00058   virtual ~csGenerateImageTexture() {}
    00060   virtual void GetColor(csColor& col, float x, float y) = 0;
    00061 };
    00062
    00063
    00074 class CS_CRYSTALSPACE_EXPORT csGenerateImage
    00075 {
    00076 private:
    00078   csGenerateImageTexture *tex;
    00079
    00080 public:
    00082   csGenerateImage();
    00084   ~csGenerateImage();
    00085
    00090   void SetTexture(csGenerateImageTexture *t) {tex = t;}
    00091
    00099   iImage *Generate(int totalw, int totalh, int startx, int starty,
    00100     int partw, int parth);
    00101 };
    00102
    00107 class CS_CRYSTALSPACE_EXPORT csGenerateImageLayer
    00108 {
    00109 public:
    00111   float value;
    00113   csGenerateImageTexture *tex;
    00115   csGenerateImageLayer *next;
    00116 };
    00117
    00121 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureSolid :
    00122   public csGenerateImageTexture
    00123 {
    00124 public:
    00126   csColor color;
    00128   virtual ~csGenerateImageTextureSolid() {}
    00130   virtual void GetColor(csColor& col, float, float) {col = color;}
    00131 };
    00132
    00136 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureSingle :
    00137   public csGenerateImageTexture
    00138 {
    00139 public:
    00141   csRef<iImage> image;
    00143   csVector2 scale;
    00145   csVector2 offset;
    00146
    00148   virtual ~csGenerateImageTextureSingle();
    00150   void SetImage(iImage *im);
    00152   virtual void GetColor(csColor& col, float x, float y);
    00154   void GetImagePixel(iImage *image, int x, int y, csRGBpixel& res);
    00156   void ComputeLayerColor(const csVector2& pos, csColor& col);
    00157 };
    00158
    00163 class CS_CRYSTALSPACE_EXPORT csGenerateImageTextureBlend :
    00164   public csGenerateImageTexture
    00165 {
    00166 public:
    00168   csGenerateImageLayer *layers;
    00170   csGenerateImageValue *valuefunc;
    00172   csGenerateImageTextureBlend();
    00174   virtual ~csGenerateImageTextureBlend();
    00176   virtual void GetColor(csColor& col, float x, float y);
    00178   void AddLayer(float value, csGenerateImageTexture *tex);
    00179 };
    00180
    00185 struct iGenerateImageFunction : public virtual iBase
    00186 {
    00187   SCF_INTERFACE (iGenerateImageFunction, 2, 0, 0);
    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