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