//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//
#include <plib/sg.h>
#include <simgear/compiler.h>
-#include STL_STRING
+#include <string>
#include <vector>
+#include <osg/Fog>
#include "bbcache.hxx"
-SG_USING_STD(string);
-SG_USING_STD(vector);
+using std::string;
+using std::vector;
+/**
+ * 3D cloud class.
+ */
class SGNewCloud {
public:
- SGNewCloud();
- ~SGNewCloud();
-
- enum CLbox_type {
- CLbox_standard = 0,
- CLbox_sc = 1,
- CLbox_cumulus = 2,
- CLbox_stratus = 3
- };
-
- enum CLTexture_type {
- CLTexture_cumulus = 1,
- CLTexture_stratus = 2,
- CLTexture_max
- };
-private:
-
- class spriteDef {
- public:
- sgVec3 pos;
- float r;
- CLbox_type sprite_type;
- sgVec4 l0, l1, l2, l3;
- int rank;
- int box;
- float dist; // distance used during sort
- bool operator<(const spriteDef &b) const {
- return this->dist < b.dist;
- }
- };
-
- typedef struct {
- sgVec3 pos;
- float r;
- // the type defines how the sprites can be positioned inside the box, their size, etc
- CLbox_type cont_type;
- sgVec3 center;
- } spriteContainer;
-
- typedef vector<spriteDef> list_of_spriteDef;
- typedef vector<spriteContainer> list_of_spriteContainer;
-
- void computeSimpleLight(sgVec3 eyePos);
- void addSprite(float x, float y, float z, float r, CLbox_type type, int box);
-
- // sort on distance to eye because of transparency
- void sortSprite( sgVec3 eyePos );
-
- // render the cloud on screen or on the RTT texture to build the impostor
- void Render3Dcloud( bool drawBB, sgVec3 eyePos, sgVec3 deltaPos, float dist_center );
-
- // compute rotations so that a quad is facing the camera
- void CalcAngles(sgVec3 refpos, sgVec3 eyePos, float *angleY, float *angleX);
-
- // draw a cloud but this time we use the impostor texture
- void RenderBB(sgVec3 deltaPos, float angleY, float angleX, float dist_center);
-
- // determine if it is a good idea to use an impostor to render the cloud
- bool isBillboardable(float dist);
-
- int cloudId, bbId;
-// int rank;
- sgVec3 cloudpos, center;
- list_of_spriteDef list_spriteDef;
- list_of_spriteContainer list_spriteContainer;
- float minx, maxx, miny, maxy, minz, maxz;
- float radius;
-
- // fading data
- bool direction, fadeActive;
- float duration, pauseLength;
- // need timer here
-
-public:
- // add a new box to the cloud
- void addContainer(float x, float y, float z, float r, CLbox_type type);
-
- // generate all sprite with defined boxes
- void genSprites(void);
+ SGNewCloud(string type,
+ const SGPath &tex_path,
+ string tex,
+ double min_w,
+ double max_w,
+ double min_h,
+ double max_h,
+ double min_sprite_w,
+ double max_sprite_w,
+ double min_sprite_h,
+ double max_sprite_h,
+ double b,
+ int n,
+ int nt_x,
+ int nt_y);
+
+ ~SGNewCloud();
+
+ // Generate a Cloud
+ osg::ref_ptr<osg::Geode> genCloud ();
+
+ static double getDensity(void)
+ {
+ return sprite_density;
+ }
+
+ // Set the sprite density
+ static void setDensity(double d)
+ {
+ sprite_density = d;
+ }
+
- // debug only, define a cumulus
- void new_cu(void);
-
- // debug only
- void drawContainers(void);
-
- // define the new position of the cloud (inside the cloud field, not on sphere)
- void SetPos(sgVec3 newPos);
+private:
- // render the cloud, fakepos is a relative position inside the cloud field
- void Render(sgVec3 fakepos);
+ double min_width;
+ double max_width;
+ double min_height;
+ double max_height;
+ double min_sprite_width;
+ double max_sprite_width;
+ double min_sprite_height;
+ double max_sprite_height;
+ double bottom_shade;
+ int num_sprites;
+ int num_textures_x;
+ int num_textures_y;
+ const string texture;
+ const string name;
+ osg::Geometry* quad;
+ osg::ref_ptr<osg::StateSet> stateSet;
+ static double sprite_density;
+
+ osg::Geometry* createOrthQuad(float w, float h, int varieties_x, int varieties_y);
- //
- void startFade(bool direction, float duration, float pauseLength);
- void setFade(float howMuch);
+};
- inline float getRadius() { return radius; }
- // load all textures used to draw cloud sprites
- static void loadTextures( const string &tex_path );
- static sgVec3 modelSunDir;
- static sgVec3 sunlight, ambLight;
- static bool useAnisotropic;
- static float nearRadius;
- static bool lowQuality;
- static SGBbCache *cldCache;
-};
#endif // _NEWCLOUD_HXX