Index: experimental/TerrainTest/rampedEllipsoidTechnique.cpp
===================================================================
--- experimental/TerrainTest/rampedEllipsoidTechnique.cpp	(revision 264)
+++ experimental/TerrainTest/rampedEllipsoidTechnique.cpp	(revision 265)
@@ -6,5 +6,5 @@
 {
 	_height = 0.0;
-	_rampWidth_percent = 10.0;
+	_rampWidthFactor = 0.1;	// 10% of ROI is ramp.
 }
 
@@ -15,30 +15,65 @@
 void rampedEllipsoidTechnique::modifyHeightfield(osg::Vec4d& modificationROI, osg::HeightField* h, osg::Vec4d tileExtends)
 {
-	//OSG_NOTIFY( osg::ALWAYS ) << "ellipsoidTechnique::modifyHeightfield()" << std::endl;
+	//OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique::modifyHeightfield()" << std::endl;
 	//OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends[0] << " | " << tileExtends[1] << std::endl;
 	//OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends[2] << " | " << tileExtends[3] << std::endl;
 
-	// calculate colum start/end and row start/end of affected vertices
-	int startX=0, startY=0, endX=h->getNumColumns(), endY=h->getNumRows();
+	// Determine modificationROI without ramp
+	double deltaLatPerSide = (modificationROI[1] - modificationROI[0]) * _rampWidthFactor / 2.0;
+	double deltaLonPerSide = (modificationROI[3] - modificationROI[2]) * _rampWidthFactor / 2.0;
+	osg::Vec4d coreROI = modificationROI;
+	coreROI[0]+=deltaLatPerSide;
+	coreROI[1]-=deltaLatPerSide;
+	coreROI[2]+=deltaLonPerSide;
+	coreROI[3]-=deltaLonPerSide;
 
-	
-	// Dertermine loop variables..
-	if(tileExtends[0]<modificationROI[0])
-		startY = (modificationROI[0] - tileExtends[0]) / h->getYInterval();
-	if(tileExtends[1]>modificationROI[1])
-		endY = (modificationROI[1] - tileExtends[0]) / h->getYInterval();
+	// Calculate colum start/end and row start/end of affected vertices
+	int Y_start=0, Y_startRamp=0, Y_startCore=0, Y_endCore=0, Y_endRamp=0, Y_end=h->getNumRows();		// Lat
+	int X_start=0, X_startRamp=0, X_startCore=0, X_endCore=0, X_endRamp=0, X_end=h->getNumColumns();	// Lon
 
-	if(tileExtends[2]<modificationROI[2])
-		startX = (modificationROI[2] - tileExtends[2]) / h->getXInterval();
-	if(tileExtends[3]>modificationROI[3])
-		endX = (modificationROI[3] - tileExtends[2]) / h->getXInterval();
+	Y_startRamp = (modificationROI[0]-tileExtends[0]) / h->getYInterval();
+	Y_startCore = (coreROI[0]-tileExtends[0]) / h->getYInterval();
+	Y_endCore   = (coreROI[1]-tileExtends[0]) / h->getYInterval();
+	Y_endRamp   = (modificationROI[1]-tileExtends[0]) / h->getYInterval();
+	clampValue(Y_startRamp, Y_start, Y_end);
+	clampValue(Y_startCore, Y_start, Y_end);
+	clampValue(Y_endCore, Y_start, Y_end);
+	clampValue(Y_endRamp, Y_start, Y_end);
+
+	X_startRamp = (modificationROI[2]-tileExtends[2]) / h->getXInterval();
+	X_startCore = (coreROI[2]-tileExtends[2]) / h->getXInterval();
+	X_endCore   = (coreROI[3]-tileExtends[2]) / h->getXInterval();
+	X_endRamp   = (modificationROI[3]-tileExtends[2]) / h->getXInterval();
+	clampValue(X_startRamp, X_start, X_end);
+	clampValue(X_startCore, X_start, X_end);
+	clampValue(X_endCore, X_start, X_end);
+	clampValue(X_endRamp, X_start, X_end);
+
+	// Determine loop variables..
+	//if(tileExtends[0]<modificationROI[0])
+	//	startY = (modificationROI[0] - tileExtends[0]) / h->getYInterval();
+	//if(tileExtends[1]>modificationROI[1])
+	//	endY = (modificationROI[1] - tileExtends[0]) / h->getYInterval();
+
+	//if(tileExtends[2]<modificationROI[2])
+	//	startX = (modificationROI[2] - tileExtends[2]) / h->getXInterval();
+	//if(tileExtends[3]>modificationROI[3])
+	//	endX = (modificationROI[3] - tileExtends[2]) / h->getXInterval();
 
 
-	// Modify height value of affected vertices
-	for(int x=startX;x<endX;x++)
+	// Modify height value of affected vertices in the core ROI
+	for(int x=X_startRamp;x<X_endRamp;x++)
 	{
-		for(int y=startY;y<endY;y++)
+		for(int y=Y_startRamp;y<Y_endRamp;y++)
 		{
-			h->setHeight( x, y, _height);
+			if( Y_startCore<=y && y<Y_endCore && X_startCore<=x && x<X_endCore )	// If vertex is inside core: Apply final height
+			{
+				h->setHeight( x, y, _height);
+			}
+			else	//  vertex is inside ramp but not inside core: apply ramp height
+			{
+				h->setHeight( x, y, _height-50.0);
+			}
+			
 		}
 	}
