Changeset 266 for experimental/TerrainTest
- Timestamp:
- Feb 28, 2011, 10:02:50 PM (14 years ago)
- Location:
- experimental/TerrainTest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/TerrainTest/rampedEllipsoidTechnique.cpp
r265 r266 6 6 { 7 7 _height = 0.0; 8 _rampWidthFactor = 0. 1; // 10% of ROI is ramp.8 _rampWidthFactor = 0.4; // 10% of ROI is ramp. 9 9 } 10 10 … … 32 32 int X_start=0, X_startRamp=0, X_startCore=0, X_endCore=0, X_endRamp=0, X_end=h->getNumColumns(); // Lon 33 33 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(); 34 // Lat 35 Y_startRamp = round((modificationROI[0]-tileExtends[0]) / h->getYInterval()); 36 Y_startCore = round((coreROI[0]-tileExtends[0]) / h->getYInterval()); 37 Y_endCore = round((coreROI[1]-tileExtends[0]) / h->getYInterval()); 38 Y_endRamp = round((modificationROI[1]-tileExtends[0]) / h->getYInterval()); 39 38 40 clampValue(Y_startRamp, Y_start, Y_end); 39 41 clampValue(Y_startCore, Y_start, Y_end); … … 41 43 clampValue(Y_endRamp, Y_start, Y_end); 42 44 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(); 45 // Lon 46 X_startRamp = round((modificationROI[2]-tileExtends[2]) / h->getXInterval()); 47 X_startCore = round((coreROI[2]-tileExtends[2]) / h->getXInterval()); 48 X_endCore = round((coreROI[3]-tileExtends[2]) / h->getXInterval()); 49 X_endRamp = round((modificationROI[3]-tileExtends[2]) / h->getXInterval()); 50 47 51 clampValue(X_startRamp, X_start, X_end); 48 52 clampValue(X_startCore, X_start, X_end); 49 53 clampValue(X_endCore, X_start, X_end); 50 54 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();62 55 63 56 … … 67 60 for(int y=Y_startRamp;y<Y_endRamp;y++) 68 61 { 62 // Calculate vertex position in global coordinate system (lat/lon) 63 double vertex_lat = y*h->getYInterval()+tileExtends[0]; 64 double vertex_lon = x*h->getXInterval()+tileExtends[2]; 65 // Calculate vertex delta h: h_dest - h_org 66 double height_org = h->getHeight(x,y); 67 double delta_h = _height - height_org; 68 // preset offsetvalue to max and let every region try to lower it... 69 double destination_height = std::numeric_limits<double>::max(); 70 71 // Calculate vertex height according to the region it is in. 69 72 if( Y_startCore<=y && y<Y_endCore && X_startCore<=x && x<X_endCore ) // If vertex is inside core: Apply final height 70 73 { 71 h->setHeight( x, y, _height); 74 if(_height<destination_height) 75 destination_height = _height; 72 76 } 73 else // vertex is inside ramp but not inside core: apply ramp height77 if(Y_startRamp<=y && y<Y_startCore) // Vertex is inside Y start ramp 74 78 { 75 h->setHeight( x, y, _height-50.0); 79 double delta_s = abs(modificationROI[0]-vertex_lat); 80 double gradient = delta_h/deltaLatPerSide; 81 double dest = delta_s*gradient + height_org; 82 if(dest<destination_height) 83 destination_height = dest; 84 } 85 if(X_startRamp<=x && x<X_startCore) // Vertex is inside X start ramp 86 { 87 double delta_s = abs(modificationROI[2]-vertex_lon); 88 double gradient = delta_h/deltaLonPerSide; 89 double dest = delta_s*gradient + height_org; 90 if(dest<destination_height) 91 destination_height = dest; 92 } 93 if(Y_endCore<=y && y<Y_endRamp) // Vertex is inside Y end ramp 94 { 95 double delta_s = abs(modificationROI[1]-vertex_lat); 96 double gradient = delta_h/deltaLatPerSide; 97 double dest = delta_s*gradient + height_org; 98 if(dest<destination_height) 99 destination_height = dest; 100 } 101 if (X_endCore<=x && x<X_endRamp) // Vertex is inside X end ramp 102 { 103 double delta_s = abs(modificationROI[3]-vertex_lon); 104 double gradient = delta_h/deltaLonPerSide; 105 double dest = delta_s*gradient + height_org; 106 if(dest<destination_height) 107 destination_height = dest; 76 108 } 77 109 110 // Set height to calculated value 111 h->setHeight( x, y, destination_height); 78 112 } 79 113 } -
experimental/TerrainTest/rampedEllipsoidTechnique.h
r265 r266 1 1 #pragma once 2 2 #include "terrainModificationTechnique.h" 3 #include <limits> 3 4 4 5 … … 15 16 16 17 private: 18 double round(double x) {return (x > 0.5) ? ceil(x) : floor(x);} 17 19 double _height; 18 20 double _rampWidthFactor; -
experimental/TerrainTest/terrainModificationTechnique.h
r265 r266 21 21 * \brief This function performs the terrain data modification. Must be subclassed. 22 22 * 23 * @param modificationROI This vector contains the extents of the region of interest which should be modified: lat 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 25 * @param tileExtends : This vector contains the extents of the tile: lat_min, lat_max, long_min, long_max
Note: See TracChangeset
for help on using the changeset viewer.