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

panda/src/collide/collisionRay.h

Go to the documentation of this file.
00001 // Filename: collisionRay.h
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 #ifndef COLLISIONRAY_H
00020 #define COLLISIONRAY_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "collisionSolid.h"
00025 
00026 class LensNode;
00027 
00028 ///////////////////////////////////////////////////////////////////
00029 //       Class : CollisionRay
00030 // Description : An infinite ray, with a specific origin and
00031 //               direction.  It begins at its origin and continues in
00032 //               one direction to infinity, and it has no radius.
00033 //               Useful for picking from a window, or for gravity
00034 //               effects.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_PANDA CollisionRay : public CollisionSolid {
00037 PUBLISHED:
00038   INLINE CollisionRay();
00039   INLINE CollisionRay(const LPoint3f &origin, const LVector3f &direction);
00040   INLINE CollisionRay(float ox, float oy, float oz,
00041                       float dx, float dy, float dz);
00042 
00043 public:
00044   INLINE CollisionRay(const CollisionRay &copy);
00045   virtual CollisionSolid *make_copy();
00046 
00047   virtual PT(CollisionEntry)
00048   test_intersection(const CollisionEntry &entry) const;
00049 
00050   virtual void xform(const LMatrix4f &mat);
00051   virtual LPoint3f get_collision_origin() const;
00052 
00053   virtual void output(ostream &out) const;
00054 
00055 PUBLISHED:
00056   INLINE void set_origin(const LPoint3f &origin);
00057   INLINE void set_origin(float x, float y, float z);
00058   INLINE const LPoint3f &get_origin() const;
00059 
00060   INLINE void set_direction(const LVector3f &direction);
00061   INLINE void set_direction(float x, float y, float z);
00062   INLINE const LVector3f &get_direction() const;
00063 
00064   bool set_from_lens(LensNode *camera, const LPoint2f &point);
00065   INLINE bool set_from_lens(LensNode *camera, float px, float py);
00066 
00067 protected:
00068   virtual BoundingVolume *recompute_bound();
00069 
00070 protected:
00071   virtual void fill_viz_geom();
00072 
00073 private:
00074   LPoint3f _origin;
00075   LVector3f _direction;
00076 
00077 public:
00078   static void register_with_read_factory();
00079   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00080 
00081 protected:
00082   static TypedWritable *make_from_bam(const FactoryParams &params);
00083   void fillin(DatagramIterator &scan, BamReader *manager);
00084 
00085 public:
00086   static TypeHandle get_class_type() {
00087     return _type_handle;
00088   }
00089   static void init_type() {
00090     CollisionSolid::init_type();
00091     register_type(_type_handle, "CollisionRay",
00092                   CollisionSolid::get_class_type());
00093   }
00094   virtual TypeHandle get_type() const {
00095     return get_class_type();
00096   }
00097   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00098 
00099 private:
00100   static TypeHandle _type_handle;
00101 };
00102 
00103 #include "collisionRay.I"
00104 
00105 #endif
00106 
00107 

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