Implementing (untested) head-above-torso tracking

parent edf06eab
......@@ -252,22 +252,27 @@ classdef itaVA < handle
VAMatlab( 'set_tracked_sound_receiver', this.handle, sound_receiver_id );
end
function set_tracked_sound_receiver_rigid_body_index( this, index )
function set_tracked_sound_receiver_head_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for sound receiver (default is 1)
VAMatlab( 'set_tracked_sound_receiver_rigid_body_index', this.handle, index )
VAMatlab( 'set_tracked_sound_receiver_head_rigid_body_index', this.handle, index )
end
function set_tracked_sound_receiver_rigid_body_translation( this, translation )
function set_tracked_sound_receiver_torso_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for sound receiver's absolute torso orientation (default is 1)
VAMatlab( 'set_tracked_sound_receiver_torso_rigid_body_index', this.handle, index )
end
function set_tracked_sound_receiver_head_rigid_body_translation( this, translation )
% Sets the pivot point translation for the tracked sound receiver rigid body
%
% Parameters:
%
% translation [double-3x1] Translation in local coordinate system of rigid body [m]
%
VAMatlab( 'set_tracked_sound_receiver_rigid_body_translation', this.handle, translation )
VAMatlab( 'set_tracked_sound_receiver_head_rigid_body_translation', this.handle, translation )
end
function set_tracked_sound_receiver_rigid_body_rotation( this, rotation )
function set_tracked_sound_receiver_head_rigid_body_rotation( this, rotation )
% Sets the rotation of orientation for the tracked sound receiver rigid body
%
% Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k)
......@@ -276,7 +281,7 @@ classdef itaVA < handle
%
% rotation [quaternion] Rotation of rigid body
%
VAMatlab( 'set_tracked_sound_receiver_rigid_body_rotation', this.handle, rotation )
VAMatlab( 'set_tracked_sound_receiver_head_rigid_body_rotation', this.handle, rotation )
end
% -- Tracked real-world sound receiver -- %
......@@ -291,22 +296,27 @@ classdef itaVA < handle
VAMatlab( 'set_tracked_real_world_sound_receiver', this.handle, sound_receiver_id );
end
function set_tracked_real_world_sound_receiver_rigid_body_index( this, index )
function set_tracked_real_world_sound_receiver_head_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for real-world sound receiver (default is 1)
VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_index', this.handle, index )
end
function set_tracked_real_world_sound_receiver_torso_rigid_body_index( this, index )
% Sets the index of the rigid body to be tracked for real-world sound receiver' torso (default is 1)
VAMatlab( 'set_tracked_real_world_sound_receiver_torso_rigid_body_index', this.handle, index )
end
function set_tracked_real_world_sound_receiver_rigid_body_translation( this, translation )
function set_tracked_real_world_sound_receiver_head_rigid_body_translation( this, translation )
% Sets the pivot point translation for the tracked real-world sound receiver rigid body
%
% Parameters:
%
% translation [double-3x1] Translation in local coordinate system of rigid body [m]
%
VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_translation', this.handle, translation )
VAMatlab( 'set_tracked_real_world_sound_receiver_head_rigid_body_translation', this.handle, translation )
end
function set_tracked_real_world_sound_receiver_rigid_body_rotation( this, rotation )
function set_tracked_real_world_sound_receiver_head_rigid_body_rotation( this, rotation )
% Sets the rotation of orientation for the tracked real-world sound receiver rigid body
%
% Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k)
......@@ -315,7 +325,7 @@ classdef itaVA < handle
%
% rotation [quaternion] Rotation of rigid body
%
VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_rotation', this.handle, rotation )
VAMatlab( 'set_tracked_real_world_sound_receiver_head_rigid_body_rotation', this.handle, rotation )
end
% -- Tracked source -- %
......
This diff is collapsed.
......@@ -34,60 +34,106 @@ void TrackerDataHandler( sFrameOfMocapData* sFrame, void* pUserData )
// SoundReceiver
int iTrackedReceiverID = pVAMatlabTracker->iTrackedSoundReceiverID;
int iTrackedReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedSoundReceiverRigidBodyIndex;
int iTrackedReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedSoundReceiverHeadRigidBodyIndex;
int iTrackedReceiverHATORigidBodyIndex = pVAMatlabTracker->iTrackedSoundReceiverTorsoRigidBodyIndex;
if( ( iTrackedReceiverID != -1 ) && ( iTrackedReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedReceiverRigidBodyIndex > 0 ) )
if( iTrackedReceiverID != -1 )
{
try
// Tracked receiver
if( ( iTrackedReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedReceiverRigidBodyIndex > 0 ) )
{
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedSoundReceiverTranslation;
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedSoundReceiverRotation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
pVACore->SetSoundReceiverPosition( iTrackedReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ) );
pVACore->SetSoundReceiverOrientationVU( iTrackedReceiverID, VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
try
{
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedSoundReceiverTranslation;
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedSoundReceiverRotation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
pVACore->SetSoundReceiverPosition( iTrackedReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ) );
pVACore->SetSoundReceiverOrientationVU( iTrackedReceiverID, VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
}
catch( ... )
{
}
}
catch( ... )
// HATO orientation
if( ( iTrackedReceiverHATORigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedReceiverHATORigidBodyIndex > 0 ) )
{
try
{
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverHATORigidBodyIndex - 1 ] );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
// Convert absolute orientation to relative HATO orientation
VAQuat qOrient = pVACore->GetSoundReceiverOrientation( iTrackedReceiverID );
VistaQuaternion qHeadOrient( qOrient.comp );
VistaQuaternion qHATOOrient = qOrientRaw * qHeadOrient;
VAQuat qFinalHATO = VAQuat( qHATOOrient[ Vista::X ], qHATOOrient[ Vista::Y ], qHATOOrient[ Vista::Z ], qHATOOrient[ Vista::W ] );
pVACore->SetSoundReceiverHeadAboveTorsoOrientation( iTrackedReceiverID, qFinalHATO );
}
catch( ... )
{
}
}
}
// Real-world listener
// Real-world sound receiver
int iTrackedRealWorldSoundReceiverID = pVAMatlabTracker->iTrackedRealWorldSoundReceiverID;
int iTrackedRealWorldSoundReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedRealWorldSoundReceiverRigidBodyIndex;
int iTrackedRealWorldSoundReceiverHATORigidBodyIndex = pVAMatlabTracker->iTrackedRealWorldSoundReceiverTorsoRigidBodyIndex;
if( ( iTrackedRealWorldSoundReceiverID != -1 ) && ( iTrackedRealWorldSoundReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedRealWorldSoundReceiverRigidBodyIndex > 0 ) )
if( iTrackedRealWorldSoundReceiverID != -1 )
{
try
// Real world receiver tracking
if( ( iTrackedRealWorldSoundReceiverRigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedRealWorldSoundReceiverRigidBodyIndex > 0 ) )
{
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation;
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
pVACore->SetSoundReceiverRealWorldPositionOrientationVU( iTrackedRealWorldSoundReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ), VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
try
{
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation;
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
pVACore->SetSoundReceiverRealWorldPositionOrientationVU( iTrackedRealWorldSoundReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ), VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
}
catch( ... )
{
}
}
catch( ... )
// Real world receiver HATO orientation
if( ( iTrackedRealWorldSoundReceiverHATORigidBodyIndex <= sFrame->nRigidBodies ) && ( iTrackedRealWorldSoundReceiverHATORigidBodyIndex > 0 ) )
{
try
{
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverHATORigidBodyIndex - 1 ] );
VAQuat qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
pVACore->SetSoundReceiverRealWorldTorsoOrientation( iTrackedReceiverID, qOrientRaw );
}
catch( ... )
{
}
}
}
......@@ -136,12 +182,14 @@ CVAMatlabTracker::CVAMatlabTracker()
void CVAMatlabTracker::Reset()
{
iTrackedSoundReceiverID = -1;
iTrackedSoundReceiverRigidBodyIndex = 1;
iTrackedSoundReceiverHeadRigidBodyIndex = 1;
iTrackedSoundReceiverTorsoRigidBodyIndex = 1;
vTrackedSoundReceiverTranslation.SetToZeroVector();
qTrackedSoundReceiverRotation.SetToNeutralQuaternion();
iTrackedRealWorldSoundReceiverID = -1;
iTrackedRealWorldSoundReceiverRigidBodyIndex = 1;
iTrackedRealWorldSoundReceiverTorsoRigidBodyIndex = 1;
vTrackedRealWorldSoundReceiverTranslation.SetToZeroVector();
qTrackedRealWorldSoundReceiverRotation.SetToNeutralQuaternion();
......
......@@ -38,12 +38,14 @@ public:
IVAInterface* pVACore; //!< Pointer to (networked) core instance
int iTrackedSoundReceiverID; //!< -1 if deactivated, will be preferred over source
int iTrackedSoundReceiverRigidBodyIndex; //!< Starts with 1 (default)
int iTrackedSoundReceiverHeadRigidBodyIndex; //!< Starts with 1 (default)
int iTrackedSoundReceiverTorsoRigidBodyIndex; //!< Starts with 1 (default)
VistaVector3D vTrackedSoundReceiverTranslation; //!< Position offset from pivot point (default NatNet rigid body barycenter)
VistaQuaternion qTrackedSoundReceiverRotation; //!< Orientation rotation from default orientation (initial NatNet rigid body orientation)
int iTrackedRealWorldSoundReceiverID; //!< -1 if deactivated
int iTrackedRealWorldSoundReceiverRigidBodyIndex; //!< Starts with 1 (default)
int iTrackedRealWorldSoundReceiverTorsoRigidBodyIndex; //!< Starts with 1 (default)
VistaVector3D vTrackedRealWorldSoundReceiverTranslation; //!< Position offset from pivot point (default NatNet rigid body barycenter)
VistaQuaternion qTrackedRealWorldSoundReceiverRotation; //!< Orientation rotation from default orientation (initial NatNet rigid body orientation)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment