Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

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 -- %
......
......@@ -630,9 +630,9 @@ void set_tracked_sound_receiver( int nlhs, mxArray *plhs[], int nrhs, const mxAr
pConnection->pVAMatlabTracker->iTrackedSoundReceiverID = isoundreceiverID;
}
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_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)" );
void set_tracked_sound_receiver_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_head_rigid_body_index );
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_head_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
......@@ -641,12 +641,26 @@ void set_tracked_sound_receiver_rigid_body_index( int nlhs, mxArray *plhs[], int
int iTrackedRigidBodyIndex = matlabGetIntegerScalar( prhs[ 1 ], "index" );
pConnection->pVAMatlabTracker->iTrackedSoundReceiverRigidBodyIndex = iTrackedRigidBodyIndex;
pConnection->pVAMatlabTracker->iTrackedSoundReceiverHeadRigidBodyIndex = iTrackedRigidBodyIndex;
}
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_rigid_body_translation );
DECLARE_FUNCTION_REQUIRED_INARG( set_tracked_sound_receiver_rigid_body_translation, offset, "real 1x3", "Tracked sound receiver rigid body position offset" );
void set_tracked_sound_receiver_rigid_body_translation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_torso_rigid_body_index );
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_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 );
......@@ -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 ) );
}
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_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)" );
void set_tracked_sound_receiver_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_head_rigid_body_rotation );
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_head_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
......@@ -690,9 +704,9 @@ void set_tracked_real_world_sound_receiver( int nlhs, mxArray *plhs[], int nrhs,
pConnection->pVAMatlabTracker->iTrackedRealWorldSoundReceiverID = iRealWorldsoundreceiverID;
}
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_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)" );
void set_tracked_real_world_sound_receiver_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_head_rigid_body_index );
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_head_rigid_body_index( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
......@@ -704,9 +718,23 @@ void set_tracked_real_world_sound_receiver_rigid_body_index( int nlhs, mxArray *
pConnection->pVAMatlabTracker->iTrackedRealWorldSoundReceiverRigidBodyIndex = iTrackedRigidBodyIndex;
}
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_rigid_body_translation );
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" );
void set_tracked_real_world_sound_receiver_rigid_body_translation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_torso_rigid_body_index );
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_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 );
......@@ -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 ) );
}
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_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)" );
void set_tracked_real_world_sound_receiver_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_head_rigid_body_rotation );
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_head_rigid_body_rotation( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
......@@ -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 ) );
}
// Tracked 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
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", "" );
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]" );
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 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
......@@ -2094,15 +2136,12 @@ void get_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const
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." );
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, 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 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
......@@ -2159,14 +2198,11 @@ void set_sound_receiver_position( int nlhs, mxArray *plhs[], int nrhs, const mxA
pConnection->pCoreInterface->SetSoundReceiverPosition( isoundreceiverID, v3Pos );
}
// ------------------------------------------------------------
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, 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 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
......@@ -2179,15 +2215,29 @@ void set_sound_receiver_orientation( int nlhs, mxArray *plhs[], int nrhs, const
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." );
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, 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 );
ConnectionHandle hHandle = GetConnectionHandle( prhs[ 0 ] );
......@@ -2223,7 +2273,21 @@ void set_sound_receiver_pose( int, mxArray *[], int nrhs, const mxArray *prhs[]
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." );
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,
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." );
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)" );
......
......@@ -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