Index: experimental/distortionNG/DistortionSet.cpp
===================================================================
--- experimental/distortionNG/DistortionSet.cpp	(revision 382)
+++ experimental/distortionNG/DistortionSet.cpp	(revision 383)
@@ -24,9 +24,10 @@
 DistortionSet::DistortionSet()
 {
-	_dirty = false;
+	_meshDirty = false;
+	_matrixDirty = false;
 
 	_distortionMeshRows = 2;
 	_distortionMeshColumns = 2;
-	//GLenum _meshType;
+	_distortionMesh = new osg::Vec4Array();
 	
 	_intensityMap = NULL;
@@ -50,14 +51,27 @@
 }
 
-void DistortionSet::setDistortionMesh(osg::Geometry*)
+void DistortionSet::setDistortionMeshDimensions(int rows, int cols)
 {
-	// todo: denormalisieren und mesh dann an seine passenden Platz vom Switch packen.
+	_distortionMeshRows = rows;
+	_distortionMeshColumns = cols;
+
+	if(_distortionMesh->size() != _distortionMeshRows * _distortionMeshRows)	// If dimensions differ: discard current mesh and createa new one
+	{
+		_distortionMesh = new osg::Vec4Array(_distortionMeshRows * _distortionMeshRows);
+		for(int row=0;row<_distortionMeshRows;row++)
+		{
+			for(int col=0;col<_distortionMeshColumns;col++)
+			{
+				float x=col/_distortionMeshColumns;	// Vertex X
+				float y=row/_distortionMeshRows;	// Vertex Y
+				float z=col/_distortionMeshColumns;	// TexCoord X
+				float w=row/_distortionMeshRows;	// TexCoord Y
+
+				_distortionMesh->at(row*_distortionMeshColumns+col).set(x,y,z,w);
+			}
+		}
+	}
 }
 
-const osg::Geometry* DistortionSet::getDistortionMesh() const
-{
-	// Todo: Normalisieren und dann zurückgeben
-	return NULL;
-}
 
 REGISTER_OBJECT_WRAPPER( osgViewer_DistortionSet,                  // The unique wrapper name
@@ -69,5 +83,5 @@
 	ADD_INT_SERIALIZER( DistortionMeshRows, 1 );	//int _distortionMeshRows;
 	ADD_INT_SERIALIZER( DistortionMeshColumns, 1 );	//int _distortionMeshColumns;
-	ADD_OBJECT_SERIALIZER( DistortionMesh, osg::Geometry, NULL );	// Normalisiertes Mesh
+	ADD_OBJECT_SERIALIZER( DistortionMesh, osg::Vec4Array, NULL );	// x,y = vertex coordinates, z,t=textureCoordinates, Werte sind normalisiert auf 0-1
 
     ADD_GLENUM_SERIALIZER( MeshType, GLenum, GL_QUAD_STRIP );  //osg::PrimitiveSet::Mode _MeshType
Index: experimental/distortionNG/DistortionSet.h
===================================================================
--- experimental/distortionNG/DistortionSet.h	(revision 382)
+++ experimental/distortionNG/DistortionSet.h	(revision 383)
@@ -54,6 +54,10 @@
 
 	// Working access
-	bool isDirty(){return(_dirty);}
-	void dirty(){_dirty=true;}
+	bool isDirty(){return(_meshDirty || _matrixDirty);}
+	void dirtyMesh(){_meshDirty = true;}
+	void dirtyMatrix(){_matrixDirty = true;}
+	void clearDirtyStatus()	{ _meshDirty = false; _matrixDirty = false;}
+	
+	void setDistortionMeshDimensions(int rows, int cols);
 
 	osg::Image* getIntensityMap()  { return _intensityMap; }	// Also for manipulating the intensity map
@@ -79,6 +83,6 @@
 	int getDistortionMeshColumns() const	{ return _distortionMeshColumns; }
 
-	void setDistortionMesh(osg::Geometry*);
-	const osg::Geometry* getDistortionMesh() const;
+	void setDistortionMesh(osg::Vec4Array* distortionMesh)	{ _distortionMesh = distortionMesh; }
+	const osg::Vec4Array* getDistortionMesh() const	{ return _distortionMesh; }
 
 	void setMeshType(GLenum meshType) { _meshType = meshType; }
@@ -106,7 +110,11 @@
 
 private:
-	bool _dirty;
+	// Blendmap has no dirty flag because changes of the intensityMap is directly effective.
+	bool _meshDirty;
+	bool _matrixDirty;
+
 	int _distortionMeshRows;
 	int _distortionMeshColumns;
+	osg::ref_ptr<osg::Vec4Array> _distortionMesh;	// x,y = vertex coordinates, z,t=textureCoordinates
 	GLenum _meshType;
 	
Index: experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp
===================================================================
--- experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp	(revision 382)
+++ experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.cpp	(revision 383)
@@ -28,5 +28,6 @@
 	_blendmapFilename = "";
 	_frustumFilename = "";
-	_distortionFilename = "";
+	_vertexDistortionFilename = "";
+	_texCoordDistortionFilename = "";
 	_distortionType = DistortionSetupStrategy::UNDEFINED;
 
@@ -39,10 +40,11 @@
 }
 
-void DistortionSetupStrategyProjectSyntropy::setDistortionInputFiles( std::string distortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type)
+void DistortionSetupStrategyProjectSyntropy::setDistortionInputFiles( std::string vertexDistortionFile, std::string texCoordDistortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type)
 {
 	_distortionType = type;
 	_blendmapFilename = blendmapFile;
 	_frustumFilename = frustumFile;
-	_distortionFilename = distortionFile;
+	_vertexDistortionFilename = vertexDistortionFile;
+	_texCoordDistortionFilename = texCoordDistortionFile;
 }
 
@@ -231,7 +233,12 @@
 	}
 
-	if(	_distortionType == DistortionSetupStrategy::UNDEFINED || _blendmapFilename.empty() || _frustumFilename.empty() || _distortionFilename.empty() )
-	{
-		OSG_ALWAYS<<"DistortionSetupStrategyProjectSyntropy::delegateDistortionSetup : You have not specified the imput filenames and distortion type!"<<std::endl;
+	if(	_distortionType == DistortionSetupStrategy::UNDEFINED 
+			|| _blendmapFilename.empty()
+			|| _frustumFilename.empty()
+			|| ( _vertexDistortionFilename.empty() && _distortionType == DistortionSetupStrategy::VERTEXDISTORTION )
+			|| ( _texCoordDistortionFilename.empty() && _distortionType == DistortionSetupStrategy::TEXCOORDDISTORTION )
+	)
+	{
+		OSG_ALWAYS<<"DistortionSetupStrategyProjectSyntropy::delegateDistortionSetup : You have not specified the imput filenames and distortion type correctly!"<<std::endl;
 		return;
 	}
@@ -242,5 +249,7 @@
 	{
 		_distortionInitialized=true;
-		distortionSet->dirty();
+		distortionSet->dirtyMesh();
+		distortionSet->dirtyMatrix();
+
 
 		// ******************** //
@@ -317,5 +326,5 @@
 			//*******************************************************************************************//
 			
-#if 1
+#if 0
 			osg::Vec3Array* vertices =  (osg::Vec3Array*) distortionMeshGeometry->getVertexArray();
 			osg::Vec2Array* texcoords0 = (osg::Vec2Array*) distortionMeshGeometry->getTexCoordArray(0);
@@ -338,34 +347,90 @@
 			//*******************************************************************************************//
 
-			// Exctract mesh dimensions from file and pass them to the container
+			// Exctract mesh dimensions from file and pass them to the container.
+			// If soley texCoordDistortion is used, _texCoordDistortionFilename is used to determine the dimensions, otherwise _vertexDistortionFilename
 			int distortionMeshRows=0, distortionMeshColumns=0;
-			readMeshDimensionsFromCSVFile(_distortionFilename, &distortionMeshRows, &distortionMeshColumns);
+			readMeshDimensionsFromCSVFile(_distortionType==DistortionSetupStrategy::TEXCOORDDISTORTION?_texCoordDistortionFilename:_vertexDistortionFilename, &distortionMeshRows, &distortionMeshColumns);
 
 			distortionSet->setDistortionMeshRows(distortionMeshRows);
 			distortionSet->setDistortionMeshColumns(distortionMeshColumns);
 
-			osg::Vec2Array* tmpMeshVec2 = new osg::Vec2Array;
-			osg::Vec3Array* vertexMeshVec3 = new osg::Vec3Array;
-
-			readMeshPointsFromCSVFile(_distortionFilename, tmpMeshVec2);
+			// If vertex- and texCoord distortion is combined: Ensure both files have the same dimensions
+			if(_distortionType==DistortionSetupStrategy::COMBINEDDISTORTION)
+			{
+				int texCoordRows=0, texCoordColumns=0;
+				readMeshDimensionsFromCSVFile(_texCoordDistortionFilename, &distortionMeshRows, &distortionMeshColumns);
+				if(distortionMeshRows!=texCoordRows || distortionMeshColumns!=texCoordColumns)
+				{
+					OSG_ALWAYS<<"The mesh dimensions of the vertex- and textureCoordinate-distortion differ!"<<std::endl;
+					return;
+				}
+			}
+
+			// Read in the mesh arrays
+			osg::Vec2Array* vertexMeshVec2 = new osg::Vec2Array;
+			osg::Vec2Array* texCoordMeshVec2 = new osg::Vec2Array;
+			osg::Vec4Array* distortionMesh = new osg::Vec4Array(distortionMeshRows*distortionMeshColumns);
+			
+			if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION))
+			{
+				readMeshPointsFromCSVFile(_vertexDistortionFilename, vertexMeshVec2);
+			}
 
 			if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION))
 			{
-				distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray(0,tmpMeshVec2);
-			}
-
-			if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION))
-			{
-				for(unsigned int i=0;i<tmpMeshVec2->size();i++)
-				{
-					// Scale vector with the screen resolution
-					osg::Vec3 tmpVec = osg::Vec3(	tmpMeshVec2->at(i).x()*width,
-													tmpMeshVec2->at(i).y()*height,
-													0.0	);
-					vertexMeshVec3->push_back( tmpVec );
-				}
-				distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setVertexArray(vertexMeshVec3);
-
-			}
+				readMeshPointsFromCSVFile(_texCoordDistortionFilename, texCoordMeshVec2);
+			}
+
+			// Transfer the read values into the combinedArray
+			for(int row=0;row<distortionMeshRows;row++)
+			{
+				for(int col=0;col<distortionMeshColumns;col++)
+				{
+					float x=col/distortionMeshColumns;	// Vertex X
+					float y=row/distortionMeshRows;		// Vertex Y
+					float z=col/distortionMeshColumns;	// TexCoord X
+					float w=row/distortionMeshRows;		// TexCoord Y
+					if(_distortionType==VERTEXDISTORTION || _distortionType==COMBINEDDISTORTION)
+					{
+						x = vertexMeshVec2->at(row*col).x();
+						y = vertexMeshVec2->at(row*col).y();
+					}
+					if(_distortionType==TEXCOORDDISTORTION || _distortionType==COMBINEDDISTORTION)
+					{
+						z = texCoordMeshVec2->at(row*col).x();
+						w = texCoordMeshVec2->at(row*col).y();
+					}
+
+					distortionMesh->at(row*distortionMeshColumns+col).set(x,y,z,w);
+				}
+			}
+
+			distortionSet->setDistortionMesh(distortionMesh);
+			distortionSet->setDistortionMeshColumns(distortionMeshColumns);
+			distortionSet->setDistortionMeshRows(distortionMeshRows);
+
+			// apply new settings
+			//if((_distortionType==TEXCOORDDISTORTION) || (_distortionType==COMBINEDDISTORTION))
+			//{
+			//	distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray(0,tmpMeshVec2);
+			//}
+
+			//if((_distortionType==VERTEXDISTORTION) || (_distortionType==COMBINEDDISTORTION))
+			//{
+			//	OSG_ALWAYS<<"New mesh ---------------------------"<<std::endl;
+			//	for(unsigned int i=0;i<tmpMeshVec2->size();i++)
+			//	{
+			//		// Scale vector with the screen resolution
+			//		osg::Vec3 tmpVec = osg::Vec3(	tmpMeshVec2->at(i).x()*width,
+			//										tmpMeshVec2->at(i).y()*height,
+			//										0.0	);
+			//		vertexMeshVec3->push_back( tmpVec );
+			//		OSG_ALWAYS<<"X:"<<tmpVec.x()<<" Y:"<<tmpVec.y()<<" Z:"<<tmpVec.z()<<std::endl;
+			//	}
+			//	OSG_ALWAYS<<"tmpMeshVec2 size:"<<tmpMeshVec2->size()<<std::endl;
+			//	distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setVertexArray(vertexMeshVec3);
+			//	distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->setTexCoordArray
+			//	distortionSet->getDistortionInternals()->getChild(osgViewer::DistortionSet::MESH)->asGeode()->getDrawable(0)->asGeometry()->dirtyDisplayList();
+			//}
 		}
 	}
Index: experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h
===================================================================
--- experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h	(revision 382)
+++ experimental/distortionNG/DistortionSetupStrategyProjectSyntropy.h	(revision 383)
@@ -35,5 +35,5 @@
 	~DistortionSetupStrategyProjectSyntropy();
 	void delegateDistortionSetup(osgViewer::DistortionSet* distortionSet);
-	void setDistortionInputFiles( std::string distortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type);
+	void setDistortionInputFiles( std::string vertexDistortionFile, std::string texCoordDistortionFile, std::string blendmapFile, std::string frustumFile, DistortionSetupStrategy::distortionType type);
 private:
 	//Functions related to CSV-File-Reading
@@ -46,5 +46,6 @@
 	std::string _blendmapFilename;
 	std::string _frustumFilename;
-	std::string _distortionFilename;
+	std::string _vertexDistortionFilename;
+	std::string _texCoordDistortionFilename;
 
 };
Index: experimental/distortionNG/main.cpp
===================================================================
--- experimental/distortionNG/main.cpp	(revision 382)
+++ experimental/distortionNG/main.cpp	(revision 383)
@@ -53,7 +53,6 @@
 	osg::ref_ptr<osgViewer::DistortionSet> _distortionSet = new osgViewer::DistortionSet();
 	_distortionSet->setIntensityMap( intMap );
-	_distortionSet->setDistortionMeshRows( 20 );
-	_distortionSet->setDistortionMeshColumns( 20 );
-
+	_distortionSet->setDistortionMeshDimensions(20, 20);
+	
 
 // ---- test plugin read / write
@@ -96,5 +95,6 @@
 
 	DistortionSetupStrategyProjectSyntropy* psStrategy = new DistortionSetupStrategyProjectSyntropy();
-	psStrategy->setDistortionInputFiles( "./resources/ProjectSyntropy/Vertices/warpmap_1.csv",
+	psStrategy->setDistortionInputFiles( "./resources/ProjectSyntropy/Vertices/warpmap_2.csv",
+										"./resources/ProjectSyntropy/TexCoords/warpmap_2.csv",
 										"./resources/ProjectSyntropy/blending_1.bmp",
 										"./resources/ProjectSyntropy/Vertices/frustum_1.csv",
