Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Implementing (untested) head-above-torso tracking

parent edf06eab
...@@ -252,22 +252,27 @@ classdef itaVA < handle ...@@ -252,22 +252,27 @@ classdef itaVA < handle
VAMatlab( 'set_tracked_sound_receiver', this.handle, sound_receiver_id ); VAMatlab( 'set_tracked_sound_receiver', this.handle, sound_receiver_id );
end 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) % 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 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 % Sets the pivot point translation for the tracked sound receiver rigid body
% %
% Parameters: % Parameters:
% %
% translation [double-3x1] Translation in local coordinate system of rigid body [m] % 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 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 % 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) % Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k)
...@@ -276,7 +281,7 @@ classdef itaVA < handle ...@@ -276,7 +281,7 @@ classdef itaVA < handle
% %
% rotation [quaternion] Rotation of rigid body % 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 end
% -- Tracked real-world sound receiver -- % % -- Tracked real-world sound receiver -- %
...@@ -291,22 +296,27 @@ classdef itaVA < handle ...@@ -291,22 +296,27 @@ classdef itaVA < handle
VAMatlab( 'set_tracked_real_world_sound_receiver', this.handle, sound_receiver_id ); VAMatlab( 'set_tracked_real_world_sound_receiver', this.handle, sound_receiver_id );
end 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) % 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 ) VAMatlab( 'set_tracked_real_world_sound_receiver_rigid_body_index', this.handle, index )
end 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 % Sets the pivot point translation for the tracked real-world sound receiver rigid body
% %
% Parameters: % Parameters:
% %
% translation [double-3x1] Translation in local coordinate system of rigid body [m] % 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 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 % 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) % Given rotation has to be a Matlab quaternion type (order: w(real), i, j, k)
...@@ -315,7 +325,7 @@ classdef itaVA < handle ...@@ -315,7 +325,7 @@ classdef itaVA < handle
% %
% rotation [quaternion] Rotation of rigid body % 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 end
% -- Tracked source -- % % -- Tracked source -- %
......
...@@ -630,9 +630,9 @@ void set_tracked_sound_receiver( int nlhs, mxArray *plhs[], int nrhs, const mxAr ...@@ -630,9 +630,9 @@ void set_tracked_sound_receiver( int nlhs, mxArray *plhs[], int nrhs, const mxAr
pConnection->pVAMatlabTracker->iTrackedSoundReceiverID = isoundreceiverID; pConnection->pVAMatlabTracker->iTrackedSoundReceiverID = isoundreceiverID;
} }
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_rigid_body_index ); REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_head_rigid_body_index );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_rigid_body_index, index, "scalar number", "Tracked sound receiver rigid body index (default is 1)" ); DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_head_rigid_body_index, index, "scalar number", "Tracked sound receiver head rigid body index (default is 1)" );
void set_tracked_sound_receiver_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) void set_tracked_sound_receiver_head_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{ {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
...@@ -641,12 +641,26 @@ void set_tracked_sound_receiver_rigid_body_index( int nlhs, mxArray *plhs[], int ...@@ -641,12 +641,26 @@ void set_tracked_sound_receiver_rigid_body_index( int nlhs, mxArray *plhs[], int
int iTrackedRigidBodyIndex = matlabGetIntegerScalar( prhs[ 1 ], "index" ); int iTrackedRigidBodyIndex = matlabGetIntegerScalar( prhs[ 1 ], "index" );
pConnection->pVAMatlabTracker->iTrackedSoundReceiverRigidBodyIndex = iTrackedRigidBodyIndex; pConnection->pVAMatlabTracker->iTrackedSoundReceiverHeadRigidBodyIndex = iTrackedRigidBodyIndex;
} }
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_rigid_body_translation ); REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_torso_rigid_body_index );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_rigid_body_translation, offset, "real 1x3", "Tracked sound receiver rigid body position offset" ); DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_torso_rigid_body_index, index, "scalar number", "Tracked hato sound receiver torso rigid body index (default is 1)" );
void set_tracked_sound_receiver_rigid_body_translation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) void set_tracked_sound_receiver_torso_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
int iTrackedRigidBodyIndex = matlabGetIntegerScalar( prhs[ 1 ], "index" );
pConnection->pVAMatlabTracker->iTrackedSoundReceiverTorsoRigidBodyIndex = iTrackedRigidBodyIndex;
}
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_head_rigid_body_translation );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_head_rigid_body_translation, offset, "real 1x3", "Tracked sound receiver rigid body position offset" );
void set_tracked_sound_receiver_head_rigid_body_translation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{ {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
...@@ -659,9 +673,9 @@ void set_tracked_sound_receiver_rigid_body_translation( int nlhs, mxArray *plhs[ ...@@ -659,9 +673,9 @@ void set_tracked_sound_receiver_rigid_body_translation( int nlhs, mxArray *plhs[
pConnection->pVAMatlabTracker->vTrackedSoundReceiverTranslation = VistaVector3D( float( v3Pos.x ), float( v3Pos.y ), float( v3Pos.z ) ); pConnection->pVAMatlabTracker->vTrackedSoundReceiverTranslation = VistaVector3D( float( v3Pos.x ), float( v3Pos.y ), float( v3Pos.z ) );
} }
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_rigid_body_rotation ); REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_head_rigid_body_rotation );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_rigid_body_rotation, rotation, "real 1x4", "Tracked sound receiver rigid body rotation (quaternion values with w (real), i, j, k)" ); DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_head_rigid_body_rotation, rotation, "real 1x4", "Tracked sound receiver rigid body rotation (quaternion values with w (real), i, j, k)" );
void set_tracked_sound_receiver_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) void set_tracked_sound_receiver_head_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{ {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
...@@ -690,9 +704,9 @@ void set_tracked_real_world_sound_receiver( int nlhs, mxArray *plhs[], int nrhs, ...@@ -690,9 +704,9 @@ void set_tracked_real_world_sound_receiver( int nlhs, mxArray *plhs[], int nrhs,
pConnection->pVAMatlabTracker->iTrackedRealWorldSoundReceiverID = iRealWorldsoundreceiverID; pConnection->pVAMatlabTracker->iTrackedRealWorldSoundReceiverID = iRealWorldsoundreceiverID;
} }
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_rigid_body_index ); REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_head_rigid_body_index );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_real_world_sound_receiver_rigid_body_index, index, "scalar number", "Tracked real-world sound receiver rigid body index (default is 1)" ); DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_real_world_sound_receiver_head_rigid_body_index, index, "scalar number", "Tracked real-world sound receiver rigid body index (default is 1)" );
void set_tracked_real_world_sound_receiver_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) void set_tracked_real_world_sound_receiver_head_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{ {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
...@@ -704,9 +718,23 @@ void set_tracked_real_world_sound_receiver_rigid_body_index( int nlhs, mxArray * ...@@ -704,9 +718,23 @@ void set_tracked_real_world_sound_receiver_rigid_body_index( int nlhs, mxArray *
pConnection->pVAMatlabTracker->iTrackedRealWorldSoundReceiverRigidBodyIndex = iTrackedRigidBodyIndex; pConnection->pVAMatlabTracker->iTrackedRealWorldSoundReceiverRigidBodyIndex = iTrackedRigidBodyIndex;
} }
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_rigid_body_translation ); REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_torso_rigid_body_index );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_real_world_sound_receiver_rigid_body_translation, offset, "real 1x3", "Tracked real-world sound receiver rigid body position offset" ); DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_real_world_sound_receiver_torso_rigid_body_index, index, "scalar number", "Tracked real-world head-above-torso sound receiver rigid body index (default is 1)" );
void set_tracked_real_world_sound_receiver_rigid_body_translation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) void set_tracked_real_world_sound_receiver_torso_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
int iTrackedRigidBodyIndex = matlabGetIntegerScalar( prhs[ 1 ], "index" );
pConnection->pVAMatlabTracker->iTrackedRealWorldSoundReceiverTorsoRigidBodyIndex = iTrackedRigidBodyIndex;
}
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_head_rigid_body_translation );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_real_world_sound_receiver_head_rigid_body_translation, offset, "real 1x3", "Tracked real-world sound receiver rigid body position offset" );
void set_tracked_real_world_sound_receiver_head_rigid_body_translation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{ {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
...@@ -719,9 +747,9 @@ void set_tracked_real_world_sound_receiver_rigid_body_translation( int nlhs, mxA ...@@ -719,9 +747,9 @@ void set_tracked_real_world_sound_receiver_rigid_body_translation( int nlhs, mxA
pConnection->pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation = VistaVector3D( float( v3Pos.x ), float( v3Pos.y ), float( v3Pos.z ) ); pConnection->pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation = VistaVector3D( float( v3Pos.x ), float( v3Pos.y ), float( v3Pos.z ) );
} }
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_rigid_body_rotation ); REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_head_rigid_body_rotation );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_real_world_sound_receiver_rigid_body_rotation, rotation, "real 1x4", "Tracked real-world sound receiver rigid body rotation (quaternion values with w (real), i, j, k)" ); DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_real_world_sound_receiver_head_rigid_body_rotation, rotation, "real 1x4", "Tracked real-world sound receiver rigid body rotation (quaternion values with w (real), i, j, k)" );
void set_tracked_real_world_sound_receiver_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) void set_tracked_real_world_sound_receiver_head_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{ {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
...@@ -734,6 +762,7 @@ void set_tracked_real_world_sound_receiver_rigid_body_rotation( int nlhs, mxArra ...@@ -734,6 +762,7 @@ void set_tracked_real_world_sound_receiver_rigid_body_rotation( int nlhs, mxArra
pConnection->pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation = VistaQuaternion( float( qOrient.x ), float( qOrient.y ), float( qOrient.z ), float( qOrient.w ) ); pConnection->pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation = VistaQuaternion( float( qOrient.x ), float( qOrient.y ), float( qOrient.z ), float( qOrient.w ) );
} }
// Tracked source // Tracked source
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_source ); REGISTER_PRIVATE_FUNCTION( set_tracked_sound_source );
...@@ -2075,14 +2104,27 @@ void get_sound_receiver_position( int nlhs, mxArray *plhs[], int nrhs, const mxA ...@@ -2075,14 +2104,27 @@ void get_sound_receiver_position( int nlhs, mxArray *plhs[], int nrhs, const mxA
plhs[ 0 ] = matlabCreateRealVector3( v3Pos ); plhs[ 0 ] = matlabCreateRealVector3( v3Pos );
} }
// ------------------------------------------------------------ REGISTER_PUBLIC_FUNCTION( get_sound_receiver_head_above_torso_orientation, "Returns the head-above-torso (relative) orientation of a sound receiver", "" );
DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_head_above_torso_orientation, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_OUTARG( get_sound_receiver_head_above_torso_orientation, orient, "double-4", "Rotation angles [w,x,y,z]" );
void get_sound_receiver_head_above_torso_orientation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
int isoundreceiverID = matlabGetIntegerScalar( prhs[ 1 ], "soundreceiverID" );
VAQuat qOrient = pConnection->pCoreInterface->GetSoundReceiverHeadAboveTorsoOrientation( isoundreceiverID );
plhs[ 0 ] = matlabCreateQuaternion( qOrient );
}
REGISTER_PUBLIC_FUNCTION( get_sound_receiver_orientation, "Returns the orientation of a sound receiver", "" ); REGISTER_PUBLIC_FUNCTION( get_sound_receiver_orientation, "Returns the orientation of a sound receiver", "" );
DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_orientation, soundreceiverID, "integer-1x1", "Sound receiver ID" ); DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_orientation, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_OUTARG( get_sound_receiver_orientation, orient, "double-4", "Rotation angles [w,x,y,z]" ); DECLARE_FUNCTION_OUTARG( get_sound_receiver_orientation, orient, "double-4", "Rotation angles [w,x,y,z]" );
void get_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void get_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] ); ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
...@@ -2094,15 +2136,12 @@ void get_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const ...@@ -2094,15 +2136,12 @@ void get_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const
plhs[ 0 ] = matlabCreateQuaternion( qOrient ); plhs[ 0 ] = matlabCreateQuaternion( qOrient );
} }
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( get_sound_receiver_orientation_view_up, "Returns the orientation of a sound receiver (as view- and up-vector)", "Note: The view and up vector must be an orthonormal pair of vectors." ); REGISTER_PUBLIC_FUNCTION( get_sound_receiver_orientation_view_up, "Returns the orientation of a sound receiver (as view- and up-vector)", "Note: The view and up vector must be an orthonormal pair of vectors." );
DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" ); DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_OUTARG( get_sound_receiver_orientation_view_up, view, "double-3", "View vector" ); DECLARE_FUNCTION_OUTARG( get_sound_receiver_orientation_view_up, view, "double-3", "View vector" );
DECLARE_FUNCTION_OUTARG( get_sound_receiver_orientation_view_up, up, "double-3", "Up vector" ); DECLARE_FUNCTION_OUTARG( get_sound_receiver_orientation_view_up, up, "double-3", "Up vector" );
void get_sound_receiver_orientation_view_up( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void get_sound_receiver_orientation_view_up( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { {
REQUIRE_INPUT_ARGS( 2 ); REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] ); ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
...@@ -2159,14 +2198,11 @@ void set_sound_receiver_position( int nlhs, mxArray *plhs[], int nrhs, const mxA ...@@ -2159,14 +2198,11 @@ void set_sound_receiver_position( int nlhs, mxArray *plhs[], int nrhs, const mxA
pConnection->pCoreInterface->SetSoundReceiverPosition( isoundreceiverID, v3Pos ); pConnection->pCoreInterface->SetSoundReceiverPosition( isoundreceiverID, v3Pos );
} }
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( set_sound_receiver_orientation, "Sets the orientation of a sound receiver", "" ); REGISTER_PUBLIC_FUNCTION( set_sound_receiver_orientation, "Sets the orientation of a sound receiver", "" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation, soundreceiverID, "integer-1x1", "Sound receiver ID" ); DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation, orient, "double-4", "Rotation quaternion [w,x,y,z]" ); DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation, orient, "double-4", "Rotation quaternion [w,x,y,z]" );
void set_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void set_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { {
REQUIRE_INPUT_ARGS( 3 ); REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] ); ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
...@@ -2179,15 +2215,29 @@ void set_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const ...@@ -2179,15 +2215,29 @@ void set_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const
pConnection->pCoreInterface->SetSoundReceiverOrientation( isoundreceiverID, qOrient ); pConnection->pCoreInterface->SetSoundReceiverOrientation( isoundreceiverID, qOrient );
} }
// ------------------------------------------------------------ REGISTER_PUBLIC_FUNCTION( set_sound_receiver_head_above_torso_orientation, "Sets the head-above-torso (relative) orientation of a sound receiver", "" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_head_above_torso_orientation, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_head_above_torso_orientation, orient, "double-4", "Rotation quaternion [w,x,y,z]" );
void set_sound_receiver_head_above_torso_orientation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 3 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
int isoundreceiverID = matlabGetIntegerScalar( prhs[ 1 ], "soundreceiverID" );
VAQuat qOrient;
matlabGetQuaternion( prhs[ 2 ], "orient", qOrient );
pConnection->pCoreInterface->SetSoundReceiverHeadAboveTorsoOrientation( isoundreceiverID, qOrient );
}
REGISTER_PUBLIC_FUNCTION( set_sound_receiver_orientation_view_up, "Sets the orientation of a sound receiver (as view- and up-vector)", "Note: The view and up vector must be an orthonormal pair of vectors." ); REGISTER_PUBLIC_FUNCTION( set_sound_receiver_orientation_view_up, "Sets the orientation of a sound receiver (as view- and up-vector)", "Note: The view and up vector must be an orthonormal pair of vectors." );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" ); DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation_view_up, view, "double-3", "View vector" ); DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation_view_up, view, "double-3", "View vector" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation_view_up, up, "double-3", "Up vector" ); DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_orientation_view_up, up, "double-3", "Up vector" );
void set_sound_receiver_orientation_view_up( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void set_sound_receiver_orientation_view_up( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { {
REQUIRE_INPUT_ARGS( 4 ); REQUIRE_INPUT_ARGS( 4 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] ); ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
...@@ -2223,7 +2273,21 @@ void set_sound_receiver_pose( int, mxArray *[], int nrhs, const mxArray *prhs[] ...@@ -2223,7 +2273,21 @@ void set_sound_receiver_pose( int, mxArray *[], int nrhs, const mxArray *prhs[]
pConnection->pCoreInterface->SetSoundReceiverPose( isoundreceiverID, v3Pos, qOrient ); pConnection->pCoreInterface->SetSoundReceiverPose( isoundreceiverID, v3Pos, qOrient );
} }
// ------------------------------------------------------------ REGISTER_PUBLIC_FUNCTION( get_sound_receiver_real_world_torso_orientation, "Returns the real-world position and orientation (as quaterion) of the sound receiver's torso", "The orientation is meant to be relative to the real world sound receiver orientation." );
DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_real_world_torso_orientation, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_OUTARG( get_sound_receiver_real_world_torso_orientation, view, "double-4", "Rotation quaternion [w,x,y,z]" );
void get_sound_receiver_real_world_torso_orientation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
int isoundreceiverID = matlabGetIntegerScalar( prhs[ 1 ], "soundreceiverID" );
VAQuat qOrient = pConnection->pCoreInterface->GetSoundReceiverRealWorldTorsoOrientation( isoundreceiverID );
plhs[ 0 ] = matlabCreateQuaternion( qOrient );
}
REGISTER_PUBLIC_FUNCTION( get_sound_receiver_real_world_head_position_orientation_view_up, "Returns the real-world position and orientation (as view- and up vector) of the sound receiver's head", "Note: The view and up vector must be an orthonormal pair of vectors. The parameter isoundreceiverID has been added for future versions and is currently unsupported. You can set it any value you like." ); REGISTER_PUBLIC_FUNCTION( get_sound_receiver_real_world_head_position_orientation_view_up, "Returns the real-world position and orientation (as view- and up vector) of the sound receiver's head", "Note: The view and up vector must be an orthonormal pair of vectors. The parameter isoundreceiverID has been added for future versions and is currently unsupported. You can set it any value you like." );
DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_real_world_head_position_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" ); DECLARE_FUNCTION_REQUIRED_INARG( get_sound_receiver_real_world_head_position_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" );
...@@ -2246,8 +2310,6 @@ void get_sound_receiver_real_world_head_position_orientation_view_up( int nlhs, ...@@ -2246,8 +2310,6 @@ void get_sound_receiver_real_world_head_position_orientation_view_up( int nlhs,
plhs[ 2 ] = matlabCreateRealVector3( v3Up ); plhs[ 2 ] = matlabCreateRealVector3( v3Up );
} }
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( set_sound_receiver_real_world_position_orientation_view_up, "Updates the real-world position and orientation (as view- and up vector) of the sound receiver's head", "Note: The view and up vector must be an orthonormal pair of vectors." ); REGISTER_PUBLIC_FUNCTION( set_sound_receiver_real_world_position_orientation_view_up, "Updates the real-world position and orientation (as view- and up vector) of the sound receiver's head", "Note: The view and up vector must be an orthonormal pair of vectors." );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_real_world_position_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" ); DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_real_world_position_orientation_view_up, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_real_world_position_orientation_view_up, pos, "double-3", "Position vector [x, y, z] (unit: meters)" ); DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_real_world_position_orientation_view_up, pos, "double-3", "Position vector [x, y, z] (unit: meters)" );
......
...@@ -34,60 +34,106 @@ void TrackerDataHandler( sFrameOfMocapData* sFrame, void* pUserData ) ...@@ -34,60 +34,106 @@ void TrackerDataHandler( sFrameOfMocapData* sFrame, void* pUserData )
// SoundReceiver // SoundReceiver
int iTrackedReceiverID = pVAMatlabTracker->iTrackedSoundReceiverID; 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; try
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedSoundReceiverRotation; {
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedSoundReceiverTranslation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverRigidBodyIndex - 1 ] ); VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedSoundReceiverRotation;
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw ); const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw; VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir(); VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem ); VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
pVACore->SetSoundReceiverPosition( iTrackedReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ) ); VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
pVACore->SetSoundReceiverOrientationVU( iTrackedReceiverID, VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) );
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 iTrackedRealWorldSoundReceiverID = pVAMatlabTracker->iTrackedRealWorldSoundReceiverID;
int iTrackedRealWorldSoundReceiverRigidBodyIndex = pVAMatlabTracker->iTrackedRealWorldSoundReceiverRigidBodyIndex; 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; try
VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation; {
VistaVector3D vPosOffsetLocalCoordinateSystem = pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation;
const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverRigidBodyIndex - 1 ] ); VistaQuaternion qOrientRotation = pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation;
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw ); const sRigidBodyData& oBodyData( sFrame->RigidBodies[ iTrackedRealWorldSoundReceiverRigidBodyIndex - 1 ] );
VistaVector3D vPosPivotPoint( oBodyData.x, oBodyData.y, oBodyData.z );
VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw; VistaQuaternion qOrientRaw( oBodyData.qx, oBodyData.qy, oBodyData.qz, oBodyData.qw );
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir(); VistaQuaternion qOrientRigidBody = qOrientRotation * qOrientRaw;
VistaVector3D vViewRigidBody = qOrientRigidBody.GetViewDir();
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem ); VistaVector3D vUpRigidBody = qOrientRigidBody.GetUpDir();
VistaVector3D vPosRigidBody = vPosPivotPoint + vPosOffsetGlobalCoordinateSystem;
VistaVector3D vPosOffsetGlobalCoordinateSystem = qOrientRigidBody.Rotate( vPosOffsetLocalCoordinateSystem );
pVACore->SetSoundReceiverRealWorldPositionOrientationVU( iTrackedRealWorldSoundReceiverID, VAVec3( vPosRigidBody[ 0 ], vPosRigidBody[ 1 ], vPosRigidBody[ 2 ] ), VAVec3( vViewRigidBody[ 0 ], vViewRigidBody[ 1 ], vViewRigidBody[ 2 ] ), VAVec3( vUpRigidBody[ 0 ], vUpRigidBody[ 1 ], vUpRigidBody[ 2 ] ) ); 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() ...@@ -136,12 +182,14 @@ CVAMatlabTracker::CVAMatlabTracker()
void CVAMatlabTracker::Reset()