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

CollisionSegment Class Reference

A finite line segment, with two specific endpoints but no thickness. More...

#include "collisionSegment.h"

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

List of all members.

Public Member Functions

 CollisionSegment ()
 Creates an invalid segment.
 CollisionSegment (const LPoint3 &a, const LPoint3 &db)
 CollisionSegment (const CollisionSegment &copy)
 CollisionSegment (PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz)
virtual TypeHandle force_init_type ()
virtual LPoint3 get_collision_origin () const
 Returns the point in space deemed to be the "origin" of the solid for collision purposes.
const LPoint3get_point_a () const
const LPoint3get_point_b () const
virtual TypeHandle get_type () const
virtual CollisionSolidmake_copy ()
virtual void output (ostream &out) const
virtual PT (CollisionEntry) test_intersection(const CollisionEntry &entry) const
bool set_from_lens (LensNode *camera, const LPoint2 &point)
 Accepts a LensNode and a 2-d point in the range [-1,1].
bool set_from_lens (LensNode *camera, PN_stdfloat px, PN_stdfloat py)
 Accepts a LensNode and a 2-d point in the range [-1,1].
void set_point_a (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
void set_point_a (const LPoint3 &a)
void set_point_b (PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
void set_point_b (const LPoint3 &b)
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual void xform (const LMatrix4 &mat)
 Transforms the solid by the indicated matrix.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type CollisionSegment.

Protected Member Functions

virtual void fill_viz_geom ()
 Fills the _viz_geom GeomNode up with Geoms suitable for rendering this solid.
void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CollisionSegment.
virtual PT (BoundingVolume) compute_internal_bounds() const

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type CollisionSegment is encountered in the Bam file.

Detailed Description

A finite line segment, with two specific endpoints but no thickness.

It's similar to a CollisionRay, except it does not continue to infinity.

It does have an ordering, from point A to point B. If more than a single point of the segment is intersecting a solid, the reported intersection point is generally the closest on the segment to point A.

Definition at line 35 of file collisionSegment.h.


Constructor & Destructor Documentation

CollisionSegment::CollisionSegment ( ) [inline]

Creates an invalid segment.

This isn't terribly useful; it's expected that the user will subsequently adjust the segment via set_origin()/set_direction() or set_from_lens().

Definition at line 25 of file collisionSegment.I.

Referenced by make_from_bam().


Member Function Documentation

void CollisionSegment::fill_viz_geom ( ) [protected, virtual]

Fills the _viz_geom GeomNode up with Geoms suitable for rendering this solid.

Reimplemented from CollisionSolid.

Definition at line 162 of file collisionSegment.cxx.

References GeomVertexWriter::add_data3(), and GeomVertexFormat::get_v3cp().

void CollisionSegment::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new CollisionSegment.

Reimplemented from CollisionSolid.

Definition at line 239 of file collisionSegment.cxx.

References LVecBase3f::read_datagram().

Referenced by make_from_bam().

LPoint3 CollisionSegment::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 79 of file collisionSegment.cxx.

TypedWritable * CollisionSegment::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type CollisionSegment is encountered in the Bam file.

It should create the CollisionSegment and extract its information from the file.

Definition at line 220 of file collisionSegment.cxx.

References CollisionSegment(), and fillin().

Referenced by register_with_read_factory().

void CollisionSegment::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type CollisionSegment.

Definition at line 194 of file collisionSegment.cxx.

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

bool CollisionSegment::set_from_lens ( LensNode camera,
PN_stdfloat  px,
PN_stdfloat  py 
) [inline]

Accepts a LensNode and a 2-d point in the range [-1,1].

Sets the CollisionSegment so that it begins at the LensNode's near plane and extends to the far plane, making it suitable for picking objects from the screen given a camera and a mouse location.

Definition at line 147 of file collisionSegment.I.

References set_from_lens().

bool CollisionSegment::set_from_lens ( LensNode camera,
const LPoint2 point 
)

Accepts a LensNode and a 2-d point in the range [-1,1].

Sets the CollisionSegment so that it begins at the LensNode's near plane and extends to the far plane, making it suitable for picking objects from the screen given a camera and a mouse location.

Returns true if the point was acceptable, false otherwise.

Definition at line 106 of file collisionSegment.cxx.

References Lens::extrude(), LVector3f::forward(), LensNode::get_lens(), CollisionSolid::mark_internal_bounds_stale(), CollisionSolid::mark_viz_stale(), and LPoint3f::origin().

Referenced by set_from_lens().

void CollisionSegment::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from CollisionSolid.

Definition at line 205 of file collisionSegment.cxx.

References LVecBase3f::write_datagram().

void CollisionSegment::xform ( const LMatrix4 mat) [virtual]

Transforms the solid by the indicated matrix.

Reimplemented from CollisionSolid.

Definition at line 63 of file collisionSegment.cxx.


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