15 #include "collisionRay.h"
16 #include "collisionHandler.h"
17 #include "collisionEntry.h"
18 #include "config_collide.h"
21 #include "boundingLine.h"
25 #include "datagramIterator.h"
26 #include "bamReader.h"
27 #include "bamWriter.h"
29 #include "geomLinestrips.h"
30 #include "geomVertexWriter.h"
52 return entry.get_into()->test_intersection_from_ray(entry);
62 _origin = _origin * mat;
63 _direction = _direction * mat;
87 output(ostream &out)
const {
88 out <<
"ray, o (" << get_origin() <<
"), d (" << get_direction() <<
")";
109 if (!lens->
extrude(point, near_point, far_point)) {
114 _origin = near_point;
115 _direction = far_point - near_point;
118 mark_internal_bounds_stale();
130 compute_internal_bounds()
const {
142 if (collide_cat.is_debug()) {
144 <<
"Recomputing viz for " << *
this <<
"\n";
147 static const int num_points = 100;
148 static const double scale = 100.0;
151 ("collision", GeomVertexFormat::get_v3cp(),
156 for (
int i = 0; i < num_points; i++) {
157 double t = ((double)i / (
double)num_points);
158 vertex.add_data3(get_origin() + t * scale * get_direction());
161 t *
LColor(0.0f, 0.0f, 0.0f, -1.0f));
165 line->add_next_vertices(num_points);
166 line->close_primitive();
169 geom->add_primitive(line);
171 _viz_geom->add_geom(geom, get_other_viz_state());
172 _bounds_viz_geom->add_geom(geom, get_other_bounds_viz_state());
213 parse_params(params, scan, manager);
214 node->fillin(scan, manager);
228 CollisionSolid::fillin(scan, manager);
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
An infinite ray, with a specific origin and direction.
A base class for any number of different kinds of lenses, linear and otherwise.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void read_datagram(DatagramIterator &source)
Reads the vector from the Datagram using get_stdfloat().
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
A node that contains a Lens.
Base class for objects that can be written to and read from Bam files.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
static const LPoint3f & origin(CoordinateSystem cs=CS_default)
Returns the origin of the indicated coordinate system.
static LVector3f forward(CoordinateSystem cs=CS_default)
Returns the forward vector for the given coordinate system.
bool extrude(const LPoint2 &point2d, LPoint3 &near_point, LPoint3 &far_point) const
Given a 2-d point in the range (-1,1) in both dimensions, where (0,0) is the center of the lens and (...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This is a 4-by-4 transform matrix.
Defines a single collision event.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual void xform(const LMatrix4 &mat)
Transforms the solid by the indicated matrix.
virtual LPoint3 get_collision_origin() const
Returns the point in space deemed to be the "origin" of the solid for collision purposes.
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
This is the base class for all three-component vectors and points.
static void register_with_read_factory()
Tells the BamReader how to create objects of type CollisionRay.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
Defines a series of line strips.
virtual void xform(const LMatrix4 &mat)
Transforms the solid by the indicated matrix.
A class to retrieve the individual data elements previously stored in a Datagram. ...
bool set_from_lens(LensNode *camera, const LPoint2 &point)
Accepts a LensNode and a 2-d point in the range [-1,1].
This is a two-component point in space.
TypeHandle is the identifier used to differentiate C++ class types.
CollisionRay()
Creates an invalid ray.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void write_datagram(Datagram &destination) const
Writes the vector to the Datagram using add_stdfloat().
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
Lens * get_lens(int index=0) const
Returns a pointer to the particular Lens associated with this LensNode, or NULL if there is not yet a...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.