/** * @file * * @author Mamadou Babaei * * @section LICENSE * * (The MIT License) * * Copyright (c) 2020 - 2022 SenseGlove * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * @section DESCRIPTION * * */ #include "SGCore/SGNovaGlove.h" #include "Runtime/Launch/Resources/Version.h" #include "SGCore/SGBasicHandModel.h" #include "SGCore/SGBuzzCommand.h" #include "SGCore/SGDeviceImplCast.h" #include "SGCore/SGForceFeedbackCommand.h" #include "SGCore/SGHandPose.h" #include "SGCore/SGHandProfile.h" #include "SGCore/SGNovaGloveInfo.h" #include "SGCore/SGNovaGloveSensorData.h" #include "SGCore/SGThumperCommand.h" #include "SGCoreImpl/SGDeviceImpl.h" #include "SGCoreImpl/SGHapticGloveImpl.h" #include "SGCoreImpl/SGExportedFunctions.h" #include "SGCoreImpl/SGNovaGloveImpl.h" #include "SGInterop/SGIC_ESGDeviceType.h" #include "SGInterop/SGIC_ESGPositionalTrackingHardware.h" #include "SGInterop/SGIC_FQuat.h" #include "SGInterop/SGIC_FSGBasicHandModelImpl.h" #include "SGInterop/SGIC_FSGBuzzCommandImpl.h" #include "SGInterop/SGIC_FSGForceFeedbackCommandImpl.h" #include "SGInterop/SGIC_FSGHandPoseImpl.h" #include "SGInterop/SGIC_FSGHandProfileImpl.h" #include "SGInterop/SGIC_FSGNovaGloveHandProfileImpl.h" #include "SGInterop/SGIC_FSGNovaGloveImpl.h" #include "SGInterop/SGIC_FSGNovaGloveInfoImpl.h" #include "SGInterop/SGIC_FSGNovaGloveSensorDataImpl.h" #include "SGInterop/SGIC_FSGThumperCommandImpl.h" #include "SGInterop/SGIC_FString.h" #include "SGInterop/SGIC_FVector.h" #include "SGInterop/SGIC_TArray_FSGNovaGloveImpl.h" #include "SGInterop/SGIC_TArray_FVector.h" #include "SGInterop/SGIC_TSharedPtr_FSGNovaGloveImpl.h" struct USGNovaGlove::FImpl { /************************ * Member variables ************************/ /************************ * Owner object ************************/ USGDevice* Owner; /************************ * Constructor / Destructor ************************/ explicit FImpl(USGNovaGlove* InOwner); ~FImpl(); /************************ * Default copy constructor & copy assignment operator ************************/ FImpl(const FImpl& Rhs) = default; FImpl& operator=(const FImpl& Rhs) = default; /************************ * Methods ************************/ void SyncUProperties(); void SyncImplObject(); }; USGNovaGlove* USGNovaGlove::NewNovaGlove(UObject* Outer, const FSGNovaGloveImpl& NovaGloveImpl) { USGNovaGlove* Instance = NewObject(Outer); Instance->SetSGDeviceImpl(NovaGloveImpl); return Instance; } USGNovaGlove* USGNovaGlove::NewNovaGlove(UObject* Outer, TSharedRef NovaGloveImpl) { USGNovaGlove* Instance = NewObject(Outer); Instance->SetSGDeviceImpl(MoveTemp(NovaGloveImpl)); return Instance; } USGNovaGlove* USGNovaGlove::NewNovaGlove(UObject* Outer) { FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer; SGCoreImpl_FSGSenseGloveImpl_ctor_MakeShared(&OutSharedPtrContainer); return NewNovaGlove(Outer, OutSharedPtrContainer.Ptr.ToSharedRef()); } USGNovaGlove* USGNovaGlove::NewNovaGlove(UObject* Outer, const USGNovaGloveInfo& DeviceInfo) { FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer; FSGIC_FSGNovaGloveInfoImpl DeviceInfoContainer{DeviceInfo.ToNovaGloveInfoImpl()}; SGCoreImpl_FSGSenseGloveImpl_ctor_Model_MakeShared(&OutSharedPtrContainer, &DeviceInfoContainer); return NewNovaGlove(Outer, OutSharedPtrContainer.Ptr.ToSharedRef()); } ANSICHAR USGNovaGlove::GetHapticsByte() { return SGCoreImpl_FSGNovaGloveImpl_GetHapticsByte(); } FVector USGNovaGlove::GetMinCalibrationRange() { FSGIC_FVector OutRangeContainer; SGCoreImpl_FSGNovaGloveImpl_GetMinCalibrationRange(&OutRangeContainer); return MoveTemp(OutRangeContainer.Vector); } USGHandPose* USGNovaGlove::CalculateHandPose(UObject* Outer, const USGBasicHandModel* HandModel, const USGNovaGloveSensorData* NovaData, const USGNovaGloveHandProfile* Profile) { FSGIC_FSGHandPoseImpl OutPoseContainer; FSGIC_FSGBasicHandModelImpl HandModelContainer{HandModel->ToBasicHandModelImpl()}; FSGIC_FSGNovaGloveSensorDataImpl NovaDataContainer{NovaData->ToNovaGloveSensorDataImpl()}; FSGIC_FSGNovaGloveHandProfileImpl ProfileContainer{Profile->ToNovaGloveHandProfileImpl()}; SGCoreImpl_FSGNovaGloveImpl_CalculateHandPose( &OutPoseContainer, &HandModelContainer, &NovaDataContainer, &ProfileContainer); return USGHandPose::NewHandPose(Outer, MoveTemp(OutPoseContainer.HandPoseImpl)); } USGDevice* USGNovaGlove::Parse(UObject* Outer, const FString& ConstantsString) { FSGIC_FSGNovaGloveImpl OutNovaGloveImplContainer; FSGIC_FString ConstantsStringContainer{ConstantsString}; SGCoreImpl_FSGSenseGloveImpl_Parse(&OutNovaGloveImplContainer, &ConstantsStringContainer); return NewNovaGlove(Outer, MoveTemp(OutNovaGloveImplContainer.NovaGloveImpl)); } TArray USGNovaGlove::GetNovaGloves(UObject* Outer) { FSGIC_TArray_FSGNovaGloveImpl OutGlovesContainer; SGCoreImpl_FSGNovaGloveImpl_GetNovaGloves(&OutGlovesContainer); TArray Gloves; for (const FSGNovaGloveImpl& NovaGloveImpl: OutGlovesContainer.Array) { USGNovaGlove* NovaGlove = USGNovaGlove::NewNovaGlove(Outer, NovaGloveImpl); Gloves.Add(NovaGlove); } return MoveTemp(Gloves); } bool USGNovaGlove::GetNovaGlove(UObject* Outer, USGNovaGlove*& OutGlove) { FSGIC_FSGNovaGloveImpl OutGloveContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetNovaGlove_OutGlove(&OutGloveContainer); if (bResult) { OutGlove = NewNovaGlove(Outer, MoveTemp(OutGloveContainer.NovaGloveImpl)); } return bResult; } bool USGNovaGlove::GetNovaGlove(UObject* Outer, const bool bRightHanded, USGNovaGlove*& OutGlove) { FSGIC_FSGNovaGloveImpl OutGloveContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetNovaGlove_bRightHanded_OutGlove( bRightHanded, &OutGloveContainer); if (bResult) { OutGlove = NewNovaGlove(Outer, MoveTemp(OutGloveContainer.NovaGloveImpl)); } return bResult; } TArray USGNovaGlove::GetCalibrationValues(const USGNovaGloveSensorData* SensorData) { FSGIC_TArray_FVector OutValuesContainer; FSGIC_FSGNovaGloveSensorDataImpl SensorDataContainer{SensorData->ToNovaGloveSensorDataImpl()}; SGCoreImpl_FSGNovaGloveImpl_GetCalibrationValues_SensorData(&OutValuesContainer, &SensorDataContainer); return MoveTemp(OutValuesContainer.Array); } void USGNovaGlove::CalibrateInterpolation(UObject* Outer, const TArray& MinValues, const TArray& MaxValues, USGNovaGloveHandProfile*& OutProfile) { FSGIC_TArray_FVector MinValuesContainer{MinValues}; FSGIC_TArray_FVector MaxValuesContainer{MaxValues}; FSGIC_FSGNovaGloveHandProfileImpl OutProfileContainer; SGCoreImpl_FSGNovaGloveImpl_CalibrateInterpolation( &MinValuesContainer, &MaxValuesContainer, &OutProfileContainer); OutProfile = USGNovaGloveHandProfile::NewNovaGloveHandProfile( Outer, MoveTemp(OutProfileContainer.NovaGloveHandProfileImpl)); } void USGNovaGlove::CalculateGloveLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, FVector& OutGlovePosition, FQuat& OutGloveRotation) { FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutGlovePositionContainer; FSGIC_FQuat OutGloveRotationContainer; SGCoreImpl_FSGNovaGloveImpl_CalculateGloveLocation( &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, bRightHanded, &OutGlovePositionContainer, &OutGloveRotationContainer); OutGlovePosition = MoveTemp(OutGlovePositionContainer.Vector); OutGloveRotation = MoveTemp(OutGloveRotationContainer.Quat); } void USGNovaGlove::CalculateGloveLocation(const FVector& ReferencePosition, const FRotator& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, FVector& OutGlovePosition, FRotator& OutGloveRotation) { FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation.Quaternion()}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutGlovePositionContainer; FSGIC_FQuat OutGloveRotationContainer; SGCoreImpl_FSGNovaGloveImpl_CalculateGloveLocation( &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, bRightHanded, &OutGlovePositionContainer, &OutGloveRotationContainer); OutGlovePosition = MoveTemp(OutGlovePositionContainer.Vector); OutGloveRotation = OutGloveRotationContainer.Quat.Rotator(); } void USGNovaGlove::CalculateWristLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, FVector& OutWristPosition, FQuat& OutWristRotation) { FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutWristPositionContainer; FSGIC_FQuat OutWristRotationContainer; SGCoreImpl_FSGNovaGloveImpl_CalculateWristLocation( &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, bRightHanded, &OutWristPositionContainer, &OutWristRotationContainer); OutWristPosition = MoveTemp(OutWristPositionContainer.Vector); OutWristRotation = MoveTemp(OutWristRotationContainer.Quat); } void USGNovaGlove::CalculateWristLocation(const FVector& ReferencePosition, const FRotator& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, FVector& OutWristPosition, FRotator& OutWristRotation) { FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation.Quaternion()}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutWristPositionContainer; FSGIC_FQuat OutWristRotationContainer; SGCoreImpl_FSGNovaGloveImpl_CalculateWristLocation( &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, bRightHanded, &OutWristPositionContainer, &OutWristRotationContainer); OutWristPosition = MoveTemp(OutWristPositionContainer.Vector); OutWristRotation = OutWristRotationContainer.Quat.Rotator(); } FString USGNovaGlove::ToBytes(const USGThumperCommand* ThumperCommand) { FSGIC_FSGThumperCommandImpl ThumperCommandContainer{ThumperCommand->ToThumperCommandImpl()}; FSGIC_FString OutBytesContainer; SGCoreImpl_FSGNovaGloveImpl_ToBytes_ThumperCommand(&OutBytesContainer, &ThumperCommandContainer); return MoveTemp(OutBytesContainer.String);; } FString USGNovaGlove::ToBytes(const USGForceFeedbackCommand* ForceFeedbackCommand) { FSGIC_FSGForceFeedbackCommandImpl ForceFeedbackCommandContainer{ ForceFeedbackCommand->ToForceFeedbackCommandImpl().Get()}; FSGIC_FString OutBytesContainer; SGCoreImpl_FSGNovaGloveImpl_ToBytes_ForceFeedbackCommand(&OutBytesContainer, &ForceFeedbackCommandContainer); return MoveTemp(OutBytesContainer.String);; } FString USGNovaGlove::ToBytes(const USGBuzzCommand* BuzzCommand) { FSGIC_FSGBuzzCommandImpl BuzzCommandContainer{BuzzCommand->ToBuzzCommandImpl().Get()}; FSGIC_FString OutBytesContainer; SGCoreImpl_FSGNovaGloveImpl_ToBytes_BuzzCommand(&OutBytesContainer, &BuzzCommandContainer); return MoveTemp(OutBytesContainer.String);; } USGNovaGlove::USGNovaGlove() : USGHapticGlove(), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer; SGCoreImpl_FSGSenseGloveImpl_ctor_MakeShared(&OutSharedPtrContainer); SetSGDeviceImpl(OutSharedPtrContainer.Ptr.ToSharedRef()); Pimpl->SyncUProperties(); } USGNovaGlove::USGNovaGlove(const USGNovaGloveInfo& DeviceInfo) : USGHapticGlove(), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer; FSGIC_FSGNovaGloveInfoImpl DeviceInfoContainer{DeviceInfo.ToNovaGloveInfoImpl()}; SGCoreImpl_FSGSenseGloveImpl_ctor_Model_MakeShared(&OutSharedPtrContainer, &DeviceInfoContainer); SetSGDeviceImpl(OutSharedPtrContainer.Ptr.ToSharedRef()); Pimpl->SyncUProperties(); } USGNovaGlove::USGNovaGlove(const FSGDeviceImpl& SGDeviceImpl) : USGHapticGlove(SGDeviceImpl), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->SyncUProperties(); } USGNovaGlove::USGNovaGlove(const FSGHapticGloveImpl& HapticGloveImpl) : USGHapticGlove(HapticGloveImpl), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->SyncUProperties(); } USGNovaGlove::USGNovaGlove(const FSGNovaGloveImpl& NovaGloveImpl) : USGHapticGlove(NovaGloveImpl), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->SyncUProperties(); } USGNovaGlove::USGNovaGlove(const TSharedRef SGDeviceImpl) : USGHapticGlove(SGDeviceImpl), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->SyncUProperties(); } USGNovaGlove::USGNovaGlove(const TSharedRef HapticGloveImpl) : USGHapticGlove(HapticGloveImpl), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->SyncUProperties(); } USGNovaGlove::USGNovaGlove(const TSharedRef NovaGloveImpl) : USGHapticGlove(NovaGloveImpl), #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->SyncUProperties(); } USGNovaGlove::~USGNovaGlove() = default; TSharedRef USGNovaGlove::ToNovaGloveImpl() const { SyncImplObject(); return FSGDeviceImplCast::ToNovaGloveImpl(ToSGDeviceImpl()); } void USGNovaGlove::SyncImplObject() const { Super::SyncImplObject(); Pimpl->SyncImplObject(); } void USGNovaGlove::SyncUProperties() { Super::SyncUProperties(); Pimpl->SyncUProperties(); } ESGDeviceType USGNovaGlove::GetDeviceType() const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_ESGDeviceType OutTypeContainer; SGCoreImpl_FSGNovaGloveImpl_GetDeviceType(&InstanceContainer, &OutTypeContainer); return OutTypeContainer.Type; } FString USGNovaGlove::GetDeviceId() const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FString OutIdContainer; SGCoreImpl_FSGNovaGloveImpl_GetDeviceId(&InstanceContainer, &OutIdContainer); return MoveTemp(OutIdContainer.String); } FString USGNovaGlove::GetHardwareVersion() const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FString OutVersionContainer; SGCoreImpl_FSGNovaGloveImpl_GetHardwareVersion(&InstanceContainer, &OutVersionContainer); return MoveTemp(OutVersionContainer.String); } int32 USGNovaGlove::GetFirmwareVersion() const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; return SGCoreImpl_FSGNovaGloveImpl_GetFirmwareVersion(&InstanceContainer); } int32 USGNovaGlove::GetSubFirmwareVersion() const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; return SGCoreImpl_FSGNovaGloveImpl_GetSubFirmwareVersion(&InstanceContainer); } bool USGNovaGlove::HasBattery() const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; return SGCoreImpl_FSGNovaGloveImpl_HasBattery(&InstanceContainer); } bool USGNovaGlove::IsCharging() { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_IsCharging(&InstanceContainer); SyncUProperties(); return bResult; } bool USGNovaGlove::GetBatteryLevel(float& OutBatteryLevel) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetBatteryLevel(&InstanceContainer, &OutBatteryLevel); SyncUProperties(); return bResult; } bool USGNovaGlove::GetSensorData(UObject* Outer, USGNovaGloveSensorData*& OutSensorData) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGNovaGloveSensorDataImpl OutSensorDataContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetSensorData(&InstanceContainer, &OutSensorDataContainer); if (bResult) { OutSensorData = USGNovaGloveSensorData::NewNovaGloveSensorData( Outer, MoveTemp(OutSensorDataContainer.NovaGloveSensorDataImpl)); } return bResult; } bool USGNovaGlove::GetImuRotation(FQuat& OutImu) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FQuat OutImuContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetImuRotation(&InstanceContainer, &OutImuContainer); SyncUProperties(); if (bResult) { OutImu = MoveTemp(OutImuContainer.Quat); } return bResult; } bool USGNovaGlove::GetImuRotation(FRotator& OutImu) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FQuat OutImuContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetImuRotation(&InstanceContainer, &OutImuContainer); SyncUProperties(); if (bResult) { OutImu = OutImuContainer.Quat.Rotator(); } return bResult; } bool USGNovaGlove::GetHandPose( UObject* Outer, const USGBasicHandModel* HandModel, const USGNovaGloveHandProfile* Profile, USGHandPose*& OutHandPose) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGBasicHandModelImpl HandModelContainer{HandModel->ToBasicHandModelImpl()}; FSGIC_FSGNovaGloveHandProfileImpl ProfileContainer{Profile->ToNovaGloveHandProfileImpl()}; FSGIC_FSGHandPoseImpl OutHandPoseContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetHandPose_HandModel_Profile_OutHandPose( &InstanceContainer, &HandModelContainer, &ProfileContainer, &OutHandPoseContainer); SyncUProperties(); if (bResult) { OutHandPose = USGHandPose::NewHandPose(Outer, MoveTemp(OutHandPoseContainer.HandPoseImpl)); } return bResult; } bool USGNovaGlove::GetHandPose(UObject* Outer, const USGBasicHandModel* HandGeometry, const USGHandProfile* HandProfile, USGHandPose*& OutHandPose) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGBasicHandModelImpl HandGeometryContainer{HandGeometry->ToBasicHandModelImpl()}; FSGIC_FSGHandProfileImpl ProfileContainer{HandProfile->ToHandProfileImpl()}; FSGIC_FSGHandPoseImpl OutHandPoseContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetHandPose_HandGeometry_HandProfile_OutHandPose( &InstanceContainer, &HandGeometryContainer, &ProfileContainer, &OutHandPoseContainer); SyncUProperties(); if (bResult) { OutHandPose = USGHandPose::NewHandPose(Outer, MoveTemp(OutHandPoseContainer.HandPoseImpl)); } return bResult; } bool USGNovaGlove::GetHandPose(UObject* Outer, const USGHandProfile* HandProfile, USGHandPose*& OutHandPose) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGHandProfileImpl ProfileContainer{HandProfile->ToHandProfileImpl()}; FSGIC_FSGHandPoseImpl OutHandPoseContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetHandPose_HandProfile_OutHandPose( &InstanceContainer, &ProfileContainer, &OutHandPoseContainer); SyncUProperties(); if (bResult) { OutHandPose = USGHandPose::NewHandPose(Outer, MoveTemp(OutHandPoseContainer.HandPoseImpl)); } return bResult; } void USGNovaGlove::SendHaptics(const USGForceFeedbackCommand* ForceFeedbackCommand, const USGBuzzCommand* BuzzCommand, const USGThumperCommand* ThumperCommand) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGForceFeedbackCommandImpl ForceFeedbackCommandContainer{ ForceFeedbackCommand->ToForceFeedbackCommandImpl().Get()}; FSGIC_FSGBuzzCommandImpl BuzzCommandContainer{BuzzCommand->ToBuzzCommandImpl().Get()}; FSGIC_FSGThumperCommandImpl ThumperCommandContainer{ThumperCommand->ToThumperCommandImpl()}; SGCoreImpl_FSGNovaGloveImpl_SendHaptics_ForceFeedbackCommand_BuzzCommand_ThumperCommand( &InstanceContainer, &ForceFeedbackCommandContainer, &BuzzCommandContainer, &ThumperCommandContainer); SyncUProperties(); } void USGNovaGlove::SendHaptics(const USGForceFeedbackCommand* ForceFeedbackCommand) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGForceFeedbackCommandImpl ForceFeedbackCommandContainer{ ForceFeedbackCommand->ToForceFeedbackCommandImpl().Get()}; SGCoreImpl_FSGNovaGloveImpl_SendHaptics_ForceFeedbackCommand(&InstanceContainer, &ForceFeedbackCommandContainer); SyncUProperties(); } void USGNovaGlove::SendHaptics(const USGBuzzCommand* BuzzCommand) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGBuzzCommandImpl BuzzCommandContainer{BuzzCommand->ToBuzzCommandImpl().Get()}; SGCoreImpl_FSGNovaGloveImpl_SendHaptics_ForceFeedbackCommand(&InstanceContainer, &BuzzCommandContainer); SyncUProperties(); } void USGNovaGlove::SendHaptics(const USGThumperCommand* ThumperCommand) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGThumperCommandImpl ThumperCommandContainer{ThumperCommand->ToThumperCommandImpl()}; SGCoreImpl_FSGNovaGloveImpl_SendHaptics_ForceFeedbackCommand(&InstanceContainer, &ThumperCommandContainer); SyncUProperties(); } bool USGNovaGlove::GetCalibrationValues(TArray& OutValues) { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_TArray_FVector OutValuesContainer; const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetCalibrationValues_OutValues( &InstanceContainer, &OutValuesContainer); SyncUProperties(); if (bResult) { OutValues = MoveTemp(OutValuesContainer.Array); } return bResult; } void USGNovaGlove::ApplyCalibration(UObject* Outer, USGHandProfile*& OutProfile) const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGHandProfileImpl OutProfileContainer; SGCoreImpl_FSGNovaGloveImpl_ApplyCalibration_HandProfile(&InstanceContainer, &OutProfileContainer); OutProfile = USGHandProfile::NewHandProfile(Outer, MoveTemp(OutProfileContainer.HandProfileImpl)); } void USGNovaGlove::ApplyCalibration(UObject* Outer, USGNovaGloveHandProfile*& OutProfile) const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FSGNovaGloveHandProfileImpl OutProfileContainer; SGCoreImpl_FSGNovaGloveImpl_ApplyCalibration_NovaGloveHandProfile(&InstanceContainer, &OutProfileContainer); OutProfile = USGNovaGloveHandProfile::NewNovaGloveHandProfile( Outer, MoveTemp(OutProfileContainer.NovaGloveHandProfileImpl)); } void USGNovaGlove::GetGloveLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, FVector& OutGlovePosition, FQuat& OutGloveRotation) const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutGlovePositionContainer; FSGIC_FQuat OutGloveRotationContainer; SGCoreImpl_FSGNovaGloveImpl_GetGloveLocation( &InstanceContainer, &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, &OutGlovePositionContainer, &OutGloveRotationContainer); OutGlovePosition = MoveTemp(OutGlovePositionContainer.Vector); OutGloveRotation = MoveTemp(OutGloveRotationContainer.Quat); } void USGNovaGlove::GetGloveLocation(const FVector& ReferencePosition, const FRotator& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, FVector& OutGlovePosition, FRotator& OutGloveRotation) const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation.Quaternion()}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutGlovePositionContainer; FSGIC_FQuat OutGloveRotationContainer; SGCoreImpl_FSGNovaGloveImpl_GetGloveLocation( &InstanceContainer, &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, &OutGlovePositionContainer, &OutGloveRotationContainer); OutGlovePosition = MoveTemp(OutGlovePositionContainer.Vector); OutGloveRotation = OutGloveRotationContainer.Quat.Rotator(); } void USGNovaGlove::GetWristLocation(const FVector& ReferencePosition, const FQuat& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, FVector& OutWristPosition, FQuat& OutWristRotation) const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutWristPositionContainer; FSGIC_FQuat OutWristRotationContainer; SGCoreImpl_FSGNovaGloveImpl_GetWristLocation( &InstanceContainer, &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, &OutWristPositionContainer, &OutWristRotationContainer); OutWristPosition = MoveTemp(OutWristPositionContainer.Vector); OutWristRotation = MoveTemp(OutWristRotationContainer.Quat); } void USGNovaGlove::GetWristLocation(const FVector& ReferencePosition, const FRotator& ReferenceRotation, const ESGPositionalTrackingHardware TrackingHardware, FVector& OutWristPosition, FRotator& OutWristRotation) const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FVector ReferencePositionContainer{ReferencePosition}; FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation.Quaternion()}; FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; FSGIC_FVector OutWristPositionContainer; FSGIC_FQuat OutWristRotationContainer; SGCoreImpl_FSGNovaGloveImpl_GetWristLocation( &InstanceContainer, &ReferencePositionContainer, &ReferenceRotationContainer, &TrackingHardwareContainer, &OutWristPositionContainer, &OutWristRotationContainer); OutWristPosition = MoveTemp(OutWristPositionContainer.Vector); OutWristRotation = OutWristRotationContainer.Quat.Rotator(); } FString USGNovaGlove::ToString() const { SyncImplObject(); FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()}; FSGIC_FString OutStringContainer; SGCoreImpl_FSGNovaGloveImpl_ToString(&InstanceContainer, &OutStringContainer); return MoveTemp(OutStringContainer.String);; } USGNovaGlove::FImpl::FImpl(USGNovaGlove* InOwner) : Owner(InOwner) { } USGNovaGlove::FImpl::~FImpl() = default; void USGNovaGlove::FImplDeleter::operator()(const FImpl* P) const { delete P; } void USGNovaGlove::FImpl::SyncUProperties() { } void USGNovaGlove::FImpl::SyncImplObject() { }