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

panda/src/collide/collisionSphere.h

Go to the documentation of this file.
00001 // Filename: collisionSphere.h
00002 // Created by:  drose (24Apr00)
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 COLLISIONSPHERE_H
00020 #define COLLISIONSPHERE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "collisionSolid.h"
00025 
00026 ///////////////////////////////////////////////////////////////////
00027 //       Class : CollisionSphere
00028 // Description : A spherical collision volume or object.
00029 ////////////////////////////////////////////////////////////////////
00030 class EXPCL_PANDA CollisionSphere : public CollisionSolid {
00031 PUBLISHED:
00032   INLINE CollisionSphere(const LPoint3f &center, float radius);
00033   INLINE CollisionSphere(float cx, float cy, float cz, float radius);
00034 
00035 public:
00036   INLINE CollisionSphere(const CollisionSphere &copy);
00037   virtual CollisionSolid *make_copy();
00038 
00039   virtual PT(CollisionEntry)
00040   test_intersection(const CollisionEntry &entry) const;
00041 
00042   virtual void xform(const LMatrix4f &mat);
00043   virtual LPoint3f get_collision_origin() const;
00044 
00045   virtual void output(ostream &out) const;
00046 
00047 PUBLISHED:
00048   INLINE void set_center(const LPoint3f &center);
00049   INLINE void set_center(float x, float y, float z);
00050   INLINE const LPoint3f &get_center() const;
00051 
00052   INLINE void set_radius(float radius);
00053   INLINE float get_radius() const;
00054 
00055 protected:
00056   INLINE CollisionSphere(void);
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   virtual PT(CollisionEntry)
00065   test_intersection_from_segment(const CollisionEntry &entry) const;
00066 
00067   virtual void fill_viz_geom();
00068 
00069   bool intersects_line(double &t1, double &t2,
00070                        const LPoint3f &from, const LVector3f &delta) const;
00071 
00072 private:
00073   LPoint3f _center;
00074   float _radius;
00075 
00076 public:
00077   static void register_with_read_factory();
00078   virtual void write_datagram(BamWriter *manager, Datagram &me);
00079 
00080 protected:
00081   static TypedWritable *make_CollisionSphere(const FactoryParams &params);
00082   void fillin(DatagramIterator &scan, BamReader *manager);
00083 
00084 public:
00085   static TypeHandle get_class_type() {
00086     return _type_handle;
00087   }
00088   static void init_type() {
00089     CollisionSolid::init_type();
00090     register_type(_type_handle, "CollisionSphere",
00091                   CollisionSolid::get_class_type());
00092   }
00093   virtual TypeHandle get_type() const {
00094     return get_class_type();
00095   }
00096   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00097 
00098 private:
00099   static TypeHandle _type_handle;
00100 };
00101 
00102 #include "collisionSphere.I"
00103 
00104 #endif
00105 
00106 

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