00001 // Filename: collisionPlane.h 00002 // Created by: drose (25Apr00) 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 COLLISIONPLANE_H 00020 #define COLLISIONPLANE_H 00021 00022 #include "pandabase.h" 00023 00024 #include "collisionSolid.h" 00025 00026 #include "luse.h" 00027 #include "plane.h" 00028 00029 /////////////////////////////////////////////////////////////////// 00030 // Class : CollisionPlane 00031 // Description : 00032 //////////////////////////////////////////////////////////////////// 00033 class EXPCL_PANDA CollisionPlane : public CollisionSolid { 00034 protected: 00035 INLINE CollisionPlane(); 00036 00037 PUBLISHED: 00038 INLINE CollisionPlane(const Planef &plane); 00039 INLINE CollisionPlane(const CollisionPlane ©); 00040 00041 public: 00042 virtual CollisionSolid *make_copy(); 00043 00044 virtual void xform(const LMatrix4f &mat); 00045 virtual LPoint3f get_collision_origin() const; 00046 00047 virtual void output(ostream &out) const; 00048 00049 PUBLISHED: 00050 INLINE LVector3f get_normal() const; 00051 INLINE float dist_to_plane(const LPoint3f &point) const; 00052 00053 INLINE void set_plane(const Planef &plane); 00054 INLINE const Planef &get_plane() const; 00055 00056 protected: 00057 virtual BoundingVolume *recompute_bound(); 00058 00059 protected: 00060 virtual PT(CollisionEntry) 00061 test_intersection_from_sphere(const CollisionEntry &entry) const; 00062 virtual PT(CollisionEntry) 00063 test_intersection_from_ray(const CollisionEntry &entry) const; 00064 00065 virtual void fill_viz_geom(); 00066 00067 private: 00068 Planef _plane; 00069 00070 public: 00071 static void register_with_read_factory(void); 00072 virtual void write_datagram(BamWriter* manager, Datagram &me); 00073 00074 static TypedWritable *make_CollisionPlane(const FactoryParams ¶ms); 00075 00076 protected: 00077 void fillin(DatagramIterator& scan, BamReader* manager); 00078 00079 public: 00080 static TypeHandle get_class_type() { 00081 return _type_handle; 00082 } 00083 static void init_type() { 00084 CollisionSolid::init_type(); 00085 register_type(_type_handle, "CollisionPlane", 00086 CollisionSolid::get_class_type()); 00087 } 00088 virtual TypeHandle get_type() const { 00089 return get_class_type(); 00090 } 00091 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00092 00093 private: 00094 static TypeHandle _type_handle; 00095 }; 00096 00097 #include "collisionPlane.I" 00098 00099 #endif 00100 00101