27 VrpnTracker(
const std::string &tracker_name, vrpn_Connection *connection) :
28 _tracker_name(tracker_name)
30 _tracker =
new vrpn_Tracker_Remote(_tracker_name.c_str(), connection);
32 _tracker->register_change_handler((
void*)
this, &vrpn_position_callback);
33 _tracker->register_change_handler((
void*)
this, &vrpn_velocity_callback);
34 _tracker->register_change_handler((
void*)
this, &vrpn_acceleration_callback);
51 if (vrpn_cat.is_debug()) {
52 vrpn_cat.debug() << *
this <<
" marking " << *device <<
"\n";
54 _devices.push_back(device);
63 if (vrpn_cat.is_debug()) {
64 vrpn_cat.debug() << *
this <<
" unmarking " << *device <<
"\n";
67 Devices::iterator di =
68 find(_devices.begin(), _devices.end(), device);
70 if (di != _devices.end()) {
79 output(std::ostream &out)
const {
87 write(std::ostream &out,
int indent_level)
const {
90 << _devices.size() <<
" devices)\n";
97 void VRPN_CALLBACK VrpnTracker::
98 vrpn_position_callback(
void *userdata,
const vrpn_TRACKERCB info) {
100 if (vrpn_cat.is_spam()) {
102 << *
self <<
" position_callback\n";
105 Devices::iterator di;
106 for (di = self->_devices.begin(); di !=
self->_devices.end(); ++di) {
110 device->tracker_changed(LPoint3(info.pos[0], info.pos[1], info.pos[2]),
111 LOrientation(info.quat[3], info.quat[0],
112 info.quat[1], info.quat[2]),
122 void VRPN_CALLBACK VrpnTracker::
123 vrpn_velocity_callback(
void *userdata,
const vrpn_TRACKERVELCB info) {
125 if (vrpn_cat.is_spam()) {
127 << *
self <<
" velocity_callback\n";
130 Devices::iterator di;
131 for (di = self->_devices.begin(); di !=
self->_devices.end(); ++di) {
135 device->tracker_changed(LPoint3(info.vel[0], info.vel[1], info.vel[2]),
136 LOrientation(info.vel_quat[3], info.vel_quat[0],
137 info.vel_quat[1], info.vel_quat[2]),
147 void VRPN_CALLBACK VrpnTracker::
148 vrpn_acceleration_callback(
void *userdata,
const vrpn_TRACKERACCCB info) {
150 if (vrpn_cat.is_spam()) {
152 << *
self <<
" acceleration_callback\n";
155 Devices::iterator di;
156 for (di = self->_devices.begin(); di !=
self->_devices.end(); ++di) {
159 device->
get_data_type() == VrpnTrackerDevice::DT_acceleration) {
160 device->tracker_changed(LPoint3(info.acc[0], info.acc[1], info.acc[2]),
161 LOrientation(info.acc_quat[3], info.acc_quat[0],
162 info.acc_quat[1], info.acc_quat[2]),