Added virtual orientationOpenGL() method into osgTerrain::Locator.
This commit is contained in:
@@ -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<osg::EllipsoidModel> _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<osg::EllipsoidModel> _em;
|
||||
|
||||
double _longitude;
|
||||
double _latitude;
|
||||
double _deltaLongitude;
|
||||
double _deltaLatitude;
|
||||
double _height;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -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; i<numColumns; ++i)
|
||||
{
|
||||
unsigned int iv = j*numColumns + i;
|
||||
(*elements)[i*2] = iv + numColumns;
|
||||
(*elements)[i*2+1] = iv;
|
||||
if (swapOrientation)
|
||||
{
|
||||
(*elements)[i*2] = iv + numColumns;
|
||||
(*elements)[i*2+1] = iv;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*elements)[i*2+1] = iv + numColumns;
|
||||
(*elements)[i*2] = iv;
|
||||
}
|
||||
}
|
||||
|
||||
if (_terrainGeometry.valid()) _terrainGeometry->addPrimitiveSet(elements);
|
||||
@@ -294,10 +303,22 @@ void GeometryTechnique::init()
|
||||
{
|
||||
for(unsigned int i=0; i<numColumns-1; ++i)
|
||||
{
|
||||
unsigned int i00 = j*numColumns + i;
|
||||
unsigned int i00;
|
||||
unsigned int i01;
|
||||
if (swapOrientation)
|
||||
{
|
||||
i01 = j*numColumns + i;
|
||||
i00 = i01+numColumns;
|
||||
}
|
||||
else
|
||||
{
|
||||
i00 = j*numColumns + i;
|
||||
i01 = i00+numColumns;
|
||||
}
|
||||
|
||||
unsigned int i10 = i00+1;
|
||||
unsigned int i01 = i00+numColumns;
|
||||
unsigned int i11 = i01+1;
|
||||
|
||||
float e00 = (*_elevations)[i00];
|
||||
float e10 = (*_elevations)[i10];
|
||||
float e01 = (*_elevations)[i01];
|
||||
|
||||
@@ -101,6 +101,11 @@ void EllipsoidLocator::setExtents(double longitude, double latitude, double delt
|
||||
_height = height;
|
||||
}
|
||||
|
||||
bool EllipsoidLocator::orientationOpenGL() const
|
||||
{
|
||||
return (_deltaLongitude * _deltaLatitude) >= 0.0;
|
||||
}
|
||||
|
||||
bool EllipsoidLocator::convertLocalToModel(const osg::Vec3d& local, osg::Vec3d& world) const
|
||||
{
|
||||
double longitude = _longitude + local.x() * _deltaLongitude;
|
||||
|
||||
Reference in New Issue
Block a user