Ignore:
Timestamp:
Feb 28, 2011, 10:02:50 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
experimental/TerrainTest
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • experimental/TerrainTest/rampedEllipsoidTechnique.cpp

    r265 r266  
    66{
    77        _height = 0.0;
    8         _rampWidthFactor = 0.1; // 10% of ROI is ramp.
     8        _rampWidthFactor = 0.4; // 10% of ROI is ramp.
    99}
    1010
     
    3232        int X_start=0, X_startRamp=0, X_startCore=0, X_endCore=0, X_endRamp=0, X_end=h->getNumColumns();        // Lon
    3333
    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
    3840        clampValue(Y_startRamp, Y_start, Y_end);
    3941        clampValue(Y_startCore, Y_start, Y_end);
     
    4143        clampValue(Y_endRamp, Y_start, Y_end);
    4244
    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
    4751        clampValue(X_startRamp, X_start, X_end);
    4852        clampValue(X_startCore, X_start, X_end);
    4953        clampValue(X_endCore, X_start, X_end);
    5054        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();
    6255
    6356
     
    6760                for(int y=Y_startRamp;y<Y_endRamp;y++)
    6861                {
     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.
    6972                        if( Y_startCore<=y && y<Y_endCore && X_startCore<=x && x<X_endCore )    // If vertex is inside core: Apply final height
    7073                        {
    71                                 h->setHeight( x, y, _height);
     74                                        if(_height<destination_height)
     75                                        destination_height = _height;
    7276                        }
    73                         else    //  vertex is inside ramp but not inside core: apply ramp height
     77                        if(Y_startRamp<=y && y<Y_startCore) // Vertex is inside Y start ramp
    7478                        {
    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;
    76108                        }
    77109                       
     110                        // Set height to calculated value
     111                        h->setHeight( x, y, destination_height);
    78112                }
    79113        }
  • experimental/TerrainTest/rampedEllipsoidTechnique.h

    r265 r266  
    11#pragma once
    22#include "terrainModificationTechnique.h"
     3#include <limits>
    34
    45
     
    1516
    1617private:
     18        double round(double x) {return (x > 0.5) ? ceil(x) : floor(x);}
    1719        double _height;
    1820        double _rampWidthFactor;
  • experimental/TerrainTest/terrainModificationTechnique.h

    r265 r266  
    2121         * \brief This function performs the terrain data modification. Must be subclassed.
    2222         *
    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
     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
    2424         * @param h : Heightfield of the tile which should be modified
    2525         * @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.