Files
Plugin/Source/SenseGloveCore/Private/SGCore/SGNovaGlove.cpp
T

665 lines
27 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 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/SGNovaGloveHandProfile.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"
USGNovaGlove* USGNovaGlove::NewNovaGlove(UObject* Outer, const FSGNovaGloveImpl& NovaGloveImpl)
{
USGNovaGlove* Instance = NewObject<USGNovaGlove>(Outer);
Instance->SetSGDeviceImpl(NovaGloveImpl);
return Instance;
}
USGNovaGlove* USGNovaGlove::NewNovaGlove(UObject* Outer, TSharedRef<FSGNovaGloveImpl> NovaGloveImpl)
{
USGNovaGlove* Instance = NewObject<USGNovaGlove>(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*> USGNovaGlove::GetNovaGloves(UObject* Outer)
{
FSGIC_TArray_FSGNovaGloveImpl OutGlovesContainer;
SGCoreImpl_FSGNovaGloveImpl_GetNovaGloves(&OutGlovesContainer);
TArray<USGNovaGlove*> 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<FVector> 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<FVector>& MinValues, const TArray<FVector>& 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()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer;
SGCoreImpl_FSGSenseGloveImpl_ctor_MakeShared(&OutSharedPtrContainer);
SetSGDeviceImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGNovaGlove::USGNovaGlove(const USGNovaGloveInfo& DeviceInfo)
: USGHapticGlove()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer;
FSGIC_FSGNovaGloveInfoImpl DeviceInfoContainer{DeviceInfo.ToNovaGloveInfoImpl()};
SGCoreImpl_FSGSenseGloveImpl_ctor_Model_MakeShared(&OutSharedPtrContainer, &DeviceInfoContainer);
SetSGDeviceImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGNovaGlove::USGNovaGlove(const FSGDeviceImpl& SGDeviceImpl)
: USGHapticGlove(SGDeviceImpl)
{
}
USGNovaGlove::USGNovaGlove(const FSGHapticGloveImpl& HapticGloveImpl)
: USGHapticGlove(HapticGloveImpl)
{
}
USGNovaGlove::USGNovaGlove(const FSGNovaGloveImpl& NovaGloveImpl)
: USGHapticGlove(NovaGloveImpl)
{
}
USGNovaGlove::USGNovaGlove(const TSharedRef<FSGDeviceImpl> SGDeviceImpl)
: USGHapticGlove(SGDeviceImpl)
{
}
USGNovaGlove::USGNovaGlove(const TSharedRef<FSGHapticGloveImpl> HapticGloveImpl)
: USGHapticGlove(HapticGloveImpl)
{
}
USGNovaGlove::USGNovaGlove(const TSharedRef<FSGNovaGloveImpl> NovaGloveImpl)
: USGHapticGlove(NovaGloveImpl)
{
}
USGNovaGlove::~USGNovaGlove() = default;
TSharedRef<FSGNovaGloveImpl> USGNovaGlove::ToNovaGloveImpl() const
{
return FSGDeviceImplCast::ToNovaGloveImpl(ToSGDeviceImpl());
}
ESGDeviceType USGNovaGlove::GetDeviceType() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_ESGDeviceType OutTypeContainer;
SGCoreImpl_FSGNovaGloveImpl_GetDeviceType(&InstanceContainer, &OutTypeContainer);
return OutTypeContainer.Type;
}
FString USGNovaGlove::GetDeviceId() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FString OutIdContainer;
SGCoreImpl_FSGNovaGloveImpl_GetDeviceId(&InstanceContainer, &OutIdContainer);
return MoveTemp(OutIdContainer.String);
}
FString USGNovaGlove::GetHardwareVersion() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FString OutVersionContainer;
SGCoreImpl_FSGNovaGloveImpl_GetHardwareVersion(&InstanceContainer, &OutVersionContainer);
return MoveTemp(OutVersionContainer.String);
}
int32 USGNovaGlove::GetFirmwareVersion() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_GetFirmwareVersion(&InstanceContainer);
}
int32 USGNovaGlove::GetSubFirmwareVersion() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_GetSubFirmwareVersion(&InstanceContainer);
}
bool USGNovaGlove::HasBattery() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_HasBattery(&InstanceContainer);
}
bool USGNovaGlove::IsCharging()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_IsCharging(&InstanceContainer);
return bResult;
}
bool USGNovaGlove::GetBatteryLevel(float& OutBatteryLevel)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetBatteryLevel(&InstanceContainer, &OutBatteryLevel);
return bResult;
}
bool USGNovaGlove::GetSensorData(UObject* Outer, USGNovaGloveSensorData*& OutSensorData)
{
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)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FQuat OutImuContainer;
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetImuRotation(&InstanceContainer, &OutImuContainer);
if (bResult)
{
OutImu = MoveTemp(OutImuContainer.Quat);
}
return bResult;
}
bool USGNovaGlove::GetImuRotation(FRotator& OutImu)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FQuat OutImuContainer;
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetImuRotation(&InstanceContainer, &OutImuContainer);
if (bResult)
{
OutImu = OutImuContainer.Quat.Rotator();
}
return bResult;
}
bool USGNovaGlove::GetHandPose(
UObject* Outer, const USGBasicHandModel* HandModel, const USGNovaGloveHandProfile* Profile,
USGHandPose*& OutHandPose)
{
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);
if (bResult)
{
OutHandPose = USGHandPose::NewHandPose(Outer, MoveTemp(OutHandPoseContainer.HandPoseImpl));
}
return bResult;
}
bool USGNovaGlove::GetHandPose(UObject* Outer, const USGBasicHandModel* HandGeometry, const USGHandProfile* HandProfile,
USGHandPose*& OutHandPose)
{
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);
if (bResult)
{
OutHandPose = USGHandPose::NewHandPose(Outer, MoveTemp(OutHandPoseContainer.HandPoseImpl));
}
return bResult;
}
bool USGNovaGlove::GetHandPose(UObject* Outer, const USGHandProfile* HandProfile, USGHandPose*& OutHandPose)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGHandProfileImpl ProfileContainer{HandProfile->ToHandProfileImpl()};
FSGIC_FSGHandPoseImpl OutHandPoseContainer;
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetHandPose_HandProfile_OutHandPose(
&InstanceContainer, &ProfileContainer, &OutHandPoseContainer);
if (bResult)
{
OutHandPose = USGHandPose::NewHandPose(Outer, MoveTemp(OutHandPoseContainer.HandPoseImpl));
}
return bResult;
}
void USGNovaGlove::SendHaptics(const USGForceFeedbackCommand* ForceFeedbackCommand,
const USGBuzzCommand* BuzzCommand,
const USGThumperCommand* ThumperCommand)
{
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);
}
void USGNovaGlove::SendHaptics(const USGForceFeedbackCommand* ForceFeedbackCommand)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGForceFeedbackCommandImpl ForceFeedbackCommandContainer{
ForceFeedbackCommand->ToForceFeedbackCommandImpl().Get()};
SGCoreImpl_FSGNovaGloveImpl_SendHaptics_ForceFeedbackCommand(&InstanceContainer, &ForceFeedbackCommandContainer);
}
void USGNovaGlove::SendHaptics(const USGBuzzCommand* BuzzCommand)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGBuzzCommandImpl BuzzCommandContainer{BuzzCommand->ToBuzzCommandImpl().Get()};
SGCoreImpl_FSGNovaGloveImpl_SendHaptics_ForceFeedbackCommand(&InstanceContainer, &BuzzCommandContainer);
}
void USGNovaGlove::SendHaptics(const USGThumperCommand* ThumperCommand)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGThumperCommandImpl ThumperCommandContainer{ThumperCommand->ToThumperCommandImpl()};
SGCoreImpl_FSGNovaGloveImpl_SendHaptics_ForceFeedbackCommand(&InstanceContainer, &ThumperCommandContainer);
}
bool USGNovaGlove::GetCalibrationValues(TArray<FVector>& OutValues)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_TArray_FVector OutValuesContainer;
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetCalibrationValues_OutValues(
&InstanceContainer, &OutValuesContainer);
if (bResult)
{
OutValues = MoveTemp(OutValuesContainer.Array);
}
return bResult;
}
void USGNovaGlove::ApplyCalibration(UObject* Outer, USGHandProfile*& OutProfile) const
{
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
{
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
{
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
{
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
{
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
{
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
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FString OutStringContainer;
SGCoreImpl_FSGNovaGloveImpl_ToString(&InstanceContainer, &OutStringContainer);
return MoveTemp(OutStringContainer.String);;
}