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