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

781 lines
30 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2024 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 "SGCore/SGBasicHandModel.h"
#include "SGCore/SGCustomWaveform.h"
#include "SGCore/SGDeviceImplCast.h"
#include "SGCore/SGHandInterpolator.h"
#include "SGCore/SGHandPose.h"
#include "SGCore/SGNovaGloveInfo.h"
#include "SGCore/SGNovaGloveSensorData.h"
#include "SGCore/SGSensorNormalization.h"
#include "SGCore/SGThresholdCommand.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_ESGHapticGloveCalibrationState.h"
#include "SGInterop/SGIC_ESGHapticLocation.h"
#include "SGInterop/SGIC_ESGNovaVibroMotor.h"
#include "SGInterop/SGIC_ESGPositionalTrackingHardware.h"
#include "SGInterop/SGIC_FQuat.h"
#include "SGInterop/SGIC_FSGBasicHandModelImpl.h"
#include "SGInterop/SGIC_FSGCustomWaveformImpl.h"
#include "SGInterop/SGIC_FSGHandInterpolatorImpl.h"
#include "SGInterop/SGIC_FSGHandPoseImpl.h"
#include "SGInterop/SGIC_FSGNovaGloveImpl.h"
#include "SGInterop/SGIC_FSGNovaGloveInfoImpl.h"
#include "SGInterop/SGIC_FSGNovaGloveSensorDataImpl.h"
#include "SGInterop/SGIC_FSGSensorNormalizationImpl.h"
#include "SGInterop/SGIC_FSGThresholdCommandImpl.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_TArray_TArray_FVector.h"
#include "SGInterop/SGIC_TArray_float.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_FSGNovaGloveImpl_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_FSGNovaGloveImpl_ctor_DeviceInfo_MakeShared(&OutSharedPtrContainer, &DeviceInfoContainer);
return NewNovaGlove(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGDevice* USGNovaGlove::Parse(UObject* Outer, const FString& ConstantsString)
{
FSGIC_FSGNovaGloveImpl OutNovaGloveImplContainer;
FSGIC_FString ConstantsStringContainer{ConstantsString};
SGCoreImpl_FSGNovaGloveImpl_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 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;
}
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();
}
ANSICHAR USGNovaGlove::GetHapticsByte()
{
return SGCoreImpl_FSGNovaGloveImpl_GetHapticsByte();
}
ANSICHAR USGNovaGlove::GetThresholdsByte()
{
return SGCoreImpl_FSGNovaGloveImpl_GetThresholdsByte();
}
ANSICHAR USGNovaGlove::GetIgnoreThresholdsByte()
{
return SGCoreImpl_FSGNovaGloveImpl_GetIgnoreThresholdsByte();
}
TArray<float> USGNovaGlove::GetNovaSensorRanges()
{
FSGIC_TArray_float OutNovaSensorRangesContainer;
SGCoreImpl_FSGNovaGloveImpl_GetNovaSensorRanges(&OutNovaSensorRangesContainer);
return OutNovaSensorRangesContainer.Array;
}
TArray<float> USGNovaGlove::ToNormalizedValues(const USGNovaGloveSensorData* SensorData)
{
FSGIC_TArray_float OutNormalizedValuesContainer;
FSGIC_FSGNovaGloveSensorDataImpl SensorDataContainer{SensorData->ToNovaGloveSensorDataImpl()};
SGCoreImpl_FSGNovaGloveImpl_ToNormalizedValues_SensorData(
&OutNormalizedValuesContainer, &SensorDataContainer);
return OutNormalizedValuesContainer.Array;
}
TArray<float> USGNovaGlove::ToNormalizedValues(
UObject* Outer, const USGNovaGloveSensorData* SensorData, USGSensorNormalization*& OutSensorNormalizer)
{
FSGIC_TArray_float OutNormalizedValuesContainer;
FSGIC_FSGNovaGloveSensorDataImpl SensorDataContainer{SensorData->ToNovaGloveSensorDataImpl()};
FSGIC_FSGSensorNormalizationImpl OutSensorNormalizerContainer;
SGCoreImpl_FSGNovaGloveImpl_ToNormalizedValues_SensorData_OutSensorNormalizer(
&OutNormalizedValuesContainer, &SensorDataContainer, &OutSensorNormalizerContainer);
OutSensorNormalizer = USGSensorNormalization::NewSensorNormalization(
Outer, MoveTemp(OutSensorNormalizerContainer.SensorNormalizationImpl));
return OutNormalizedValuesContainer.Array;
}
TArray<TArray<FVector>> USGNovaGlove::CalculateHandAngles(
const TArray<float>& NormalizedValues, const USGHandInterpolator* Interpolator)
{
FSGIC_TArray_TArray_FVector OutHandAnglesContainer;
FSGIC_TArray_float NormalizedValuesContainer{NormalizedValues};
FSGIC_FSGHandInterpolatorImpl InterpolatorContainer{Interpolator->ToHandInterpolatorImpl()};
SGCoreImpl_FSGNovaGloveImpl_CalculateHandAngles(
&OutHandAnglesContainer, &NormalizedValuesContainer, &InterpolatorContainer);
return OutHandAnglesContainer.Array;
}
FString USGNovaGlove::ToNovaCommandAsFlexion(const USGThresholdCommand* Thresholds)
{
FSGIC_FString OutStringContainer;
FSGIC_FSGThresholdCommandImpl ThresholdsContainer{Thresholds->ToThresholdCommandImpl()};
SGCoreImpl_FSGNovaGloveImpl_ToNovaCommandAsFlexion(&OutStringContainer, &ThresholdsContainer);
return OutStringContainer.String;
}
FString USGNovaGlove::ToNovaCommandAsRaw(
const USGThresholdCommand* Thresholds, const USGSensorNormalization* Interpolator)
{
FSGIC_FString OutStringContainer;
FSGIC_FSGThresholdCommandImpl ThresholdsContainer{Thresholds->ToThresholdCommandImpl()};
FSGIC_FSGSensorNormalizationImpl InterpolatorContainer{Interpolator->ToSensorNormalizationImpl()};
SGCoreImpl_FSGNovaGloveImpl_ToNovaCommandAsRaw(
&OutStringContainer, &ThresholdsContainer, &InterpolatorContainer);
return OutStringContainer.String;
}
USGNovaGlove::USGNovaGlove()
: USGHapticGlove()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer;
SGCoreImpl_FSGNovaGloveImpl_ctor_MakeShared(&OutSharedPtrContainer);
SetSGDeviceImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGNovaGlove::USGNovaGlove(const USGNovaGloveInfo& DeviceInfo)
: USGHapticGlove()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl OutSharedPtrContainer;
FSGIC_FSGNovaGloveInfoImpl DeviceInfoContainer{DeviceInfo.ToNovaGloveInfoImpl()};
SGCoreImpl_FSGNovaGloveImpl_ctor_DeviceInfo_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 OutIdContainer.String;
}
FString USGNovaGlove::GetHardwareVersion() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FString OutVersionContainer;
SGCoreImpl_FSGNovaGloveImpl_GetHardwareVersion(&InstanceContainer, &OutVersionContainer);
return 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);
}
void USGNovaGlove::SetDeviceIndex(int32 NewIndex)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_SetDeviceIndex(&InstanceContainer, NewIndex);
}
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::IsRight() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_IsRight(&InstanceContainer);
}
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* HandGeometry, USGHandPose*& OutHandPose) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGBasicHandModelImpl HandModelContainer{HandGeometry->ToBasicHandModelImpl()};
FSGIC_FSGHandPoseImpl OutHandPoseContainer;
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetHandPose(
&InstanceContainer, &HandModelContainer, &OutHandPoseContainer);
if (bResult)
{
OutHandPose = USGHandPose::NewHandPose(Outer, MoveTemp(OutHandPoseContainer.HandPoseImpl));
}
return bResult;
}
bool USGNovaGlove::GetHandAngles(TArray<TArray<FVector>>& OutHandAngles) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_TArray_TArray_FVector OutHandAnglesContainer;
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetHandAngles(&InstanceContainer, &OutHandAnglesContainer);
OutHandAngles = MoveTemp(OutHandAnglesContainer.Array);
return bResult;
}
ESGHapticGloveCalibrationState USGNovaGlove::GetCalibrationState() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_ESGHapticGloveCalibrationState OutHapticGloveCalibrationStateContainer;
SGCoreImpl_FSGNovaGloveImpl_GetCalibrationState(&InstanceContainer, &OutHapticGloveCalibrationStateContainer);
return OutHapticGloveCalibrationStateContainer.State;
}
void USGNovaGlove::EndCalibration()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
SGCoreImpl_FSGNovaGloveImpl_EndCalibration(&InstanceContainer);
}
void USGNovaGlove::ResetCalibration()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
SGCoreImpl_FSGNovaGloveImpl_ResetCalibration(&InstanceContainer);
}
void USGNovaGlove::StopHaptics()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
SGCoreImpl_FSGNovaGloveImpl_StopHaptics(&InstanceContainer);
}
void USGNovaGlove::StopVibrations()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
SGCoreImpl_FSGNovaGloveImpl_StopVibrations(&InstanceContainer);
}
bool USGNovaGlove::SendHaptics()
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_SendHaptics(&InstanceContainer);
}
bool USGNovaGlove::SupportsCustomWaveform(ESGHapticLocation AtLocation) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_SendHaptics(&InstanceContainer);
}
bool USGNovaGlove::SendCustomWaveform(USGCustomWaveform* OutWaveform, ESGHapticLocation Location)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_SendHaptics(&InstanceContainer);
}
bool USGNovaGlove::QueueForceFeedbackLevels(const TArray<float>& Levels01)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_TArray_float Levels01Container{Levels01};
return SGCoreImpl_FSGNovaGloveImpl_QueueForceFeedbackLevels(&InstanceContainer, &Levels01Container);
}
bool USGNovaGlove::QueueForceFeedbackLevel(const int32 Finger, const float Level01)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_QueueForceFeedbackLevel(&InstanceContainer, Finger, Level01);
}
bool USGNovaGlove::QueueVibroLevels(const TArray<float>& Amplitudes)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_TArray_float AmplitudesContainer{Amplitudes};
return SGCoreImpl_FSGNovaGloveImpl_QueueVibroLevels(&InstanceContainer, &AmplitudesContainer);
}
bool USGNovaGlove::QueueVibroLevel(ESGHapticLocation Location, float Level01)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_ESGHapticLocation LocationContainer{Location};
return SGCoreImpl_FSGNovaGloveImpl_QueueVibroLevel_Localtion_Level01(
&InstanceContainer, &LocationContainer, Level01);
}
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();
}
USGNovaGloveInfo* USGNovaGlove::GetGloveInfo(UObject* Outer) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGNovaGloveInfoImpl OutGloveInfoContainer;
SGCoreImpl_FSGNovaGloveImpl_GetGloveInfo(&InstanceContainer, &OutGloveInfoContainer);
return USGNovaGloveInfo::NewNovaGloveInfo(Outer, MoveTemp(OutGloveInfoContainer.NovaGloveInfoImpl));
}
bool USGNovaGlove::SupportsThresholds() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_SupportsThresholds(&InstanceContainer);
}
bool USGNovaGlove::SupportsCustomWaveforms() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_SupportsCustomWaveforms(&InstanceContainer);
}
bool USGNovaGlove::SupportsOnBoardNormalization() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_SupportsOnBoardNormalization(&InstanceContainer);
}
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::GetNormalizedInput(TArray<float>& OutNormalizedValues) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_TArray_float OutNormalizedValuesContainer;
const bool bResult = SGCoreImpl_FSGNovaGloveImpl_GetNormalizedInput(
&InstanceContainer, &OutNormalizedValuesContainer);
if (bResult)
{
OutNormalizedValues = MoveTemp(OutNormalizedValuesContainer.Array);
}
return bResult;
}
FString USGNovaGlove::ToNovaCommand(
const TArray<float>& ForceFeedbackLevels, const TArray<float>& BuzzLevels, float WristLevel) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FString OutStringContainer;
FSGIC_TArray_float ForceFeedbackLevelsContainer{ForceFeedbackLevels};
FSGIC_TArray_float BuzzLevelsContainer{BuzzLevels};
SGCoreImpl_FSGNovaGloveImpl_ToNovaCommand(&InstanceContainer, &OutStringContainer,
&ForceFeedbackLevelsContainer, &BuzzLevelsContainer, WristLevel);
return OutStringContainer.String;
}
bool USGNovaGlove::QueueVibroLevel(const int32 Finger, const float Amplitude)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_QueueVibroLevel_Finger_Amplitude(&InstanceContainer, Finger, Amplitude);
}
bool USGNovaGlove::QueueWristLevel(const float Amplitude)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_QueueWristLevel(&InstanceContainer, Amplitude);
}
ESGNovaVibroMotor USGNovaGlove::ToNovaMotor(const ESGHapticLocation Location) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_ESGNovaVibroMotor OutVibroMotorContainer;
FSGIC_ESGHapticLocation LocationContainer{Location};
SGCoreImpl_FSGNovaGloveImpl_ToNovaMotor(&InstanceContainer, &OutVibroMotorContainer, &LocationContainer);
return OutVibroMotorContainer.Motor;
}
int32 USGNovaGlove::ChannelIndex(const ESGNovaVibroMotor Motor) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_ESGNovaVibroMotor MotorContainer{Motor};
return SGCoreImpl_FSGNovaGloveImpl_ChannelIndex(&InstanceContainer, &MotorContainer);
}
void USGNovaGlove::ValidateWaveform(USGCustomWaveform* OutWaveform, const ESGNovaVibroMotor Motor) const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGCustomWaveformImpl OutWaveformContainer{OutWaveform->ToCustomWaveformImpl()};
FSGIC_ESGNovaVibroMotor MotorContainer{Motor};
SGCoreImpl_FSGNovaGloveImpl_ValidateWaveform(&InstanceContainer, &OutWaveformContainer, &MotorContainer);
}
bool USGNovaGlove::SendCustomWaveform_Nova(
USGCustomWaveform* OutWaveform, const ESGNovaVibroMotor Motor, const bool bValidateWaveform)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FSGCustomWaveformImpl OutWaveformContainer{OutWaveform->ToCustomWaveformImpl()};
FSGIC_ESGNovaVibroMotor MotorContainer{Motor};
return SGCoreImpl_FSGNovaGloveImpl_SendCustomWaveform_Nova(
&InstanceContainer, &OutWaveformContainer, &MotorContainer, bValidateWaveform);
}
bool USGNovaGlove::QueueThresholdCommand_Flexion(const int32 Finger, const float FlexionThreshold)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_QueueThresholdCommand_Flexion(&InstanceContainer, Finger, FlexionThreshold);
}
bool USGNovaGlove::QueueClearThreshold(const int32 Finger)
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
return SGCoreImpl_FSGNovaGloveImpl_QueueClearThreshold(&InstanceContainer, Finger);
}
FString USGNovaGlove::ToString() const
{
FSGIC_TSharedPtr_FSGNovaGloveImpl InstanceContainer{ToNovaGloveImpl()};
FSGIC_FString OutStringContainer;
SGCoreImpl_FSGNovaGloveImpl_ToString(&InstanceContainer, &OutStringContainer);
return OutStringContainer.String;;
}