[264] | 1 | #include "rampedEllipsoidTechnique.h" |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | rampedEllipsoidTechnique::rampedEllipsoidTechnique() |
---|
| 6 | { |
---|
| 7 | _height = 0.0; |
---|
[265] | 8 | _rampWidthFactor = 0.1; // 10% of ROI is ramp. |
---|
[264] | 9 | } |
---|
| 10 | |
---|
| 11 | rampedEllipsoidTechnique::~rampedEllipsoidTechnique() |
---|
| 12 | { |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | void rampedEllipsoidTechnique::modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends) |
---|
| 16 | { |
---|
[265] | 17 | //OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique::modifyHeightfield()" << std::endl; |
---|
[264] | 18 | //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends[0] << " | " << tileExtends[1] << std::endl; |
---|
| 19 | //OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends[2] << " | " << tileExtends[3] << std::endl; |
---|
| 20 | |
---|
[265] | 21 | // Determine modificationROI without ramp |
---|
| 22 | double deltaLatPerSide = (modificationROI[1] - modificationROI[0]) * _rampWidthFactor / 2.0; |
---|
| 23 | double deltaLonPerSide = (modificationROI[3] - modificationROI[2]) * _rampWidthFactor / 2.0; |
---|
| 24 | osg::Vec4d coreROI = modificationROI; |
---|
| 25 | coreROI[0]+=deltaLatPerSide; |
---|
| 26 | coreROI[1]-=deltaLatPerSide; |
---|
| 27 | coreROI[2]+=deltaLonPerSide; |
---|
| 28 | coreROI[3]-=deltaLonPerSide; |
---|
[264] | 29 | |
---|
[265] | 30 | // Calculate colum start/end and row start/end of affected vertices |
---|
| 31 | int Y_start=0, Y_startRamp=0, Y_startCore=0, Y_endCore=0, Y_endRamp=0, Y_end=h->getNumRows(); // Lat |
---|
| 32 | int X_start=0, X_startRamp=0, X_startCore=0, X_endCore=0, X_endRamp=0, X_end=h->getNumColumns(); // Lon |
---|
[264] | 33 | |
---|
[265] | 34 | Y_startRamp = (modificationROI[0]-tileExtends[0]) / h->getYInterval(); |
---|
| 35 | Y_startCore = (coreROI[0]-tileExtends[0]) / h->getYInterval(); |
---|
| 36 | Y_endCore = (coreROI[1]-tileExtends[0]) / h->getYInterval(); |
---|
| 37 | Y_endRamp = (modificationROI[1]-tileExtends[0]) / h->getYInterval(); |
---|
| 38 | clampValue(Y_startRamp, Y_start, Y_end); |
---|
| 39 | clampValue(Y_startCore, Y_start, Y_end); |
---|
| 40 | clampValue(Y_endCore, Y_start, Y_end); |
---|
| 41 | clampValue(Y_endRamp, Y_start, Y_end); |
---|
[264] | 42 | |
---|
[265] | 43 | X_startRamp = (modificationROI[2]-tileExtends[2]) / h->getXInterval(); |
---|
| 44 | X_startCore = (coreROI[2]-tileExtends[2]) / h->getXInterval(); |
---|
| 45 | X_endCore = (coreROI[3]-tileExtends[2]) / h->getXInterval(); |
---|
| 46 | X_endRamp = (modificationROI[3]-tileExtends[2]) / h->getXInterval(); |
---|
| 47 | clampValue(X_startRamp, X_start, X_end); |
---|
| 48 | clampValue(X_startCore, X_start, X_end); |
---|
| 49 | clampValue(X_endCore, X_start, X_end); |
---|
| 50 | clampValue(X_endRamp, X_start, X_end); |
---|
[264] | 51 | |
---|
[265] | 52 | // Determine loop variables.. |
---|
| 53 | //if(tileExtends[0]<modificationROI[0]) |
---|
| 54 | // startY = (modificationROI[0] - tileExtends[0]) / h->getYInterval(); |
---|
| 55 | //if(tileExtends[1]>modificationROI[1]) |
---|
| 56 | // endY = (modificationROI[1] - tileExtends[0]) / h->getYInterval(); |
---|
| 57 | |
---|
| 58 | //if(tileExtends[2]<modificationROI[2]) |
---|
| 59 | // startX = (modificationROI[2] - tileExtends[2]) / h->getXInterval(); |
---|
| 60 | //if(tileExtends[3]>modificationROI[3]) |
---|
| 61 | // endX = (modificationROI[3] - tileExtends[2]) / h->getXInterval(); |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | // Modify height value of affected vertices in the core ROI |
---|
| 65 | for(int x=X_startRamp;x<X_endRamp;x++) |
---|
[264] | 66 | { |
---|
[265] | 67 | for(int y=Y_startRamp;y<Y_endRamp;y++) |
---|
[264] | 68 | { |
---|
[265] | 69 | if( Y_startCore<=y && y<Y_endCore && X_startCore<=x && x<X_endCore ) // If vertex is inside core: Apply final height |
---|
| 70 | { |
---|
| 71 | h->setHeight( x, y, _height); |
---|
| 72 | } |
---|
| 73 | else // vertex is inside ramp but not inside core: apply ramp height |
---|
| 74 | { |
---|
| 75 | h->setHeight( x, y, _height-50.0); |
---|
| 76 | } |
---|
| 77 | |
---|
[264] | 78 | } |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|