Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/collide/collisionSolid.h

Go to the documentation of this file.
00001 // Filename: collisionSolid.h
00002 // Created by:  drose (24Apr00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef COLLISIONSOLID_H
00020 #define COLLISIONSOLID_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "typedWritableReferenceCount.h"
00025 #include "boundedObject.h"
00026 #include "luse.h"
00027 #include "pointerTo.h"
00028 #include "renderState.h"
00029 #include "geomNode.h"
00030 
00031 class CollisionHandler;
00032 class CollisionEntry;
00033 class CollisionSphere;
00034 class GeomNode;
00035 class CollisionNode;
00036 
00037 ///////////////////////////////////////////////////////////////////
00038 //       Class : CollisionSolid
00039 // Description : The abstract base class for all things that can
00040 //               collide with other things in the world, and all the
00041 //               things they can collide with (except geometry).
00042 //
00043 //               This class and its derivatives really work very
00044 //               similarly to the way BoundingVolume and all of its
00045 //               derivatives work.  There's a different subclass for
00046 //               each basic shape of solid, and double-dispatch
00047 //               function calls handle the subset of the N*N
00048 //               intersection tests that we care about.
00049 ////////////////////////////////////////////////////////////////////
00050 class EXPCL_PANDA CollisionSolid :
00051   public TypedWritableReferenceCount, public BoundedObject {
00052 public:
00053   CollisionSolid();
00054   CollisionSolid(const CollisionSolid &copy);
00055   virtual ~CollisionSolid();
00056 
00057   virtual CollisionSolid *make_copy()=0;
00058   virtual LPoint3f get_collision_origin() const=0;
00059 
00060 PUBLISHED:
00061   INLINE void set_tangible(bool tangible);
00062   INLINE bool is_tangible() const;
00063 
00064 public:
00065   virtual PT(CollisionEntry)
00066   test_intersection(const CollisionEntry &entry) const;
00067 
00068   virtual void xform(const LMatrix4f &mat)=0;
00069 
00070   GeomNode *get_viz() const;
00071 
00072 PUBLISHED:
00073   virtual void output(ostream &out) const;
00074   virtual void write(ostream &out, int indent_level = 0) const;
00075 
00076 protected:
00077   virtual PT(CollisionEntry)
00078   test_intersection_from_sphere(const CollisionEntry &entry) const;
00079   virtual PT(CollisionEntry)
00080   test_intersection_from_ray(const CollisionEntry &entry) const;
00081   virtual PT(CollisionEntry)
00082   test_intersection_from_segment(const CollisionEntry &entry) const;
00083 
00084   static void report_undefined_intersection_test(TypeHandle from_type,
00085                                                  TypeHandle into_type);
00086   static void report_undefined_from_intersection(TypeHandle from_type);
00087 
00088   INLINE void mark_viz_stale();
00089   virtual void fill_viz_geom();
00090 
00091   CPT(RenderState) get_solid_viz_state();
00092   CPT(RenderState) get_wireframe_viz_state();
00093   CPT(RenderState) get_other_viz_state();
00094 
00095   PT(GeomNode) _viz_geom;
00096   bool _viz_geom_stale;
00097   bool _tangible;
00098 
00099 public:
00100   virtual void write_datagram(BamWriter* manager, Datagram &me);
00101 
00102 protected:
00103   void fillin(DatagramIterator& scan, BamReader* manager);
00104 
00105 public:
00106   static TypeHandle get_class_type() {
00107     return _type_handle;
00108   }
00109   static void init_type() {
00110     TypedWritableReferenceCount::init_type();
00111     BoundedObject::init_type();
00112     register_type(_type_handle, "CollisionSolid",
00113                   TypedWritableReferenceCount::get_class_type(),
00114                   BoundedObject::get_class_type());
00115   }
00116   virtual TypeHandle get_type() const {
00117     return get_class_type();
00118   }
00119   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00120 
00121 private:
00122   static TypeHandle _type_handle;
00123 
00124   friend class CollisionSphere;
00125   friend class CollisionRay;
00126   friend class CollisionSegment;
00127 };
00128 
00129 INLINE ostream &operator << (ostream &out, const CollisionSolid &cs) {
00130   cs.output(out);
00131   return out;
00132 }
00133 
00134 #include "collisionSolid.I"
00135 
00136 #endif
00137 

Generated on Fri May 2 00:35:45 2003 for Panda by doxygen1.3