CollisionSegment

class CollisionSegment

Bases: CollisionSolid

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.

Inheritance diagram

Inheritance diagram of CollisionSegment

CollisionSegment(void)
explicit CollisionSegment(LPoint3 const &a, LPoint3 const &db)
explicit CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz)

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

static TypeHandle get_class_type(void)
LPoint3 const &get_point_a(void) const
LPoint3 const &get_point_b(void) const
bool set_from_lens(LensNode *camera, LPoint2 const &point)
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]. 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.

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.

void set_point_a(LPoint3 const &a)
void set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
void set_point_b(LPoint3 const &b)
void set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)