Panda3D
collisionPlane.h
1 // Filename: collisionPlane.h
2 // Created by: drose (25Apr00)
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 COLLISIONPLANE_H
16 #define COLLISIONPLANE_H
17 
18 #include "pandabase.h"
19 
20 #include "collisionSolid.h"
21 
22 #include "luse.h"
23 #include "plane.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : CollisionPlane
27 // Description :
28 ////////////////////////////////////////////////////////////////////
29 class EXPCL_PANDA_COLLIDE CollisionPlane : public CollisionSolid {
30 protected:
31  INLINE CollisionPlane();
32 
33 PUBLISHED:
34  INLINE CollisionPlane(const LPlane &plane);
35  INLINE CollisionPlane(const CollisionPlane &copy);
36 
37  virtual LPoint3 get_collision_origin() const;
38 
39 public:
40  virtual CollisionSolid *make_copy();
41 
42  virtual void xform(const LMatrix4 &mat);
43 
44  virtual PStatCollector &get_volume_pcollector();
46 
47  virtual void output(ostream &out) const;
48 
49  INLINE static void flush_level();
50 
51 PUBLISHED:
52  INLINE LVector3 get_normal() const;
53  INLINE PN_stdfloat dist_to_plane(const LPoint3 &point) const;
54 
55  INLINE void set_plane(const LPlane &plane);
56  INLINE const LPlane &get_plane() const;
57 
58  INLINE void flip();
59 
60 protected:
61  virtual PT(BoundingVolume) compute_internal_bounds() const;
62 
63 protected:
64  virtual PT(CollisionEntry)
65  test_intersection_from_sphere(const CollisionEntry &entry) const;
66  virtual PT(CollisionEntry)
67  test_intersection_from_line(const CollisionEntry &entry) const;
68  virtual PT(CollisionEntry)
69  test_intersection_from_ray(const CollisionEntry &entry) const;
70  virtual PT(CollisionEntry)
71  test_intersection_from_segment(const CollisionEntry &entry) const;
72  virtual PT(CollisionEntry)
73  test_intersection_from_parabola(const CollisionEntry &entry) const;
74 
75  virtual void fill_viz_geom();
76 
77 private:
78  LPlane _plane;
79 
80  static PStatCollector _volume_pcollector;
81  static PStatCollector _test_pcollector;
82 
83 public:
84  static void register_with_read_factory();
85  virtual void write_datagram(BamWriter* manager, Datagram &me);
86 
87  static TypedWritable *make_CollisionPlane(const FactoryParams &params);
88 
89 protected:
90  void fillin(DatagramIterator& scan, BamReader* manager);
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  CollisionSolid::init_type();
98  register_type(_type_handle, "CollisionPlane",
99  CollisionSolid::get_class_type());
100  }
101  virtual TypeHandle get_type() const {
102  return get_class_type();
103  }
104  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
105 
106 private:
107  static TypeHandle _type_handle;
108 };
109 
110 #include "collisionPlane.I"
111 
112 #endif
113 
114 
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
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
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
Defines a single collision event.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43