Panda3D
 All Classes Functions Variables Enumerations
physxController.h
1 // Filename: physxController.h
2 // Created by: enn0x (24Sep09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PHYSXCONTROLLER_H
16 #define PHYSXCONTROLLER_H
17 
18 #include "pandabase.h"
19 #include "pointerTo.h"
20 #include "luse.h"
21 
22 #include "physxObject.h"
23 #include "physxEnums.h"
24 #include "physx_includes.h"
25 
26 class PhysxActor;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : PhysxController
30 // Description : Abstract base class for character controllers.
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDAPHYSX PhysxController : public PhysxObject, public PhysxEnums {
33 
34 PUBLISHED:
35  void release();
36 
37  PhysxActor *get_actor() const;
38 
39  void set_pos(const LPoint3f &pos);
40  void set_sharpness(float sharpness);
41  void set_collision(bool enable);
42  void set_min_distance(float min_dist);
43  void set_step_offset(float offset);
44 
45  LPoint3f get_pos() const;
46  float get_sharpness() const;
47 
48  void set_global_speed(const LVector3f &speed);
49  void set_local_speed(const LVector3f &speed);
50  void set_omega(float omega);
51  void set_h(float heading);
52  float get_h() const;
53 
54  void report_scene_changed();
55  void start_jump(float v0);
56  void stop_jump();
57 
58  INLINE void ls() const;
59  INLINE void ls(ostream &out, int indent_level=0) const;
60 
61 public:
62  void update_controller(float dt);
63 
64  static PhysxController *factory(NxControllerType shapeType);
65 
66  virtual NxController *ptr() const = 0;
67 
68  virtual void link(NxController *controllerPtr) = 0;
69  virtual void unlink() = 0;
70 
71 protected:
72  INLINE PhysxController();
73 
74 private:
75  NxReal get_jump_height(float dt, NxVec3 &gravity);
76 
77  float _sharpness;
78  float _min_dist;
79 
80  bool _jumping;
81  float _jump_time;
82  float _jump_v0;
83 
84  float _omega;
85  float _heading;
86  NxVec3 _speed;
87 
88  NxVec3 _up_vector;
89  NxQuat _up_quat;
90  NxQuat _up_quat_inv;
91  NxHeightFieldAxis _up_axis;
92 
93 ////////////////////////////////////////////////////////////////////
94 public:
95  static TypeHandle get_class_type() {
96  return _type_handle;
97  }
98  static void init_type() {
99  PhysxObject::init_type();
100  register_type(_type_handle, "PhysxController",
101  PhysxObject::get_class_type());
102  }
103  virtual TypeHandle get_type() const {
104  return get_class_type();
105  }
106  virtual TypeHandle force_init_type() {
107  init_type();
108  return get_class_type();
109  }
110 
111 private:
112  static TypeHandle _type_handle;
113 };
114 
115 #include "physxController.I"
116 
117 #endif // PHYSXCONTROLLER_H
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
Abstract base class for character controllers.
This class exists just to provide scoping for the enums shared by PhysX classes.
Definition: physxEnums.h:357
Actors are the main simulation objects.
Definition: physxActor.h:48
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85