Files
Plugin/Source/SenseGloveCoreKismet/Private/SGCoreKismet/SGSenseGloveKismetLibrary.cpp
T

432 lines
17 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2026 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 "SGCoreKismet/SGSenseGloveKismetLibrary.h"
#include "SGCore/SGDevice.h"
#include "SGCore/SGHandInterpolator.h"
#include "SGCore/SGHandPose.h"
#include "SGCore/SGSenseGlove.h"
#include "SGCore/SGSenseGlovePose.h"
#include "SGCore/SGSenseGloveSensorData.h"
#include "SGCore/SGSenseGloveSensorNormalizer.h"
#include "SGUtils/SGArrayUtils.h"
USGDevice* USGSenseGloveKismetLibrary::Parse(UObject* WorldContextObject, const FString& ConstantsString)
{
return USGSenseGlove::Parse(WorldContextObject, ConstantsString);
}
TArray<USGSenseGlove*> USGSenseGloveKismetLibrary::GetSenseGloves(UObject* WorldContextObject)
{
return USGSenseGlove::GetSenseGloves(WorldContextObject);
}
bool USGSenseGloveKismetLibrary::GetSenseGlove_OutG(UObject* WorldContextObject, USGSenseGlove*& OutGlove)
{
return USGSenseGlove::GetSenseGlove(WorldContextObject, OutGlove);
}
bool USGSenseGloveKismetLibrary::GetSenseGlove_bRH_OutG(UObject* WorldContextObject,
const bool bRightHanded, USGSenseGlove*& OutGlove)
{
return USGSenseGlove::GetSenseGlove(WorldContextObject, bRightHanded, OutGlove);
}
void USGSenseGloveKismetLibrary::CalculateGloveLocation_RP_FQuat_RR_TH_bRH_MO_OutGP_FQuat_OutGR(
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const ESGFinger MountedOn,
FVector& OutGlovePosition, FQuat& OutGloveRotation)
{
USGSenseGlove::CalculateGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, MountedOn,
OutGlovePosition, OutGloveRotation);
}
void USGSenseGloveKismetLibrary::CalculateGloveLocation_RP_FRotator_RR_TH_bRH_MO_OutGP_FRotator_OutGR(
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const ESGFinger MountedOn,
FVector& OutGlovePosition, FRotator& OutGloveRotation)
{
USGSenseGlove::CalculateGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, MountedOn,
OutGlovePosition, OutGloveRotation);
}
void USGSenseGloveKismetLibrary::CalculateWristLocation_RP_FQuat_RR_TH_bRH_MO_GWPOffset_FQuat_GWRO_OutWP_FQuat_OutWR(
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const ESGFinger MountedOn,
const FVector& GloveWristPositionOffset, const FQuat& GloveWristRotationOffset,
FVector& OutWristPosition, FQuat& OutWristRotation)
{
USGSenseGlove::CalculateWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, MountedOn,
GloveWristPositionOffset, GloveWristRotationOffset,
OutWristPosition, OutWristRotation);
}
void
USGSenseGloveKismetLibrary::CalculateWristLocation_RP_FRotator_RR_TH_bRH_MO_GWPOffset_FRotator_GWRO_OutWP_FRotator_OutWR(
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const ESGFinger MountedOn,
const FVector& GloveWristPositionOffset, const FRotator& GloveWristRotationOffset,
FVector& OutWristPosition, FRotator& OutWristRotation)
{
USGSenseGlove::CalculateWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, MountedOn,
GloveWristPositionOffset, GloveWristRotationOffset,
OutWristPosition, OutWristRotation);
}
FString USGSenseGloveKismetLibrary::GetHapticsByte()
{
return FString::Printf(TEXT("%c"), USGSenseGlove::GetHapticsByte());
}
FString USGSenseGloveKismetLibrary::GetThumperByte()
{
return FString::Printf(TEXT("%c"), USGSenseGlove::GetThumperByte());
}
FVector USGSenseGloveKismetLibrary::GetDefaultThimbleOffset()
{
return USGSenseGlove::GetDefaultThimbleOffset();
}
USGSenseGlovePose* USGSenseGloveKismetLibrary::CalculateGlovePose_SD_GM(
UObject* WorldContextObject,
const USGSenseGloveSensorData* SensorData, const USGSenseGloveInfo* GloveModel)
{
return USGSenseGlove::CalculateGlovePose(WorldContextObject, SensorData, GloveModel);
}
USGSenseGlovePose* USGSenseGloveKismetLibrary::CalculateGlovePose_GA_GM(
UObject* WorldContextObject,
const TArray<FSGVectorArray>& GloveAngles, const USGSenseGloveInfo* GloveModel)
{
TArray<TArray<FVector>> GloveAnglesNestedArray{
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
};
return USGSenseGlove::CalculateGlovePose(WorldContextObject, MoveTemp(GloveAnglesNestedArray), GloveModel);
}
void USGSenseGloveKismetLibrary::NormalizeValues(
const TArray<FVector>& SumAngles, const USGSenseGloveSensorNormalizer* Normalizer,
TArray<float>& OutFlexions, TArray<float>& OutAbductions)
{
USGSenseGlove::NormalizeValues(SumAngles, Normalizer, OutFlexions, OutAbductions);
}
void USGSenseGloveKismetLibrary::CalculateHandAngles(
const USGSenseGlovePose* GlovePose,
const USGSenseGloveSensorNormalizer* Normalizer, const USGHandInterpolator* NormalizedToAngles,
TArray<FSGVectorArray>& OutHandAngles)
{
TArray<TArray<FVector>> OutHandAnglesArray;
USGSenseGlove::CalculateHandAngles(GlovePose, Normalizer, NormalizedToAngles, OutHandAnglesArray);
TArray<FSGVectorArray> OutHandHandAnglesNestedArray{
FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(OutHandAnglesArray)
};
OutHandAngles = MoveTemp(OutHandHandAnglesNestedArray);
}
void USGSenseGloveKismetLibrary::CalculateHandPose(
UObject* WorldContextObject,
const USGSenseGlovePose* GlovePose, const USGBasicHandModel* HandModel,
const USGSenseGloveSensorNormalizer* Normalizer, const USGHandInterpolator* NormalizedToAngles,
USGHandPose*& OutHandPose)
{
USGSenseGlove::CalculateHandPose(
WorldContextObject,
GlovePose, HandModel, Normalizer, NormalizedToAngles, OutHandPose);
}
ESGDeviceType USGSenseGloveKismetLibrary::GetDeviceType(const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetDeviceType();
}
FString USGSenseGloveKismetLibrary::GetDeviceId(const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetDeviceId();
}
FString USGSenseGloveKismetLibrary::GetHardwareVersion(const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetHardwareVersion();
}
int32 USGSenseGloveKismetLibrary::GetFirmwareVersion(const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetFirmwareVersion();
}
int32 USGSenseGloveKismetLibrary::GetSubFirmwareVersion(const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetSubFirmwareVersion();
}
bool USGSenseGloveKismetLibrary::IsRight(const USGSenseGlove* SenseGlove)
{
return SenseGlove->IsRight();
}
bool USGSenseGloveKismetLibrary::GetImuRotation_FQuat_OutI(USGSenseGlove* SenseGlove, FQuat& OutImu)
{
return SenseGlove->GetImuRotation(OutImu);
}
bool USGSenseGloveKismetLibrary::GetImuRotation_FRotator_OutI(USGSenseGlove* SenseGlove, FRotator& OutImu)
{
return SenseGlove->GetImuRotation(OutImu);
}
bool USGSenseGloveKismetLibrary::GetHandPose(
UObject* WorldContextObject, USGSenseGlove* SenseGlove, const USGBasicHandModel* HandModel,
USGHandPose*& OutHandPose)
{
return SenseGlove->GetHandPose(WorldContextObject, HandModel, OutHandPose);
}
bool USGSenseGloveKismetLibrary::GetHandAngles(const USGSenseGlove* SenseGlove, TArray<FSGVectorArray>& OutHandAngles)
{
TArray<TArray<FVector>> HandAnglesNestedArray;
const bool bResult = SenseGlove->GetHandAngles(HandAnglesNestedArray);
OutHandAngles = FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(MoveTemp(HandAnglesNestedArray));
return bResult;
}
ESGHapticGloveCalibrationState USGSenseGloveKismetLibrary::GetCalibrationState(const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetCalibrationState();
}
void USGSenseGloveKismetLibrary::EndCalibration(USGSenseGlove* SenseGlove)
{
SenseGlove->EndCalibration();
}
void USGSenseGloveKismetLibrary::ResetCalibration(USGSenseGlove* SenseGlove)
{
SenseGlove->ResetCalibration();
}
void USGSenseGloveKismetLibrary::StopHaptics(USGSenseGlove* SenseGlove)
{
SenseGlove->StopHaptics();
}
void USGSenseGloveKismetLibrary::StopVibrations(USGSenseGlove* SenseGlove)
{
SenseGlove->StopVibrations();
}
bool USGSenseGloveKismetLibrary::SendHaptics(USGSenseGlove* SenseGlove)
{
return SenseGlove->SendHaptics();
}
bool USGSenseGloveKismetLibrary::QueueForceFeedbackLevels(USGSenseGlove* SenseGlove, const TArray<float>& Levels01)
{
return SenseGlove->QueueForceFeedbackLevels(Levels01);
}
bool USGSenseGloveKismetLibrary::QueueForceFeedbackLevel(USGSenseGlove* SenseGlove,
const int32 Finger, const float Level01)
{
return SenseGlove->QueueForceFeedbackLevel(Finger, Level01);
}
bool USGSenseGloveKismetLibrary::QueueVibroLevels(USGSenseGlove* SenseGlove, const TArray<float>& Amplitudes)
{
return SenseGlove->QueueVibroLevels(Amplitudes);
}
bool USGSenseGloveKismetLibrary::QueueVibroLevel_L_L(USGSenseGlove* SenseGlove,
const ESGHapticLocation Location, const float Level01)
{
return SenseGlove->QueueVibroLevel(Location, Level01);
}
void USGSenseGloveKismetLibrary::GetGloveLocation_RP_FQuat_RR_TH_OutGP_FQuat_OutGR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutGlovePosition, FQuat& OutGloveRotation)
{
SenseGlove->GetGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutGlovePosition, OutGloveRotation);
}
void USGSenseGloveKismetLibrary::GetGloveLocation_RP_FRotator_RR_TH_OutGP_FRotator_OutGR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutGlovePosition, FRotator& OutGloveRotation)
{
SenseGlove->GetGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutGlovePosition, OutGloveRotation);
}
void USGSenseGloveKismetLibrary::GetGloveLocation_RP_FQuat_RR_TH_MO_OutGP_FQuat_OutGR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const ESGFinger MountedOn,
FVector& OutGlovePosition, FQuat& OutGloveRotation)
{
SenseGlove->GetGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, MountedOn,
OutGlovePosition, OutGloveRotation);
}
void USGSenseGloveKismetLibrary::GetGloveLocation_RP_FRotator_RR_TH_MO_OutGP_FRotator_OutGR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const ESGFinger MountedOn, FVector& OutGlovePosition,
FRotator& OutGloveRotation)
{
SenseGlove->GetGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, MountedOn,
OutGlovePosition, OutGloveRotation);
}
void USGSenseGloveKismetLibrary::GetWristLocation_RP_FQuat_RR_TH_OutWP_FQuat_OutWR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FQuat& OutWristRotation)
{
SenseGlove->GetWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutWristPosition, OutWristRotation);
}
void USGSenseGloveKismetLibrary::GetWristLocation_RP_FRotator_RR_TH_OutWP_FRotator_OutWR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FRotator& OutWristRotation)
{
SenseGlove->GetWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutWristPosition, OutWristRotation);
}
void USGSenseGloveKismetLibrary::GetWristLocation_RP_FQuat_RR_TH_GWPO_FQuat_GWRO_OutWP_FQuat_OutWR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
const FVector& GloveWristPositionOffset, const FQuat& GloveWristRotationOffset,
FVector& OutWristPosition, FQuat& OutWristRotation)
{
SenseGlove->GetWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
GloveWristPositionOffset, GloveWristRotationOffset,
OutWristPosition, OutWristRotation);
}
void USGSenseGloveKismetLibrary::GetWristLocation_RP_FRotator_RR_TH_GWPO_FRotator_GWRO_OutWP_FRotator_OutWR(
const USGSenseGlove* SenseGlove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
const FVector& GloveWristPositionOffset, const FRotator& GloveWristRotationOffset,
FVector& OutWristPosition, FRotator& OutWristRotation)
{
SenseGlove->GetWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
GloveWristPositionOffset, GloveWristRotationOffset,
OutWristPosition, OutWristRotation);
}
USGSenseGloveInfo* USGSenseGloveKismetLibrary::GetGloveInfo(
UObject* WorldContextObject, const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetGloveInfo(WorldContextObject);
}
TArray<FVector> USGSenseGloveKismetLibrary::GetFingerThimbleOffsets(const USGSenseGlove* SenseGlove)
{
return SenseGlove->GetFingerThimbleOffsets();
}
void USGSenseGloveKismetLibrary::SetFingerThimbleOffset(USGSenseGlove* SenseGlove,
const int32 Finger, const FVector& Offset)
{
SenseGlove->SetFingerThimbleOffset(Finger, Offset);
}
bool USGSenseGloveKismetLibrary::SupportsWristActuator(const USGSenseGlove* SenseGlove)
{
return SenseGlove->SupportsWristActuator();
}
bool USGSenseGloveKismetLibrary::GetSensorData(UObject* WorldContextObject, const USGSenseGlove* SenseGlove,
USGSenseGloveSensorData*& OutSensorData)
{
return SenseGlove->GetSensorData(WorldContextObject, OutSensorData);
}
bool USGSenseGloveKismetLibrary::GetGlovePose_OutGP(UObject* WorldContextObject, USGSenseGlove* SenseGlove,
USGSenseGlovePose*& OutGlovePose)
{
return SenseGlove->GetGlovePose(WorldContextObject, OutGlovePose);
}
bool USGSenseGloveKismetLibrary::GetGlovePose_SD_OutGP(
UObject* WorldContextObject, USGSenseGlove* SenseGlove,
const USGSenseGloveSensorData* SensorData, USGSenseGlovePose*& OutGlovePose)
{
return SenseGlove->GetGlovePose(WorldContextObject, SensorData, OutGlovePose);
}
bool USGSenseGloveKismetLibrary::QueueVibroLevel_F_A(USGSenseGlove* SenseGlove, const int32 Finger,
const float Amplitude)
{
return SenseGlove->QueueVibroLevel(Finger, Amplitude);
}
bool USGSenseGloveKismetLibrary::QueueThumperCommand(USGSenseGlove* SenseGlove,
const ESGSenseGloveThumperCommand Command)
{
return SenseGlove->QueueThumperCommand(Command);
}
FString USGSenseGloveKismetLibrary::ToString(const USGSenseGlove* SenseGlove)
{
return SenseGlove->ToString();
}