Index: GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 1404)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp	(revision 1415)
@@ -220,90 +220,93 @@
 void X3dParseHandlers::EndShape()
 {
-	 //-- if shape is merely a definition => don't create particular mesh instance
-	 if (!mCurrentMesh || mIsMeshDefinition) 
-	 { 
-		 return;
-	 }
-
-	 ////////////////////////////////////
-	 //-- each triangle is one single mesh
-
-	 if (!mLoadMeshes)
-	 {
-		 cout << "m";	
-		 Mesh tempMesh(*mCurrentMesh);
-		 ApplyTransformations(mTransformations, &tempMesh);
-
-		 FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end();
-		
-		 for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit)
-		 {
-			 cout << "f";
-			 // triangulate the faces
-			 Face *face = *fit;
-			 vector<Triangle3> triangles;
-			 Polygon3 poly(face, &tempMesh);
-			 poly.Triangulate(triangles);
-
-			 vector<Triangle3>::const_iterator tit, tit_end = triangles.end();
-
-			 for (tit = triangles.begin(); tit != tit_end; ++ tit)
-			 {
-				 //cout << "triangle: " << *tit << endl;
-				 TriangleIntersectable *ti = new TriangleIntersectable(*tit);
-				 mCurrentNode->mGeometry.push_back(ti);
-			 }
+	//////////////
+	//-- shape is only a definition => 
+	//-- don't create particular mesh instance
+
+	if (!mCurrentMesh || mIsMeshDefinition) 
+	{ 
+		return;
+	}
+
+	if (!mLoadMeshes)
+	{
+		////////////////////////////////////
+		//-- load data as single triangles instead of whole meshes
+
+		//cout << "m";	
+		Mesh tempMesh(*mCurrentMesh);
+		ApplyTransformations(mTransformations, &tempMesh);
+
+		FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end();
+
+		for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit)
+		{
+			//cout << "f";
+			// triangulate the faces
+			Face *face = *fit;
+			vector<Triangle3> triangles;
+			Polygon3 poly(face, &tempMesh);
+			poly.Triangulate(triangles);
+
+			vector<Triangle3>::const_iterator tit, tit_end = triangles.end();
+
+			for (tit = triangles.begin(); tit != tit_end; ++ tit)
+			{
+				//cout << "triangle: " << *tit << endl;
+				TriangleIntersectable *ti = new TriangleIntersectable(*tit);
+				mCurrentNode->mGeometry.push_back(ti);
+			}
 #if 0
-			 // we create a new mesh for each face from the current mesh
-			 Mesh *mesh = MeshManager::GetSingleton()->CreateResource();
-			
-			 VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end();
-		
-			 int i = 0;
-			 // dummy vertex indices container
-			 VertexIndexContainer vcIndices;
-
-			 for (vit = face->mVertexIndices.begin(); vit != vit_end; ++ vit, ++ i)
-			 {
-				 cout << "i";
-				 const int index = (*vit);
-				 // add vertices
-				 mesh->mVertices.push_back(mCurrentMesh->mVertices[index]);
-				 // indices don't make much sense if mesh == face, but we need them anyway ...
-				 vcIndices.push_back(i);
-			 }
-
-			 mesh->mFaces.push_back(new Face(vcIndices));
-
-			 // write transformations directly into the mesh
-			 // note: could be transformed in parent mesh, save some transformations
-			 ApplyTransformations(mTransformations, mesh);
-
-			 mesh->Preprocess();
-				
-			 if (mesh->mFaces.empty())
-			 {
-				 cout << "error: empy mesh" << endl;
-			 }
-			 else
-			 {
-				 // make an instance of this mesh
-				 MeshInstance *mi = new MeshInstance(mesh);
-				 mCurrentNode->mGeometry.push_back(mi);
-
-				 if (mCurrentMaterial && !mCurrentMesh->mMaterial)
-				 {
-					 // HACK: add the material to the mesh directly if no material yet
-					 mCurrentMesh->mMaterial = mCurrentMaterial;
-				 }
-			 }
+			// we create a new mesh for each face from the current mesh
+			Mesh *mesh = MeshManager::GetSingleton()->CreateResource();
+
+			VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end();
+
+			int i = 0;
+			// dummy vertex indices container
+			VertexIndexContainer vcIndices;
+
+			for (vit = face->mVertexIndices.begin(); vit != vit_end; ++ vit, ++ i)
+			{
+				cout << "i";
+				const int index = (*vit);
+				// add vertices
+				mesh->mVertices.push_back(mCurrentMesh->mVertices[index]);
+				// indices don't make much sense if mesh == face, but we need them anyway ...
+				vcIndices.push_back(i);
+			}
+
+			mesh->mFaces.push_back(new Face(vcIndices));
+
+			// write transformations directly into the mesh
+			// note: could be transformed in parent mesh, save some transformations
+			ApplyTransformations(mTransformations, mesh);
+
+			mesh->Preprocess();
+
+			if (mesh->mFaces.empty())
+			{
+				cout << "error: empy mesh" << endl;
+			}
+			else
+			{
+				// make an instance of this mesh
+				MeshInstance *mi = new MeshInstance(mesh);
+				mCurrentNode->mGeometry.push_back(mi);
+
+				if (mCurrentMaterial && !mCurrentMesh->mMaterial)
+				{
+					// HACK: add the material to the mesh directly if no material yet
+					mCurrentMesh->mMaterial = mCurrentMaterial;
+				}
+			}
 #endif
-		 }
-
-		 // this mesh is not needed, unless it is used as a definition
-		 if (!mUsingMeshDefinition)
-		 {
-		 	 MeshManager::GetSingleton()->DestroyEntry(mCurrentMesh->GetId());
-		 }
+		}
+
+		// this mesh is not needed, unless it is used as a definition
+		if (!mUsingMeshDefinition)
+		{
+			MeshManager::GetSingleton()->DestroyEntry(mCurrentMesh->GetId());
+		}
 	}
 	else // default usage: create a mesh instance from the current mesh
@@ -321,12 +324,12 @@
 		else
 		{
-			 // make an instance of this mesh
+			// make an instance of this mesh
 			TransformedMeshInstance *tmi = new TransformedMeshInstance(mCurrentMesh);
 
-			 // apply transformation on the instance of the mesh 
-			 ApplyTransformations(mTransformations, tmi);
-			 mi = tmi;
-		}
-			
+			// apply transformation on the instance of the mesh 
+			ApplyTransformations(mTransformations, tmi);
+			mi = tmi;
+		}
+
 		if (mCurrentMaterial)
 		{
@@ -341,5 +344,5 @@
 			}
 		}
-		
+
 		// create local mesh kd tree
 		mCurrentMesh->Preprocess();
@@ -368,5 +371,5 @@
 
 	VertexIndexContainer vertices;
-  
+
 	mIsMeshDefinition = false;
 	mUsingMeshDefinition = false;
@@ -579,5 +582,5 @@
  
   if (element == "Shape") {
-	  cout << "+"; 
+	  //cout << "+"; 
 
 	  // reset current shape values
