00001 // Filename: trackerData.I 00002 // Created by: jason (04Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: TrackerData::Default Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 INLINE TrackerData:: 00025 TrackerData() : 00026 _flags(0) 00027 { 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: TrackerData::Copy Constructor 00032 // Access: Public 00033 // Description: 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE TrackerData:: 00036 TrackerData(const TrackerData ©) { 00037 (*this) = copy; 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: TrackerData::clear 00042 // Access: Public 00043 // Description: Removes all data from the structure. 00044 //////////////////////////////////////////////////////////////////// 00045 INLINE void TrackerData:: 00046 clear() { 00047 _flags = 0; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: TrackerData::set_time 00052 // Access: Public 00053 // Description: Indicates the time at which the position information 00054 // (pos and orient) are effective. This is a time 00055 // elapsed in seconds since some undefined epoch; it may 00056 // or may not correspond to the clock time indicated in 00057 // the global ClockObject. 00058 //////////////////////////////////////////////////////////////////// 00059 INLINE void TrackerData:: 00060 set_time(double time) { 00061 _time = time; 00062 _flags |= F_has_time; 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: TrackerData::has_time 00067 // Access: Public 00068 // Description: Returns true if the position information time is 00069 // available. See set_time(). 00070 //////////////////////////////////////////////////////////////////// 00071 INLINE bool TrackerData:: 00072 has_time() const { 00073 return (_flags & F_has_time) != 0; 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: TrackerData::get_time 00078 // Access: Public 00079 // Description: Returns the time at which the position information 00080 // (pos and orient) are effective. It is an error to 00081 // call this if has_time() does not return true. See 00082 // set_time(). 00083 //////////////////////////////////////////////////////////////////// 00084 INLINE double TrackerData:: 00085 get_time() const { 00086 nassertr(has_time(), 0.0); 00087 return _time; 00088 } 00089 00090 //////////////////////////////////////////////////////////////////// 00091 // Function: TrackerData::set_pos 00092 // Access: Public 00093 // Description: Indicates the current position of the tracker sensor 00094 // in space. The coordinate system of this position is 00095 // defined by the tracker. 00096 //////////////////////////////////////////////////////////////////// 00097 INLINE void TrackerData:: 00098 set_pos(const LPoint3f &pos) { 00099 _pos = pos; 00100 _flags |= F_has_pos; 00101 } 00102 00103 //////////////////////////////////////////////////////////////////// 00104 // Function: TrackerData::has_pos 00105 // Access: Public 00106 // Description: Returns true if the current position is available. 00107 // See set_pos(). 00108 //////////////////////////////////////////////////////////////////// 00109 INLINE bool TrackerData:: 00110 has_pos() const { 00111 return (_flags & F_has_pos) != 0; 00112 } 00113 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: TrackerData::get_pos 00116 // Access: Public 00117 // Description: Returns the current position of the tracker. It is 00118 // legal to call this if has_pos() returns false; in 00119 // this case, the position will always be (0, 0, 0). 00120 //////////////////////////////////////////////////////////////////// 00121 INLINE const LPoint3f &TrackerData:: 00122 get_pos() const { 00123 if (has_pos()) { 00124 return _pos; 00125 } else { 00126 static LPoint3f zero(0.0, 0.0, 0.0); 00127 return zero; 00128 } 00129 } 00130 00131 //////////////////////////////////////////////////////////////////// 00132 // Function: TrackerData::set_orient 00133 // Access: Public 00134 // Description: Indicates the current orientation of the tracker 00135 // sensor in space. The coordinate system of this 00136 // orientation is defined by the tracker, but should be 00137 // the same coordinate system as that reflected by 00138 // set_pos(). 00139 //////////////////////////////////////////////////////////////////// 00140 INLINE void TrackerData:: 00141 set_orient(const LOrientationf &orient) { 00142 _orient = orient; 00143 _flags |= F_has_orient; 00144 } 00145 00146 //////////////////////////////////////////////////////////////////// 00147 // Function: TrackerData::has_orient 00148 // Access: Public 00149 // Description: Returns true if the current orientation is available. 00150 // See set_orient(). 00151 //////////////////////////////////////////////////////////////////// 00152 INLINE bool TrackerData:: 00153 has_orient() const { 00154 return (_flags & F_has_orient) != 0; 00155 } 00156 00157 //////////////////////////////////////////////////////////////////// 00158 // Function: TrackerData::get_orient 00159 // Access: Public 00160 // Description: Returns the current orientation of the tracker. It 00161 // is legal to call this if has_orient() returns false; 00162 // in this case, the result is always the identity 00163 // orientation. 00164 //////////////////////////////////////////////////////////////////// 00165 INLINE const LOrientationf &TrackerData:: 00166 get_orient() const { 00167 if (has_orient()) { 00168 return _orient; 00169 } else { 00170 static LOrientationf ident = LOrientationf::ident_quat(); 00171 return ident; 00172 } 00173 } 00174 00175 //////////////////////////////////////////////////////////////////// 00176 // Function: TrackerData::set_dt 00177 // Access: Public 00178 // Description: Indicates the amount of elapsed time over which which 00179 // the information (pos and orient) were computed. This 00180 // only makes sense if the information represents 00181 // velocity or acceleration, rather than position. This 00182 // is an elapsed time in seconds. 00183 //////////////////////////////////////////////////////////////////// 00184 INLINE void TrackerData:: 00185 set_dt(double dt) { 00186 _dt = dt; 00187 _flags |= F_has_dt; 00188 } 00189 00190 //////////////////////////////////////////////////////////////////// 00191 // Function: TrackerData::has_dt 00192 // Access: Public 00193 // Description: Returns true if the computed elapsed time is 00194 // available. See set_dt(). 00195 //////////////////////////////////////////////////////////////////// 00196 INLINE bool TrackerData:: 00197 has_dt() const { 00198 return (_flags & F_has_dt) != 0; 00199 } 00200 00201 //////////////////////////////////////////////////////////////////// 00202 // Function: TrackerData::get_dt 00203 // Access: Public 00204 // Description: Returns the amount of elapsed time over which the 00205 // information (pos and orient) were computed. It 00206 // is an error to call this if has_dt() does not return 00207 // true. See set_dt(). 00208 //////////////////////////////////////////////////////////////////// 00209 INLINE double TrackerData:: 00210 get_dt() const { 00211 nassertr(has_dt(), 0.0); 00212 return _dt; 00213 }