// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the
-// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#define _SG_CLOUD_HXX_
#include <simgear/compiler.h>
+#include <simgear/misc/sg_path.hxx>
+#include <simgear/math/SGMath.hxx>
+#include <simgear/structure/SGReferenced.hxx>
-#include <plib/ssg.h>
+#include <string>
+using std::string;
-#include STL_STRING
-SG_USING_STD(string);
-
-// #include <iostream>
-// SG_USING_STD(cout);
-// SG_USING_STD(endl);
+#include <osg/ref_ptr>
+#include <osg/Array>
+#include <osg/Geode>
+#include <osg/Group>
+#include <osg/MatrixTransform>
+#include <osg/Switch>
class SGCloudField;
/**
* A class layer to model a single cloud layer
*/
-class SGCloudLayer {
+class SGCloudLayer : public SGReferenced {
public:
/**
SG_MAX_CLOUD_COVERAGES
};
+ static const std::string SG_CLOUD_OVERCAST_STRING; // "overcast"
+ static const std::string SG_CLOUD_BROKEN_STRING; // "broken"
+ static const std::string SG_CLOUD_SCATTERED_STRING; // "scattered"
+ static const std::string SG_CLOUD_FEW_STRING; // "few"
+ static const std::string SG_CLOUD_CIRRUS_STRING; // "cirrus"
+ static const std::string SG_CLOUD_CLEAR_STRING; // "clear"
+
/**
* Constructor
* @param tex_path the path to the set of cloud textures
*/
void setCoverage (Coverage coverage);
+ /** get coverage as string */
+ const string & getCoverageString() const;
+
+ /** get coverage as string */
+ static const string & getCoverageString( Coverage coverage );
+
+ /** get coverage type from string */
+ static Coverage getCoverageType( const std::string & coverage );
+
+ /** set coverage as string */
+ void setCoverageString( const string & coverage );
+
/**
* set the cloud movement direction
* @param dir the cloud movement direction
/** build the cloud object */
void rebuild();
+ /** Enable/disable 3D clouds in this layer */
+ void set_enable3dClouds(bool enable);
+
/**
* repaint the cloud colors based on the specified fog_color
* @param fog_color the fog color
*/
- bool repaint( sgVec3 fog_color );
+ bool repaint( const SGVec3f& fog_color );
/**
* reposition the cloud layer at the specified origin and
* (and orients the sunrise/set effects)
* @param dt the time elapsed since the last call
*/
- bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt,
+ bool reposition( const SGVec3f& p, const SGVec3f& up,
+ double lon, double lat, double alt,
double dt = 0.0 );
- /** draw the cloud layer */
- void draw( bool top );
+ osg::Switch* getNode() { return cloud_root.get(); }
static bool enable_bump_mapping;
-private:
-
- struct CloudVertex {
- sgVec3 position;
- sgVec2 texCoord;
- sgVec3 tangentSpLight;
- sgVec3 sTangent;
- sgVec3 tTangent;
- sgVec3 normal;
- sgVec4 color;
- };
+ /** return the 3D layer cloud associated with this 2D layer */
+ SGCloudField *get_layer3D(void) { return layer3D; }
- CloudVertex *vertices;
- unsigned int *indices;
+protected:
+ void setTextureOffset(const osg::Vec2& offset);
+private:
- ssgRoot *layer_root;
- ssgTransform *layer_transform;
- ssgLeaf *layer[4];
- ssgStateSelector *state_sel;
+ osg::ref_ptr<osg::Switch> cloud_root;
+ osg::ref_ptr<osg::Switch> layer_root;
+ osg::ref_ptr<osg::Group> group_top, group_bottom;
+ osg::ref_ptr<osg::MatrixTransform> layer_transform;
+ osg::ref_ptr<osg::Geode> layer[4];
float cloud_alpha; // 1.0 = drawn fully, 0.0 faded out completely
- ssgColourArray *cl[4];
- ssgVertexArray *vl[4];
- ssgTexCoordArray *tl[4];
+ osg::ref_ptr<osg::Vec4Array> cl[4];
+ osg::ref_ptr<osg::Vec3Array> vl[4];
+ osg::ref_ptr<osg::Vec2Array> tl[4];
+ osg::ref_ptr<osg::Vec3Array> tl2[4];
// height above sea level (meters)
SGPath texture_path;
// from winds, and to simulate the clouds being tied to ground
// position, not view position
// double xoff, yoff;
- double last_lon, last_lat, last_course;
-
- SGCloudField *layer3D;
-};
+ SGGeod last_pos;
+ double last_course;
+ osg::Vec2 base;
-// make an ssgSimpleState for a cloud layer given the named texture
-ssgSimpleState *sgCloudMakeState( const string &path );
+ SGCloudField *layer3D;
+};
#endif // _SG_CLOUD_HXX_