Changeset 265
- Timestamp:
- Feb 27, 2011, 8:11:34 PM (14 years ago)
- Location:
- experimental/TerrainTest
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/TerrainTest/ModificationVisitor.cpp
r262 r265 6 6 { 7 7 setTraversalMode( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ); 8 _technique = new ellipsoidTechnique();8 _technique = new rampedEllipsoidTechnique(); 9 9 10 10 // Set ROI to flatten and estimated height after correction 11 _technique->setModifiedHeight( 450);11 _technique->setModifiedHeight(600); // 450 12 12 } 13 13 -
experimental/TerrainTest/ModificationVisitor.h
r264 r265 21 21 void modifyTile(osgTerrain::TerrainTile* tile); 22 22 std::string _extensionToSet; 23 osg::ref_ptr< ellipsoidTechnique> _technique;23 osg::ref_ptr<rampedEllipsoidTechnique> _technique; 24 24 25 25 }; -
experimental/TerrainTest/ellipsoidTechnique.cpp
r264 r265 21 21 22 22 23 // De rtermine loop variables..23 // Determine loop variables.. 24 24 if(tileExtends[0]<modificationROI[0]) 25 25 startY = (modificationROI[0] - tileExtends[0]) / h->getYInterval(); -
experimental/TerrainTest/rampedEllipsoidTechnique.cpp
r264 r265 6 6 { 7 7 _height = 0.0; 8 _rampWidth _percent = 10.0;8 _rampWidthFactor = 0.1; // 10% of ROI is ramp. 9 9 } 10 10 … … 15 15 void rampedEllipsoidTechnique::modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends) 16 16 { 17 //OSG_NOTIFY( osg::ALWAYS ) << " ellipsoidTechnique::modifyHeightfield()" << std::endl;17 //OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique::modifyHeightfield()" << std::endl; 18 18 //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends[0] << " | " << tileExtends[1] << std::endl; 19 19 //OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends[2] << " | " << tileExtends[3] << std::endl; 20 20 21 // calculate colum start/end and row start/end of affected vertices 22 int startX=0, startY=0, endX=h->getNumColumns(), endY=h->getNumRows(); 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; 23 29 24 25 // Dertermine loop variables.. 26 if(tileExtends[0]<modificationROI[0]) 27 startY = (modificationROI[0] - tileExtends[0]) / h->getYInterval(); 28 if(tileExtends[1]>modificationROI[1]) 29 endY = (modificationROI[1] - tileExtends[0]) / h->getYInterval(); 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 30 33 31 if(tileExtends[2]<modificationROI[2]) 32 startX = (modificationROI[2] - tileExtends[2]) / h->getXInterval(); 33 if(tileExtends[3]>modificationROI[3]) 34 endX = (modificationROI[3] - tileExtends[2]) / h->getXInterval(); 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); 42 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); 51 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(); 35 62 36 63 37 // Modify height value of affected vertices 38 for(int x= startX;x<endX;x++)64 // Modify height value of affected vertices in the core ROI 65 for(int x=X_startRamp;x<X_endRamp;x++) 39 66 { 40 for(int y= startY;y<endY;y++)67 for(int y=Y_startRamp;y<Y_endRamp;y++) 41 68 { 42 h->setHeight( x, y, _height); 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 43 78 } 44 79 } -
experimental/TerrainTest/rampedEllipsoidTechnique.h
r264 r265 12 12 void modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends); 13 13 void setModifiedHeight(double height) {_height=height;} 14 void setRampWidth _percent(double rampWidth_percent) {_rampWidth_percent=rampWidth_percent;}14 void setRampWidthFactor(double rampWidthFactor) {_rampWidthFactor=rampWidthFactor;} 15 15 16 16 private: 17 17 double _height; 18 double _rampWidth _percent;18 double _rampWidthFactor; 19 19 }; -
experimental/TerrainTest/terrainModificationTechnique.h
r264 r265 23 23 * @param modificationROI This vector contains the extents of the region of interest which should be modified: lat min, lat_max, long_min, long_max 24 24 * @param h : Heightfield of the tile which should be modified 25 * @param tileExtends : This vector contains the extents of the tile: lat 25 * @param tileExtends : This vector contains the extents of the tile: lat_min, lat_max, long_min, long_max 26 26 */ 27 27 virtual void modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends)=0; 28 28 29 protected: 30 void clampValue(double& value, double min, double max){if(value<min)value=min;if(value>max)value=max;} 31 void clampValue(int& value, int min, int max){if(value<min)value=min;if(value>max)value=max;} 29 32 };
Note: See TracChangeset
for help on using the changeset viewer.