Panda3D
physxController.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 physxController.h
10  * @author enn0x
11  * @date 2009-09-24
12  */
13 
14 #ifndef PHYSXCONTROLLER_H
15 #define PHYSXCONTROLLER_H
16 
17 #include "pandabase.h"
18 #include "pointerTo.h"
19 #include "luse.h"
20 
21 #include "physxObject.h"
22 #include "physxEnums.h"
23 #include "physx_includes.h"
24 
25 class PhysxActor;
26 
27 /**
28  * Abstract base class for character controllers.
29  */
30 class EXPCL_PANDAPHYSX PhysxController : public PhysxObject, public PhysxEnums {
31 
32 PUBLISHED:
33  void release();
34 
35  PhysxActor *get_actor() const;
36 
37  void set_pos(const LPoint3f &pos);
38  void set_sharpness(float sharpness);
39  void set_collision(bool enable);
40  void set_min_distance(float min_dist);
41  void set_step_offset(float offset);
42 
43  LPoint3f get_pos() const;
44  float get_sharpness() const;
45 
46  void set_global_speed(const LVector3f &speed);
47  void set_local_speed(const LVector3f &speed);
48  void set_omega(float omega);
49  void set_h(float heading);
50  float get_h() const;
51 
52  void report_scene_changed();
53  void start_jump(float v0);
54  void stop_jump();
55 
56  INLINE void ls() const;
57  INLINE void ls(std::ostream &out, int indent_level=0) const;
58 
59 public:
60  void update_controller(float dt);
61 
62  static PhysxController *factory(NxControllerType shapeType);
63 
64  virtual NxController *ptr() const = 0;
65 
66  virtual void link(NxController *controllerPtr) = 0;
67  virtual void unlink() = 0;
68 
69 protected:
70  INLINE PhysxController();
71 
72 private:
73  NxReal get_jump_height(float dt, NxVec3 &gravity);
74 
75  float _sharpness;
76  float _min_dist;
77 
78  bool _jumping;
79  float _jump_time;
80  float _jump_v0;
81 
82  float _omega;
83  float _heading;
84  NxVec3 _speed;
85 
86  NxVec3 _up_vector;
87  NxQuat _up_quat;
88  NxQuat _up_quat_inv;
89  NxHeightFieldAxis _up_axis;
90 
91 public:
92  static TypeHandle get_class_type() {
93  return _type_handle;
94  }
95  static void init_type() {
96  PhysxObject::init_type();
97  register_type(_type_handle, "PhysxController",
98  PhysxObject::get_class_type());
99  }
100  virtual TypeHandle get_type() const {
101  return get_class_type();
102  }
103  virtual TypeHandle force_init_type() {
104  init_type();
105  return get_class_type();
106  }
107 
108 private:
109  static TypeHandle _type_handle;
110 };
111 
112 #include "physxController.I"
113 
114 #endif // PHYSXCONTROLLER_H
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.
Abstract base class for character controllers.
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition: physxEnums.h:355
Actors are the main simulation objects.
Definition: physxActor.h:44
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.