Changeset 262
- Timestamp:
- Feb 25, 2011, 11:01:49 PM (14 years ago)
- Location:
- experimental/TerrainTest
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/TerrainTest/ModificationVisitor.cpp
r260 r262 6 6 { 7 7 setTraversalMode( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ); 8 technique = new ellipsoidTechnique(); 8 _technique = new ellipsoidTechnique(); 9 10 // Set ROI to flatten and estimated height after correction 11 _technique->setModifiedHeight(450); 9 12 } 10 13 … … 49 52 50 53 // ROI to flatten 51 double roi_lat_min = 48.336808; 52 double roi_lat_max = 48.370467; 53 double roi_lon_min = 11.736750; 54 double roi_lon_max = 11.835322; 54 osg::Vec4d modificationROI = osg::Vec4d( 48.336808, 48.370467, 11.736750, 11.835322 ); // roi_lat_min, roi_lat_max, roi_lon_min, roi_lon_max 55 55 56 56 // Determine extend of the tile. … … 61 61 62 62 // Check if tile is fully or partially inside ROI: 63 if(lat_max> roi_lat_min && lat_min<roi_lat_max // lat inside ROI64 && lon_max> roi_lon_min && lon_min<roi_lon_max ) // lon inside ROI63 if(lat_max>modificationROI[0] && lat_min<modificationROI[1] // lat inside ROI? 64 && lon_max>modificationROI[2] && lon_min<modificationROI[3] ) // lon inside ROI? 65 65 { 66 technique->modifyHeightfield(h, lat_min, lat_max, lon_min, lon_max);66 _technique->modifyHeightfield( modificationROI, h, osg::Vec4d(lat_min, lat_max, lon_min, lon_max) ); 67 67 } 68 68 } -
experimental/TerrainTest/ModificationVisitor.h
r258 r262 20 20 void modifyTile(osgTerrain::TerrainTile* tile); 21 21 std::string _extensionToSet; 22 osg::ref_ptr<ellipsoidTechnique> _technique; 22 23 23 ellipsoidTechnique* technique;24 24 }; -
experimental/TerrainTest/Plugins terrainmod/Plugins terrainmod.vcproj
r258 r262 191 191 > 192 192 </File> 193 <File 194 RelativePath="..\terrainModificationTechnique.cpp" 195 > 196 </File> 193 197 </Filter> 194 198 <Filter … … 209 213 > 210 214 </File> 215 <File 216 RelativePath="..\terrainModificationTechnique.h" 217 > 218 </File> 211 219 </Filter> 212 220 <Filter -
experimental/TerrainTest/ellipsoidTechnique.cpp
r261 r262 5 5 ellipsoidTechnique::ellipsoidTechnique() 6 6 { 7 _height = 0.0; 7 8 } 8 9 … … 11 12 } 12 13 13 void ellipsoidTechnique::modifyHeightfield(osg:: HeightField* h, double lat_min, double lat_max, double lon_min, double lon_max)14 void ellipsoidTechnique::modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends) 14 15 { 15 16 OSG_NOTIFY( osg::ALWAYS ) << "ellipsoidTechnique::modifyHeightfield()" << std::endl; 16 OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << lat_min << " | " << lat_max << std::endl; 17 OSG_NOTIFY( osg::ALWAYS ) << "LON: " << lon_min << " | " << lon_max << std::endl; 18 19 int rows = h->getNumRows(); 20 int cols = h->getNumColumns(); 17 OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends[0] << " | " << tileExtends[1] << std::endl; 18 OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends[2] << " | " << tileExtends[3] << std::endl; 21 19 22 20 // calculate colum start/end and row start/end of affected vertices 23 int startX=0, startY=0,endX=cols,endY=rows;21 int startX=0, startY=0, endX=h->getNumColumns(), endY=h->getNumRows(); 24 22 25 double roi_lat_min = 48.336808; 26 double roi_lat_max = 48.370467; 27 double roi_lon_min = 11.736750; 28 double roi_lon_max = 11.835322; 23 24 // Dertermine loop variables.. 25 if(tileExtends[0]<modificationROI[0]) 26 startY = (modificationROI[0] - tileExtends[0]) / h->getYInterval(); 27 if(tileExtends[1]>modificationROI[1]) 28 endY = (modificationROI[1] - tileExtends[0]) / h->getYInterval(); 29 29 30 // dertermining loop variables 31 if(lat_min<roi_lat_min) 32 startY = (roi_lat_min - lat_min) / h->getYInterval(); 33 if(lat_max>roi_lat_max) 34 endY = (roi_lat_max - lat_min) / h->getYInterval(); 35 36 if(lon_min<roi_lon_min) 37 startX = (roi_lon_min - lon_min) / h->getXInterval(); 38 if(lon_max>roi_lon_max) 39 endX = (roi_lon_max - lon_min) / h->getXInterval(); 30 if(tileExtends[2]<modificationROI[2]) 31 startX = (modificationROI[2] - tileExtends[2]) / h->getXInterval(); 32 if(tileExtends[3]>modificationROI[3]) 33 endX = (modificationROI[3] - tileExtends[2]) / h->getXInterval(); 40 34 41 35 42 // modify height value of affected vertices36 // Modify height value of affected vertices 43 37 for(int x=startX;x<endX;x++) 44 38 { 45 39 for(int y=startY;y<endY;y++) 46 40 { 47 h->setHeight( x, y, 550);41 h->setHeight( x, y, _height); 48 42 } 49 43 } 50 51 44 } 52 45 -
experimental/TerrainTest/ellipsoidTechnique.h
r258 r262 1 1 #pragma once 2 2 3 #include <osgTerrain/GeometryTechnique> 4 #include <osg/Image> 3 #include "terrainModificationTechnique.h" 5 4 6 class ellipsoidTechnique 5 6 class ellipsoidTechnique : public terrainModificationTechnique 7 7 { 8 8 public: … … 10 10 ~ellipsoidTechnique(); 11 11 12 void modifyHeightfield(osg::HeightField* h, double lat_min, double lat_max, double lon_min, double lon_max); 12 void modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends); 13 void setModifiedHeight(double height) {_height=height;} 14 15 private: 16 double _height; 13 17 }; 14 18
Note: See TracChangeset
for help on using the changeset viewer.