MVRCore/source/InputDeviceVRPNTracker.cpp
/**
The tracker reports the transformation that would transform stuff
in tracker space to device space (that is, to the space relative to
the origin of the tracking device).  First we change the units on
the translation part of this since we usually work in feet and most
tracking systems report mesurements in some metric system.  Then we
have a transformation in feet relative to the device.  We multiply
by a transformation that transforms stuff in device space to IS3D
room space.  You can think of this as what rotation, then
translation would move the origin of RoomSpace to the origin of
tracking device.  This is the deviceToRoom coordinate frame.
*/
The tracker reports the transformation that would transform stuff
in tracker space to device space (that is, to the space relative to
the origin of the tracking device).  First we change the units on
the translation part of this since we usually work in feet and most
tracking systems report mesurements in some metric system.  Then we
have a transformation in feet relative to the device.  We multiply
by a transformation that transforms stuff in device space to IS3D
room space.  You can think of this as what rotation, then
translation would move the origin of RoomSpace to the origin of
tracking device.  This is the deviceToRoom coordinate frame.
The tracker reports the transformation that would transform stuff in tracker space to device space ( that is to the space relative to the origin of the tracking device ) . First we change the units on the translation part of this since we usually work in feet and most tracking systems report mesurements in some metric system . Then we have a transformation in feet relative to the device . We multiply by a transformation that transforms stuff in device space to IS3D room space . You can think of this as what rotation then translation would move the origin of RoomSpace to the origin of tracking device . This is the deviceToRoom coordinate frame .
void InputDeviceVRPNTracker::processEvent(const glm::dmat4 &vrpnEvent, int sensorNum, const boost::posix_time::ptime &msg_time)
{
	if(_ignoreZeroes && glm::column(vrpnEvent, 3) == glm::dvec4(0.0, 0.0, 0.0, 1.0)){
		return;
	}
	_newReportFlag = true;
	glm::dmat4 trackerToDevice = vrpnEvent;
	if (_convertLHtoRH) {
		trackerToDevice[3][2] = -trackerToDevice[3][2];
		trackerToDevice[2][0] = -trackerToDevice[2][0];
		trackerToDevice[2][1] = -trackerToDevice[2][1];
		trackerToDevice[0][2] = -trackerToDevice[0][2];
		trackerToDevice[1][2] = -trackerToDevice[1][2];
	}
	trackerToDevice[3][0] *= _trackerUnitsToRoomUnitsScale;
	trackerToDevice[3][1] *= _trackerUnitsToRoomUnitsScale;
	trackerToDevice[3][2] *= _trackerUnitsToRoomUnitsScale;
	glm::dmat4 eventRoom = _finalOffset[sensorNum] * _deviceToRoom * trackerToDevice * _propToTracker[sensorNum];
	if ((_printSensor0) && (sensorNum == 0)) {
		glm::dvec4 translation = glm::column(eventRoom, 3);
		std::cout << translation << std::endl;
	}
	_pendingEvents.push_back(EventRef(new Event(getEventName(sensorNum), eventRoom, nullptr, sensorNum, msg_time)));
}
void InputDeviceVRPNTracker :: processEvent ( const glm :: dmat4 & vrpnEvent , int sensorNum , const boost :: posix_time :: ptime & msg_time ) { if ( _ignoreZeroes && glm :: column ( vrpnEvent , 3 ) == glm :: dvec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) ) { return ; } _newReportFlag = true ; glm :: dmat4 trackerToDevice = vrpnEvent ; if ( _convertLHtoRH ) { trackerToDevice [ 3 ] [ 2 ] = - trackerToDevice [ 3 ] [ 2 ] ; trackerToDevice [ 2 ] [ 0 ] = - trackerToDevice [ 2 ] [ 0 ] ; trackerToDevice [ 2 ] [ 1 ] = - trackerToDevice [ 2 ] [ 1 ] ; trackerToDevice [ 0 ] [ 2 ] = - trackerToDevice [ 0 ] [ 2 ] ; trackerToDevice [ 1 ] [ 2 ] = - trackerToDevice [ 1 ] [ 2 ] ; } trackerToDevice [ 3 ] [ 0 ] *= _trackerUnitsToRoomUnitsScale ; trackerToDevice [ 3 ] [ 1 ] *= _trackerUnitsToRoomUnitsScale ; trackerToDevice [ 3 ] [ 2 ] *= _trackerUnitsToRoomUnitsScale ; glm :: dmat4 eventRoom = _finalOffset [ sensorNum ] * _deviceToRoom * trackerToDevice * _propToTracker [ sensorNum ] ; if ( ( _printSensor0 ) && ( sensorNum == 0 ) ) { glm :: dvec4 translation = glm :: column ( eventRoom , 3 ) ; std :: cout << translation << std :: endl ; } _pendingEvents . push_back ( EventRef ( new Event ( getEventName ( sensorNum ) , eventRoom , nullptr , sensorNum , msg_time ) ) ) ; }
The tracker reports the transformation that would transform stuff
in tracker space to device space (that is, to the space relative to
the origin of the tracking device).
The tracker reports the transformation that would transform stuff in tracker space to device space ( that is to the space relative to the origin of the tracking device ) .
// first, adjust units of trackerToDevice.  after this, everything // is in RoomSpace units (typically feet for VRG3D). // convert a left handed coordinate system to a right handed one // not sure if this actually works.. /*** This is code from syzygy..
		CoordinateFrame switchMat(Matrix3(1,0,0, 0,0,1, 0,-1,0), Vector3::zero());
		CoordinateFrame transMat(switchMat.inverse() * vrpnEvent.translation);
		CoordinateFrame rotMat(vrpnEvent.rotation, Vector3::zero());
		trackerToDevice = transMat * switchMat.inverse() * rotMat * switchMat;
		***/ // This code is based on the article "Conversion of Left-Handed // Coordinates to Right-Handed Coordinates" by David Eberly, // available online: // http://www.geometrictools.com/Documentation/LeftHandedToRightHanded.pdf