Panda3D
 All Classes Functions Variables Enumerations
collisionInvSphere.h
00001 // Filename: collisionInvSphere.h
00002 // Created by:  drose (05Jan05)
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 COLLISIONINVSPHERE_H
00016 #define COLLISIONINVSPHERE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "collisionSphere.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : CollisionInvSphere
00024 // Description : An inverted sphere: this is a sphere whose collision
00025 //               surface is the inside surface of the sphere.
00026 //               Everything outside the sphere is solid matter;
00027 //               everything inside is empty space.  Useful for
00028 //               constraining objects to remain within a spherical
00029 //               perimeter.
00030 ////////////////////////////////////////////////////////////////////
00031 class EXPCL_PANDA_COLLIDE CollisionInvSphere : public CollisionSphere {
00032 PUBLISHED:
00033   INLINE CollisionInvSphere(const LPoint3 &center, PN_stdfloat radius);
00034   INLINE CollisionInvSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius);
00035 
00036 protected:
00037   INLINE CollisionInvSphere();
00038 
00039 public:
00040   INLINE CollisionInvSphere(const CollisionInvSphere &copy);
00041   virtual CollisionSolid *make_copy();
00042 
00043   virtual PT(CollisionEntry)
00044   test_intersection(const CollisionEntry &entry) const;
00045 
00046   virtual PStatCollector &get_volume_pcollector();
00047   virtual PStatCollector &get_test_pcollector();
00048 
00049   virtual void output(ostream &out) const;
00050 
00051 protected:
00052   virtual PT(BoundingVolume) compute_internal_bounds() const;
00053 
00054   virtual PT(CollisionEntry)
00055   test_intersection_from_sphere(const CollisionEntry &entry) const;
00056   virtual PT(CollisionEntry)
00057   test_intersection_from_line(const CollisionEntry &entry) const;
00058   virtual PT(CollisionEntry)
00059   test_intersection_from_ray(const CollisionEntry &entry) const;
00060   virtual PT(CollisionEntry)
00061   test_intersection_from_segment(const CollisionEntry &entry) const;
00062 
00063   virtual void fill_viz_geom();
00064 
00065 private:
00066   static PStatCollector _volume_pcollector;
00067   static PStatCollector _test_pcollector;
00068 
00069 public:
00070   static void register_with_read_factory();
00071   virtual void write_datagram(BamWriter *manager, Datagram &me);
00072 
00073 protected:
00074   static TypedWritable *make_CollisionInvSphere(const FactoryParams &params);
00075   void fillin(DatagramIterator &scan, BamReader *manager);
00076 
00077 public:
00078   static TypeHandle get_class_type() {
00079     return _type_handle;
00080   }
00081   static void init_type() {
00082     CollisionSphere::init_type();
00083     register_type(_type_handle, "CollisionInvSphere",
00084                   CollisionSphere::get_class_type());
00085   }
00086   virtual TypeHandle get_type() const {
00087     return get_class_type();
00088   }
00089   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00090 
00091 private:
00092   static TypeHandle _type_handle;
00093 };
00094 
00095 #include "collisionInvSphere.I"
00096 
00097 #endif
00098 
00099 
 All Classes Functions Variables Enumerations