CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

cstool/prsky.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_PROCSKYTEX_H__
00020 #define __CS_PROCSKYTEX_H__
00021 
00022 #include "csextern.h"
00023 
00024 #include "csgeom/math3d.h"
00025 #include "csgfx/rgbpixel.h"
00026 #include "csutil/cscolor.h"
00027 #include "cstool/proctex.h"
00028 
00029 class csProcSky;
00030 
00034 class CS_CSTOOL_EXPORT csProcSkyTexture : public csProcTexture
00035 {
00037   csProcSky *sky;
00039   csProcSkyTexture *next;
00040 
00042   csVector3 txtorig, txtu, txtv;
00044   csVector3 *isect;
00046   bool forcerender;
00047 
00048 public:
00050   csProcSkyTexture(csProcSky *par);
00052   virtual ~csProcSkyTexture();
00053 
00054   void SetNextSky(csProcSkyTexture *n) {next = n;}
00055   csProcSkyTexture *GetNextSky() const {return next;}
00056 
00057   virtual bool PrepareAnim ();
00058 
00060   virtual void Animate (csTicks current_time);
00061 
00063   int GetWidth() const {return mat_w;}
00065   int GetHeight() const {return mat_h;}
00067   void GetTextureSpace(csVector3& orig, csVector3& u, csVector3& v) const
00068   { orig = txtorig; u = txtu; v = txtv; }
00070   void SetIntersect(csVector3 *icache) {isect = icache;}
00072   csVector3 *GetIntersect() const {return isect;}
00073 
00075   void ForceRerender() {forcerender = true;}
00077   bool MustRender() const {return forcerender;}
00079   void UnsetForceRender() {forcerender = false;}
00081   bool AnimPrepared () {return anim_prepared;}
00091   void SetTextureSpace(const csVector3& tex_orig, const csVector3& total_u,
00092     const csVector3& total_v) {txtorig=tex_orig; txtu=total_u; txtv=total_v;}
00093 };
00094 
00095 
00100 class CS_CSTOOL_EXPORT csProcSky
00101 {
00103   csProcSkyTexture *firstsky;
00104 
00106   float radius;
00108   csVector3 center;
00110   csVector3 cam;
00112   csVector3 sunpos;
00114   csColor suncolor;
00116   csRGBcolor maxhaze;
00117 
00119   int nr_octaves;
00121   int octsize;
00123   uint8 *octaves;
00125   uint8** enlarged;
00126 
00127 
00129   bool animated;
00131   int *periods;
00133   int *curposition;
00138   uint8 *startoctaves, *endoctaves;
00140   csTicks old_time;
00142   csVector2 windpos;
00144   csVector2 winddir;
00145 
00147   void Initialize();
00149   void InitOctave(uint8 *octs, int nr);
00151   void SmoothOctave(uint8 *octs, int nr, int smoothpower);
00153   void Enlarge(uint8 *dest, uint8 *src, int factor, int rshift);
00155   void Combine(uint8 *dest, uint8 *start, uint8 *end, int pos, int max, int nr);
00157   void AnimOctave(int nr, int elapsed);
00159   uint8& GetOctave(uint8 *octaves, int oct, int x, int y)
00160   { return octaves [ oct*octsize*octsize + y*octsize + x ]; }
00161   void SetOctave(uint8 *octaves, int oct, int x, int y, uint8 val)
00162   { octaves[ oct*octsize*octsize + y*octsize + x ] = val; }
00164   void CopyOctave(uint8 *srcocts, int srcnr, uint8 *destocts, int destnr);
00165 
00167   bool SphereIntersect(const csVector3& point, csVector3& isect);
00169   csRGBcolor GetSkyBlue(const csVector3& spot, float& haze, float sundist,
00170     bool& below);
00172   uint8 GetCloudVal(int x, int y);
00174   float GetSundist(const csVector3& spot);
00175 
00176 public:
00177   csProcSky();
00178   ~csProcSky();
00179 
00181   void DrawToTexture (csProcSkyTexture *skytex, csTicks current_time,
00182         iObjectRegistry* object_reg);
00183 
00185   void MakeIntersectCache(csProcSkyTexture *skytex);
00186 
00195   void SetAnimated (iObjectRegistry* object_reg,
00196         bool anim=true, csTicks current_time=0);
00198   bool GetAnimated() const {return animated;}
00200   csProcSkyTexture *GetFirstSky() const {return firstsky;}
00202   void SetFirstSky(csProcSkyTexture *s) {firstsky = s;}
00203 };
00204 
00205 #endif // __CS_PROCSKYTEX_H__

Generated for Crystal Space by doxygen 1.2.18