____________________________________ Reference for PlayerControlClass.h ____________________________________ // 1. create IAnimatedMeshSceneNode // 2. create IPlayerBP // 3. call BipedPlayer1.attachMesh(Player1Mesh) // 4. create WASDMouseBPControl // 5. call WASDCtrlr.attachPlayerBP(&BipedPlayer1) // 6-11. optional: include I3rdPersonCam.h // 7. create I3rdPersonCam object ; // 8. attach a CameraSceneNode with Cam1.attachCamera() // 9. attach to a target with Cam1.setTarget() // 10. call Cam1.modOrientation(pan, tilt, zoom) or Cam1.setOrientation(pan, tilt, zool) to position camera // 11. call Cam1.updatePosition() to apply new Position data // 12. repeat 10 and 11 as needed //-----example code // IAnimatedMeshSceneNode *Player1; // I3rdPersonCam My3rdCam1; // IPlayerBP MainPlayer; // WASDMouseBPControl WASD1; // MainPlayer.attachMesh(Player1); // WASD1.attachPlayerBP(&MainPlayer); //My3rdCam1.setTarget(Player1); //My3rdCam1.setOffset(vector3df(0,20,0)); //My3rdCam1.attachCamera(camnode); //while(1){ // WASD1.Tick("Time_in_milliseconds_from_last_frame"); // My3rdCam1.modOrientation( "orientation"); // My3rdCam.updatePosition(); //} // end example returns distance from pos to terrain surface float GetHeight(irr::IrrlichtDevice *device,scene::ITriangleSelector *Ground, const vector3df& pos, float maxHeight) { class IPlayerBP{ public: IAnimatedMeshSceneNode *myMesh; IrrlichtDevice *MyDevice; scene::ITriangleSelector *MyFloor; scene::ITerrainSceneNode *MyFloorTerrain; float momentum; float gravity; bool Forward, Back, Run, Walk, StrafeLeft, StrafeRight, Swim, Crouch, Jump,Idle; float WalkSpeed,RunSpeed,SwimSpeed; bool CanJump; bool Jumping; bool JumpLanding; vector3df JumpDirection; vector3df GroundOffset; float forwardAngle; int JumpTime, JumpTimer; int WALKFrames[2], WalkFrameSpeed; int LANDFrames[2],LandFrameSpeed; int RUNFrames[2], RunFrameSpeed; int CROUCHWALKFrames[2],CrouchWalkframeSpeed; int CROUCHWALKBACKFrames[2],CrouchWalkBackframeSpeed; int STANDFrames[2],StandFrameSpeed; int SWIMFrames[2], SwimFrameSpeed; int JUMPFrames[2], JumpFrameSpeed; int CROUCHFrames[2],CrouchFrameSpeed; int DIEFrames[2], DieFrameSpeed; int WALKBACKFrames[2],WalkBackFrameSpeed; Initializer: IPlayerBP() Clears Most Flags: void NULLifyFlags() Sets Gravity: void SetGravity(float UnitsPerSecond) Sets distance from Model Origin down to ground (if feet are above ground use a negative offset) void SetGroundOffset(vector3df GO) Associates the device used in your game with this object void SetDevice(IrrlichtDevice *dev1) Sets the ground terrain used for collision detection void SetGround(IrrlichtDevice *dev1,ITerrainSceneNode *ground1) Sets the Jump Force applied when jump key is pressed void SetJumpForce(int frc) calls the Jump Landing animation sequence (used internally void EndJumpMode() Applies gravity to model (used internally) void ApplyGravity(int msec) Sets the walking speed void SetWalkSpeed(float speed) Sets the running speed void SetRunSpeed(float speed) Sets the swimming speed void SetSwimSpeed(float speed) Spins the player left or right void Turn(float tdegrees) Attaches an animated mesh to this object void attachMesh(IAnimatedMeshSceneNode *m1) //Set Animation Frame Sets Functions void SetCrouchFrames(int FirstFrame,int LastFrame,int speed) void SetJumpLandFrames(int FirstFrame,int LastFrame,int speed) void SetCrouchWalkFrames(int FirstFrame,int LastFrame,int speed) void SetCrouchWalkBackFrames(int FirstFrame,int LastFrame,int speed) void SetDieFrames(int FirstFrame,int LastFrame,int speed) void SetWalkFrames(int FirstFrame,int LastFrame,int speed) void SetRunFrames(int FirstFrame,int LastFrame,int speed) void SetStandFrames(int FirstFrame,int LastFrame,int speed) void SetSwimFrames(int FirstFrame,int LastFrame,int speed) void SetJumpFrames(int FirstFrame,int LastFrame,int speed) void SetWalkBackFrames(int FirstFrame,int LastFrame,int speed) //end set Frames functions //Animation Modes void Die() void StandMode() void IdleMode() void Freeze() // new modified functions begin here void JumpMode() void RunForwardMode() void RunBackMode() void WalkForwardMode() void WalkBackMode() void WalkForwardCrouchMode() void WalkBackCrouchMode() void StrafeLeftMode() void StrafeRightMode() void StrafeLeftCrouchMode() void StrafeRightCrouchMode() void StrafeLeftForwardMode() void StrafeRightForwardMode() void StrafeLeftBackMode() void StrafeRightBackMode() void StrafeLeftForwardCrouchMode() void StrafeRightForwardCrouchMode() void StrafeLeftBackCrouchMode() void StrafeRightBackCrouchMode() void CrouchMode() //SwimFunctions void SwimBackMode() void SwimForwardMode() void SwimStrafeLeftMode() void SwimStrafeRightMode() void SwimStrafeLeftBackMode() void SwimStrafeRightBackMode() void SwimStrafeLeftForwardMode() void SwimStrafeRightForwardMode() // end animation mode functions Applies motion based on time and motion flags void stepMotion(int milliseconds) // All but the last of these functions are pretty self-explanatory class WASDMouseBPControl{ public: IPlayerBP *MyBP; int Key_For_Walk; int Key_For_Back; int Key_For_Left; int Key_For_Right; int Key_For_Jump; int Key_For_Crouch; int Key_For_Run; bool Crouch_Key_Down; WASDMouseBPControl(){ Key_For_Walk=KEY_KEY_W; Key_For_Back=KEY_KEY_S; Key_For_Left=KEY_KEY_A; Key_For_Right=KEY_KEY_D; Key_For_Jump=KEY_SPACE; Key_For_Crouch=KEY_KEY_C; Key_For_Run=KEY_SHIFT; } void SetWalkKey(int key1) void SetBackKey(int key1) void SetLeftKey(int key1) void SetRightKey(int key1) void SetJumpKey(int key1) void SetCrouchKey(int key1) void SetRunKey(int key1) attaches an IPlayerBP to this object for this object to control void attachPlayerBP(IPlayerBP *BPtoAttach) this function uses data provided by EventReceiver to call It's biped functions such as setting AnimationModes and then stepmotion void Tick(int msecs) };