Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

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   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   iGenerateImageFunction* heightfunc;
00194 
00195 public:
00196   csGenerateImageValueFunc () : heightfunc (NULL) { }
00197   virtual ~csGenerateImageValueFunc ()
00198   {
00199     if (heightfunc) heightfunc->DecRef ();
00200   }
00201 
00203   virtual float GetValue(float x, float y)
00204   {
00205     return heightfunc->GetValue (x, y);
00206   }
00208   void SetFunction (iGenerateImageFunction* func)
00209   {
00210     SCF_SET_REF (heightfunc, func);
00211   }
00212 };
00213 
00217 class csGenerateImageValueFuncConst : public csGenerateImageValue
00218 {
00219 public:
00221   float constant;
00223   virtual float GetValue(float, float){return constant;}
00224 };
00225 
00230 class csGenerateImageValueFuncTex : public csGenerateImageValue
00231 {
00232 public:
00234   csGenerateImageTexture *tex;
00236   ~csGenerateImageValueFuncTex();
00238   virtual float GetValue(float x, float y);
00239 };
00240 
00241 
00242 #endif // __CS_GENTERTEX_H__
00243 

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000