Panda3D
 All Classes Functions Variables Enumerations
collisionInvSphere.h
1 // Filename: collisionInvSphere.h
2 // Created by: drose (05Jan05)
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 COLLISIONINVSPHERE_H
16 #define COLLISIONINVSPHERE_H
17 
18 #include "pandabase.h"
19 
20 #include "collisionSphere.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : CollisionInvSphere
24 // Description : An inverted sphere: this is a sphere whose collision
25 // surface is the inside surface of the sphere.
26 // Everything outside the sphere is solid matter;
27 // everything inside is empty space. Useful for
28 // constraining objects to remain within a spherical
29 // perimeter.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_COLLIDE CollisionInvSphere : public CollisionSphere {
32 PUBLISHED:
33  INLINE CollisionInvSphere(const LPoint3 &center, PN_stdfloat radius);
34  INLINE CollisionInvSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius);
35 
36 protected:
37  INLINE CollisionInvSphere();
38 
39 public:
40  INLINE CollisionInvSphere(const CollisionInvSphere &copy);
41  virtual CollisionSolid *make_copy();
42 
43  virtual PT(CollisionEntry)
44  test_intersection(const CollisionEntry &entry) const;
45 
48 
49  virtual void output(ostream &out) const;
50 
51 protected:
52  virtual PT(BoundingVolume) compute_internal_bounds() const;
53 
54  virtual PT(CollisionEntry)
55  test_intersection_from_sphere(const CollisionEntry &entry) const;
56  virtual PT(CollisionEntry)
57  test_intersection_from_line(const CollisionEntry &entry) const;
58  virtual PT(CollisionEntry)
59  test_intersection_from_ray(const CollisionEntry &entry) const;
60  virtual PT(CollisionEntry)
61  test_intersection_from_segment(const CollisionEntry &entry) const;
62 
63  virtual void fill_viz_geom();
64 
65 private:
66  static PStatCollector _volume_pcollector;
67  static PStatCollector _test_pcollector;
68 
69 public:
70  static void register_with_read_factory();
71  virtual void write_datagram(BamWriter *manager, Datagram &me);
72 
73 protected:
74  static TypedWritable *make_CollisionInvSphere(const FactoryParams &params);
75  void fillin(DatagramIterator &scan, BamReader *manager);
76 
77 public:
78  static TypeHandle get_class_type() {
79  return _type_handle;
80  }
81  static void init_type() {
82  CollisionSphere::init_type();
83  register_type(_type_handle, "CollisionInvSphere",
84  CollisionSphere::get_class_type());
85  }
86  virtual TypeHandle get_type() const {
87  return get_class_type();
88  }
89  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
90 
91 private:
92  static TypeHandle _type_handle;
93 };
94 
95 #include "collisionInvSphere.I"
96 
97 #endif
98 
99 
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
static void register_with_read_factory()
Factory method to generate a CollisionSphere object.
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).
virtual PStatCollector & get_volume_pcollector()
Returns a PStatCollector that is used to count the number of bounding volume tests made against a sol...
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
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
A spherical collision volume or object.
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...
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
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
An inverted sphere: this is a sphere whose collision surface is the inside surface of the sphere...