#include "rampedEllipsoidTechnique.h" rampedEllipsoidTechnique::rampedEllipsoidTechnique() { _height = 0.0; _rampWidthFactor = 0.4; // 10% of ROI is ramp. } rampedEllipsoidTechnique::~rampedEllipsoidTechnique() { } void rampedEllipsoidTechnique::modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends) { //OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique::modifyHeightfield()" << std::endl; //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends[0] << " | " << tileExtends[1] << std::endl; //OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends[2] << " | " << tileExtends[3] << std::endl; // Determine modificationROI without ramp double deltaLatPerSide = (modificationROI[1] - modificationROI[0]) * _rampWidthFactor / 2.0; double deltaLonPerSide = (modificationROI[3] - modificationROI[2]) * _rampWidthFactor / 2.0; osg::Vec4d coreROI = modificationROI; coreROI[0]+=deltaLatPerSide; coreROI[1]-=deltaLatPerSide; coreROI[2]+=deltaLonPerSide; coreROI[3]-=deltaLonPerSide; // Calculate colum start/end and row start/end of affected vertices int Y_start=0, Y_startRamp=0, Y_startCore=0, Y_endCore=0, Y_endRamp=0, Y_end=h->getNumRows(); // Lat int X_start=0, X_startRamp=0, X_startCore=0, X_endCore=0, X_endRamp=0, X_end=h->getNumColumns(); // Lon // Lat Y_startRamp = round((modificationROI[0]-tileExtends[0]) / h->getYInterval()); Y_startCore = round((coreROI[0]-tileExtends[0]) / h->getYInterval()); Y_endCore = round((coreROI[1]-tileExtends[0]) / h->getYInterval()); Y_endRamp = round((modificationROI[1]-tileExtends[0]) / h->getYInterval()); clampValue(Y_startRamp, Y_start, Y_end); clampValue(Y_startCore, Y_start, Y_end); clampValue(Y_endCore, Y_start, Y_end); clampValue(Y_endRamp, Y_start, Y_end); // Lon X_startRamp = round((modificationROI[2]-tileExtends[2]) / h->getXInterval()); X_startCore = round((coreROI[2]-tileExtends[2]) / h->getXInterval()); X_endCore = round((coreROI[3]-tileExtends[2]) / h->getXInterval()); X_endRamp = round((modificationROI[3]-tileExtends[2]) / h->getXInterval()); clampValue(X_startRamp, X_start, X_end); clampValue(X_startCore, X_start, X_end); clampValue(X_endCore, X_start, X_end); clampValue(X_endRamp, X_start, X_end); // Modify height value of affected vertices in the core ROI for(int x=X_startRamp;xgetYInterval()+tileExtends[0]; double vertex_lon = x*h->getXInterval()+tileExtends[2]; // Calculate vertex delta h: h_dest - h_org double height_org = h->getHeight(x,y); double delta_h = _height - height_org; // preset offsetvalue to max and let every region try to lower it... double destination_height = std::numeric_limits::max(); // Calculate vertex height according to the region it is in. if( Y_startCore<=y && ysetHeight( x, y, destination_height); } } }