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()) {
88 output(std::ostream &out)
const {
96 write(std::ostream &out,
int indent_level)
const {
99 << _devices.size() <<
" devices)\n";
106 void VRPN_CALLBACK VrpnTracker::
107 vrpn_position_callback(
void *userdata,
const vrpn_TRACKERCB info) {
109 if (vrpn_cat.is_spam()) {
111 << *
self <<
" position_callback\n";
114 Devices::iterator di;
115 for (di = self->_devices.begin(); di !=
self->_devices.end(); ++di) {
119 device->tracker_changed(LPoint3(info.pos[0], info.pos[1], info.pos[2]),
120 LOrientation(info.quat[3], info.quat[0],
121 info.quat[1], info.quat[2]),
131 void VRPN_CALLBACK VrpnTracker::
132 vrpn_velocity_callback(
void *userdata,
const vrpn_TRACKERVELCB info) {
134 if (vrpn_cat.is_spam()) {
136 << *
self <<
" velocity_callback\n";
139 Devices::iterator di;
140 for (di = self->_devices.begin(); di !=
self->_devices.end(); ++di) {
144 device->tracker_changed(LPoint3(info.vel[0], info.vel[1], info.vel[2]),
145 LOrientation(info.vel_quat[3], info.vel_quat[0],
146 info.vel_quat[1], info.vel_quat[2]),
156 void VRPN_CALLBACK VrpnTracker::
157 vrpn_acceleration_callback(
void *userdata,
const vrpn_TRACKERACCCB info) {
159 if (vrpn_cat.is_spam()) {
161 << *
self <<
" acceleration_callback\n";
164 Devices::iterator di;
165 for (di = self->_devices.begin(); di !=
self->_devices.end(); ++di) {
168 device->
get_data_type() == VrpnTrackerDevice::DT_acceleration) {
169 device->tracker_changed(LPoint3(info.acc[0], info.acc[1], info.acc[2]),
170 LOrientation(info.acc_quat[3], info.acc_quat[0],
171 info.acc_quat[1], info.acc_quat[2]),