Ignore:
Timestamp:
Mar 7, 2011, 9:52:06 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/TerrainTest/rampedEllipsoidTechnique.cpp

    r266 r269  
    1313}
    1414
    15 void rampedEllipsoidTechnique::modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends)
     15void rampedEllipsoidTechnique::modifyHeightfield(region& modificationROI, osg::HeightField* h, region tileExtends)
    1616{
    1717        //OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique::modifyHeightfield()" << std::endl;
    18         //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends[0] << " | " << tileExtends[1] << std::endl;
    19         //OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends[2] << " | " << tileExtends[3] << std::endl;
     18        //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends._lat_min << " | " << tileExtends._lat_max << std::endl;
     19        //OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends._lon_min << " | " << tileExtends._lon_max << std::endl;
    2020
    2121        // 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;
     22        double deltaLatPerSide = modificationROI.delta_lat() * _rampWidthFactor / 2.0;
     23        double deltaLonPerSide = modificationROI.delta_lon() * _rampWidthFactor / 2.0;
     24        region coreROI = modificationROI;
     25        coreROI._lat_min+=deltaLatPerSide;
     26        coreROI._lat_max-=deltaLatPerSide;
     27        coreROI._lon_min+=deltaLonPerSide;
     28        coreROI._lon_max-=deltaLonPerSide;
    2929
    3030        // Calculate colum start/end and row start/end of affected vertices
     
    3333
    3434        // 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());
     35        Y_startRamp = round((modificationROI._lat_min-tileExtends._lat_min) / h->getYInterval());
     36        Y_startCore = round((coreROI._lat_min-tileExtends._lat_min) / h->getYInterval());
     37        Y_endCore   = round((coreROI._lat_max-tileExtends._lat_min) / h->getYInterval());
     38        Y_endRamp   = round((modificationROI._lat_max-tileExtends._lat_min) / h->getYInterval());
    3939
    4040        clampValue(Y_startRamp, Y_start, Y_end);
     
    4444
    4545        // 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());
     46        X_startRamp = round((modificationROI._lon_min-tileExtends._lon_min) / h->getXInterval());
     47        X_startCore = round((coreROI._lon_min-tileExtends._lon_min) / h->getXInterval());
     48        X_endCore   = round((coreROI._lon_max-tileExtends._lon_min) / h->getXInterval());
     49        X_endRamp   = round((modificationROI._lon_max-tileExtends._lon_min) / h->getXInterval());
    5050
    5151        clampValue(X_startRamp, X_start, X_end);
     
    6161                {
    6262                        // 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];
     63                        double vertex_lat = y*h->getYInterval()+tileExtends._lat_min;
     64                        double vertex_lon = x*h->getXInterval()+tileExtends._lon_min;
    6565                        // Calculate vertex delta h: h_dest - h_org
    6666                        double height_org = h->getHeight(x,y);
     
    7777                        if(Y_startRamp<=y && y<Y_startCore) // Vertex is inside Y start ramp
    7878                        {
    79                                 double delta_s = abs(modificationROI[0]-vertex_lat);
     79                                double delta_s = abs(modificationROI._lat_min-vertex_lat);
    8080                                double gradient = delta_h/deltaLatPerSide;
    8181                                double dest = delta_s*gradient + height_org;
     
    8585                        if(X_startRamp<=x && x<X_startCore)     // Vertex is inside X start ramp
    8686                        {
    87                                 double delta_s = abs(modificationROI[2]-vertex_lon);
     87                                double delta_s = abs(modificationROI._lon_min-vertex_lon);
    8888                                double gradient = delta_h/deltaLonPerSide;
    8989                                double dest = delta_s*gradient + height_org;
     
    9393                        if(Y_endCore<=y && y<Y_endRamp)  // Vertex is inside Y end ramp
    9494                        {
    95                                 double delta_s = abs(modificationROI[1]-vertex_lat);
     95                                double delta_s = abs(modificationROI._lat_max-vertex_lat);
    9696                                double gradient = delta_h/deltaLatPerSide;
    9797                                double dest = delta_s*gradient + height_org;
     
    101101                        if (X_endCore<=x && x<X_endRamp) // Vertex is inside X end ramp
    102102                        {
    103                                 double delta_s = abs(modificationROI[3]-vertex_lon);
     103                                double delta_s = abs(modificationROI._lon_max-vertex_lon);
    104104                                double gradient = delta_h/deltaLonPerSide;
    105105                                double dest = delta_s*gradient + height_org;
Note: See TracChangeset for help on using the changeset viewer.