Index: /GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp
===================================================================
--- /GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp	(revision 1124)
+++ /GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp	(revision 1306)
@@ -67,11 +67,5 @@
 		}
 
-		ibuf = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 
-			Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 
-			indices_to_render, // number of indexes 
-			Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage
-			false); // no shadow buffer 
-					
-		mRenderOp.indexData->indexBuffer = ibuf;
+		ibuf = mRenderOp.indexData->indexBuffer;
 		mRenderOp.indexData->indexStart = 0;
 		mRenderOp.indexData->indexCount = indices_to_render;		
@@ -276,4 +270,9 @@
 		Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/ML12m.mesh");
 
+		if (!meshloader->GetLodStripsData())
+            OGRE_EXCEPT(1, "The loaded mesh does not contain LOD info for the trunk","LOD Demo");
+		if (!meshloader->GetTreeSimpSeq())
+            OGRE_EXCEPT(1, "The loaded mesh does not contain LOD info for the foliage","LOD Demo");
+
 		myTrees = new Geometry::LodTreeLibrary(meshloader->GetLodStripsData(),meshloader->GetTreeSimpSeq(),themesh);
 
@@ -283,8 +282,24 @@
 		{
 			bool istrunk = myTrees->GetLeavesSubMesh()!=submesh;
+			int indices_to_render = 0;
 			if (istrunk)
+			{
 				entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/trunk");
+				indices_to_render = myTrees->GetValidTrunkIndexCount(submesh);
+			}
 			else
+			{
 				entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/leaf");
+				indices_to_render = myTrees->CurrentLOD_Foliage_IndexCount();
+			}
+
+			Ogre::RenderOperation mRenderOp;
+			ogreMesh->getSubMesh(submesh)->_getRenderOperation(mRenderOp,0);
+
+			mRenderOp.indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 
+				Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 
+				indices_to_render, // number of indexes 
+				Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage
+				false); // no shadow buffer 
 		}
 
Index: /GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp
===================================================================
--- /GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp	(revision 1128)
+++ /GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp	(revision 1306)
@@ -121,12 +121,6 @@
 		original_mesh->getSubMesh(submesh)->_getRenderOperation(mRenderOp,0);
 
-		ibuf = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 
-			Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 
-			indices_to_render, // number of indexes 
-			Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage
-			false); // no shadow buffer 
-					
-		mRenderOp.indexData->indexBuffer = ibuf;
-		mRenderOp.indexData->indexStart = 0;//offset; 
+		ibuf = mRenderOp.indexData->indexBuffer;
+		mRenderOp.indexData->indexStart = 0;
 		mRenderOp.indexData->indexCount = indices_to_render;
 
@@ -135,7 +129,6 @@
 		for (int k=0; k<indices_to_render; k++)
 			pIdx[k] = lodStripsLib->dataRetrievalInterface->GetIndex(k+offset);
-			
+
 		ibuf->unlock();
-
 	}
 }
@@ -200,6 +193,4 @@
 			lodfactor=1.0f;
 
-/*		if (lodfactor >= 0.0f && lodfactor <= 1.0f)			
-		{*/
 		static float lodfactorBefore = -1.0f;
 		if (fabsf(lodfactorBefore-lodfactor)>0.05f || 
@@ -210,50 +201,6 @@
 			DumpDataToOgreBuffers(ogreMesh,myStrips);
 			lodfactorBefore=lodfactor;
-
-/*			if (lodfactor < 0.333f)
-			{
-				color.r=0.0;
-				color.g=(lodfactor)*3.0f;//nlod*1.0/(diflods/3);
-				color.b=(0.3f-lodfactor)*3.0f;//(nlod*1.0/(diflods/3));
-			}
-			else
-			{
-				if (lodfactor<0.666f)
-				{
-					color.r=(lodfactor-0.333f)*3.0f;//(nlod-diflods/3)*1.0/(diflods/3);
-					color.g=1.0;
-					color.b=0.0;
-				}
-				else
-				{
-					color.r=1.0;
-					color.g=(0.3f-lodfactor)*3.0f;//(nlod-(2*diflods/3))*1.0/(diflods/3);
-					color.b=0.0;
-				}
-			}
-			mat[0]->setDiffuse(color);*/
 		}
-/*		else
-		{
-			if ((distance > dist_max))
-			{
-				color.r=0.0;
-				color.g=0.0;
-				color.b=1.0;
-				mat[0]->setDiffuse(color);
-
-			}
-			else
-			{
-				if ((distance < dist_min))
-				{
-					color.r=1.0;
-					color.g=0.0;
-					color.b=0.0;
-					mat[0]->setDiffuse(color);
-				}
-			}
-		}
-*/
+
 		// Move the node
 		if(mInputDevice->isKeyDown(Ogre::KC_UP))
@@ -452,28 +399,29 @@
 		lod_file.append(".lod");
 
-//		myStrips = new LodStripsLibrary(lod_file,entity->getMesh().getPointer());
-
 		if (!meshloader->GetLodStripsData())
             OGRE_EXCEPT(1, "The loaded mesh does not contain any LOD info","LOD Demo");
 
 		myStrips = new Geometry::LodStripsLibrary(meshloader->GetLodStripsData(),themesh);
+		
+		for (unsigned int i=0; i<ogreMesh->getNumSubMeshes(); i++)
+		{
+			Ogre::RenderOperation mRenderOp;
+			ogreMesh->getSubMesh(i)->_getRenderOperation(mRenderOp,0);
+			int indices_to_render = myStrips->GetValidIndexCount(i);
+
+			mRenderOp.indexData->indexBuffer = 
+					Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( 
+						Ogre::HardwareIndexBuffer::IT_32BIT, // type of index 
+						indices_to_render, // number of indexes 
+						Ogre::HardwareBuffer::HBU_DISCARDABLE , // usage
+						false);
+		}
 
 		entity->setNormaliseNormals(true);
-
 		aboveWaterEnts.push_back(entity);
-
-		// Colour-coded material
-/*		mat[0] = MaterialManager::getSingleton().create("test_mat", 
-			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-		mat[0]->setCullingMode(CULL_NONE);
-		mat[0]->setAmbient(ColourValue(0.5f,0.5f,0.5f));
-		mat[0]->setDiffuse(color);
-		mat[0]->setLightingEnabled(true);*/
-		//entity->setMaterialName("test_mat");
 		entity->setMaterialName("LODStripsDemo/Ogro");
 
-
-		for (int i=-3; i<7; i++) // 20
-			for (int j=0; j<4; j++) // 20
+		for (int i=-3; i<7; i++)
+			for (int j=0; j<4; j++)
 			{
 				char newObjName[16]="";
