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