Panda3D
 All Classes Functions Variables Enumerations
collisionHandlerFloor.h
1 // Filename: collisionHandlerFloor.h
2 // Created by: drose (16Mar02)
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 COLLISIONHANDLERFLOOR_H
16 #define COLLISIONHANDLERFLOOR_H
17 
18 #include "pandabase.h"
19 
20 #include "collisionHandlerPhysical.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : CollisionHandlerFloor
24 // Description : A specialized kind of CollisionHandler that sets the
25 // Z height of the collider to a fixed linear offset
26 // from the highest detected collision point each frame.
27 // It's intended to implement walking around on a floor
28 // of varying height by casting a ray down from the
29 // avatar's head.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_COLLIDE CollisionHandlerFloor : public CollisionHandlerPhysical {
32 PUBLISHED:
34  virtual ~CollisionHandlerFloor();
35 
36  INLINE void set_offset(PN_stdfloat offset);
37  INLINE PN_stdfloat get_offset() const;
38 
39  INLINE void set_reach(PN_stdfloat reach);
40  INLINE PN_stdfloat get_reach() const;
41 
42  INLINE void set_max_velocity(PN_stdfloat max_vel);
43  INLINE PN_stdfloat get_max_velocity() const;
44 
45 protected:
46  PN_stdfloat set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries);
47  virtual bool handle_entries();
48  virtual void apply_linear_force(ColliderDef &def, const LVector3 &force);
49 
50 private:
51  PN_stdfloat _offset;
52  PN_stdfloat _reach;
53  PN_stdfloat _max_velocity;
54 
55 
56 public:
57  static TypeHandle get_class_type() {
58  return _type_handle;
59  }
60  static void init_type() {
61  CollisionHandlerPhysical::init_type();
62  register_type(_type_handle, "CollisionHandlerFloor",
63  CollisionHandlerPhysical::get_class_type());
64  }
65  virtual TypeHandle get_type() const {
66  return get_class_type();
67  }
68  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
69 
70 private:
71  static TypeHandle _type_handle;
72 };
73 
74 #include "collisionHandlerFloor.I"
75 
76 #endif
77 
78 
79 
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
The abstract base class for a number of CollisionHandlers that have some physical effect on their mov...
A specialized kind of CollisionHandler that sets the Z height of the collider to a fixed linear offse...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165