source: GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/FPSPlayer.h @ 2411

Revision 2411, 2.8 KB checked in by szirmay, 17 years ago (diff)
Line 
1#pragma once
2
3#include "Ogre.h"
4#include "NXOgre.h"
5
6using namespace Ogre;
7using namespace NxOgre;
8
9enum PlayerAnimState
10{
11        PLAYERANIMSTATE_STAND,
12        PLAYERANIMSTATE_IDLE,
13        PLAYERANIMSTATE_ATTACK,
14        PLAYERANIMSTATE_BLOCK,
15        PLAYERANIMSTATE_WALK,
16        PLAYERANIMSTATE_PAIN,
17        PLAYERANIMSTATE_DEATH,
18        PLAYERANIMSTATE_URN
19};
20
21class MyCharMoveController;
22
23class PlayerCharacter  : public FrameListener
24{
25public:
26
27        PlayerCharacter(String name, Scene* scene, SceneManager* sceneManager, Vector3 dimensions, Vector3 startPosition, bool debug = false);
28       
29        virtual void addPlayerMesh(String meshname, float meshscale, bool rotateModel);
30        bool frameStarted(const FrameEvent& evt);
31        virtual void addWeaponModel(String meshname, String attachBoneName);
32        void doAction(float dt);
33
34        static unsigned int frameListenerPriority;
35       
36protected:
37       
38        String mName;
39        Entity* mCharacterMeshEntity;
40        Entity* mWeaponEntity;
41        Bone* mWeaponAttachBone;
42    SceneNode* mWeaponNode;
43        SceneNode*  mWeaponBoundNode;
44        SceneNode*  mWeaponBoundDebugNode;
45        SceneNode*  mPlayerBoundDebugNode;
46        Actor* mWeaponBound;
47        Scene* mScene;
48        Character* mPlayerCharacter;
49        SceneNode* mPlayerNode;
50        float mMeshScale;
51        AnimationState* mCharacterMesh_AnimState;
52        SceneManager* mSceneManager;
53        PlayerAnimState mCurrentAnimState;
54        int mWeapon;
55        bool mMoving;
56        bool mForceAnimChange;
57        MyCharMoveController* mCharacterController;
58        Vector3 mPlayerDimensions;
59        bool mRunning;
60       
61        SceneNode* mWeaponNode2;
62        bool mDebug;
63
64        virtual String getAnimStateName(PlayerAnimState as,  int option = 0){return "walk";}
65        virtual void setAnimState(PlayerAnimState as)
66        {
67                if(mCurrentAnimState != PLAYERANIMSTATE_WALK)
68                {
69                        mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(as));
70                        mCharacterMesh_AnimState->setLoop(true);
71                        mCharacterMesh_AnimState->setEnabled(true);
72                }
73        }
74};
75
76class FPSPlayer : public PlayerCharacter
77{
78public:
79        FPSPlayer(Scene* scene, SceneManager* sceneManager, Vector3 dimensions, Vector3 startPosition, float cameraHeight, Camera* cam, bool debug = false);
80        ~FPSPlayer(void);
81
82        void addPlayerMesh(String meshname, float meshscale, bool rotateModel);
83        virtual void processKeyInputs(InputReader* inputDevice);
84        bool frameStarted(const FrameEvent& evt);
85        virtual void processMouseInputs(InputReader* inputDevice);     
86        void addWeaponModel(String meshname, String attachBoneName);
87        Vector3 getPosition(){return mPlayerNode->getWorldPosition();
88                return mPlayerCharacter->getGlobalPosition();}
89//      Vector3 getOrienation(){return mPlayerCharacter->getGlobalOrientation();}
90
91        static FPSPlayer* thePlayer;
92        static FPSPlayer* getPlayer(){return thePlayer;}
93
94protected:
95
96        Camera* mCamera;
97        float mCameraHeight;   
98
99        String getAnimStateName(PlayerAnimState as,  int option = 0);
100        void setAnimState(PlayerAnimState as);
101};
Note: See TracBrowser for help on using the repository browser.