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"
55 SGNewCloud(CLFamilly_type classification=CLFamilly_nn);
56 SGNewCloud(string classification);
67 CLTexture_cumulus = 1,
68 CLTexture_stratus = 2,
78 CLbox_type sprite_type;
79 sgVec4 l0, l1, l2, l3;
80 sgVec3 normal, n0, n1, n2, n3;
83 float dist; // distance used during sort
84 bool operator<(const spriteDef &b) const {
85 return (this->dist < b.dist);
92 // the type defines how the sprites can be positioned inside the box, their size, etc
97 typedef vector<spriteDef> list_of_spriteDef;
98 typedef vector<spriteContainer> list_of_spriteContainer;
102 void computeSimpleLight(sgVec3 eyePos);
103 void addSprite(float x, float y, float z, float r, CLbox_type type, int box);
105 // sort on distance to eye because of transparency
106 void sortSprite( sgVec3 eyePos );
108 // render the cloud on screen or on the RTT texture to build the impostor
109 void Render3Dcloud( bool drawBB, sgVec3 eyePos, sgVec3 deltaPos, float dist_center );
111 // compute rotations so that a quad is facing the camera
112 void CalcAngles(sgVec3 refpos, sgVec3 eyePos, float *angleY, float *angleX);
114 // draw a cloud but this time we use the impostor texture
115 void RenderBB(sgVec3 deltaPos, bool first_time, float dist_center);
117 // determine if it is a good idea to use an impostor to render the cloud
118 bool isBillboardable(float dist);
124 sgVec3 cloudpos, center;
126 list_of_spriteDef list_spriteDef;
127 list_of_spriteContainer list_spriteContainer;
129 CLFamilly_type familly;
132 bool direction, fadeActive;
133 float duration, pauseLength, fadetimer;
137 // add a new box to the cloud
138 void addContainer(float x, float y, float z, float r, CLbox_type type);
140 // generate all sprite with defined boxes
141 void genSprites(void);
143 // debug only, define a cumulus
147 void drawContainers(void);
149 // define the new position of the cloud (inside the cloud field, not on sphere)
150 void SetPos(sgVec3 newPos);
152 // render the cloud, fakepos is a relative position inside the cloud field
153 void Render(sgVec3 fakepos);
156 void startFade(bool direction, float duration, float pauseLength);
157 void setFade(float howMuch);
159 inline float getRadius() { return radius; }
160 inline sgVec3 *getCenter() { return ¢er; }
161 inline int getId() { return cloudId; }
163 inline CLFamilly_type getFamilly(void) { return familly; }
165 // load all textures used to draw cloud sprites
166 static void loadTextures( const string &tex_path );
167 static sgVec3 modelSunDir;
168 static sgVec3 sunlight, ambLight;
169 static bool useAnisotropic;
170 static float nearRadius;
171 static bool lowQuality;
172 static SGBbCache *cldCache;
175 #endif // _NEWCLOUD_HXX