Index: GTP/trunk/App/Demos/Geom/OgreStuff/media/materials/scripts/Example.material
===================================================================
--- GTP/trunk/App/Demos/Geom/OgreStuff/media/materials/scripts/Example.material	(revision 1092)
+++ GTP/trunk/App/Demos/Geom/OgreStuff/media/materials/scripts/Example.material	(revision 1104)
@@ -735,4 +735,37 @@
 }
 
+material Examples/Populifolia/leaf
+{
+    technique
+    {
+        pass
+        {
+		alpha_rejection greater 150 
+		scene_blend alpha_blend
+	      cull_hardware none
+            cull_software none
+            texture_unit
+            {
+                texture Pinus-leaf.tif 
+            }
+        }
+    }
+}
+
+material Examples/Populifolia/trunk
+{
+	technique
+	{
+		pass
+		{
+			cull_hardware anticlockwise
+			texture_unit
+			{
+				texture populifolia-trunk.png 
+			}
+		}
+	}
+}
+
 material Examples/Rockwall
 {
Index: GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp
===================================================================
--- GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp	(revision 1092)
+++ GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp	(revision 1104)
@@ -30,7 +30,7 @@
 Ogre::Mesh *ogreMesh=NULL;
 Geometry::GeoMeshLoader *meshloader=NULL;
-SceneNode* node;
-
-MaterialPtr *mat;
+bool force_maxLODfactor = false;
+
+Ogre::Vector3 forest_center;
 
 ColourValue color=ColourValue::Red;
@@ -75,5 +75,5 @@
 		mRenderOp.indexData->indexBuffer = ibuf;
 		mRenderOp.indexData->indexStart = 0;
-		mRenderOp.indexData->indexCount = indices_to_render;
+		mRenderOp.indexData->indexCount = indices_to_render;		
 
 		unsigned long* pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));
@@ -138,64 +138,25 @@
 		int i=0;
 
-		dist = node->getPosition() - mCamera->getPosition(); 
+		dist = forest_center - mCamera->getPosition(); 
 		distance =dist.length();
-
-		DumpDataToOgreBuffers(ogreMesh,myTrees);
 
 		float lodfactor = (float)(distance - dist_min) / (float)(dist_max - dist_min);
 		lodfactor = 1.0f - lodfactor;
 
-		if (lodfactor >= 0.0f && lodfactor <= 1.0f)			
+		if (lodfactor<0.0f)
+			lodfactor=0.0f;
+		if (lodfactor>1.0f)
+			lodfactor=1.0f;
+
+		if (force_maxLODfactor)
+			lodfactor=1.0f;
+
+		static float lodfactorBefore = -1.0f;
+		if (fabsf(lodfactorBefore-lodfactor)>0.05f)
 		{
 			myTrees->GoToLod(lodfactor);
-
-			if (lodfactor < 0.333f)
-			{
-				color.r=0.0;
-				color.g=(lodfactor)*3.0f;//nlod*1.0/(diflods/3);
-				color.b=(1.0-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=(1.0-lodfactor)*3.0f;//(nlod-(2*diflods/3))*1.0/(diflods/3);
-					color.b=0.0;
-				}
-			}
-			mat[0]->setDiffuse(color);
-		}
-/*		else
-		{
-			if ((distance > dist_max))
-			{
-			//	myStrips->GoToLod(1.0f);
-
-				color.r=0.0;
-				color.g=0.0;
-				color.b=1.0;
-				mat[0]->setDiffuse(color);
-
-			}
-			else
-			{
-				if ((distance < dist_min))
-				{
-				//	myStrips->GoToLod(0.0f);
-
-					color.r=1.0;
-					color.g=0.0;
-					color.b=0.0;
-					mat[0]->setDiffuse(color);
-				}
-			}
-		}*/
+			DumpDataToOgreBuffers(ogreMesh,myTrees);
+			lodfactorBefore=lodfactor;
+		}
 
 		// Move the node
@@ -211,33 +172,12 @@
 		  mCamera->yaw(mRotScale);
 
+		force_maxLODfactor=mInputDevice->isKeyDown(Ogre::KC_F2);		  
+
 		if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
 		  mCamera->yaw(-mRotScale);
 
-		// Move the node
-		if(mInputDevice->isKeyDown(Ogre::KC_W))
-		  node->translate(0,mMoveScale,0);
-
-		if(mInputDevice->isKeyDown(Ogre::KC_S))
-		  node->translate(0,-mMoveScale,0);
-
-		if(mInputDevice->isKeyDown(Ogre::KC_Z))
-		  node->scale(1.01,1.01,1.01);
-
-		if(mInputDevice->isKeyDown(Ogre::KC_X))
-		  node->scale(0.99,0.99,0.99);
-
-		// Rotate
-		if(mInputDevice->isKeyDown(Ogre::KC_A))
-		  node->yaw(mRotScale);
-
-		if(mInputDevice->isKeyDown(Ogre::KC_D))
-		  node->yaw(-mRotScale);
-
 		if(mInputDevice->isKeyDown(Ogre::KC_ESCAPE))
 		{
-			delete myTrees;
-
-			delete [] mat;
-
+			//delete myTrees;
 		    return false;
 		}
@@ -262,8 +202,4 @@
 		mInfo->setCaption(cadena);
 
-		if (lodfactor<0.0f)
-			lodfactor=0.0f;
-		if (lodfactor>1.0f)
-			lodfactor=1.0f;
 		sprintf(cadena,"LOD factor: %f",lodfactor);
 
@@ -296,15 +232,17 @@
     void createScene(void)
     {
-		mat = new MaterialPtr[1];
+//		mat = new MaterialPtr[1];
 		
         theCam = mCamera;
         theCam->setPosition(0,20,dist_max+50);
         // Set ambient light
-        mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));
-
-        // Create a point light
-        Light* l = mSceneMgr->createLight("MainLight");
-        l->setType(Light::LT_DIRECTIONAL);
-        l->setDirection(0.0,0.0,-1.0);
+//        mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3));
+		mSceneMgr->setAmbientLight(ColourValue(1.0, 1.0, 1.0));
+
+        // Create a directional light
+/*		Light* l = mSceneMgr->createLight("MainLight");
+		l->setType(Light::LT_DIRECTIONAL);
+        l->setDirection(0.0,-1.0,0.0);*/
+	//	l->setAttenuation(1000000.0f, 1.0f, 1.0f, 1.0f);
         
         // Define a floor plane mesh
@@ -332,5 +270,5 @@
 
 		//Models
-        entity = mSceneMgr->createEntity(model_name, "../../../OgreStuff/media/GT/betulalod.mesh");
+        entity = mSceneMgr->createEntity(model_name, "../../../OgreStuff/media/GT/ML12m.mesh");
 
 		ogreMesh = entity->getMesh().getPointer();
@@ -338,41 +276,36 @@
 		// load LOD info from the object
 		meshloader=new Geometry::GeoMeshLoader;
-		Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/betulalod.mesh");
-
-        node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
-        node->attachObject( entity );
-		node->rotate(Ogre::Vector3(1,0,0),Ogre::Radian(-90.0f));
-
-//		myStrips = new LodStripsLibrary(lod_file,entity->getMesh().getPointer());
+		Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/ML12m.mesh");
+
+		myTrees = new Geometry::LodTreeLibrary(meshloader->GetLodStripsData(),meshloader->GetTreeSimpSeq(),themesh);
+
+		entity->setNormaliseNormals(true);
+
+		for (int submesh=0; submesh < ogreMesh->getNumSubMeshes(); submesh++)
+		{
+			bool istrunk = myTrees->GetLeavesSubMesh()!=submesh;
+			if (istrunk)
+				entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/trunk");
+			else
+				entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/leaf");
+		}
+
+		forest_center=Ogre::Vector3(150.0f,0.0f,0.0f);
+		for (int i=1; i<8; i++) // 20
+			for (int j=1; j<8; j++) // 20
+			{
+				char newTreeName[16]="";
+				sprintf(newTreeName,"arbol_%d_%d",i,j);
+				Ogre::SceneNode * auxnode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
+				auxnode->attachObject( entity->clone(newTreeName) );
+				auxnode->scale(4.0f,4.0f,4.0f);
+				auxnode->rotate(Ogre::Vector3(1,0,0),Ogre::Radian(-3.14159f*0.5f));
+				float randomsepx = (float)((rand()%18)-9);
+				float randomsepy = (float)((rand()%12)-6);
+				auxnode->translate(i*30.0f+randomsepx,0.0f,-j*30.0f-randomsepx);
+			}
 
 		if (!meshloader->GetLodStripsData() || !meshloader->GetTreeSimpSeq())
 			exit(1);
-
-//		myStrips = new Geometry::LodStripsLibrary(meshloader->GetLodStripsData(),themesh);
-		myTrees = new Geometry::LodTreeLibrary(meshloader->GetLodStripsData(),meshloader->GetTreeSimpSeq(),themesh);
-
-		entity->setNormaliseNormals(true);
-
-/*		// Colour-coded material
-		mat[0] = MaterialManager::getSingleton().create("test_mat", 
-			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-		mat[0]->setCullingMode(CULL_ANTICLOCKWISE);
-		mat[0]->setAmbient(ColourValue::Black);
-		mat[0]->setDiffuse(color);
-		mat[0]->setLightingEnabled(true);
-		entity->setMaterialName("test_mat");*/
-
-
-		// Colour-coded material
-		mat[0] = MaterialManager::getSingleton().create("test_mat", 
-			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
-		mat[0]->setCullingMode(CULL_NONE);
-		mat[0]->setAmbient(ColourValue::Black);
-		mat[0]->setDiffuse(color);
-		mat[0]->setLightingEnabled(true);
-		mat[0]->createTechnique()->createPass()->createTextureUnitState("nm_rt.png");
-		//entity->setMaterialName("test_mat");
-		entity->setMaterialName("Examples/GrassFloor");
-
 
         // show overlay
Index: GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp
===================================================================
--- GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp	(revision 1092)
+++ GTP/trunk/App/Demos/Geom/Demo_LodStrips/main.cpp	(revision 1104)
@@ -446,5 +446,5 @@
 
 		//Models
-        entity = mSceneMgr->createEntity(model_name, "../../../OgreStuff/media/GT/dwarflod.mesh");
+        entity = mSceneMgr->createEntity(model_name, "../../../OgreStuff/media/GT/bunnylod.mesh");
 
 		ogreMesh = entity->getMesh().getPointer();
@@ -452,5 +452,5 @@
 		// load LOD info from the object
 		meshloader=new Geometry::GeoMeshLoader;
-		Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/dwarflod.mesh");
+		Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/bunnylod.mesh");
 
         node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
@@ -481,4 +481,19 @@
 		entity->setMaterialName("test_mat");
 
+
+		for (int i=1; i<4; i++) // 20
+			for (int j=1; j<4; j++) // 20
+			{
+				char newObjName[16]="";
+				sprintf(newObjName,"arbol_%d_%d",i,j);
+				Ogre::SceneNode * auxnode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
+				auxnode->attachObject( entity->clone(newObjName) );
+				auxnode->scale(0.8f,0.8f,0.8f);
+				float randomsepx = (float)((rand()%18)-9);
+				float randomsepy = (float)((rand()%12)-6);
+				auxnode->translate(i*100.0f+randomsepx,0.0f,-j*100.0f-randomsepx);
+			}
+
+
         // show overlay
         Overlay* pOver = OverlayManager::getSingleton().getByName("Demo_LodStrips/Overlay");    
