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

panda/src/collide/collisionRay.I

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

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