Panda3D
|
00001 // Filename: vrpnTracker.h 00002 // Created by: drose (25Jan01) 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 #ifndef VRPNTRACKER_H 00016 #define VRPNTRACKER_H 00017 00018 #include "pandabase.h" 00019 00020 #include "vrpn_interface.h" 00021 00022 #include "pvector.h" 00023 00024 class VrpnTrackerDevice; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : VrpnTracker 00028 // Description : This is the actual interface to a particular VRPN 00029 // tracker object, and all of its sensors. A pointer to 00030 // this object is stored in the VrpnClient class for 00031 // each differently-named VRPN tracker we connect to. 00032 // 00033 // The VRPN callbacks go here, which in turn get 00034 // vectored out to any VrpnTrackerDevice objects that 00035 // register with this. When the last VrpnTrackerDevice 00036 // object unregisters, the VrpnTracker will be deleted 00037 // by the VrpnClient. 00038 // 00039 // This class does not need to be exported from the DLL. 00040 //////////////////////////////////////////////////////////////////// 00041 class VrpnTracker { 00042 public: 00043 VrpnTracker(const string &tracker_name, vrpn_Connection *connection); 00044 ~VrpnTracker(); 00045 00046 INLINE const string &get_tracker_name() const; 00047 INLINE bool is_empty() const; 00048 00049 void mark(VrpnTrackerDevice *device); 00050 void unmark(VrpnTrackerDevice *device); 00051 00052 INLINE void poll(); 00053 00054 void output(ostream &out) const; 00055 void write(ostream &out, int indent_level = 0) const; 00056 00057 private: 00058 static void VRPN_CALLBACK 00059 vrpn_position_callback(void *userdata, const vrpn_TRACKERCB info); 00060 static void VRPN_CALLBACK 00061 vrpn_velocity_callback(void *userdata, const vrpn_TRACKERVELCB info); 00062 static void VRPN_CALLBACK 00063 vrpn_acceleration_callback(void *userdata, const vrpn_TRACKERACCCB info); 00064 00065 private: 00066 string _tracker_name; 00067 vrpn_Tracker_Remote *_tracker; 00068 00069 typedef pvector<VrpnTrackerDevice *> Devices; 00070 Devices _devices; 00071 }; 00072 00073 INLINE ostream &operator << (ostream &out, const VrpnTracker &tracker) { 00074 tracker.output(out); 00075 return out; 00076 } 00077 00078 #include "vrpnTracker.I" 00079 00080 #endif 00081