Panda3D
collisionSegment.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file collisionSegment.h
10 * @author drose
11 * @date 2001-01-30
12 */
13
14#ifndef COLLISIONSEGMENT_H
15#define COLLISIONSEGMENT_H
16
17#include "pandabase.h"
18
19#include "collisionSolid.h"
20
21class LensNode;
22
23/**
24 * A finite line segment, with two specific endpoints but no thickness. It's
25 * similar to a CollisionRay, except it does not continue to infinity.
26 *
27 * It does have an ordering, from point A to point B. If more than a single
28 * point of the segment is intersecting a solid, the reported intersection
29 * point is generally the closest on the segment to point A.
30 */
31class EXPCL_PANDA_COLLIDE CollisionSegment : public CollisionSolid {
32PUBLISHED:
33 INLINE CollisionSegment();
34 INLINE explicit CollisionSegment(const LPoint3 &a, const LPoint3 &db);
35 INLINE explicit CollisionSegment(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az,
36 PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz);
37
38 virtual LPoint3 get_collision_origin() const;
39
40public:
41 INLINE CollisionSegment(const CollisionSegment &copy);
42 virtual CollisionSolid *make_copy();
43
44 virtual PT(CollisionEntry)
45 test_intersection(const CollisionEntry &entry) const;
46
47 virtual void xform(const LMatrix4 &mat);
48
49 virtual void output(std::ostream &out) const;
50
51PUBLISHED:
52 INLINE void set_point_a(const LPoint3 &a);
53 INLINE void set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
54 INLINE const LPoint3 &get_point_a() const;
55
56 INLINE void set_point_b(const LPoint3 &b);
57 INLINE void set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
58 INLINE const LPoint3 &get_point_b() const;
59
60 bool set_from_lens(LensNode *camera, const LPoint2 &point);
61 INLINE bool set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py);
62
63PUBLISHED:
64 MAKE_PROPERTY(point_a, get_point_a, set_point_a);
65 MAKE_PROPERTY(point_b, get_point_b, set_point_b);
66
67protected:
68 virtual PT(BoundingVolume) compute_internal_bounds() const;
69
70protected:
71 virtual void fill_viz_geom();
72
73private:
74 LPoint3 _a, _b;
75
76public:
77 static void register_with_read_factory();
78 virtual void write_datagram(BamWriter *manager, Datagram &dg);
79
80protected:
81 static TypedWritable *make_from_bam(const FactoryParams &params);
82 void fillin(DatagramIterator &scan, BamReader *manager);
83
84public:
85 static TypeHandle get_class_type() {
86 return _type_handle;
87 }
88 static void init_type() {
89 CollisionSolid::init_type();
90 register_type(_type_handle, "CollisionSegment",
91 CollisionSolid::get_class_type());
92 }
93 virtual TypeHandle get_type() const {
94 return get_class_type();
95 }
96 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
97
98private:
99 static TypeHandle _type_handle;
100};
101
102#include "collisionSegment.I"
103
104#endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
Defines a single collision event.
A finite line segment, with two specific endpoints but no thickness.
The abstract base class for all things that can collide with other things in the world,...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
A node that contains a Lens.
Definition: lensNode.h:29
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22