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