Panda3D

collisionRay.I

00001 // Filename: collisionRay.I
00002 // Created by:  drose (22Jun00)
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: CollisionRay::Default Constructor
00018 //       Access: Public
00019 //  Description: Creates an invalid ray.  This isn't terribly useful;
00020 //               it's expected that the user will subsequently adjust
00021 //               the ray via set_origin()/set_direction() or
00022 //               set_from_lens().
00023 ////////////////////////////////////////////////////////////////////
00024 INLINE CollisionRay::
00025 CollisionRay() :
00026   _origin(LPoint3(0.0, 0.0, 0.0)),
00027   _direction(LVector3(0.0, 0.0, 0.0))
00028 {
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: CollisionRay::Constructor
00033 //       Access: Public
00034 //  Description:
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE CollisionRay::
00037 CollisionRay(const LPoint3 &origin, const LVector3 &direction) :
00038   _origin(origin), _direction(direction)
00039 {
00040   nassertv(_direction != LPoint3::zero());
00041 }
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: CollisionRay::Constructor
00045 //       Access: Public
00046 //  Description:
00047 ////////////////////////////////////////////////////////////////////
00048 INLINE CollisionRay::
00049 CollisionRay(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz,
00050              PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz) :
00051   _origin(ox, oy, oz), _direction(dx, dy, dz)
00052 {
00053   nassertv(_direction != LPoint3::zero());
00054 }
00055 
00056 ////////////////////////////////////////////////////////////////////
00057 //     Function: CollisionRay::Copy Constructor
00058 //       Access: Public
00059 //  Description:
00060 ////////////////////////////////////////////////////////////////////
00061 INLINE CollisionRay::
00062 CollisionRay(const CollisionRay &copy) :
00063   CollisionSolid(copy),
00064   _origin(copy._origin),
00065   _direction(copy._direction)
00066 {
00067 }
00068 
00069 ////////////////////////////////////////////////////////////////////
00070 //     Function: CollisionRay::set_origin
00071 //       Access: Public
00072 //  Description:
00073 ////////////////////////////////////////////////////////////////////
00074 INLINE void CollisionRay::
00075 set_origin(const LPoint3 &origin) {
00076   _origin = origin;
00077   mark_internal_bounds_stale();
00078   mark_viz_stale();
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: CollisionRay::set_origin
00083 //       Access: Public
00084 //  Description:
00085 ////////////////////////////////////////////////////////////////////
00086 INLINE void CollisionRay::
00087 set_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00088   set_origin(LPoint3(x, y, z));
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: CollisionRay::get_origin
00093 //       Access: Public
00094 //  Description:
00095 ////////////////////////////////////////////////////////////////////
00096 INLINE const LPoint3 &CollisionRay::
00097 get_origin() const {
00098   return _origin;
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: CollisionRay::set_direction
00103 //       Access: Public
00104 //  Description:
00105 ////////////////////////////////////////////////////////////////////
00106 INLINE void CollisionRay::
00107 set_direction(const LVector3 &direction) {
00108   _direction = direction;
00109   mark_internal_bounds_stale();
00110   mark_viz_stale();
00111   nassertv(_direction != LPoint3::zero());
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: CollisionRay::set_direction
00116 //       Access: Public
00117 //  Description:
00118 ////////////////////////////////////////////////////////////////////
00119 INLINE void CollisionRay::
00120 set_direction(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
00121   set_direction(LVector3(x, y, z));
00122 }
00123 
00124 ////////////////////////////////////////////////////////////////////
00125 //     Function: CollisionRay::get_direction
00126 //       Access: Public
00127 //  Description:
00128 ////////////////////////////////////////////////////////////////////
00129 INLINE const LVector3 &CollisionRay::
00130 get_direction() const {
00131   return _direction;
00132 }
00133 
00134 ////////////////////////////////////////////////////////////////////
00135 //     Function: CollisionRay::set_from_lens
00136 //       Access: Public
00137 //  Description: Accepts a LensNode and a 2-d point in the range
00138 //               [-1,1].  Sets the CollisionRay so that it begins at
00139 //               the LensNode's near plane and extends to
00140 //               infinity, making it suitable for picking objects from
00141 //               the screen given a camera and a mouse location.
00142 ////////////////////////////////////////////////////////////////////
00143 INLINE bool CollisionRay::
00144 set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py) {
00145   return set_from_lens(camera, LPoint2(px, py));
00146 }
 All Classes Functions Variables Enumerations