Panda3D
 All Classes Functions Variables Enumerations
trackerData.I
1 // Filename: trackerData.I
2 // Created by: jason (04Aug00)
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 ////////////////////////////////////////////////////////////////////
16 // Function: TrackerData::Default Constructor
17 // Access: Public
18 // Description:
19 ////////////////////////////////////////////////////////////////////
20 INLINE TrackerData::
21 TrackerData() :
22  _flags(0)
23 {
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: TrackerData::Copy Constructor
28 // Access: Public
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE TrackerData::
32 TrackerData(const TrackerData &copy) {
33  (*this) = copy;
34 }
35 
36 ////////////////////////////////////////////////////////////////////
37 // Function: TrackerData::clear
38 // Access: Public
39 // Description: Removes all data from the structure.
40 ////////////////////////////////////////////////////////////////////
41 INLINE void TrackerData::
42 clear() {
43  _flags = 0;
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: TrackerData::set_time
48 // Access: Public
49 // Description: Indicates the time at which the position information
50 // (pos and orient) are effective. This is a time
51 // elapsed in seconds since some undefined epoch; it may
52 // or may not correspond to the clock time indicated in
53 // the global ClockObject.
54 ////////////////////////////////////////////////////////////////////
55 INLINE void TrackerData::
56 set_time(double time) {
57  _time = time;
58  _flags |= F_has_time;
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: TrackerData::has_time
63 // Access: Public
64 // Description: Returns true if the position information time is
65 // available. See set_time().
66 ////////////////////////////////////////////////////////////////////
67 INLINE bool TrackerData::
68 has_time() const {
69  return (_flags & F_has_time) != 0;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: TrackerData::get_time
74 // Access: Public
75 // Description: Returns the time at which the position information
76 // (pos and orient) are effective. It is an error to
77 // call this if has_time() does not return true. See
78 // set_time().
79 ////////////////////////////////////////////////////////////////////
80 INLINE double TrackerData::
81 get_time() const {
82  nassertr(has_time(), 0.0);
83  return _time;
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: TrackerData::set_pos
88 // Access: Public
89 // Description: Indicates the current position of the tracker sensor
90 // in space. The coordinate system of this position is
91 // defined by the tracker.
92 ////////////////////////////////////////////////////////////////////
93 INLINE void TrackerData::
94 set_pos(const LPoint3 &pos) {
95  _pos = pos;
96  _flags |= F_has_pos;
97 }
98 
99 ////////////////////////////////////////////////////////////////////
100 // Function: TrackerData::has_pos
101 // Access: Public
102 // Description: Returns true if the current position is available.
103 // See set_pos().
104 ////////////////////////////////////////////////////////////////////
105 INLINE bool TrackerData::
106 has_pos() const {
107  return (_flags & F_has_pos) != 0;
108 }
109 
110 ////////////////////////////////////////////////////////////////////
111 // Function: TrackerData::get_pos
112 // Access: Public
113 // Description: Returns the current position of the tracker. It is
114 // legal to call this if has_pos() returns false; in
115 // this case, the position will always be (0, 0, 0).
116 ////////////////////////////////////////////////////////////////////
117 INLINE const LPoint3 &TrackerData::
118 get_pos() const {
119  if (has_pos()) {
120  return _pos;
121  } else {
122  static LPoint3 zero(0.0, 0.0, 0.0);
123  return zero;
124  }
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: TrackerData::set_orient
129 // Access: Public
130 // Description: Indicates the current orientation of the tracker
131 // sensor in space. The coordinate system of this
132 // orientation is defined by the tracker, but should be
133 // the same coordinate system as that reflected by
134 // set_pos().
135 ////////////////////////////////////////////////////////////////////
136 INLINE void TrackerData::
137 set_orient(const LOrientation &orient) {
138  _orient = orient;
139  _flags |= F_has_orient;
140 }
141 
142 ////////////////////////////////////////////////////////////////////
143 // Function: TrackerData::has_orient
144 // Access: Public
145 // Description: Returns true if the current orientation is available.
146 // See set_orient().
147 ////////////////////////////////////////////////////////////////////
148 INLINE bool TrackerData::
149 has_orient() const {
150  return (_flags & F_has_orient) != 0;
151 }
152 
153 ////////////////////////////////////////////////////////////////////
154 // Function: TrackerData::get_orient
155 // Access: Public
156 // Description: Returns the current orientation of the tracker. It
157 // is legal to call this if has_orient() returns false;
158 // in this case, the result is always the identity
159 // orientation.
160 ////////////////////////////////////////////////////////////////////
161 INLINE const LOrientation &TrackerData::
162 get_orient() const {
163  if (has_orient()) {
164  return _orient;
165  } else {
166  static LOrientation ident = LOrientation::ident_quat();
167  return ident;
168  }
169 }
170 
171 ////////////////////////////////////////////////////////////////////
172 // Function: TrackerData::set_dt
173 // Access: Public
174 // Description: Indicates the amount of elapsed time over which which
175 // the information (pos and orient) were computed. This
176 // only makes sense if the information represents
177 // velocity or acceleration, rather than position. This
178 // is an elapsed time in seconds.
179 ////////////////////////////////////////////////////////////////////
180 INLINE void TrackerData::
181 set_dt(double dt) {
182  _dt = dt;
183  _flags |= F_has_dt;
184 }
185 
186 ////////////////////////////////////////////////////////////////////
187 // Function: TrackerData::has_dt
188 // Access: Public
189 // Description: Returns true if the computed elapsed time is
190 // available. See set_dt().
191 ////////////////////////////////////////////////////////////////////
192 INLINE bool TrackerData::
193 has_dt() const {
194  return (_flags & F_has_dt) != 0;
195 }
196 
197 ////////////////////////////////////////////////////////////////////
198 // Function: TrackerData::get_dt
199 // Access: Public
200 // Description: Returns the amount of elapsed time over which the
201 // information (pos and orient) were computed. It
202 // is an error to call this if has_dt() does not return
203 // true. See set_dt().
204 ////////////////////////////////////////////////////////////////////
205 INLINE double TrackerData::
206 get_dt() const {
207  nassertr(has_dt(), 0.0);
208  return _dt;
209 }
static const LQuaternionf & ident_quat()
Returns an identity quaternion.
Definition: lquaternion.h:851
void clear()
Removes all data from the structure.
Definition: trackerData.I:42
void set_time(double time)
Indicates the time at which the position information (pos and orient) are effective.
Definition: trackerData.I:56
This is a unit quaternion representing an orientation.
Definition: lorientation.h:92
void set_pos(const LPoint3 &pos)
Indicates the current position of the tracker sensor in space.
Definition: trackerData.I:94
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
void set_orient(const LOrientation &orient)
Indicates the current orientation of the tracker sensor in space.
Definition: trackerData.I:137
const LPoint3 & get_pos() const
Returns the current position of the tracker.
Definition: trackerData.I:118
bool has_dt() const
Returns true if the computed elapsed time is available.
Definition: trackerData.I:193
double get_time() const
Returns the time at which the position information (pos and orient) are effective.
Definition: trackerData.I:81
double get_dt() const
Returns the amount of elapsed time over which the information (pos and orient) were computed...
Definition: trackerData.I:206
Stores the kinds of data that a tracker might output.
Definition: trackerData.h:25
const LOrientation & get_orient() const
Returns the current orientation of the tracker.
Definition: trackerData.I:162
bool has_pos() const
Returns true if the current position is available.
Definition: trackerData.I:106
bool has_orient() const
Returns true if the current orientation is available.
Definition: trackerData.I:149
void set_dt(double dt)
Indicates the amount of elapsed time over which which the information (pos and orient) were computed...
Definition: trackerData.I:181
bool has_time() const
Returns true if the position information time is available.
Definition: trackerData.I:68