Index: /GTP/trunk/App/Demos/Illum/Ogre/src/PRMDemo/include/PRMDemo.h
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/src/PRMDemo/include/PRMDemo.h	(revision 2334)
+++ /GTP/trunk/App/Demos/Illum/Ogre/src/PRMDemo/include/PRMDemo.h	(revision 2405)
@@ -26,4 +26,5 @@
 #include "SceneSerializer.h"
 
+Light* blueLight;
 
 // Listener class for frame updates
@@ -54,4 +55,11 @@
 		bool result = ExampleFrameListener::frameStarted(evt);
        framecount++;
+
+	   static float t = 0;
+	   float dt = evt.timeSinceLastFrame / 4.0;
+	   t += dt;
+
+	   //blueLight->setDirection(sin(t),sin(t),cos(t));
+	   blueLight->getParentSceneNode()->setPosition(30 * sin(t), 1, 30 * cos(t));
 	  
         return result;     
@@ -81,5 +89,5 @@
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic");
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc");
-		//ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Demo");
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_PathMap");
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_PathMapDemo");
 	}
@@ -225,6 +233,6 @@
 		OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
 		OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
-		OgreIlluminationManager::getSingleton().setShadowMapSize(512);
-		OgreIlluminationManager::getSingleton().setShadowMapMaterialName("GTP/Basic/Distance_Normalized");
+		OgreIlluminationManager::getSingleton().setShadowMapMaterialName(Light::LT_SPOTLIGHT, "GTP/Basic/Distance_Normalized");
+		OgreIlluminationManager::getSingleton().setShadowMapMaterialName(Light::LT_POINT, "GTP/Basic/Distance_Normalized");
 		OgreIlluminationManager::getSingleton().setFocusingSM(false);
 	   OgreIlluminationManager::getSingleton().setShadowMapSize(512);
@@ -253,36 +261,33 @@
 			
 		//createPlane("p","GTP/Basic/ShadowReceiver/Depth",Vector3(0,-0.3,0),Vector2(150,150));
-
+/*
 		mainLight = mSceneMgr->createLight("MainLight");
 		mainLight->setType(Light::LT_SPOTLIGHT);
-		mainLight->setCastShadows(false);
-        mainLight->setDiffuseColour(ColourValue(0.5,0.8,1,1));
+		mainLight->setCastShadows(true);
+        mainLight->setDiffuseColour(ColourValue(1.0,0.5,0.3,1));
 		mainLight->setSpecularColour(ColourValue::White);
 		mainLightNode = rootNode->createChildSceneNode();
 		
 		mainLightNode->setPosition(30,1,0.0);		
-		mainLight->setPosition(30,0,0);
-		mainLight->setPowerScale(300);
+		//mainLight->setPosition(30,1,0);
+		mainLight->setPowerScale(200);
 		mainLight->setDirection(-1, 0, 0);
 		mainLight->setSpotlightOuterAngle(Radian(Degree(90)));
-		mainLight->setAttenuation(50, 0, 1, 0);
+		mainLight->setAttenuation(200, 0, 0, 1);
 		mainLightNode->attachObject(mainLight); 	
-
-
-
-
-		Light* blueLight = mSceneMgr->createLight("BlueLight");
-		blueLight->setType(Light::LT_SPOTLIGHT);
-		blueLight->setCastShadows(false);
-        blueLight->setDiffuseColour(ColourValue(0.0,0.1,1,1));
+*/
+		blueLight = mSceneMgr->createLight("BlueLight");
+		blueLight->setType(Light::LT_POINT);
+		blueLight->setCastShadows(true);
+        blueLight->setDiffuseColour(ColourValue(1,1,1,1));
 		blueLight->setSpecularColour(ColourValue::White);
 		SceneNode* blueLightNode = rootNode->createChildSceneNode();
 		
 		blueLightNode->setPosition(-30,1,0.0);		
-		blueLight->setPosition(-30,0,0);
-		blueLight->setPowerScale(300);
-		blueLight->setDirection(1, 0, 0);
-		blueLight->setSpotlightOuterAngle(Radian(Degree(90)));
-		blueLight->setAttenuation(50, 0, 1, 0);
+		//blueLight->setPosition(-30,1,0);
+		blueLight->setPowerScale(200);
+	//	blueLight->setDirection(1, 0, 0);
+	//	blueLight->setSpotlightOuterAngle(Radian(Degree(90)));
+		blueLight->setAttenuation(200, 0, 0, 1);
 		blueLightNode->attachObject(blueLight); 	
 
Index: /GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h	(revision 2395)
+++ /GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h	(revision 2405)
@@ -28,5 +28,5 @@
 #include "FPSPlayer.h"
 
-AnimationState* mAnimState;
+AnimationState* mAnimState = 0;
 bool cullCamera = true;
 Body *throwSphere = 0;
@@ -69,5 +69,5 @@
 		framecount++;
 	  
-	    mAnimState->addTime(evt.timeSinceLastFrame * 0.5);  
+//	    mAnimState->addTime(evt.timeSinceLastFrame * 1.0);  
 		
 
@@ -119,4 +119,12 @@
             mTimeUntilNextToggle = 1;
         }
+		if (mInputDevice->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0)
+        {
+			char tmp[20];
+			sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots);
+            mWindow->writeContentsToFile(tmp);
+            mTimeUntilNextToggle = 0.5;
+			mWindow->setDebugText(String("Wrote ") + tmp);
+        }
 		return true;
 	}
@@ -148,9 +156,9 @@
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic");
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap");
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc");
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Particles");
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_PathMap");
 		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Moria");		
-		//ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap");
 		//ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Caustic");
 	}
@@ -289,5 +297,5 @@
 		bbs->setMaterialName("Flare");
 		mainLightNode->attachObject(bbs);
-
+/*
 		    Entity* ent = mSceneMgr->createEntity("troll", "troll.mesh");
 			ent->setCastShadows(true);
@@ -296,11 +304,14 @@
 			trollNode->attachObject(ent);
 			trollNode->setScale(0.05,0.05,0.05);
-            mAnimState = ent->getAnimationState("stand");
-            mAnimState->setEnabled(true);
-
-		gFPSPlayer = new FPSPlayer(NXScene, mSceneMgr, Vector3(0.5, 1.8, 0.3), Vector3(15, 1, 15), 1.6, mCamera, false);
-		gFPSPlayer->addPlayerMesh("FPSarm.mesh", 0.02, true);
-		gFPSPlayer->addWeaponModel("sword.mesh", "joint28");
-
+            mAnimState = ent->getAnimationState("walk");
+            mAnimState->setEnabled(true);*/
+
+//		PlayerCharacter::frameListenerPriority = 20;
+		gFPSPlayer = new FPSPlayer(NXScene, mSceneMgr, Vector3(0.5, 1.8, 0.3), Vector3(5, 10, 15), 1.6, mCamera, false);
+		//gFPSPlayer->addPlayerMesh("FPSarm.mesh", 0.02, true);
+		//gFPSPlayer->addWeaponModel("sword.mesh", "joint28");
+/*
+		PlayerCharacter* troll = new PlayerCharacter("troll1", NXScene, mSceneMgr, Vector3(1.5, 3.0, 1.2), Vector3(5, 10, 5), false);
+		troll->addPlayerMesh("troll.mesh", 0.05, false);*/
 		for(float i = 0; i< 7; i++)
 		{
@@ -312,5 +323,5 @@
 			Body* b = NXScene->createBody("cube.mesh",
 								new CubeShape(size, size, size),
-								Vector3(3,size/2.0 + size * (i + 0.01),3),
+								Vector3(3,size/2.0 + i * 5.0,3),
 								ac);
 			b->setCharacterCollisionGroup(NX_CHARACTER_COL_GROUP_PUSHABLE);
@@ -354,7 +365,7 @@
         mFrameListener->setPriority(10);	
 		mRoot->addFrameListener(mFrameListener);
-		gFPSPlayer->setPriority(20);
-	    mRoot->addFrameListener(gFPSPlayer);
-		OgreIlluminationManager::getSingleton().setPriority(30);
+//		gFPSPlayer->setPriority(20);
+//		mRoot->addFrameListener(gFPSPlayer);
+		OgreIlluminationManager::getSingleton().setPriority(40);
 	    mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
 	  
Index: /GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h	(revision 2405)
+++ /GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h	(revision 2405)
@@ -0,0 +1,100 @@
+#pragma once
+
+#include "Ogre.h"
+#include "NXOgre.h"
+
+using namespace Ogre;
+using namespace NxOgre;
+
+enum PlayerAnimState
+{
+	PLAYERANIMSTATE_STAND,
+	PLAYERANIMSTATE_IDLE,
+	PLAYERANIMSTATE_ATTACK,
+	PLAYERANIMSTATE_BLOCK,
+	PLAYERANIMSTATE_WALK,
+	PLAYERANIMSTATE_PAIN,
+	PLAYERANIMSTATE_DEATH,
+	PLAYERANIMSTATE_URN
+};
+
+class MyCharMoveController;
+
+class PlayerCharacter  : public FrameListener
+{
+public:
+
+	PlayerCharacter(String name, Scene* scene, SceneManager* sceneManager, Vector3 dimensions, Vector3 startPosition, bool debug = false);
+	
+	virtual void addPlayerMesh(String meshname, float meshscale, bool rotateModel);
+	bool frameStarted(const FrameEvent& evt);
+	virtual void addWeaponModel(String meshname, String attachBoneName);
+	void doAction();
+
+	static unsigned int frameListenerPriority;
+	
+protected:
+	
+	String mName;
+	Entity* mCharacterMeshEntity;
+	Entity* mWeaponEntity;
+	Bone* mWeaponAttachBone;
+    SceneNode* mWeaponNode;
+	SceneNode*  mWeaponBoundNode;
+	SceneNode*  mWeaponBoundDebugNode;
+	SceneNode*  mPlayerBoundDebugNode;
+	Actor* mWeaponBound;
+	Scene* mScene;
+	Character* mPlayerCharacter;
+	SceneNode* mPlayerNode;
+	float mMeshScale;
+	AnimationState* mCharacterMesh_AnimState;
+	SceneManager* mSceneManager;
+	PlayerAnimState mCurrentAnimState;
+	int mWeapon;
+	bool mMoving;
+	bool mForceAnimChange;
+	MyCharMoveController* mCharacterController;
+	Vector3 mPlayerDimensions;
+	bool mRunning;
+	
+	SceneNode* mWeaponNode2;
+	bool mDebug;
+
+	virtual String getAnimStateName(PlayerAnimState as,  int option = 0){return "walk";}
+	virtual void setAnimState(PlayerAnimState as)
+	{
+		if(mCurrentAnimState != PLAYERANIMSTATE_WALK)
+		{
+			mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(as));
+			mCharacterMesh_AnimState->setLoop(true);
+			mCharacterMesh_AnimState->setEnabled(true);
+		}
+	}
+};
+
+class FPSPlayer : public PlayerCharacter
+{
+public:
+	FPSPlayer(Scene* scene, SceneManager* sceneManager, Vector3 dimensions, Vector3 startPosition, float cameraHeight, Camera* cam, bool debug = false);
+	~FPSPlayer(void);
+
+	void addPlayerMesh(String meshname, float meshscale, bool rotateModel);
+	virtual void processKeyInputs(InputReader* inputDevice);
+	bool frameStarted(const FrameEvent& evt);
+	virtual void processMouseInputs(InputReader* inputDevice);	
+	void addWeaponModel(String meshname, String attachBoneName);
+	Vector3 getPosition(){return mPlayerCharacter->getGlobalPosition();}
+//	Vector3 getOrienation(){return mPlayerCharacter->getGlobalOrientation();}
+
+	static FPSPlayer* thePlayer;
+	static FPSPlayer* getPlayer(){return thePlayer;}
+
+protected:
+
+	Camera* mCamera;
+	float mCameraHeight;	
+
+	String getAnimStateName(PlayerAnimState as,  int option = 0);
+	void setAnimState(PlayerAnimState as);
+};
Index: /GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp	(revision 2405)
+++ /GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp	(revision 2405)
@@ -0,0 +1,559 @@
+#include "fpsplayer.h"
+
+FPSPlayer* FPSPlayer::thePlayer = NULL;
+unsigned int PlayerCharacter::frameListenerPriority = 1;
+
+class MyTrigger : public Trigger
+{
+public:
+	MyTrigger(const NxString& meshIdentifier, Scene* scene, ShapeDescription* shape, const NxOgre::Pose& pose, ActorParams params = ""):
+	  Trigger(meshIdentifier, scene, shape, pose, params)
+	  {
+	  }
+
+	 void onEnter(Actor* a)
+	 {
+		int ize = 0;
+	 }
+};
+
+class MyCharMoveController : public CharacterMovementVectorController
+{
+public:
+	MyCharMoveController(float speed = 1.5){movespeed = speed; mWeaponBound = 0;}
+	float movespeed;
+	Actor* mWeaponBound;
+	Vector3 mWeaponPosition;
+	SceneNode* mWeaponDebugNode;
+	void move(NxVec3 &out, NxVec3 &moveVector, NxQuat &direction, NxVec3 &g, float t, Character*)
+	{
+		NxVec3 dir = direction.rot(moveVector);
+		out = ((dir * movespeed) + g) * t;
+	
+		if(mWeaponBound)
+		{
+			Vector3 addDir(0,0,0);
+			//if(moveVector.z < 0)
+				addDir = Vector3(dir.x,0,dir.z) * t * movespeed * 1.2;
+			
+			Vector3 newPos = mWeaponPosition/* + addDir*/;
+			mWeaponBound->setGlobalPosition(newPos);
+			mWeaponBound->simulate(t);
+			//if(mWeaponDebugNode)
+			//mWeaponDebugNode->setPosition(newPos);
+			//mWeaponBound->moveGlobalPosition(mWeaponPosition);
+			//mWeaponDebugNode->setPosition(mWeaponPosition);
+		}
+	}
+};
+
+PlayerCharacter::PlayerCharacter(String name, Scene* scene, SceneManager* sceneManager, Vector3 dimensions, Vector3 startPosition, bool debug)
+{
+	mName = name;
+	mPlayerDimensions = dimensions;
+	mDebug = debug;
+	mSceneManager = sceneManager;
+	mScene = scene;
+	CharacterParams cp;
+	cp.setToDefault();
+	cp.mDimensions = NxVec3(dimensions.x, dimensions.y, dimensions.z);
+	cp.mType = CharacterParams::CT_Box;
+	mPlayerCharacter = mScene->createCharacter(mName, startPosition, cp); 
+	mPlayerCharacter->createNode();
+	mPlayerNode = mPlayerCharacter->getNode();
+	
+	mCharacterController = new MyCharMoveController(2.0);
+	mPlayerCharacter->setMovementVectorController(mCharacterController);
+
+	if(mDebug)
+	{
+		mPlayerBoundDebugNode = mPlayerNode->createChildSceneNode(mName + "_BoundDebugNode");
+		mPlayerBoundDebugNode->setScale(dimensions);
+		mPlayerBoundDebugNode->attachObject(mSceneManager->createEntity(mName + "_BoundDebug", "cube.mesh"));
+	}
+
+	//mCharacterMesh_AnimState = 0;
+	mForceAnimChange = false;
+	mWeapon = 0;
+	mWeaponBound = 0;
+	mWeaponBoundDebugNode = 0;
+	
+//	this->setPriority(frameListenerPriority++);
+//	Root::getSingleton().addFrameListener(this);
+
+	//mPlayerCharacter->setCharacterCollisionGroup(NX_CHARACTER_COL_GROUP_CHARACTER);
+	//mScene->getNxScene()->setGroupCollisionFlag(NX_CHARACTER_COL_GROUP_CHARACTER, NX_CHARACTER_COL_GROUP_NON_COLLIDABLE,false);
+}
+
+FPSPlayer::FPSPlayer(Scene* scene, SceneManager* sceneManager, Vector3 dimensions, Vector3 startPosition, float cameraHeight, Camera* cam, bool debug)
+: PlayerCharacter("FPSPlayerCharacter", scene, sceneManager, dimensions, startPosition, debug)
+{
+	mCameraHeight = cameraHeight - dimensions.y / 2.0;
+	mCamera = cam;
+	mCamera->setPosition(Vector3(0, mCameraHeight, 0));
+	mPlayerNode->attachObject(cam); 
+
+	thePlayer = this;
+}
+
+FPSPlayer::~FPSPlayer(void)
+{
+}
+
+void PlayerCharacter::addPlayerMesh(String meshname, float meshscale, bool rotateModel)
+{
+	mCharacterMeshEntity = mSceneManager->createEntity(mName, meshname);
+	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));
+}
+
+void FPSPlayer::addPlayerMesh(String meshname, float meshscale, bool rotateModel)
+{
+	mCharacterMeshEntity = mSceneManager->createEntity(mName, meshname);
+	mCharacterMeshEntity->setCastShadows(true);
+	mMeshScale = meshscale;
+	mCurrentAnimState = PLAYERANIMSTATE_STAND;
+	mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_STAND));
+	mCharacterMesh_AnimState->setEnabled(true);
+	mCharacterMesh_AnimState->setLoop(true);
+	SceneNode* FPSArmNode = mPlayerNode->createChildSceneNode(mName+"_ArmNode");
+	FPSArmNode->attachObject(mCharacterMeshEntity); 
+	FPSArmNode->setPosition(0,mCameraHeight,0);
+	FPSArmNode->setScale(meshscale, meshscale, meshscale);
+	if(rotateModel)
+	FPSArmNode->rotate(Vector3::UNIT_Y, Degree(180.0));
+}
+
+void PlayerCharacter::addWeaponModel(String meshname, String attachBoneName)
+{
+	
+	mWeaponEntity = mSceneManager->createEntity(mName + "_Weapon", meshname);
+	mWeaponAttachBone = mCharacterMeshEntity->getSkeleton()->getBone(attachBoneName);
+	mWeaponNode = mCharacterMeshEntity->getParentSceneNode()->createChildSceneNode(mName + "_WeaponNode");	
+	mWeaponNode->attachObject(mWeaponEntity);
+
+	AxisAlignedBox bb = mWeaponEntity->getBoundingBox();
+
+	Vector3 max = bb.getMaximum();
+	//max.z *= 2.0;
+	Vector3 min = bb.getMinimum();
+	Vector3 center = (min + max) / 2.0;
+	//center.z = max.z;
+
+	mWeaponBoundNode = mWeaponNode->createChildSceneNode(mName + "_WeaponBoundNode");
+	mWeaponBoundNode->setPosition(center);
+/*
+	SceneNode* ArmNode2 = mPlayerNode->createChildSceneNode();
+	ArmNode2->setPosition(0,mCameraHeight , -mPlayerDimensions.z);
+	ArmNode2->rotate(Vector3::UNIT_Y, Degree(180.0));
+	mWeaponNode2 = ArmNode2->createChildSceneNode();
+	mWeaponBoundNode = mWeaponNode2->createChildSceneNode();
+	mWeaponBoundNode->setPosition(center * mMeshScale );
+*/	
+
+	max *= mMeshScale;
+	min *= mMeshScale;
+	float dimX = max.x-min.x;
+	float dimY = max.y-min.y;
+	float dimZ = max.z-min.z;
+	Vector3 dim(dimX, dimY, dimZ);
+
+	mWeaponBound = new MyTrigger(mName + "_WeaponTrigger", mScene, new CubeShape(dimX, dimY, dimZ, "trigger: yes"), Vector3(0,0,0), "mass: 0, density: 0");
+	mScene->addTrigger((Trigger*)mWeaponBound);
+	
+	mCharacterController->mWeaponBound = mWeaponBound;
+	
+	if(mDebug)
+	{
+		mWeaponBoundDebugNode = mSceneManager->getRootSceneNode()->createChildSceneNode(mName+"_WeaponBoundDebugNode");
+		mWeaponBoundDebugNode->setScale(dim);
+		mWeaponBoundDebugNode->attachObject(mSceneManager->createEntity(mName+"_WeaponBoundDebug", "cube.mesh"));
+		mCharacterController->mWeaponDebugNode = mWeaponBoundDebugNode;
+	}
+
+	//mWeaponBound->setCharacterCollisionGroup(NX_CHARACTER_COL_GROUP_NON_COLLIDABLE);	
+}
+
+void FPSPlayer::addWeaponModel(String meshname, String attachBoneName)
+{
+	
+	mWeaponEntity = mSceneManager->createEntity(mName + "_Weapon", meshname);
+	mWeaponAttachBone = mCharacterMeshEntity->getSkeleton()->getBone(attachBoneName);
+	mWeaponNode = mCharacterMeshEntity->getParentSceneNode()->createChildSceneNode(mName+"_WeaponNode");	
+	mWeaponNode->attachObject(mWeaponEntity);
+
+	AxisAlignedBox bb = mWeaponEntity->getBoundingBox();
+
+	Vector3 max = bb.getMaximum();
+	//max.z *= 2.0;
+	Vector3 min = bb.getMinimum();
+	Vector3 center = (min + max) / 2.0;
+	//center.z = max.z;
+
+	//mWeaponBoundNode = mWeaponNode->createChildSceneNode();
+	//mWeaponBoundNode->setPosition(center);
+
+	SceneNode* ArmNode2 = mPlayerNode->createChildSceneNode(mName+"_ArmNode2");
+	ArmNode2->setPosition(0,mCameraHeight , -mPlayerDimensions.z);
+	ArmNode2->rotate(Vector3::UNIT_Y, Degree(180.0));
+	mWeaponNode2 = ArmNode2->createChildSceneNode();
+	mWeaponBoundNode = mWeaponNode2->createChildSceneNode(mName+"_WeaponBoundNode");
+	mWeaponBoundNode->setPosition(center * mMeshScale );
+	
+
+	max *= mMeshScale;
+	min *= mMeshScale;
+	float dimX = max.x-min.x;
+	float dimY = max.y-min.y;
+	dimY *=3;
+	float dimZ = max.z-min.z;
+	Vector3 dim(dimX, dimY, dimZ);
+
+//	mWeaponBound = mScene->createActor("FPSPlayerWeapon", new CubeShape(dimX, dimY, dimZ), Vector3(0,0,0), "kinematic: yes, mass: 10");
+	mWeaponBound = new MyTrigger(mName + "_WeaponTrigger", mScene, new CubeShape(dimX, dimY, dimZ, "trigger: yes"), Vector3(0,0,0), "mass: 0, density: 0");
+	mScene->addTrigger((Trigger*)mWeaponBound);
+	
+	mCharacterController->mWeaponBound = mWeaponBound;
+	
+	if(mDebug)
+	{
+		mWeaponBoundDebugNode = mSceneManager->getRootSceneNode()->createChildSceneNode(mName+"_WeaponBoundDebugNode");
+		mWeaponBoundDebugNode->setScale(dim);
+		mWeaponBoundDebugNode->attachObject(mSceneManager->createEntity(mName+"_WeaponBoundDebug", "cube.mesh"));
+		mCharacterController->mWeaponDebugNode = mWeaponBoundDebugNode;
+	}
+
+	mWeaponBound->setCharacterCollisionGroup(NX_CHARACTER_COL_GROUP_NON_COLLIDABLE);	
+}
+
+void PlayerCharacter::doAction()
+{
+	FPSPlayer* thePlayer = FPSPlayer::getPlayer();
+
+	if(thePlayer)
+	{
+		Vector3 playerPos = thePlayer->getPosition();
+		Vector3 myPos = mPlayerCharacter->getGlobalPosition();
+		Vector3 dir = playerPos - myPos;
+		dir.y = 0;
+		if( dir.length() > 1.0)
+		{
+			dir.normalise();
+			Vector3 right = dir.crossProduct(Vector3::UNIT_Y);
+			Quaternion q; 
+			Matrix3 rot;
+			rot.SetColumn(0, right);
+			rot.SetColumn(1, Vector3::UNIT_Y);
+			rot.SetColumn(2, dir);
+			//rot = rot.Transpose();
+
+			q.FromRotationMatrix(rot);			
+			mPlayerCharacter->setDirection(q); 
+			((MyCharMoveController*)mCharacterController)->movespeed = 0.2;
+		//	mPlayerCharacter->addMovement(Character::DR_Forward);
+		}
+
+	}
+	if(mCharacterMeshEntity)
+	setAnimState(PLAYERANIMSTATE_WALK);
+}
+
+bool PlayerCharacter::frameStarted(const FrameEvent& evt)
+{
+//	LogManager::getSingleton().logMessage("CHARACTERPLAYER_FRAMESTARTED");
+	doAction();
+
+	float dt = evt.timeSinceLastFrame;
+		
+	if(mCharacterMesh_AnimState)
+	{
+		float animspeed = 1.2;
+		if(mCurrentAnimState == PLAYERANIMSTATE_WALK && !mRunning)
+			animspeed /= 2;
+
+		mCharacterMesh_AnimState->addTime(dt*animspeed);	
+	}
+
+	return true;
+}
+
+void FPSPlayer::processKeyInputs(InputReader* inputDevice)
+{		
+		mMoving = false;
+		if (inputDevice->isKeyDown(KC_W))
+		{ 
+			mPlayerCharacter->addMovement(Character::DR_StepLeft); 
+			mMoving = true;
+		} 	
+		if (inputDevice->isKeyDown(KC_S))
+		{ 
+			mPlayerCharacter->addMovement(Character::DR_StepRight);
+			mMoving = true;
+		} 
+		if (inputDevice->isKeyDown(KC_A))
+		{ 
+			mPlayerCharacter->addMovement(Character::DR_Forward);
+			mMoving = true;
+		} 
+		if (inputDevice->isKeyDown(KC_D))
+		{ 
+			mPlayerCharacter->addMovement(Character::DR_Backward); 
+			mMoving = true;
+		} 
+
+		if (inputDevice->isKeyDown(KC_1))
+		{
+			mWeapon = 0;
+			mForceAnimChange = true;
+		}
+		if (inputDevice->isKeyDown(KC_2))
+		{
+			mWeapon = 1;
+			mForceAnimChange = true;
+		}
+
+		if (inputDevice->isKeyDown(KC_LSHIFT))
+		{
+			((MyCharMoveController*)mCharacterController)->movespeed = 4.0;
+			mRunning = true;
+		}
+		else
+		{
+			((MyCharMoveController*)mCharacterController)->movespeed = 2.0;
+			mRunning = false;
+		}
+}
+
+void FPSPlayer::processMouseInputs(InputReader* inputDevice)
+{
+	if( inputDevice->getMouseButton( 0 ) )//attack
+		setAnimState(PLAYERANIMSTATE_ATTACK);
+		
+	else if( inputDevice->getMouseButton( 1 ) )//block
+		setAnimState(PLAYERANIMSTATE_BLOCK);
+
+	Quaternion q; 
+	q.FromAngleAxis( Radian(Degree(-inputDevice->getMouseRelX() * 0.13)), Vector3::UNIT_Y ); 
+	q = mPlayerCharacter->getGlobalOrientation() * q; 
+	mPlayerCharacter->setDirection(q); 
+
+	mCamera->pitch(Radian(Degree(-inputDevice->getMouseRelY() * 0.13)));		
+}
+
+bool FPSPlayer::frameStarted(const FrameEvent& evt)
+{
+//	LogManager::getSingleton().logMessage("FPSPLAYER_FRAMESTARTED");
+
+	float dt = evt.timeSinceLastFrame;
+		
+	if(mCharacterMesh_AnimState)
+	{
+		float animspeed = 1.2;
+		if(mCurrentAnimState == PLAYERANIMSTATE_WALK && !mRunning)
+			animspeed /= 2;
+
+		mCharacterMesh_AnimState->addTime(dt*animspeed);	
+	}
+
+	static float moveTime=0;
+	
+	float movecameraup = 0;
+	if(mDebug)movecameraup = 1.0;
+
+	if(mMoving)
+	{
+		setAnimState(PLAYERANIMSTATE_WALK);
+
+		moveTime += dt;
+		mCamera->setPosition(Vector3(0,mCameraHeight + movecameraup,0) + Vector3(0,0.009 * pow(sin(moveTime*5.0), 2),0));
+	}
+	else
+	{
+		if(Math::UnitRandom() > 0.98)
+			setAnimState(PLAYERANIMSTATE_IDLE);
+		else
+			setAnimState(PLAYERANIMSTATE_STAND);
+
+		moveTime = 0;
+		mCamera->setPosition(Vector3(0,mCameraHeight + movecameraup,0));
+	}
+
+	this->mCharacterMeshEntity->_updateAnimation();
+
+	if(mWeaponEntity)
+	{
+		mWeaponNode->setPosition(mWeaponAttachBone->getWorldPosition());
+		mWeaponNode->setOrientation(mWeaponAttachBone->getWorldOrientation());
+
+		mWeaponNode2->setPosition(mWeaponAttachBone->getWorldPosition() * mMeshScale);
+		mWeaponNode2->setOrientation(mWeaponAttachBone->getWorldOrientation());
+
+		Vector3 translation = mWeaponBoundNode->getWorldPosition();
+		Quaternion orientation = mWeaponBoundNode->getWorldOrientation();
+
+		mCharacterController->mWeaponPosition  = translation;
+		
+		mWeaponBound->setGlobalOrientation(orientation);		
+		//mWeaponBound->moveGlobalPosition(translation);
+
+		//mWeaponBound->setGlobalPosition(translation);		
+		//mWeaponBound->setGlobalOrientation(orientation);
+
+		if(mDebug)
+		{
+			mWeaponBoundDebugNode->setPosition(translation);
+			mWeaponBoundDebugNode->setOrientation(orientation);
+		}
+	}
+
+	return true;
+}
+
+String FPSPlayer::getAnimStateName(PlayerAnimState as, int option)
+{
+	switch (as)
+	{
+		case PLAYERANIMSTATE_IDLE:
+		{
+			if(mWeapon < 1)
+				return "sword_idle";
+			else
+				return "magic_idle";
+		}
+		case PLAYERANIMSTATE_STAND:
+		{
+			if(mWeapon < 1)
+				return "sword_stand";
+			else
+				return "magic_stand";
+		}
+		case PLAYERANIMSTATE_BLOCK:
+		{
+				return "block";			
+		}
+		case PLAYERANIMSTATE_WALK:
+		{
+				return "walk";			
+		}
+		case PLAYERANIMSTATE_ATTACK:
+		{
+			if(option)
+			{
+				if(mWeapon < 1)
+					return "attack1";
+				else
+					return "magic_attack";
+			}
+			else
+			{
+				if(mWeapon < 1)
+					return "attack2";
+				else
+					return "magic_attack";
+			}
+		}
+	}
+	return "";
+}
+
+void FPSPlayer::setAnimState(PlayerAnimState as)
+{
+	switch(as)	
+	{
+		case PLAYERANIMSTATE_STAND:
+		{
+			if(mCurrentAnimState != PLAYERANIMSTATE_STAND || mForceAnimChange)
+			{
+				//wait until anim finishes
+				if(mCharacterMesh_AnimState->getTimePosition() >=
+					mCharacterMesh_AnimState->getLength() || mCharacterMesh_AnimState->getLoop())
+				{
+					mCurrentAnimState = PLAYERANIMSTATE_STAND;
+					mCharacterMesh_AnimState->setEnabled(false);
+					mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_STAND));
+					mCharacterMesh_AnimState->setLoop(true);
+					mCharacterMesh_AnimState->setEnabled(true);
+				}
+			}
+			break;
+		}
+		case PLAYERANIMSTATE_IDLE:
+		{
+			if(mCurrentAnimState != PLAYERANIMSTATE_IDLE || mForceAnimChange)
+			{
+				//wait until anim finishes
+				if(mCharacterMesh_AnimState->getTimePosition() >=
+					mCharacterMesh_AnimState->getLength() || mCharacterMesh_AnimState->getLoop() || mCurrentAnimState == PLAYERANIMSTATE_IDLE)
+				{
+					mCurrentAnimState = PLAYERANIMSTATE_IDLE;
+					mCharacterMesh_AnimState->setEnabled(false);
+					mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_IDLE));
+					mCharacterMesh_AnimState->setTimePosition(0);
+					mCharacterMesh_AnimState->setLoop(false);
+					mCharacterMesh_AnimState->setEnabled(true);
+				}
+			}
+			break;
+		}
+		case PLAYERANIMSTATE_WALK:
+		{
+			if(mCurrentAnimState != PLAYERANIMSTATE_WALK)
+			{
+				if(mCurrentAnimState == PLAYERANIMSTATE_IDLE || mCurrentAnimState == PLAYERANIMSTATE_STAND)
+				{
+					mCurrentAnimState = PLAYERANIMSTATE_WALK;
+					mCharacterMesh_AnimState->setEnabled(false);
+					mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_WALK));
+					mCharacterMesh_AnimState->setLoop(true);
+					mCharacterMesh_AnimState->setEnabled(true);
+				}
+			}
+			break;
+		}
+		case PLAYERANIMSTATE_ATTACK:
+		{
+			if(mCharacterMesh_AnimState->getTimePosition() >=
+					mCharacterMesh_AnimState->getLength() || mCharacterMesh_AnimState->getLoop() || mCurrentAnimState == PLAYERANIMSTATE_IDLE)
+			{
+			    int attackType = 0;
+				if(Math::UnitRandom() > 0.5)
+					 attackType = 1;
+
+				mCurrentAnimState = PLAYERANIMSTATE_ATTACK;
+				mCharacterMesh_AnimState->setEnabled(false);
+				mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_ATTACK, attackType));
+				mCharacterMesh_AnimState->setTimePosition(0);
+				mCharacterMesh_AnimState->setLoop(false);
+				mCharacterMesh_AnimState->setEnabled(true);
+			}
+			break;
+		}		
+		case PLAYERANIMSTATE_BLOCK:
+		{
+			if(mCharacterMesh_AnimState->getTimePosition() >=
+					mCharacterMesh_AnimState->getLength() || mCharacterMesh_AnimState->getLoop() || mCurrentAnimState == PLAYERANIMSTATE_IDLE)
+			{
+				mCurrentAnimState = PLAYERANIMSTATE_BLOCK;
+				mCharacterMesh_AnimState->setEnabled(false);
+				mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_BLOCK));
+				mCharacterMesh_AnimState->setTimePosition(0);
+				mCharacterMesh_AnimState->setLoop(false);
+				mCharacterMesh_AnimState->setEnabled(true);
+			}
+			break;
+		}
+	}
+
+	if(mForceAnimChange)
+		mForceAnimChange = false;
+}
