Panda3D
collisionRay.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 collisionRay.h
10  * @author drose
11  * @date 2000-06-22
12  */
13 
14 #ifndef COLLISIONRAY_H
15 #define COLLISIONRAY_H
16 
17 #include "pandabase.h"
18 
19 #include "collisionSolid.h"
20 #include "lensNode.h"
21 
22 /**
23  * An infinite ray, with a specific origin and direction. It begins at its
24  * origin and continues in one direction to infinity, and it has no radius.
25  * Useful for picking from a window, or for gravity effects.
26  */
27 class EXPCL_PANDA_COLLIDE CollisionRay : public CollisionSolid {
28 PUBLISHED:
29  INLINE CollisionRay();
30  INLINE explicit CollisionRay(const LPoint3 &origin, const LVector3 &direction);
31  INLINE explicit CollisionRay(PN_stdfloat ox, PN_stdfloat oy, PN_stdfloat oz,
32  PN_stdfloat dx, PN_stdfloat dy, PN_stdfloat dz);
33 
34  virtual LPoint3 get_collision_origin() const;
35 
36 public:
37  INLINE CollisionRay(const CollisionRay &copy);
38  virtual CollisionSolid *make_copy();
39 
40  virtual PT(CollisionEntry)
41  test_intersection(const CollisionEntry &entry) const;
42 
43  virtual void xform(const LMatrix4 &mat);
44 
45  virtual void output(std::ostream &out) const;
46 
47 PUBLISHED:
48  INLINE void set_origin(const LPoint3 &origin);
49  INLINE void set_origin(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
50  INLINE const LPoint3 &get_origin() const;
51  MAKE_PROPERTY(origin, get_origin, set_origin);
52 
53  INLINE void set_direction(const LVector3 &direction);
54  INLINE void set_direction(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
55  INLINE const LVector3 &get_direction() const;
56  MAKE_PROPERTY(direction, get_direction, set_direction);
57 
58  bool set_from_lens(LensNode *camera, const LPoint2 &point);
59  INLINE bool set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py);
60 
61 protected:
62  virtual PT(BoundingVolume) compute_internal_bounds() const;
63 
64 protected:
65  virtual void fill_viz_geom();
66 
67 private:
68  LPoint3 _origin;
69  LVector3 _direction;
70 
71 public:
72  static void register_with_read_factory();
73  virtual void write_datagram(BamWriter *manager, Datagram &dg);
74 
75 protected:
76  static TypedWritable *make_from_bam(const FactoryParams &params);
77  void fillin(DatagramIterator &scan, BamReader *manager);
78 
79 public:
80  static TypeHandle get_class_type() {
81  return _type_handle;
82  }
83  static void init_type() {
84  CollisionSolid::init_type();
85  register_type(_type_handle, "CollisionRay",
86  CollisionSolid::get_class_type());
87  }
88  virtual TypeHandle get_type() const {
89  return get_class_type();
90  }
91  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
92 
93 private:
94  static TypeHandle _type_handle;
95 };
96 
97 #include "collisionRay.I"
98 
99 #endif
An infinite ray, with a specific origin and direction.
Definition: collisionRay.h:27
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
The abstract base class for all things that can collide with other things in the world,...
A node that contains a Lens.
Definition: lensNode.h:29
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:36
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.