Panda3D
bulletCharacterControllerNode.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file bulletCharacterControllerNode.h
10  * @author enn0x
11  * @date 2010-11-21
12  */
13 
14 #ifndef __BULLET_CHARACTER_CONTROLLER_NODE_H__
15 #define __BULLET_CHARACTER_CONTROLLER_NODE_H__
16 
17 #include "pandabase.h"
18 
19 #include "bullet_includes.h"
20 #include "bullet_utils.h"
21 #include "bulletShape.h"
23 
24 #include "luse.h"
25 #include "transformState.h"
26 #include "nodePath.h"
27 
28 /**
29  *
30  */
32 PUBLISHED:
33  explicit BulletCharacterControllerNode(BulletShape *shape, PN_stdfloat step_height,
34  const char *name="character");
36 
37  void set_linear_movement(const LVector3 &velocity, bool is_local);
38  void set_angular_movement(PN_stdfloat omega);
39 
40  BulletShape *get_shape() const;
41 
42  void set_gravity(PN_stdfloat gravity);
43  PN_stdfloat get_gravity() const;
44 
45  void set_fall_speed(PN_stdfloat fall_speed);
46  void set_jump_speed(PN_stdfloat jump_speed);
47  void set_max_jump_height(PN_stdfloat max_jump_height);
48 
49  void set_max_slope(PN_stdfloat max_slope);
50  PN_stdfloat get_max_slope() const;
51 
52  void set_use_ghost_sweep_test(bool value);
53 
54  bool is_on_ground() const;
55  bool can_jump() const;
56  void do_jump();
57 
58  MAKE_PROPERTY(shape, get_shape);
59  MAKE_PROPERTY(gravity, get_gravity, set_gravity);
60  MAKE_PROPERTY(max_slope, get_max_slope, set_max_slope);
61  MAKE_PROPERTY(on_ground, is_on_ground);
62 
63 public:
64  INLINE virtual btPairCachingGhostObject *get_ghost() const;
65  INLINE virtual btCharacterControllerInterface *get_character() const;
66 
67  virtual void do_sync_p2b(PN_stdfloat dt, int num_substeps);
68  virtual void do_sync_b2p();
69 
70 protected:
71  virtual void transform_changed();
72 
73 private:
74  CPT(TransformState) _sync;
75  bool _sync_disable;
76 
77  BulletUpAxis _up;
78 
79  btKinematicCharacterController *_character;
80  btPairCachingGhostObject *_ghost;
81 
82  PT(BulletShape) _shape;
83 
84  LVector3 _linear_movement;
85  bool _linear_movement_is_local;
86  PN_stdfloat _angular_movement;
87 
88  void do_transform_changed();
89 
90 public:
91  static TypeHandle get_class_type() {
92  return _type_handle;
93  }
94  static void init_type() {
95  BulletBaseCharacterControllerNode::init_type();
96  register_type(_type_handle, "BulletCharacterControllerNode",
97  BulletBaseCharacterControllerNode::get_class_type());
98  }
99  virtual TypeHandle get_type() const {
100  return get_class_type();
101  }
102  virtual TypeHandle force_init_type() {
103  init_type();
104  return get_class_type();
105  }
106 
107 private:
108  static TypeHandle _type_handle;
109 };
110 
112 
113 #endif // __BULLET_CHARACTER_CONTROLLER_NODE_H__
Indicates a coordinate-system transform on vertices.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.