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

CollisionRay Class Reference

An infinite ray, with a specific origin and direction. More...

#include "collisionRay.h"

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

List of all members.

Public Member Functions

 CollisionRay ()
 Creates an invalid ray.
 CollisionRay (const LPoint3f &origin, const LVector3f &direction)
 CollisionRay (const CollisionRay &copy)
 CollisionRay (float ox, float oy, float oz, float dx, float dy, float dz)
virtual TypeHandle force_init_type ()
virtual LPoint3f get_collision_origin () const
 Returns the point in space deemed to be the "origin" of the solid for collision purposes.
const LVector3fget_direction () const
const LPoint3fget_origin () const
virtual TypeHandle get_type () const
virtual CollisionSolidmake_copy ()
virtual void output (ostream &out) const
virtual PT (CollisionEntry) test_intersection(const CollisionEntry &entry) const
void set_direction (const LVector3f &direction)
void set_direction (float x, float y, float z)
bool set_from_lens (LensNode *camera, float px, float py)
 Accepts a LensNode and a 2-d point in the range [-1,1].
bool set_from_lens (LensNode *camera, const LPoint2f &point)
 Accepts a LensNode and a 2-d point in the range [-1,1].
void set_origin (float x, float y, float z)
void set_origin (const LPoint3f &origin)
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 LMatrix4f &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 CollisionRay.

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 CollisionRay.
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 CollisionRay is encountered in the Bam file.

Detailed Description

An infinite ray, with a specific origin and direction.

It begins at its origin and continues in one direction to infinity, and it has no radius. Useful for picking from a window, or for gravity effects.

Definition at line 32 of file collisionRay.h.


Constructor & Destructor Documentation

CollisionRay::CollisionRay ( ) [inline]

Creates an invalid ray.

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

Definition at line 25 of file collisionRay.I.

Referenced by make_from_bam().


Member Function Documentation

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

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

Reimplemented from CollisionSolid.

Reimplemented in CollisionLine.

Definition at line 141 of file collisionRay.cxx.

References GeomVertexWriter::add_data3f(), GeomVertexWriter::add_data4f(), and GeomVertexFormat::get_v3cp().

void CollisionRay::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 CollisionRay.

Reimplemented from CollisionSolid.

Reimplemented in CollisionLine.

Definition at line 227 of file collisionRay.cxx.

References LVecBase3f::read_datagram().

Referenced by make_from_bam().

LPoint3f CollisionRay::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 77 of file collisionRay.cxx.

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

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

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

Reimplemented in CollisionLine.

Definition at line 208 of file collisionRay.cxx.

References CollisionRay(), and fillin().

Referenced by register_with_read_factory().

void CollisionRay::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type CollisionRay.

Reimplemented in CollisionLine.

Definition at line 182 of file collisionRay.cxx.

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

bool CollisionRay::set_from_lens ( LensNode camera,
float  px,
float  py 
) [inline]

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

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

Definition at line 144 of file collisionRay.I.

References set_from_lens().

bool CollisionRay::set_from_lens ( LensNode camera,
const LPoint2f point 
)

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

Sets the CollisionRay so that it begins at the LensNode's near plane and extends to infinity, 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 104 of file collisionRay.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 CollisionRay::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.

Reimplemented in CollisionLine.

Definition at line 193 of file collisionRay.cxx.

References LVecBase3f::write_datagram().

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

Transforms the solid by the indicated matrix.

Reimplemented from CollisionSolid.

Definition at line 61 of file collisionRay.cxx.


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