Panda3D

physxController.h

00001 // Filename: physxController.h
00002 // Created by:  enn0x (24Sep09)
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 PHYSXCONTROLLER_H
00016 #define PHYSXCONTROLLER_H
00017 
00018 #include "pandabase.h"
00019 #include "pointerTo.h"
00020 #include "luse.h"
00021 
00022 #include "physxObject.h"
00023 #include "physxEnums.h"
00024 #include "physx_includes.h"
00025 
00026 class PhysxActor;
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : PhysxController
00030 // Description : Abstract base class for character controllers.
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_PANDAPHYSX PhysxController : public PhysxObject, public PhysxEnums {
00033 
00034 PUBLISHED:
00035   void release();
00036 
00037   PhysxActor *get_actor() const;
00038 
00039   void set_pos(const LPoint3f &pos);
00040   void set_sharpness(float sharpness);
00041   void set_collision(bool enable);
00042   void set_min_distance(float min_dist);
00043   void set_step_offset(float offset);
00044 
00045   LPoint3f get_pos() const;
00046   float get_sharpness() const;
00047 
00048   void set_global_speed(const LVector3f &speed);
00049   void set_local_speed(const LVector3f &speed);
00050   void set_omega(float omega);
00051   void set_h(float heading);
00052   float get_h() const;
00053 
00054   void report_scene_changed();
00055   void start_jump(float v0);
00056   void stop_jump();
00057 
00058   INLINE void ls() const;
00059   INLINE void ls(ostream &out, int indent_level=0) const;
00060 
00061 public:
00062   void update_controller(float dt);
00063 
00064   static PhysxController *factory(NxControllerType shapeType);
00065 
00066   virtual NxController *ptr() const = 0;
00067 
00068   virtual void link(NxController *controllerPtr) = 0;
00069   virtual void unlink() = 0;
00070 
00071 protected:
00072   INLINE PhysxController();
00073 
00074 private:
00075   NxReal get_jump_height(float dt, NxVec3 &gravity);
00076 
00077   float _sharpness;
00078   float _min_dist;
00079 
00080   bool  _jumping;
00081   float _jump_time;
00082   float _jump_v0;
00083 
00084   float _omega;
00085   float _heading;
00086   NxVec3 _speed;
00087 
00088   NxVec3 _up_vector;
00089   NxQuat _up_quat;
00090   NxQuat _up_quat_inv;
00091   NxHeightFieldAxis _up_axis;
00092 
00093 ////////////////////////////////////////////////////////////////////
00094 public:
00095   static TypeHandle get_class_type() {
00096     return _type_handle;
00097   }
00098   static void init_type() {
00099     PhysxObject::init_type();
00100     register_type(_type_handle, "PhysxController", 
00101                   PhysxObject::get_class_type());
00102   }
00103   virtual TypeHandle get_type() const {
00104     return get_class_type();
00105   }
00106   virtual TypeHandle force_init_type() {
00107     init_type();
00108     return get_class_type();
00109   }
00110 
00111 private:
00112   static TypeHandle _type_handle;
00113 };
00114 
00115 #include "physxController.I"
00116 
00117 #endif // PHYSXCONTROLLER_H
 All Classes Functions Variables Enumerations