|
prsky.h00001 /* 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 __PROCSKYTEX_H__ 00020 #define __PROCSKYTEX_H__ 00021 00022 #include "csgeom/math3d.h" 00023 #include "csgfx/rgbpixel.h" 00024 #include "csutil/cscolor.h" 00025 #include "cstool/proctex.h" 00026 00027 class csProcSky; 00028 00032 class csProcSkyTexture : public csProcTexture { 00034 csProcSky *sky; 00036 csProcSkyTexture *next; 00037 00039 csVector3 txtorig, txtu, txtv; 00041 csVector3 *isect; 00043 bool forcerender; 00044 00045 public: 00047 csProcSkyTexture(csProcSky *par); 00049 virtual ~csProcSkyTexture(); 00050 00051 void SetNextSky(csProcSkyTexture *n) {next = n;} 00052 csProcSkyTexture *GetNextSky() const {return next;} 00053 00054 virtual bool PrepareAnim (); 00055 00057 virtual void Animate (csTicks current_time); 00058 00060 iGraphics2D* GetG2D() const {return ptG2D;} 00062 iGraphics3D* GetG3D() const {return ptG3D;} 00064 iTextureManager* GetTextureManager() const {return ptTxtMgr;} 00066 int GetWidth() const {return mat_w;} 00068 int GetHeight() const {return mat_h;} 00070 void GetTextureSpace(csVector3& orig, csVector3& u, csVector3& v) const 00071 { orig = txtorig; u = txtu; v = txtv; } 00073 void SetIntersect(csVector3 *icache) {isect = icache;} 00075 csVector3 *GetIntersect() const {return isect;} 00076 00078 void ForceRerender() {forcerender = true;} 00080 bool MustRender() const {return forcerender;} 00082 void UnsetForceRender() {forcerender = false;} 00084 bool AnimPrepared () {return anim_prepared;} 00094 void SetTextureSpace(const csVector3& tex_orig, const csVector3& total_u, 00095 const csVector3& total_v) {txtorig=tex_orig; txtu=total_u; txtv=total_v;} 00096 }; 00097 00098 00103 class csProcSky { 00105 csProcSkyTexture *firstsky; 00106 00108 float radius; 00110 csVector3 center; 00112 csVector3 cam; 00114 csVector3 sunpos; 00116 csColor suncolor; 00118 csRGBcolor maxhaze; 00119 00121 int nr_octaves; 00123 int octsize; 00125 uint8 *octaves; 00127 uint8** enlarged; 00128 00129 00131 bool animated; 00133 int *periods; 00135 int *curposition; 00140 uint8 *startoctaves, *endoctaves; 00142 csTicks old_time; 00144 csVector2 windpos; 00146 csVector2 winddir; 00147 00149 void Initialize(); 00151 void InitOctave(uint8 *octs, int nr); 00153 void SmoothOctave(uint8 *octs, int nr, int smoothpower); 00155 void Enlarge(uint8 *dest, uint8 *src, int factor, int rshift); 00157 void Combine(uint8 *dest, uint8 *start, uint8 *end, int pos, int max, int nr); 00159 void AnimOctave(int nr, int elapsed); 00161 uint8& GetOctave(uint8 *octaves, int oct, int x, int y) 00162 { return octaves [ oct*octsize*octsize + y*octsize + x ]; } 00163 void SetOctave(uint8 *octaves, int oct, int x, int y, uint8 val) 00164 { octaves[ oct*octsize*octsize + y*octsize + x ] = val; } 00166 void CopyOctave(uint8 *srcocts, int srcnr, uint8 *destocts, int destnr); 00167 00169 bool SphereIntersect(const csVector3& point, csVector3& isect); 00171 csRGBcolor GetSkyBlue(const csVector3& spot, float& haze, float sundist, 00172 bool& below); 00174 uint8 GetCloudVal(int x, int y); 00176 float GetSundist(const csVector3& spot); 00177 00178 public: 00179 csProcSky(); 00180 ~csProcSky(); 00181 00183 void DrawToTexture(csProcSkyTexture *skytex, csTicks current_time); 00184 00186 void MakeIntersectCache(csProcSkyTexture *skytex); 00187 00196 void SetAnimated(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 // __PROCSKYTEX_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |