Index: GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h	(revision 2459)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h	(revision 2473)
@@ -391,5 +391,5 @@
 	
 		TrollCharacter* troll = new TrollCharacter("troll1", NXScene, mSceneMgr, Vector3(1.5, 3.0, 1.2), Vector3(15, 10, 15), false);
-		troll->addPlayerMesh("troll.mesh", 0.05, false);
+		troll->addPlayerMesh("trollLOD.mesh", 0.05, false);
 		troll->addWeaponModel("trollMace.mesh", "RightHand");
 
Index: GTP/trunk/App/Demos/Illum/Ogre/src/Moria/scripts/Moria.7.10.vcproj
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/Moria/scripts/Moria.7.10.vcproj	(revision 2459)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/Moria/scripts/Moria.7.10.vcproj	(revision 2473)
@@ -21,5 +21,5 @@
 				Optimization="0"
 				ImproveFloatingPointConsistency="TRUE"
-				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include;&quot;$(NXOGRE_PATH)\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Physics\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Foundation\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Cooking\include&quot;;&quot;$(PHYSX_DIR)\SDKs\NxCharacter\include&quot;;&quot;$(PHYSX_DIR)\SDKs\PhysXLoader\include&quot;"
+				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include;&quot;$(NXOGRE_PATH)\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Physics\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Foundation\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Cooking\include&quot;;&quot;$(PHYSX_DIR)\SDKs\NxCharacter\include&quot;;&quot;$(PHYSX_DIR)\SDKs\PhysXLoader\include&quot;;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE"
 				MinimalRebuild="TRUE"
@@ -35,8 +35,8 @@
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="OgreMain_d.lib IllumModule_Ogre.lib IllumModule.lib NxOgre_d.lib"
+				AdditionalDependencies="OgreMain_d.lib GTGeometry_d.lib IllumModule_Ogre.lib IllumModule.lib NxOgre_d.lib"
 				OutputFile="$(OutDir)/Moria.exe"
-				LinkIncremental="2"
-				AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Debug;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Debug;&quot;$(NXOGRE_PATH)/lib&quot;"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Debug;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Debug;&quot;$(NXOGRE_PATH)/lib&quot;;&quot;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\build\$(ConfigurationName)&quot;"
 				IgnoreDefaultLibraryNames=""
 				GenerateDebugInformation="TRUE"
@@ -84,7 +84,7 @@
 				OmitFramePointers="TRUE"
 				EnableFiberSafeOptimizations="FALSE"
-				OptimizeForProcessor="2"
+				OptimizeForProcessor="3"
 				OptimizeForWindowsApplication="TRUE"
-				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include;&quot;$(NXOGRE_PATH)\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Physics\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Foundation\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Cooking\include&quot;;&quot;$(PHYSX_DIR)\SDKs\NxCharacter\include&quot;;&quot;$(PHYSX_DIR)\SDKs\PhysXLoader\include&quot;"
+				AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include;&quot;$(NXOGRE_PATH)\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Physics\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Foundation\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Cooking\include&quot;;&quot;$(PHYSX_DIR)\SDKs\NxCharacter\include&quot;;&quot;$(PHYSX_DIR)\SDKs\PhysXLoader\include&quot;;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE"
 				StringPooling="TRUE"
@@ -102,8 +102,10 @@
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="OgreMain.lib IllumModule_Ogre.lib IllumModule.lib NxOgre.lib"
+				AdditionalDependencies="OgreMain.lib GTGeometry.lib IllumModule_Ogre.lib IllumModule.lib NxOgre.lib"
 				OutputFile="$(OutDir)/Moria.exe"
 				LinkIncremental="1"
-				AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Release;&quot;$(NXOGRE_PATH)\lib&quot;"
+				AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Release;&quot;$(NXOGRE_PATH)\lib&quot;;&quot;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\build\$(ConfigurationName)&quot;"
+				IgnoreAllDefaultLibraries="FALSE"
+				IgnoreDefaultLibraryNames=""
 				GenerateDebugInformation="FALSE"
 				SubSystem="2"
Index: GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h	(revision 2462)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h	(revision 2473)
@@ -5,4 +5,6 @@
 #include "OgreIlluminationManager.h"
 #include "NXOgre.h"
+#include "GeoLodStripsLibrary.h"
+#include "GeoMeshLoader.h"
 
 using namespace Ogre;
@@ -127,4 +129,5 @@
 	float getHit(){ if(mCurrentAnimState == PLAYERANIMSTATE_ATTACK) return 20; else return 0;}
 	void addHit(float hit);
+	void addPlayerMesh(String meshname, float meshscale, bool rotateModel);
 
 	bool frameStarted(const FrameEvent& evt)
@@ -142,4 +145,8 @@
 
 	static float MaxHealth;
+	static Geometry::GeoMeshLoader* meshLoader;
+	static Geometry::Mesh *trollLODMesh;
+	Geometry::LodStripsLibrary *lodObject;
+	float lastLodLevel;
 };
 
Index: GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp	(revision 2468)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp	(revision 2473)
@@ -5,4 +5,35 @@
 float TrollCharacter::MaxHealth = 350;
 CharacterManager* CharacterManager::mSingleton = 0;
+Geometry::GeoMeshLoader* TrollCharacter::meshLoader = 0;
+Geometry::Mesh* TrollCharacter::trollLODMesh = 0;
+
+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 *){}
+};
 
 void CharacterManager::levelUP()
@@ -26,5 +57,5 @@
 															Vector3(25, 10, 25 - i * 10), false);
 
-			troll->addPlayerMesh("troll.mesh", 0.05, false);
+			troll->addPlayerMesh("trollLOD.mesh", 0.05, false);
 			troll->addWeaponModel("trollMace.mesh", "RightHand");
 			OgreIlluminationManager::getSingleton().initTechniques(troll->getMeshEntity());
@@ -291,4 +322,5 @@
 : PlayerCharacter(name, scene, sceneManager, dimensions, startPosition, debug)
 {
+	lastLodLevel = -1.0f;
 	mHealth = MaxHealth;
 }
@@ -363,4 +395,42 @@
 }
 
+void TrollCharacter::addPlayerMesh(String meshname, float meshscale, bool rotateModel)
+{
+	if(!meshLoader)
+	{
+		meshLoader = new Geometry::GeoMeshLoader;
+		trollLODMesh = meshLoader->load("../../Media/MORIA/trollLOD.mesh");
+	}
+	//clone the mesh
+	Mesh* originalMesh = (Mesh*) MeshManager::getSingleton().getByName(meshname).getPointer();
+	if(!originalMesh)
+		originalMesh = MeshManager::getSingleton().load("trollLOD.mesh", "GTP_Moria").getPointer();
+	String newMeshName = (meshname + "_CLONE_" + mName);
+	Ogre::Mesh *newOgreMesh = originalMesh->clone(newMeshName).getPointer();
+
+	mCharacterMeshEntity = mSceneManager->createEntity(mName, newMeshName);
+	mCharacterMeshEntity->setCastShadows(true);
+	mMeshScale = meshscale;
+	mCurrentAnimState = PLAYERANIMSTATE_STAND;
+	mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_STAND));
+	mCharacterMesh_AnimState->setEnabled(true);
+	mCharacterMesh_AnimState->setLoop(true);
+	SceneNode* meshNode = mPlayerNode->createChildSceneNode(mName + "_MeshNode");
+	meshNode->attachObject(mCharacterMeshEntity);
+	meshNode->setPosition(0 ,-mPlayerDimensions.y / 2.0, 0);
+	meshNode->setScale(meshscale, meshscale, meshscale);
+	if(rotateModel)
+	meshNode->rotate(Vector3::UNIT_Y, Degree(180.0));	
+
+	if (!meshLoader->GetLodStripsData())
+		OGRE_EXCEPT(1, "LOD info for the trunk not found","TrollCharacter::addPlayerMesh");
+
+	lodObject = new Geometry::LodStripsLibrary(meshLoader->GetLodStripsData(),
+				trollLODMesh,
+				new CustomIndexData(this->mCharacterMeshEntity->getMesh().getPointer()));
+
+	
+}
+
 void PlayerCharacter::addWeaponModel(String meshname, String attachBoneName)
 {
@@ -460,5 +530,23 @@
 		q.FromAxes(right,Vector3::UNIT_Y, dir);
 		mPlayerCharacter->setDirection(q);
-		
+
+		float dist_min = 2.0;
+		float dist_max = 10.0;
+		float lodLevel;
+		lodLevel = (float)(dist - dist_min) / (float)(dist_max - dist_min);
+		lodLevel = 1.0f - lodLevel;
+		
+		if (lodLevel < 0.0f)
+			lodLevel = 0.0f;
+		if (lodLevel > 1.0f)
+			lodLevel = 1.0f;
+		if (fabsf(lastLodLevel-lodLevel)>0.03f || 
+			(lastLodLevel > 0.0f && lodLevel == 0.0f) ||
+			(lastLodLevel < 1.0f && lodLevel == 1.0f))
+		{
+			lodObject->GoToLod(lodLevel);
+			lastLodLevel = lodLevel;
+		}
+
 		if(dist < 1.8)
 		{
