Panda3D
|
A spherical collision volume or object. More...
#include "collisionSphere.h"
Public Member Functions | |
CollisionSphere (const LPoint3 ¢er, PN_stdfloat radius) | |
CollisionSphere (PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) | |
CollisionSphere (const CollisionSphere ©) | |
virtual TypeHandle | force_init_type () |
const LPoint3 & | get_center () const |
virtual LPoint3 | get_collision_origin () const |
Returns the point in space deemed to be the "origin" of the solid for collision purposes. | |
PN_stdfloat | get_radius () const |
virtual PStatCollector & | get_test_pcollector () |
Returns a PStatCollector that is used to count the number of intersection tests made against a solid of this type in a given frame. | |
virtual TypeHandle | get_type () const |
virtual PStatCollector & | get_volume_pcollector () |
Returns a PStatCollector that is used to count the number of bounding volume tests made against a solid of this type in a given frame. | |
virtual CollisionSolid * | make_copy () |
virtual void | output (ostream &out) const |
virtual | PT (CollisionEntry) test_intersection(const CollisionEntry &entry) const |
void | set_center (const LPoint3 ¢er) |
void | set_center (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) |
void | set_radius (PN_stdfloat radius) |
virtual void | write_datagram (BamWriter *manager, Datagram &me) |
Function to write the important information in the particular object to a Datagram. | |
virtual void | xform (const LMatrix4 &mat) |
Transforms the solid by the indicated matrix. | |
Static Public Member Functions | |
static void | flush_level () |
Flushes the PStatCollectors used during traversal. | |
static TypeHandle | get_class_type () |
static void | init_type () |
static void | register_with_read_factory () |
Factory method to generate a CollisionSphere object. | |
Protected Member Functions | |
CollisionSphere () | |
Creates an invalid sphere. | |
LVertex | compute_point (PN_stdfloat latitude, PN_stdfloat longitude) const |
Returns a point on the surface of the sphere. | |
virtual void | fill_viz_geom () |
Fills the _viz_geom GeomNode up with Geoms suitable for rendering this solid. | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place. | |
bool | intersects_line (double &t1, double &t2, const LPoint3 &from, const LVector3 &delta, PN_stdfloat inflate_radius) const |
Determine the point(s) of intersection of a parametric line with the sphere. | |
bool | intersects_parabola (double &t, const LParabola ¶bola, double t1, double t2, const LPoint3 &p1, const LPoint3 &p2) const |
Determine a point of intersection of a parametric parabola with the sphere. | |
virtual | PT (CollisionEntry) test_intersection_from_box(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_sphere(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_ray(const CollisionEntry &entry) const |
virtual | PT (BoundingVolume) compute_internal_bounds() const |
virtual | PT (CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const |
virtual | PT (CollisionEntry) test_intersection_from_line(const CollisionEntry &entry) const |
Static Protected Member Functions | |
static TypedWritable * | make_CollisionSphere (const FactoryParams ¶ms) |
Factory method to generate a CollisionSphere object. |
A spherical collision volume or object.
Definition at line 27 of file collisionSphere.h.
CollisionSphere::CollisionSphere | ( | ) | [inline, protected] |
Creates an invalid sphere.
Only used when reading from a bam file.
Definition at line 47 of file collisionSphere.I.
Referenced by make_CollisionSphere().
LVertex CollisionSphere::compute_point | ( | PN_stdfloat | latitude, |
PN_stdfloat | longitude | ||
) | const [protected] |
Returns a point on the surface of the sphere.
latitude and longitude range from 0.0 to 1.0. This is used by fill_viz_geom() to create a visible representation of the sphere.
Definition at line 757 of file collisionSphere.cxx.
Referenced by fill_viz_geom(), and CollisionInvSphere::fill_viz_geom().
void CollisionSphere::fill_viz_geom | ( | ) | [protected, virtual] |
Fills the _viz_geom GeomNode up with Geoms suitable for rendering this solid.
Reimplemented from CollisionSolid.
Reimplemented in CollisionInvSphere.
Definition at line 567 of file collisionSphere.cxx.
References GeomVertexWriter::add_data3(), compute_point(), and GeomVertexFormat::get_v3().
void CollisionSphere::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
Function that reads out of the datagram (or asks manager to read) all of the data that is needed to re-create this object and stores it in the appropiate place.
Reimplemented from CollisionSolid.
Reimplemented in CollisionInvSphere.
Definition at line 816 of file collisionSphere.cxx.
References DatagramIterator::get_stdfloat(), and LVecBase3f::read_datagram().
Referenced by make_CollisionSphere().
void CollisionSphere::flush_level | ( | ) | [inline, static] |
Flushes the PStatCollectors used during traversal.
Definition at line 69 of file collisionSphere.I.
LPoint3 CollisionSphere::get_collision_origin | ( | ) | const [virtual] |
Returns the point in space deemed to be the "origin" of the solid for collision purposes.
The closest intersection point to this origin point is considered to be the most significant.
Implements CollisionSolid.
Definition at line 87 of file collisionSphere.cxx.
PStatCollector & CollisionSphere::get_test_pcollector | ( | ) | [virtual] |
Returns a PStatCollector that is used to count the number of intersection tests made against a solid of this type in a given frame.
Reimplemented from CollisionSolid.
Reimplemented in CollisionInvSphere.
Definition at line 111 of file collisionSphere.cxx.
PStatCollector & CollisionSphere::get_volume_pcollector | ( | ) | [virtual] |
Returns a PStatCollector that is used to count the number of bounding volume tests made against a solid of this type in a given frame.
Reimplemented from CollisionSolid.
Reimplemented in CollisionInvSphere.
Definition at line 99 of file collisionSphere.cxx.
bool CollisionSphere::intersects_line | ( | double & | t1, |
double & | t2, | ||
const LPoint3 & | from, | ||
const LVector3 & | delta, | ||
PN_stdfloat | inflate_radius | ||
) | const [protected] |
Determine the point(s) of intersection of a parametric line with the sphere.
The line is infinite in both directions, and passes through "from" and from+delta. If the line does not intersect the sphere, the function returns false, and t1 and t2 are undefined. If it does intersect the sphere, it returns true, and t1 and t2 are set to the points along the equation from+t*delta that correspond to the two points of intersection.
Definition at line 618 of file collisionSphere.cxx.
Referenced by intersects_parabola().
bool CollisionSphere::intersects_parabola | ( | double & | t, |
const LParabola & | parabola, | ||
double | t1, | ||
double | t2, | ||
const LPoint3 & | p1, | ||
const LPoint3 & | p2 | ||
) | const [protected] |
Determine a point of intersection of a parametric parabola with the sphere.
We only consider the segment of the parabola between t1 and t2, which has already been computed as corresponding to points p1 and p2. If there is an intersection, t is set to the parametric point of intersection, and true is returned; otherwise, false is returned.
Definition at line 695 of file collisionSphere.cxx.
References intersects_line().
TypedWritable * CollisionSphere::make_CollisionSphere | ( | const FactoryParams & | params | ) | [static, protected] |
Factory method to generate a CollisionSphere object.
Definition at line 797 of file collisionSphere.cxx.
References CollisionSphere(), and fillin().
Referenced by register_with_read_factory().
void CollisionSphere::register_with_read_factory | ( | ) | [static] |
Factory method to generate a CollisionSphere object.
Reimplemented in CollisionInvSphere.
Definition at line 774 of file collisionSphere.cxx.
References BamReader::get_factory(), make_CollisionSphere(), and Factory< Type >::register_factory().
Function to write the important information in the particular object to a Datagram.
Reimplemented from CollisionSolid.
Reimplemented in CollisionInvSphere.
Definition at line 785 of file collisionSphere.cxx.
References Datagram::add_stdfloat(), and LVecBase3f::write_datagram().
void CollisionSphere::xform | ( | const LMatrix4 & | mat | ) | [virtual] |
Transforms the solid by the indicated matrix.
Reimplemented from CollisionSolid.
Definition at line 67 of file collisionSphere.cxx.
References CollisionSolid::mark_internal_bounds_stale(), and CollisionSolid::mark_viz_stale().