Panda3D
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions

CollisionSphere Class Reference

A spherical collision volume or object. More...

#include "collisionSphere.h"

Inheritance diagram for CollisionSphere:
CollisionSolid CopyOnWriteObject CachedTypedWritableReferenceCount TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase CollisionInvSphere

List of all members.

Public Member Functions

 CollisionSphere (const LPoint3f &center, float radius)
 CollisionSphere (float cx, float cy, float cz, float radius)
 CollisionSphere (const CollisionSphere &copy)
virtual TypeHandle force_init_type ()
const LPoint3fget_center () const
virtual LPoint3f get_collision_origin () const
 Returns the point in space deemed to be the "origin" of the solid for collision purposes.
float get_radius () const
virtual PStatCollectorget_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 PStatCollectorget_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 CollisionSolidmake_copy ()
virtual void output (ostream &out) const
virtual PT (CollisionEntry) test_intersection(const CollisionEntry &entry) const
void set_center (const LPoint3f &center)
void set_center (float x, float y, float z)
void set_radius (float 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 LMatrix4f &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.
Vertexf compute_point (float latitude, float 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 LPoint3f &from, const LVector3f &delta, float inflate_radius) const
 Determine the point(s) of intersection of a parametric line with the sphere.
bool intersects_parabola (double &t, const Parabolaf &parabola, double t1, double t2, const LPoint3f &p1, const LPoint3f &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_segment(const CollisionEntry &entry) const
virtual PT (CollisionEntry) test_intersection_from_ray(const CollisionEntry &entry) const
virtual PT (CollisionEntry) test_intersection_from_ds_solid(const CollisionEntry &entry) const
virtual PT (CollisionEntry) test_intersection_from_sphere(const CollisionEntry &entry) const
virtual PT (CollisionEntry) test_intersection_from_line(const CollisionEntry &entry) const
virtual PT (BoundingVolume) compute_internal_bounds() const

Static Protected Member Functions

static TypedWritablemake_CollisionSphere (const FactoryParams &params)
 Factory method to generate a CollisionSphere object.

Detailed Description

A spherical collision volume or object.

Definition at line 27 of file collisionSphere.h.


Constructor & Destructor Documentation

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().


Member Function Documentation

Vertexf CollisionSphere::compute_point ( float  latitude,
float  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 927 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 737 of file collisionSphere.cxx.

References GeomVertexWriter::add_data3f(), 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 986 of file collisionSphere.cxx.

References DatagramIterator::get_float32(), 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.

LPoint3f 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 88 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 112 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 100 of file collisionSphere.cxx.

bool CollisionSphere::intersects_line ( double &  t1,
double &  t2,
const LPoint3f from,
const LVector3f delta,
float  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 788 of file collisionSphere.cxx.

Referenced by intersects_parabola().

bool CollisionSphere::intersects_parabola ( double &  t,
const Parabolaf &  parabola,
double  t1,
double  t2,
const LPoint3f p1,
const LPoint3f 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 865 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 967 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 944 of file collisionSphere.cxx.

References BamReader::get_factory(), make_CollisionSphere(), and Factory< Type >::register_factory().

void CollisionSphere::write_datagram ( BamWriter manager,
Datagram me 
) [virtual]

Function to write the important information in the particular object to a Datagram.

Reimplemented from CollisionSolid.

Reimplemented in CollisionInvSphere.

Definition at line 955 of file collisionSphere.cxx.

References Datagram::add_float32(), and LVecBase3f::write_datagram().

void CollisionSphere::xform ( const LMatrix4f mat) [virtual]

Transforms the solid by the indicated matrix.

Reimplemented from CollisionSolid.

Definition at line 68 of file collisionSphere.cxx.

References CollisionSolid::mark_internal_bounds_stale(), and CollisionSolid::mark_viz_stale().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations