Panda3D

bulletCharacterControllerNode.h

00001 // Filename: bulletCharacterControllerNode.h
00002 // Created by:  enn0x (21Nov10)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef __BULLET_CHARACTER_CONTROLLER_NODE_H__
00016 #define __BULLET_CHARACTER_CONTROLLER_NODE_H__
00017 
00018 #include "pandabase.h"
00019 
00020 #include "bullet_includes.h"
00021 #include "bullet_utils.h"
00022 #include "bulletShape.h"
00023 #include "bulletBaseCharacterControllerNode.h"
00024 
00025 #include "luse.h"
00026 #include "transformState.h"
00027 #include "nodePath.h"
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : BulletCharacterControllerNode
00031 // Description : 
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDABULLET BulletCharacterControllerNode : public BulletBaseCharacterControllerNode {
00034 
00035 PUBLISHED:
00036   BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height, const char *name="character");
00037   INLINE ~BulletCharacterControllerNode();
00038 
00039   void set_linear_movement(const LVector3 &velocity, bool is_local);
00040   void set_angular_movement(PN_stdfloat omega);
00041 
00042   BulletShape *get_shape() const;
00043 
00044   PN_stdfloat get_gravity() const;
00045   PN_stdfloat get_max_slope() const;
00046 
00047   void set_fall_speed(PN_stdfloat fall_speed);
00048   void set_jump_speed(PN_stdfloat jump_speed);
00049   void set_max_jump_height(PN_stdfloat max_jump_height);
00050   void set_max_slope(PN_stdfloat max_slope);
00051   void set_gravity(PN_stdfloat gravity);
00052   void set_use_ghost_sweep_test(bool value);
00053 
00054   bool is_on_ground() const;
00055   bool can_jump() const;
00056   void do_jump();
00057 
00058 public:
00059   INLINE virtual btPairCachingGhostObject *get_ghost() const;
00060   INLINE virtual btCharacterControllerInterface *get_character() const;
00061 
00062   virtual void sync_p2b(PN_stdfloat dt, int num_substeps);
00063   virtual void sync_b2p();
00064 
00065 protected:
00066   virtual void transform_changed();
00067 
00068 private:
00069   CPT(TransformState) _sync;
00070   bool _sync_disable;
00071 
00072   BulletUpAxis _up;
00073 
00074   btKinematicCharacterController *_character;
00075   btPairCachingGhostObject *_ghost;
00076 
00077   PT(BulletShape) _shape;
00078 
00079   LVector3 _linear_movement;
00080   bool _linear_movement_is_local;
00081   PN_stdfloat _angular_movement;
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 public:
00085   static TypeHandle get_class_type() {
00086     return _type_handle;
00087   }
00088   static void init_type() {
00089     BulletBaseCharacterControllerNode::init_type();
00090     register_type(_type_handle, "BulletCharacterControllerNode", 
00091                   BulletBaseCharacterControllerNode::get_class_type());
00092   }
00093   virtual TypeHandle get_type() const {
00094     return get_class_type();
00095   }
00096   virtual TypeHandle force_init_type() {
00097     init_type();
00098     return get_class_type();
00099   }
00100 
00101 private:
00102   static TypeHandle _type_handle;
00103 };
00104 
00105 #include "bulletCharacterControllerNode.I"
00106 
00107 #endif // __BULLET_CHARACTER_CONTROLLER_NODE_H__
00108 
 All Classes Functions Variables Enumerations