Panda3D
collisionRay.h
1 // Filename: collisionRay.h
2 // Created by: drose (22Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef COLLISIONRAY_H
16 #define COLLISIONRAY_H
17 
18 #include "pandabase.h"
19 
20 #include "collisionSolid.h"
21 #include "lensNode.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : CollisionRay
25 // Description : An infinite ray, with a specific origin and
26 // direction. It begins at its origin and continues in
27 // one direction to infinity, and it has no radius.
28 // Useful for picking from a window, or for gravity
29 // effects.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_COLLIDE CollisionRay : public CollisionSolid {
32 PUBLISHED:
33  INLINE CollisionRay();
34  INLINE CollisionRay(const LPoint3 &origin, const LVector3 &direction);
35  INLINE CollisionRay(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz,
36  PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz);
37 
38  virtual LPoint3 get_collision_origin() const;
39 
40 public:
41  INLINE CollisionRay(const CollisionRay &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(ostream &out) const;
50 
51 PUBLISHED:
52  INLINE void set_origin(const LPoint3 &origin);
53  INLINE void set_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
54  INLINE const LPoint3 &get_origin() const;
55 
56  INLINE void set_direction(const LVector3 &direction);
57  INLINE void set_direction(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
58  INLINE const LVector3 &get_direction() 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 
63 protected:
64  virtual PT(BoundingVolume) compute_internal_bounds() const;
65 
66 protected:
67  virtual void fill_viz_geom();
68 
69 private:
70  LPoint3 _origin;
71  LVector3 _direction;
72 
73 public:
74  static void register_with_read_factory();
75  virtual void write_datagram(BamWriter *manager, Datagram &dg);
76 
77 protected:
78  static TypedWritable *make_from_bam(const FactoryParams &params);
79  void fillin(DatagramIterator &scan, BamReader *manager);
80 
81 public:
82  static TypeHandle get_class_type() {
83  return _type_handle;
84  }
85  static void init_type() {
86  CollisionSolid::init_type();
87  register_type(_type_handle, "CollisionRay",
88  CollisionSolid::get_class_type());
89  }
90  virtual TypeHandle get_type() const {
91  return get_class_type();
92  }
93  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
94 
95 private:
96  static TypeHandle _type_handle;
97 };
98 
99 #include "collisionRay.I"
100 
101 #endif
102 
103 
An infinite ray, with a specific origin and direction.
Definition: collisionRay.h:31
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
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.
Definition: lensNode.h:32
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
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.
Definition: lmatrix.h:451
Defines a single collision event.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
A class to retrieve the individual data elements previously stored in a Datagram. ...
This is a two-component point in space.
Definition: lpoint2.h:92
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43