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

panda/src/collide/collisionSegment.h

Go to the documentation of this file.
00001 // Filename: collisionSegment.h
00002 // Created by:  drose (30Jan01)
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 COLLISIONSEGMENT_H
00020 #define COLLISIONSEGMENT_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "collisionSolid.h"
00025 
00026 class LensNode;
00027 
00028 ///////////////////////////////////////////////////////////////////
00029 //       Class : CollisionSegment
00030 // Description : A finite line segment, with two specific endpoints
00031 //               but no thickness.  It's similar to a CollisionRay,
00032 //               except it does not continue to infinity.
00033 //
00034 //               It does have an ordering, from point A to point B.
00035 //               If more than a single point of the segment is
00036 //               intersecting a solid, the reported intersection point
00037 //               is generally the closest on the segment to point A.
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDA CollisionSegment : public CollisionSolid {
00040 PUBLISHED:
00041   INLINE CollisionSegment();
00042   INLINE CollisionSegment(const LPoint3f &a, const LPoint3f &db);
00043   INLINE CollisionSegment(float ax, float ay, float az,
00044                           float bx, float by, float bz);
00045 
00046 public:
00047   INLINE CollisionSegment(const CollisionSegment &copy);
00048   virtual CollisionSolid *make_copy();
00049 
00050   virtual PT(CollisionEntry)
00051   test_intersection(const CollisionEntry &entry) const;
00052 
00053   virtual void xform(const LMatrix4f &mat);
00054   virtual LPoint3f get_collision_origin() const;
00055 
00056   virtual void output(ostream &out) const;
00057 
00058 PUBLISHED:
00059   INLINE void set_point_a(const LPoint3f &a);
00060   INLINE void set_point_a(float x, float y, float z);
00061   INLINE const LPoint3f &get_point_a() const;
00062 
00063   INLINE void set_point_b(const LPoint3f &b);
00064   INLINE void set_point_b(float x, float y, float z);
00065   INLINE const LPoint3f &get_point_b() const;
00066 
00067   bool set_from_lens(LensNode *camera, const LPoint2f &point);
00068   INLINE bool set_from_lens(LensNode *camera, float px, float py);
00069 
00070 protected:
00071   virtual BoundingVolume *recompute_bound();
00072 
00073 protected:
00074   virtual void fill_viz_geom();
00075 
00076 private:
00077   LPoint3f _a, _b;
00078 
00079 public:
00080   static void register_with_read_factory();
00081   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00082 
00083 protected:
00084   static TypedWritable *make_from_bam(const FactoryParams &params);
00085   void fillin(DatagramIterator &scan, BamReader *manager);
00086 
00087 public:
00088   static TypeHandle get_class_type() {
00089     return _type_handle;
00090   }
00091   static void init_type() {
00092     CollisionSolid::init_type();
00093     register_type(_type_handle, "CollisionSegment",
00094                   CollisionSolid::get_class_type());
00095   }
00096   virtual TypeHandle get_type() const {
00097     return get_class_type();
00098   }
00099   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00100 
00101 private:
00102   static TypeHandle _type_handle;
00103 };
00104 
00105 #include "collisionSegment.I"
00106 
00107 #endif
00108 
00109 

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