Panda3D
 All Classes Functions Variables Enumerations
collisionSegment.I
00001 // Filename: collisionSegment.I
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: CollisionSegment::Default Constructor
00018 //       Access: Public
00019 //  Description: Creates an invalid segment.  This isn't terribly useful;
00020 //               it's expected that the user will subsequently adjust
00021 //               the segment via set_origin()/set_direction() or
00022 //               set_from_lens().
00023 ////////////////////////////////////////////////////////////////////
00024 INLINE CollisionSegment::
00025 CollisionSegment() :
00026   _a(LPoint3(0.0, 0.0, 0.0)),
00027   _b(LPoint3(0.0, 0.0, 0.0))
00028 {
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: CollisionSegment::Constructor
00033 //       Access: Public
00034 //  Description:
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE CollisionSegment::
00037 CollisionSegment(const LPoint3 &a, const LPoint3 &b) :
00038   _a(a), _b(b)
00039 {
00040   nassertv(_a != _b);
00041 }
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: CollisionSegment::Constructor
00045 //       Access: Public
00046 //  Description:
00047 ////////////////////////////////////////////////////////////////////
00048 INLINE CollisionSegment::
00049 CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az,
00050                  PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz) :
00051   _a(ax, ay, az), _b(bx, by, bz)
00052 {
00053   nassertv(_a != _b);
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: CollisionSegment::Copy Constructor
00058 //       Access: Public
00059 //  Description:
00060 ////////////////////////////////////////////////////////////////////
00061 INLINE CollisionSegment::
00062 CollisionSegment(const CollisionSegment &copy) :
00063   CollisionSolid(copy),
00064   _a(copy._a),
00065   _b(copy._b)
00066 {
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: CollisionSegment::set_point_a
00071 //       Access: Public
00072 //  Description:
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE void CollisionSegment::
00075 set_point_a(const LPoint3 &a) {
00076   _a = a;
00077   mark_internal_bounds_stale();
00078   mark_viz_stale();
00079   // We don't assert here that a != b, on the assumption that you
00080   // might be about to change both at once, and you'll probably start
00081   // by changing a first.
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: CollisionSegment::set_point_a
00086 //       Access: Public
00087 //  Description:
00088 ////////////////////////////////////////////////////////////////////
00089 INLINE void CollisionSegment::
00090 set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00091   set_point_a(LPoint3(x, y, z));
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: CollisionSegment::get_point_a
00096 //       Access: Public
00097 //  Description:
00098 ////////////////////////////////////////////////////////////////////
00099 INLINE const LPoint3 &CollisionSegment::
00100 get_point_a() const {
00101   return _a;
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: CollisionSegment::set_point_b
00106 //       Access: Public
00107 //  Description:
00108 ////////////////////////////////////////////////////////////////////
00109 INLINE void CollisionSegment::
00110 set_point_b(const LPoint3 &b) {
00111   _b = b;
00112   mark_internal_bounds_stale();
00113   mark_viz_stale();
00114   nassertv(_a != _b);
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: CollisionSegment::set_point_b
00119 //       Access: Public
00120 //  Description:
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE void CollisionSegment::
00123 set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00124   set_point_b(LPoint3(x, y, z));
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: CollisionSegment::get_point_b
00129 //       Access: Public
00130 //  Description:
00131 ////////////////////////////////////////////////////////////////////
00132 INLINE const LPoint3 &CollisionSegment::
00133 get_point_b() const {
00134   return _b;
00135 }
00136 
00137 ////////////////////////////////////////////////////////////////////
00138 //     Function: CollisionSegment::set_from_lens
00139 //       Access: Public
00140 //  Description: Accepts a LensNode and a 2-d point in the range
00141 //               [-1,1].  Sets the CollisionSegment so that it begins at
00142 //               the LensNode's near plane and extends to the
00143 //               far plane, making it suitable for picking objects
00144 //               from the screen given a camera and a mouse location.
00145 ////////////////////////////////////////////////////////////////////
00146 INLINE bool CollisionSegment::
00147 set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py) {
00148   return set_from_lens(camera, LPoint2(px, py));
00149 }
 All Classes Functions Variables Enumerations