Panda3D
Loading...
Searching...
No Matches
trackerData.I
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 trackerData.I
10 * @author jason
11 * @date 2000-08-04
12 */
13
14/**
15 *
16 */
17INLINE TrackerData::
18TrackerData() :
19 _flags(0)
20{
21}
22
23/**
24 *
25 */
26INLINE TrackerData::
27TrackerData(const TrackerData &copy) {
28 (*this) = copy;
29}
30
31/**
32 * Removes all data from the structure.
33 */
34INLINE void TrackerData::
35clear() {
36 _flags = 0;
37}
38
39/**
40 * Indicates the time at which the position information (pos and orient) are
41 * effective. This is a time elapsed in seconds since some undefined epoch;
42 * it may or may not correspond to the clock time indicated in the global
43 * ClockObject.
44 */
45INLINE void TrackerData::
46set_time(double time) {
47 _time = time;
48 _flags |= F_has_time;
49}
50
51/**
52 * Returns true if the position information time is available. See
53 * set_time().
54 */
55INLINE bool TrackerData::
56has_time() const {
57 return (_flags & F_has_time) != 0;
58}
59
60/**
61 * Returns the time at which the position information (pos and orient) are
62 * effective. It is an error to call this if has_time() does not return true.
63 * See set_time().
64 */
65INLINE double TrackerData::
66get_time() const {
67 nassertr(has_time(), 0.0);
68 return _time;
69}
70
71/**
72 * Indicates the current position of the tracker sensor in space. The
73 * coordinate system of this position is defined by the tracker.
74 */
75INLINE void TrackerData::
76set_pos(const LPoint3 &pos) {
77 _pos = pos;
78 _flags |= F_has_pos;
79}
80
81/**
82 * Returns true if the current position is available. See set_pos().
83 */
84INLINE bool TrackerData::
85has_pos() const {
86 return (_flags & F_has_pos) != 0;
87}
88
89/**
90 * Returns the current position of the tracker. It is legal to call this if
91 * has_pos() returns false; in this case, the position will always be (0, 0,
92 * 0).
93 */
94INLINE const LPoint3 &TrackerData::
95get_pos() const {
96 if (has_pos()) {
97 return _pos;
98 } else {
99 static LPoint3 zero(0.0, 0.0, 0.0);
100 return zero;
101 }
102}
103
104/**
105 * Indicates the current orientation of the tracker sensor in space. The
106 * coordinate system of this orientation is defined by the tracker, but should
107 * be the same coordinate system as that reflected by set_pos().
108 */
109INLINE void TrackerData::
110set_orient(const LOrientation &orient) {
111 _orient = orient;
112 _flags |= F_has_orient;
113}
114
115/**
116 * Returns true if the current orientation is available. See set_orient().
117 */
118INLINE bool TrackerData::
119has_orient() const {
120 return (_flags & F_has_orient) != 0;
121}
122
123/**
124 * Returns the current orientation of the tracker. It is legal to call this
125 * if has_orient() returns false; in this case, the result is always the
126 * identity orientation.
127 */
128INLINE const LOrientation &TrackerData::
129get_orient() const {
130 if (has_orient()) {
131 return _orient;
132 } else {
133 static LOrientation ident = LOrientation::ident_quat();
134 return ident;
135 }
136}
137
138/**
139 * Indicates the amount of elapsed time over which which the information (pos
140 * and orient) were computed. This only makes sense if the information
141 * represents velocity or acceleration, rather than position. This is an
142 * elapsed time in seconds.
143 */
144INLINE void TrackerData::
145set_dt(double dt) {
146 _dt = dt;
147 _flags |= F_has_dt;
148}
149
150/**
151 * Returns true if the computed elapsed time is available. See set_dt().
152 */
153INLINE bool TrackerData::
154has_dt() const {
155 return (_flags & F_has_dt) != 0;
156}
157
158/**
159 * Returns the amount of elapsed time over which the information (pos and
160 * orient) were computed. It is an error to call this if has_dt() does not
161 * return true. See set_dt().
162 */
163INLINE double TrackerData::
164get_dt() const {
165 nassertr(has_dt(), 0.0);
166 return _dt;
167}
Stores the kinds of data that a tracker might output.
Definition trackerData.h:23
bool has_dt() const
Returns true if the computed elapsed time is available.
bool has_time() const
Returns true if the position information time is available.
Definition trackerData.I:56
bool has_pos() const
Returns true if the current position is available.
Definition trackerData.I:85
set_pos
Indicates the current position of the tracker sensor in space.
Definition trackerData.h:49
bool has_orient() const
Returns true if the current orientation is available.
set_orient
Indicates the current orientation of the tracker sensor in space.
Definition trackerData.h:50
get_pos
Returns the current position of the tracker.
Definition trackerData.h:49
get_time
Returns the time at which the position information (pos and orient) are effective.
Definition trackerData.h:48
set_dt
Indicates the amount of elapsed time over which which the information (pos and orient) were computed.
Definition trackerData.h:51
get_orient
Returns the current orientation of the tracker.
Definition trackerData.h:50
set_time
Indicates the time at which the position information (pos and orient) are effective.
Definition trackerData.h:48
get_dt
Returns the amount of elapsed time over which the information (pos and orient) were computed.
Definition trackerData.h:51
void clear()
Removes all data from the structure.
Definition trackerData.I:35