Index: GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp
===================================================================
--- GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp	(revision 1321)
+++ GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp	(revision 1529)
@@ -43,5 +43,5 @@
 
 
-void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodTreeLibrary *lodTreesLib)
+/*void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodTreeLibrary *lodTreesLib)
 {
 	// Copy to Ogre buffers including the degenerated triangles
@@ -81,5 +81,5 @@
 		ibuf->unlock();
 	}
-}
+}*/
 
 class FresnelFrameListener : public ExampleFrameListener
@@ -149,5 +149,5 @@
 		{
 			myTrees->GoToLod(lodfactor);
-			DumpDataToOgreBuffers(ogreMesh,myTrees);
+//			DumpDataToOgreBuffers(ogreMesh,myTrees);
 			lodfactorBefore=lodfactor;
 		}
@@ -207,4 +207,35 @@
 };
 
+class CustomIndexData : public Geometry::IndexData
+{
+private:
+	Ogre::Mesh *targetMesh;
+	Ogre::HardwareIndexBufferSharedPtr ibuf;
+	Ogre::RenderOperation mRenderOp;
+	unsigned long* pIdx;
+public:
+	CustomIndexData(Ogre::Mesh *ogremesh):Geometry::IndexData(){
+		targetMesh=ogremesh;
+		pIdx=NULL;
+	}
+	virtual ~CustomIndexData(void){}
+
+	virtual void Begin(unsigned int submeshid, unsigned int indexcount){
+		targetMesh->getSubMesh(submeshid)->_getRenderOperation(mRenderOp,0);
+		ibuf = mRenderOp.indexData->indexBuffer;
+		mRenderOp.indexData->indexCount = indexcount;
+		pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
+	}
+	virtual void SetIndex(unsigned int i, unsigned int index){
+		pIdx[i] = index; //lodStripsLib->dataRetrievalInterface->GetIndex(k+offset);
+	}
+	virtual void End(){
+		ibuf->unlock();
+	}
+
+	virtual void BorrowIndexData(const Geometry::IndexData *){}
+};
+
+
 class FresnelApplication : public ExampleApplication
 {
@@ -274,5 +305,8 @@
             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);
+		myTrees = new Geometry::LodTreeLibrary(	meshloader->GetLodStripsData(),
+												meshloader->GetTreeSimpSeq(),
+												themesh,
+												new CustomIndexData(ogreMesh));
 
 		entity->setNormaliseNormals(true);
Index: GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp
===================================================================
--- GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp	(revision 1321)
+++ GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp	(revision 1529)
@@ -105,31 +105,35 @@
 };
 
-void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodStripsLibrary *lodStripsLib)
-{
-	// Copy to Ogre buffers including the degenerated triangles
-
-	Ogre::HardwareIndexBufferSharedPtr	ibuf;
-	Ogre::IndexData	*indexes;
+class CustomIndexData : public Geometry::IndexData
+{
+private:
+	Ogre::Mesh *targetMesh;
+	Ogre::HardwareIndexBufferSharedPtr ibuf;
 	Ogre::RenderOperation mRenderOp;
-
-	for (int submesh=0; submesh < original_mesh->getNumSubMeshes(); submesh++)
-	{
-		int indices_to_render = lodStripsLib->GetValidIndexCount(submesh);
-		int offset = lodStripsLib->GetValidOffset(submesh);
-
-		original_mesh->getSubMesh(submesh)->_getRenderOperation(mRenderOp,0);
-
+	unsigned long* pIdx;
+public:
+	CustomIndexData(Ogre::Mesh *ogremesh):Geometry::IndexData(){
+		targetMesh=ogremesh;
+		pIdx=NULL;
+	}
+	virtual ~CustomIndexData(void){}
+
+	virtual void Begin(unsigned int submeshid, unsigned int indexcount){
+		targetMesh->getSubMesh(submeshid)->_getRenderOperation(mRenderOp,0);
 		ibuf = mRenderOp.indexData->indexBuffer;
-		mRenderOp.indexData->indexStart = 0;
-		mRenderOp.indexData->indexCount = indices_to_render;
-
-		unsigned long* pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
-
-		for (int k=0; k<indices_to_render; k++)
-			pIdx[k] = lodStripsLib->dataRetrievalInterface->GetIndex(k+offset);
-
+		mRenderOp.indexData->indexCount = indexcount;
+		pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
+	}
+	virtual void SetIndex(unsigned int i, unsigned int index){
+		pIdx[i] = index; //lodStripsLib->dataRetrievalInterface->GetIndex(k+offset);
+	}
+	virtual void End(){
 		ibuf->unlock();
 	}
-}
+	virtual unsigned int GetIndex(unsigned int) const { return 0; } // HAY QUE ELIMINAR ESTA FUNCION
+
+	virtual void BorrowIndexData(const Geometry::IndexData *){}
+
+};
 
 class FresnelFrameListener : public ExampleFrameListener
@@ -198,5 +202,5 @@
 		{
 			myStrips->GoToLod(lodfactor);
-			DumpDataToOgreBuffers(ogreMesh,myStrips);
+//			DumpDataToOgreBuffers(ogreMesh,myStrips);
 			lodfactorBefore=lodfactor;
 		}
@@ -401,5 +405,7 @@
             OGRE_EXCEPT(1, "The loaded mesh does not contain any LOD info","LOD Demo");
 
-		myStrips = new Geometry::LodStripsLibrary(meshloader->GetLodStripsData(),themesh);
+		myStrips = new Geometry::LodStripsLibrary(	meshloader->GetLodStripsData(),
+													themesh,
+													new CustomIndexData(ogreMesh)	);
 		
 		entity->setNormaliseNormals(true);
