Panda3D
|
00001 // Filename: collisionHandlerFloor.h 00002 // Created by: drose (16Mar02) 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 COLLISIONHANDLERFLOOR_H 00016 #define COLLISIONHANDLERFLOOR_H 00017 00018 #include "pandabase.h" 00019 00020 #include "collisionHandlerPhysical.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : CollisionHandlerFloor 00024 // Description : A specialized kind of CollisionHandler that sets the 00025 // Z height of the collider to a fixed linear offset 00026 // from the highest detected collision point each frame. 00027 // It's intended to implement walking around on a floor 00028 // of varying height by casting a ray down from the 00029 // avatar's head. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_COLLIDE CollisionHandlerFloor : public CollisionHandlerPhysical { 00032 PUBLISHED: 00033 CollisionHandlerFloor(); 00034 virtual ~CollisionHandlerFloor(); 00035 00036 INLINE void set_offset(PN_stdfloat offset); 00037 INLINE PN_stdfloat get_offset() const; 00038 00039 INLINE void set_reach(PN_stdfloat reach); 00040 INLINE PN_stdfloat get_reach() const; 00041 00042 INLINE void set_max_velocity(PN_stdfloat max_vel); 00043 INLINE PN_stdfloat get_max_velocity() const; 00044 00045 protected: 00046 PN_stdfloat set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries); 00047 virtual bool handle_entries(); 00048 virtual void apply_linear_force(ColliderDef &def, const LVector3 &force); 00049 00050 private: 00051 PN_stdfloat _offset; 00052 PN_stdfloat _reach; 00053 PN_stdfloat _max_velocity; 00054 00055 00056 public: 00057 static TypeHandle get_class_type() { 00058 return _type_handle; 00059 } 00060 static void init_type() { 00061 CollisionHandlerPhysical::init_type(); 00062 register_type(_type_handle, "CollisionHandlerFloor", 00063 CollisionHandlerPhysical::get_class_type()); 00064 } 00065 virtual TypeHandle get_type() const { 00066 return get_class_type(); 00067 } 00068 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00069 00070 private: 00071 static TypeHandle _type_handle; 00072 }; 00073 00074 #include "collisionHandlerFloor.I" 00075 00076 #endif 00077 00078 00079