Index: experimental/TerrainTest/ModificationManager.cpp
===================================================================
--- experimental/TerrainTest/ModificationManager.cpp	(revision 274)
+++ experimental/TerrainTest/ModificationManager.cpp	(revision 275)
@@ -17,4 +17,45 @@
 #include "ModificationManager.h"
 
+#define USE_TERRAIN_PROTO_WORKAROUND USE_TERRAIN_PROTO_WORKAROUND
 
 
+void ModificationManager::addTerrainToManage(osgTerrain::Terrain* terrain)
+{
+	if(terrain)
+		managedTerrain.push_back(terrain);
+}
+
+bool ModificationManager::removeTerrainToManage(osgTerrain::Terrain* terrain)
+{
+	for(unsigned int i=0;i<managedTerrain.size();i++)
+	{
+		if(managedTerrain[i] == terrain)
+		{
+			managedTerrain.erase(managedTerrain.begin()+i);
+			return true;
+		}
+	}
+	return false;
+}
+
+void ModificationManager::setGeometryTechniquePrototype( osgTerrain::GeometryTechnique* geomTechnique, osgTerrain::Terrain* terrain )
+{
+	if(!geomTechnique)	// Remove the installed geometry technique
+	{
+		terrain->setTerrainTechniquePrototype( NULL );
+#ifdef USE_TERRAIN_PROTO_WORKAROUND
+		osgTerrain::TerrainTile::setTileLoadedCallback(NULL);
+#endif
+		return;
+	}
+
+
+	terrain->setTerrainTechniquePrototype( geomTechnique );
+#ifdef USE_TERRAIN_PROTO_WORKAROUND
+	osg::ref_ptr<osgTerrain::myTileLoadedCallback> tlcb = new osgTerrain::myTileLoadedCallback( terrain);
+	osgTerrain::TerrainTile::setTileLoadedCallback(tlcb);
+#endif
+
+
+}
+
Index: experimental/TerrainTest/ModificationManager.h
===================================================================
--- experimental/TerrainTest/ModificationManager.h	(revision 274)
+++ experimental/TerrainTest/ModificationManager.h	(revision 275)
@@ -17,22 +17,72 @@
 
 #include "region.h"
+#include "myTileLoadedCallback.h"
+#include "terrainModificationTechnique.h"
+#include <osgTerrain/Terrain>
+#include <osgTerrain/GeometryTechnique>
 #include <osg/observer_ptr>
+#include <vector>
 
 
+
+
+/**
+ * \brief This class provides a management interface to control terrain modification.
+ * 
+ * It is possible to modify preprocessed VirtualPLanetBuilder (VPB) Databases on the fly.
+ * The modification can be performed in two ways: 
+ * a) Modifying only the tile data and using the standard geometryTechnique to mesh the drawable.
+ * b) Using an userdefined geometryTechnique to create other meshes than the regular triangle mesh.
+ * 
+ * Currently the changes are made on run time but in the pseudo loader. This way the modification does not affect the frame rate but only the delay in the tile delivery to the rendering thread.
+ * 
+ * @author Torben Dannhauer
+ * @date  Mrz 2011
+ */ 
 class ModificationManager
 {
 public:
+	//! Destructor: Must be public to ensure the singleton can be cleand up at the end of the programm.
 	~ModificationManager(){};
 
+	/**
+	 * \brief This function returns a reference to the singleton instance of the terrain manager.
+	 * 
+	 * @return Reference to the singleton instance of the terrain manager.
+	 */ 
 	static ModificationManager* getInstance() {static ModificationManager instance; return &instance;}
 
-	//void addRoi();
+	/**
+	 * \brief This function adds a terrain class to the manager to be managed and accessible to terrain modifications.
+	 * 
+	 * @param terrain : Terrain to manage.
+	 */ 
+	void addTerrainToManage(osgTerrain::Terrain* terrain);
 
-private:
-	ModificationManager(){};
-
-	ModificationManager(const ModificationManager& cc) {};
+	/**
+	 * \brief This functions removes a terrain class from the manager to stop it's managing.
+	 * 
+	 * @param terrain : Terrain to remove.
+	 * @return : True of the specified terrain was managed and is now removed. If the specified terrain was not managed it will return false.
+	 */ 
+	bool removeTerrainToManage(osgTerrain::Terrain* terrain);
 
 
 
+	//void addRoi(region modificationROI, terrainModificationTechnique* technique=NULL);
+	//bool removeRoi(region modificationROI);
+
+	void setGeometryTechniquePrototype( osgTerrain::GeometryTechnique* geomTechnique, osgTerrain::Terrain* terrain=NULL );
+
+
+private:
+	//! Constructor: Private to avoid that this class can be instantiated - it should only be usable as singleton.
+	ModificationManager(){};
+
+	//! Copy-Constructor: Private to avoid that someone can create an class instance by copying the singleton instance.
+	ModificationManager(const ModificationManager& cc) {};
+
+	//! Vector of all managed terrain pointers.
+	std::vector<osgTerrain::Terrain*> managedTerrain;
+
 };
Index: experimental/TerrainTest/ModificationVisitor.cpp
===================================================================
--- experimental/TerrainTest/ModificationVisitor.cpp	(revision 274)
+++ experimental/TerrainTest/ModificationVisitor.cpp	(revision 275)
@@ -22,5 +22,5 @@
 {
 	setTraversalMode( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN );
-	_technique = new ellipsoidTechnique();
+	_technique = new rampedEllipsoidTechnique();
 
 	// Set ROI to flatten and estimated height after correction
@@ -71,6 +71,7 @@
 
 	// ROI to flatten
-	//region modificationROI = region( 48.336808, 48.370467, 11.736750, 11.835322 );		// roi_lat_min, roi_lat_max, roi_lon_min, roi_lon_max
-	region modificationROI = region( 48.331808, 48.375467, 11.731750, 11.840322 );		// roi_lat_min, roi_lat_max, roi_lon_min, roi_lon_max
+	//region modificationROI = region( 48.336808, 48.370467, 11.736750, 11.835322 );		// roi_lat_min, roi_lat_max, roi_lon_min, roi_lon_max	// MUC
+	region modificationROI = region( 48.331808, 48.375467, 11.731750, 11.840322 );		// roi_lat_min, roi_lat_max, roi_lon_min, roi_lon_max	// MUC in größer wegen Rampe.
+	//region modificationROI = region( 30.0, 50.0, 9.0, 15.0 );		// roi_lat_min, roi_lat_max, roi_lon_min, roi_lon_max		// Large ROI für Bluemarble.
 
 	// Check if tile is fully or partially inside ROI:
Index: experimental/TerrainTest/ModificationVisitor.h
===================================================================
--- experimental/TerrainTest/ModificationVisitor.h	(revision 274)
+++ experimental/TerrainTest/ModificationVisitor.h	(revision 275)
@@ -23,5 +23,5 @@
 
 #include "ellipsoidTechnique.h"
-#include "ellipsoidTechnique.h"
+#include "rampedEllipsoidTechnique.h"
 
 
@@ -36,5 +36,5 @@
 	void modifyTile(osgTerrain::TerrainTile* tile);
 	std::string _extensionToSet;
-	osg::ref_ptr<ellipsoidTechnique> _technique;
+	osg::ref_ptr<rampedEllipsoidTechnique> _technique;
 
 };
Index: experimental/TerrainTest/Plugins terrainmod/Plugins terrainmod.vcproj
===================================================================
--- experimental/TerrainTest/Plugins terrainmod/Plugins terrainmod.vcproj	(revision 274)
+++ experimental/TerrainTest/Plugins terrainmod/Plugins terrainmod.vcproj	(revision 275)
@@ -192,4 +192,8 @@
 			</File>
 			<File
+				RelativePath="..\myTerrainTechnique.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\rampedEllipsoidTechnique.cpp"
 				>
@@ -226,4 +230,12 @@
 			</File>
 			<File
+				RelativePath="..\myTerrainTechnique.h"
+				>
+			</File>
+			<File
+				RelativePath="..\myTileLoadedCallback.h"
+				>
+			</File>
+			<File
 				RelativePath="..\rampedEllipsoidTechnique.h"
 				>
Index: experimental/TerrainTest/TerrainTest.vcproj
===================================================================
--- experimental/TerrainTest/TerrainTest.vcproj	(revision 274)
+++ experimental/TerrainTest/TerrainTest.vcproj	(revision 275)
@@ -346,8 +346,4 @@
 			</File>
 			<File
-				RelativePath=".\myTileLoadedCallback.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\osgterrain.cpp"
 				>
Index: experimental/TerrainTest/myTerrainTechnique.cpp
===================================================================
--- experimental/TerrainTest/myTerrainTechnique.cpp	(revision 274)
+++ experimental/TerrainTest/myTerrainTechnique.cpp	(revision 275)
@@ -32,11 +32,12 @@
 	h->setHeight( 0,0, 1000);
 
+	 /*
 	 ImageLayer* il = dynamic_cast<ImageLayer*>( getTerrainTile()->getColorLayer(0) );
 	 osg::Image* img = il->getImage();
 	 //img->setInternalTextureFormat( GL_RGBA );
 
-	/* if( img->getPixelFormat() == GL_RGBA )
+	  if( img->getPixelFormat() == GL_RGBA )
 		 OSG_ALWAYS << "Format ist RGBA" << std::endl;
-	 if( img->getPixelFormat() == GL_RGB )
+	  if( img->getPixelFormat() == GL_RGB )
 		 OSG_ALWAYS << "Format ist RGB" << std::endl;
 	  if( img->getPixelFormat() == GL_COMPRESSED_RGB_S3TC_DXT1_EXT )
@@ -44,72 +45,6 @@
 
 	 
-
-	 //osg::ref_ptr<osg::Image> img2 = new osg::Image();
-	 //img2->setInternalTextureFormat( GL_RGBA );
-	 //OSG_ALWAYS << "test: " << std::hex << img->getPixelFormat() << std::endl;
-
     GeometryTechnique::init(dirtyMask, assumeMultiThreaded);
 
-	//getTerrainTile()->getLocator()->
-
-	OpenThreads::Thread::microSleep( 50000 );
+	//OpenThreads::Thread::microSleep( 50000 );	/ To simulate some complex tile modification.
 }
-
-void myTerrainTechnique::ConvertImage(osg::ref_ptr<osg::Image> a_toImage, osg::ref_ptr<osg::Image> a_fromImage, GLenum a_pixelFormat, GLenum a_dataType)
-{
-	GLenum dataType = a_fromImage -> getDataType();
-
-	//setInternalTextureFormat( 0); // tmp
-	a_toImage -> allocateImage(
-		a_fromImage -> s(),
-		a_fromImage -> t(),
-		a_fromImage -> r(),
-		a_pixelFormat, a_dataType, a_fromImage -> getPacking());
-
-	//// Wenn Quelle und Ziel RGBA sind
-	//if( a_toImage -> getPixelFormat() == GL_RGBA && a_fromImage -> getPixelFormat() == GL_RGBA)
-	//{
-	//	unsigned nr = a_fromImage->t();
-	//	unsigned nc = a_fromImage->s();
-	//	for (unsigned r = 0; r < nr; ++r)
-	//	{
-	//		for (unsigned c = 0; c < nc; ++c)
-	//		{
-	//			unsigned char * fromPixelData = a_fromImage -> data(c, nr-r-1);
-	//			unsigned char *   toPixelData =   a_toImage -> data(c, nr-r-1);
-
-	//			// Copy r, g, b, a.
-	//			for( int component = 0; component < 4; ++ component)
-	//			{
-	//				My_OSG_Library::OSG_PixelComponent pixelComponent( a_fromImage -> getDataType(), fromPixelData, component /* r, g, b, a */);
-	//				pixelComponent.Store( a_toImage -> getDataType(), toPixelData, component);
-	//			}
-	//		}
-	//	}
-	//}
-	//else
-	// Wenn Quelle RGB ist und Ziel RGBA
-	//if( a_toImage -> getPixelFormat() == GL_RGBA && a_fromImage -> getPixelFormat() == GL_RGB)
-	//{
-	//	unsigned nr = a_fromImage -> t();
-	//	unsigned nc = a_fromImage -> s();
-	//	for (unsigned r = 0; r < nr; ++r)
-	//	{
-	//		for (unsigned c = 0; c < nc; ++c)
-	//		{
-	//			unsigned char * fromPixelData = a_fromImage -> data(c, nr-r-1);
-	//			unsigned char *   toPixelData =   a_toImage -> data(c, nr-r-1);
-
-	//			// Copy r, g, b.
-	//			for( int component = 0; component < 3; ++ component)
-	//			{
-	//				My_OSG_Library::OSG_PixelComponent pixelComponent( a_fromImage -> getDataType(), fromPixelData, component /* r, g, b */);
-	//				pixelComponent.Store( a_toImage -> getDataType(), toPixelData, component);
-	//			}
-
-	//			// Initialize alpha to opaque.
-	//			My_OSG_Library::OSG_PixelComponent::One().Store( a_toImage -> getDataType(), toPixelData, 3);
-	//		}
-	//	}
-	//}
-}
Index: experimental/TerrainTest/myTerrainTechnique.h
===================================================================
--- experimental/TerrainTest/myTerrainTechnique.h	(revision 274)
+++ experimental/TerrainTest/myTerrainTechnique.h	(revision 275)
@@ -20,6 +20,4 @@
 
 	virtual void init(int dirtyMask, bool assumeMultiThreaded);
-
-	void ConvertImage(osg::ref_ptr<osg::Image> a_toImage, osg::ref_ptr<osg::Image> a_fromImage, GLenum a_pixelFormat, GLenum a_dataType);
 };
 
Index: experimental/TerrainTest/myTileLoadedCallback.cpp
===================================================================
--- experimental/TerrainTest/myTileLoadedCallback.cpp	(revision 274)
+++ 	(revision )
@@ -1,29 +1,0 @@
-#include "myTileLoadedCallback.h"
-#include <osgTerrain/Terrain>
-
-#include "myTerrainTechnique.h"
-
-using namespace osgTerrain;
-
-myTileLoadedCallback::myTileLoadedCallback(osgTerrain::Terrain* terrain) : _terrain(terrain)
-{
-}
-
-myTileLoadedCallback::~myTileLoadedCallback()
-{
-
-}
-
-bool myTileLoadedCallback::deferExternalLayerLoading() const
-{
-    return true;
-}
-
-void myTileLoadedCallback::loaded(osgTerrain::TerrainTile* tile, const osgDB::ReaderWriter::Options* options) const
-{
-	//OSG_ALWAYS << "Executing myTileLoadedCallback!" << std::endl;
-	tile->setTerrain( _terrain );
-	tile->setTerrainTechnique( new osgTerrain::myTerrainTechnique() );
-	_terrain->updateTerrainTileOnNextFrame(tile);
-}
-    
Index: experimental/TerrainTest/myTileLoadedCallback.h
===================================================================
--- experimental/TerrainTest/myTileLoadedCallback.h	(revision 274)
+++ experimental/TerrainTest/myTileLoadedCallback.h	(revision 275)
@@ -1,22 +1,35 @@
 #pragma once
 #include <osgTerrain/TerrainTile>
+#include "myTerrainTechnique.h"
+
 
 namespace osgTerrain {
-
-class Terrain;
 
 class  myTileLoadedCallback : public TerrainTile::TileLoadedCallback
 {
 public:
-    myTileLoadedCallback(osgTerrain::Terrain* terrain);
-    virtual bool deferExternalLayerLoading() const;
-    virtual void loaded(osgTerrain::TerrainTile* tile, const osgDB::ReaderWriter::Options* options) const;
-    
-protected:
-    virtual ~myTileLoadedCallback();
+	//! Constructor: Nothing to do.
+	myTileLoadedCallback() {};
 
-	osg::ref_ptr<osgTerrain::Terrain> _terrain;
-   
+	//! Destructor: Nothing to do.
+	virtual ~myTileLoadedCallback() {};
+
+	/**
+	 * \brief This function must be implemented. 
+	 * 
+	 * @return : Extrnal layer loding status.
+	 */ 
+	virtual bool deferExternalLayerLoading() const {return true;}
+
+	/**
+	 * \brief This function is performed after every tile loading.
+	 * 
+	 * It is used to install a custom geometryTechnique on every tile, because VPB databases older VPB 0.10 have a hardcoded geometryTechnique which ignores the GeometryTechniquePrototype of osgTerrain.
+	 * 
+	 * @param tile : Loaded tile.
+	 * @param options : Reader writer optins. Defined as interface, but in this class not used.
+	 */ 
+	virtual void loaded(osgTerrain::TerrainTile* tile, const osgDB::ReaderWriter::Options* options) const {tile->setTerrainTechnique( new osgTerrain::myTerrainTechnique() );}; 
 };
 
-}
+}	// Namespace end.
Index: experimental/TerrainTest/osgterrain.cpp
===================================================================
--- experimental/TerrainTest/osgterrain.cpp	(revision 274)
+++ experimental/TerrainTest/osgterrain.cpp	(revision 275)
@@ -232,13 +232,7 @@
 	//terrain->setTerrainTechniquePrototype( myT );
 
-	//// Manually set the terrain technque for a tile ( his example, the first found tile) works, but then the whole database has to be processed
-	//osgTerrain::TerrainTile* tile = findTopMostNodeOfType<osgTerrain::TerrainTile>(rootnode);
-	//if(tile)
-	//{
-	//	tile->setTerrainTechnique( myT );
-	//}
 
 	// Use Tile load Callback
-	osg::ref_ptr<osgTerrain::myTileLoadedCallback> tlcb = new osgTerrain::myTileLoadedCallback( terrain);
+	osg::ref_ptr<osgTerrain::myTileLoadedCallback> tlcb = new osgTerrain::myTileLoadedCallback();
 	osgTerrain::TerrainTile::setTileLoadedCallback(tlcb);
 
Index: experimental/TerrainTest/rampedEllipsoidTechnique.cpp
===================================================================
--- experimental/TerrainTest/rampedEllipsoidTechnique.cpp	(revision 274)
+++ experimental/TerrainTest/rampedEllipsoidTechnique.cpp	(revision 275)
@@ -57,5 +57,5 @@
 	clampValue(Y_endCore, Y_start, Y_end);
 	clampValue(Y_endRamp, Y_start, Y_end);
-	OSG_NOTIFY( osg::ALWAYS ) << "Y_startRamp:" << Y_startRamp << " Y_startCore:" << Y_startCore << " Y_endCore:" << Y_endCore << " Y_endRamp:" << Y_endRamp << std::endl;
+	//OSG_NOTIFY( osg::ALWAYS ) << "Y_startRamp:" << Y_startRamp << " Y_startCore:" << Y_startCore << " Y_endCore:" << Y_endCore << " Y_endRamp:" << Y_endRamp << std::endl;
 
 	// Lon
@@ -69,5 +69,5 @@
 	clampValue(X_endCore, X_start, X_end);
 	clampValue(X_endRamp, X_start, X_end);
-	OSG_NOTIFY( osg::ALWAYS ) << "X_startRamp:" << X_startRamp << " X_startCore:" << X_startCore << " X_endCore:" << X_endCore << " X_endRamp:" << X_endRamp << std::endl;
+	//OSG_NOTIFY( osg::ALWAYS ) << "X_startRamp:" << X_startRamp << " X_startCore:" << X_startCore << " X_endCore:" << X_endCore << " X_endRamp:" << X_endRamp << std::endl;
 
 	// Modify height value of affected vertices in the core ROI
@@ -125,5 +125,5 @@
 			
 			// Set height to calculated value
-			OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique: destination_height=" << destination_height << std::endl;
+			//OSG_NOTIFY( osg::ALWAYS ) << "rampedEllipsoidTechnique: destination_height=" << destination_height << std::endl;
 			h->setHeight( x, y, destination_height);
 		}
