Index: experimental/distortionNG/distortionNG.cpp
===================================================================
--- experimental/distortionNG/distortionNG.cpp	(revision 329)
+++ experimental/distortionNG/distortionNG.cpp	(revision 331)
@@ -124,2 +124,13 @@
 	_highlighter->dirtyBound(); 
 }
+
+/*
+	Grundsätzliche Gedanken Schritte:
+ Die Verzerrung kann auf zwei Arten realisiert werden
+	- Verzerrung der Textur-Koordinaten aus der RTT-Szene
+    - Verzerrung des Meshes im Verzerrungs-Rendern
+ Die IntensityMap muss über das fertige verzerrte Bild gelegt werden.
+
+
+
+*/
Index: experimental/distortionNG/extViewer.cpp
===================================================================
--- experimental/distortionNG/extViewer.cpp	(revision 329)
+++ experimental/distortionNG/extViewer.cpp	(revision 331)
@@ -30,4 +30,86 @@
 {
 
+}
+
+static osg::Geometry* createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows, osg::Image* intensityMap, const osg::Matrix& projectorMatrix)
+{
+	// Create Quad to render on
+	osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
+
+	geom->setUseDisplayList( false );
+
+	osg::Vec3 xAxis(widthVector);
+    float width = widthVector.length();
+    xAxis /= width;
+
+    osg::Vec3 yAxis(heightVector);
+    float height = heightVector.length();
+    yAxis /= height;
+
+	osg::Vec3 dx = xAxis*(width/((float)(columns-1)));
+    osg::Vec3 dy = yAxis*(height/((float)(rows-1)));
+
+
+	// Create vertices and coordinates
+	osg::Vec3Array* vertices = new osg::Vec3Array;
+    osg::Vec2Array* texcoords0 = new osg::Vec2Array;
+    osg::Vec2Array* texcoords1 = intensityMap==0 ? new osg::Vec2Array : 0;
+    osg::Vec4Array* colors = new osg::Vec4Array;
+
+	geom->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
+
+	for ( unsigned int row=0; row<rows; row++ )
+	{
+		for ( unsigned int col=0; col<columns; col++ )
+		{
+			// Create coordinates of the mesh node (geometry).
+			vertices->push_back( origin+dy*row+dx*col );
+
+			// Create tex coordinates
+			osg::Vec2 texcoord = osg::Vec2((float)col/(float)(columns-1), (float)row/(float)(rows-1));
+
+			// Set Coordinates for RTT-Texture (scene rendering)
+			texcoords0->push_back( texcoord );
+
+			// Set Color of the mesh node
+			if (intensityMap)
+			{
+				colors->push_back(intensityMap->getColor(texcoord));
+			}
+			else
+			{
+				colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
+			}
+
+			// Set coordinates for second texcoords array (if applyIntensityMapAsColours==true)
+			if (texcoords1) texcoords1->push_back( texcoord );
+		}
+	}
+
+	// Pass the created vertex array to the points geometry object.
+	geom->setUseVertexBufferObjects( true );
+	geom->setVertexArray(vertices);
+
+	geom->setColorArray(colors);
+    geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
+
+    geom->setTexCoordArray(0,texcoords0);
+    if (texcoords1) geom->setTexCoordArray(1,texcoords1);
+
+ //   osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
+ //   geometry->addPrimitiveSet(elements);
+
+	for ( unsigned int row=0; row<rows-1; row++ )	// each strip consists of two affected vertex rows, so we need only row-1 strips.
+	{
+		osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(GL_QUAD_STRIP, columns*2);	// columns*2 = number of involved vertices for this strip.
+		for ( unsigned int col=0; col<columns; col++ )
+		{
+			(*de)[col*2 + 0] = row*columns + col;
+			(*de)[col*2 + 1] = (row+1)*columns + col;
+		}
+		geom->addPrimitiveSet( de.get() );
+	}
+
+	return geom.release();
 }
 
@@ -66,5 +148,5 @@
     traits->sharedContext = 0;
 
-	bool applyIntensityMapAsColours = true;
+	bool applyIntensityMapAsColours = false;
 
 	osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext(traits.get());
@@ -132,9 +214,9 @@
     {
         osg::Geode* geode = new osg::Geode();
-		//geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 1, 0.45, 0, projectorMatrix));
-		osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, projectorMatrix);
+		//geode->addDrawable(createParoramicSphericalDisplayDistortionMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 1, 0.45, intensityMap, projectorMatrix));
+		osg::Geometry* distortionMesh = createMesh(osg::Vec3(0.0f,0.0f,0.0f), osg::Vec3(width,0.0f,0.0f), osg::Vec3(0.0f,height,0.0f), 20, 20, intensityMap, projectorMatrix);
 		geode->addDrawable(distortionMesh);
 
-        // new we need to add the texture to the mesh, we do so by creating a
+        // new we need to add the scene texture to the mesh, we do so by creating a
         // StateSet to contain the Texture StateAttribute.
         osg::StateSet* stateset = geode->getOrCreateStateSet();
@@ -189,77 +271,2 @@
     }
 }
-
-osg::Geometry* extViewer::createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows, const osg::Matrix& projectorMatrix)
-{
-	// Create Quad to render on
-	osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
-
-	geom->setUseDisplayList( false );
-
-	osg::Vec3 xAxis(widthVector);
-    float width = widthVector.length();
-    xAxis /= width;
-
-    osg::Vec3 yAxis(heightVector);
-    float height = heightVector.length();
-    yAxis /= height;
-
-	osg::Vec3 dx = xAxis*(width/((float)(columns-1)));
-    osg::Vec3 dy = yAxis*(height/((float)(rows-1)));
-
-
-	// Create vertices and coordinates
-	osg::Vec3Array* vertices = new osg::Vec3Array;
-    osg::Vec2Array* texcoords0 = new osg::Vec2Array;
-    //osg::Vec2Array* texcoords1 = intensityMap==0 ? new osg::Vec2Array : 0;
-    osg::Vec4Array* colors = new osg::Vec4Array;
-
-	geom->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED);
-
-	for ( unsigned int row=0; row<rows; row++ )
-	{
-		for ( unsigned int col=0; col<columns; col++ )
-		{
-			vertices->push_back( origin+dy*row+dx*col );	// geometry
-			osg::Vec2 texcoord = osg::Vec2((float)col/(float)(columns-1), (float)row/(float)(rows-1));
-			texcoords0->push_back( texcoord );
-
-//	if (intensityMap)
-//    {
-//        colors->push_back(intensityMap->getColor(texcoord1));
-//    }
-//    else
-//    {
-        colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f));
-//        if (texcoords1) texcoords1->push_back( texcoord1 );
-//    }
-
-		}
-	}
-
-	// Pass the created vertex array to the points geometry object.
-	geom->setUseVertexBufferObjects( true );
-	geom->setVertexArray(vertices);
-
-	geom->setColorArray(colors);
-    geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
-
-    geom->setTexCoordArray(0,texcoords0);
-    //if (texcoords1) geometry->setTexCoordArray(1,texcoords1);
-
- //   osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES);
- //   geometry->addPrimitiveSet(elements);
-
-	for ( unsigned int row=0; row<rows-1; row++ )	// each strip consists of two affected vertex rows, so we need only row-1 strips.
-	{
-		osg::ref_ptr<osg::DrawElementsUInt> de = new osg::DrawElementsUInt(GL_QUAD_STRIP, columns*2);	// columns*2 = number of involved vertices for this strip.
-		for ( unsigned int col=0; col<columns; col++ )
-		{
-			(*de)[col*2 + 0] = row*columns + col;
-			(*de)[col*2 + 1] = (row+1)*columns + col;
-		}
-		geom->addPrimitiveSet( de.get() );
-	}
-
-	return geom.release();
-}
Index: experimental/distortionNG/extViewer.h
===================================================================
--- experimental/distortionNG/extViewer.h	(revision 329)
+++ experimental/distortionNG/extViewer.h	(revision 331)
@@ -15,5 +15,3 @@
 		/** Convenience method for projection on curved screens using a slave camera rendering scene and a second camera doing distortion correction to present on a nonplaner display.*/
         void setUpViewForManualDistortion(unsigned int screenNum=0, osg::Image* intensityMap=0, const osg::Matrixd& projectorMatrix = osg::Matrixd());
-
-		static osg::Geometry* createMesh(const osg::Vec3& origin, const osg::Vec3& widthVector, const osg::Vec3& heightVector, unsigned int columns, unsigned int rows, const osg::Matrix& projectorMatrix);
 };
Index: experimental/distortionNG/main.cpp
===================================================================
--- experimental/distortionNG/main.cpp	(revision 329)
+++ experimental/distortionNG/main.cpp	(revision 331)
@@ -41,8 +41,16 @@
     // construct the viewer.
     extViewer viewer(arguments);
-	viewer.setUpViewForManualDistortion();
-	//viewer.setUpViewFor3DSphericalDisplay();
 
-    // set up the camera manipulators.
+	osg::Image* intMap = osgDB::readImageFile("intensitymap.png");
+	if (!intMap)
+	{
+		osg::notify(osg::WARN) << "Couldn't find intensity map, quiting." << std::endl;
+		return -1;
+	} 
+
+	viewer.setUpViewForManualDistortion(0, intMap);
+	//viewer.setUpViewForPanoramicSphericalDisplay(1, 0, 0, intMap);
+    
+	// set up the camera manipulators.
     {
         osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
