diff --git a/include/osgTerrain/Locator b/include/osgTerrain/Locator index 1a54d9c27..11240c2a5 100644 --- a/include/osgTerrain/Locator +++ b/include/osgTerrain/Locator @@ -33,6 +33,8 @@ class OSGTERRAIN_EXPORT Locator : public osg::Object META_Object(osgTerrain, Locator); + virtual bool orientationOpenGL() const { return true; } + virtual bool convertLocalToModel(const osg::Vec3d& /*local*/, osg::Vec3d& /*world*/) const { return false; } virtual bool convertModelToLocal(const osg::Vec3d& /*world*/, osg::Vec3d& /*local*/) const { return false; } @@ -55,36 +57,37 @@ class OSGTERRAIN_EXPORT Locator : public osg::Object class OSGTERRAIN_EXPORT EllipsoidLocator : public osgTerrain::Locator { -public: - - - EllipsoidLocator(double longitude, double latitude, double deltaLongitude, double deltaLatitude, double height=0.0); + public: - void setExtents(double longitude, double latitude, double deltaLongitude, double deltaLatitude, double height=0.0); - double getLongitude() const { return _longitude; } - double getDeltaLongitude() const { return _deltaLongitude; } + EllipsoidLocator(double longitude, double latitude, double deltaLongitude, double deltaLatitude, double height=0.0); - double getLatitude() const { return _latitude; } - double getDeltaLatitude() const { return _deltaLatitude; } - - double getHeight() const { return _height; } + void setExtents(double longitude, double latitude, double deltaLongitude, double deltaLatitude, double height=0.0); - osg::EllipsoidModel* getEllipsoidModel() { return _em.get(); } - const osg::EllipsoidModel* getEllipsoidModel() const { return _em.get(); } + double getLongitude() const { return _longitude; } + double getDeltaLongitude() const { return _deltaLongitude; } - bool convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) const; - bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const; + double getLatitude() const { return _latitude; } + double getDeltaLatitude() const { return _deltaLatitude; } -protected: + double getHeight() const { return _height; } - osg::ref_ptr _em; - - double _longitude; - double _latitude; - double _deltaLongitude; - double _deltaLatitude; - double _height; + osg::EllipsoidModel* getEllipsoidModel() { return _em.get(); } + const osg::EllipsoidModel* getEllipsoidModel() const { return _em.get(); } + + virtual bool orientationOpenGL() const; + virtual bool convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) const; + virtual bool convertModelToLocal(const osg::Vec3d& world, osg::Vec3d& local) const; + + protected: + + osg::ref_ptr _em; + + double _longitude; + double _latitude; + double _deltaLongitude; + double _deltaLatitude; + double _height; }; } diff --git a/src/osgTerrain/GeometryTechnique.cpp b/src/osgTerrain/GeometryTechnique.cpp index f1d511f5e..30389f4e5 100644 --- a/src/osgTerrain/GeometryTechnique.cpp +++ b/src/osgTerrain/GeometryTechnique.cpp @@ -261,6 +261,7 @@ void GeometryTechnique::init() // populate primitive sets bool optimizeOrientations = _elevations!=0; + bool swapOrientation = !(masterLocator->orientationOpenGL()); if (!optimizeOrientations) { @@ -271,8 +272,16 @@ void GeometryTechnique::init() for(unsigned int i=0; iaddPrimitiveSet(elements); @@ -294,10 +303,22 @@ void GeometryTechnique::init() { for(unsigned int i=0; i= 0.0; +} + bool EllipsoidLocator::convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) const { double longitude = _longitude + local.x() * _deltaLongitude;