3 // Written by Harald JOHNSEN, started April 2005.
5 // Copyright (C) 2005 Harald JOHNSEN - hjohnsen@evc.net
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
27 #include <simgear/compiler.h>
31 #include "bbcache.hxx"
50 CLTexture_cumulus = 1,
51 CLTexture_stratus = 2,
60 CLbox_type sprite_type;
61 sgVec4 l0, l1, l2, l3;
64 float dist; // distance used during sort
65 bool operator<(const spriteDef &b) const {
66 return this->dist < b.dist;
73 // the type defines how the sprites can be positioned inside the box, their size, etc
78 typedef vector<spriteDef> list_of_spriteDef;
79 typedef vector<spriteContainer> list_of_spriteContainer;
81 void computeSimpleLight(sgVec3 eyePos);
82 void addSprite(float x, float y, float z, float r, CLbox_type type, int box);
84 // sort on distance to eye because of transparency
85 void sortSprite( sgVec3 eyePos );
87 // render the cloud on screen or on the RTT texture to build the impostor
88 void Render3Dcloud( bool drawBB, sgVec3 eyePos, sgVec3 deltaPos, float dist_center );
90 // compute rotations so that a quad is facing the camera
91 void CalcAngles(sgVec3 refpos, sgVec3 eyePos, float *angleY, float *angleX);
93 // draw a cloud but this time we use the impostor texture
94 void RenderBB(sgVec3 deltaPos, float angleY, float angleX, float dist_center);
96 // determine if it is a good idea to use an impostor to render the cloud
97 bool isBillboardable(float dist);
101 sgVec3 cloudpos, center;
102 list_of_spriteDef list_spriteDef;
103 list_of_spriteContainer list_spriteContainer;
104 float minx, maxx, miny, maxy, minz, maxz;
108 bool direction, fadeActive;
109 float duration, pauseLength;
113 // add a new box to the cloud
114 void addContainer(float x, float y, float z, float r, CLbox_type type);
116 // generate all sprite with defined boxes
117 void genSprites(void);
119 // debug only, define a cumulus
123 void drawContainers(void);
125 // define the new position of the cloud (inside the cloud field, not on sphere)
126 void SetPos(sgVec3 newPos);
128 // render the cloud, fakepos is a relative position inside the cloud field
129 void Render(sgVec3 fakepos);
132 void startFade(bool direction, float duration, float pauseLength);
133 void setFade(float howMuch);
135 inline float getRadius() { return radius; }
137 // load all textures used to draw cloud sprites
138 static void loadTextures( const string &tex_path );
139 static sgVec3 modelSunDir;
140 static sgVec3 sunlight, ambLight;
141 static bool useAnisotropic;
142 static float nearRadius;
143 static bool lowQuality;
144 static SGBbCache *cldCache;
147 #endif // _NEWCLOUD_HXX