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

389 lines
14 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 "SGCoreKismet/SGNova2GloveKismetLibrary.h"
#include "SGCore/SGHandPose.h"
#include "SGCore/SGNova2Glove.h"
#include "SGCore/SGNova2GloveSensorData.h"
#include "SGUtils/SGArrayUtils.h"
USGDevice* USGNova2GloveKismetLibrary::Parse(UObject* WorldContextObject, const FString& ConstantsString)
{
return USGNova2Glove::Parse(WorldContextObject, ConstantsString);
}
TArray<USGNova2Glove*> USGNova2GloveKismetLibrary::GetNova2Gloves(UObject* WorldContextObject)
{
return USGNova2Glove::GetNova2Gloves(WorldContextObject);
}
bool USGNova2GloveKismetLibrary::GetNova2Glove_OutG(UObject* WorldContextObject, USGNova2Glove*& OutGlove)
{
return USGNova2Glove::GetNova2Glove(WorldContextObject, OutGlove);
}
bool USGNova2GloveKismetLibrary::GetNova2Glove_bRH_OutG(UObject* WorldContextObject,
const bool bRightHanded, USGNova2Glove*& OutGlove)
{
return USGNova2Glove::GetNova2Glove(WorldContextObject, bRightHanded, OutGlove);
}
void USGNova2GloveKismetLibrary::CalculateGloveLocation_RP_FQuat_RR_TH_bRH_HW_OutGP_OutGR(
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const FString& HardwareVersion,
FVector& OutGlovePosition, FQuat& OutGloveRotation)
{
USGNova2Glove::CalculateGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, HardwareVersion,
OutGlovePosition, OutGloveRotation);
}
void USGNova2GloveKismetLibrary::CalculateGloveLocation_RP_FRotator_RR_TH_bRH_HW_OutGP_OutGR(
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const FString& HardwareVersion,
FVector& OutGlovePosition, FRotator& OutGloveRotation)
{
USGNova2Glove::CalculateGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, HardwareVersion,
OutGlovePosition, OutGloveRotation);
}
void USGNova2GloveKismetLibrary::CalculateWristLocation_RP_FQuat_RR_TH_bRH_HW_OutWP_OutWR(
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const FString& HardwareVersion,
FVector& OutWristPosition, FQuat& OutWristRotation)
{
USGNova2Glove::CalculateWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, HardwareVersion,
OutWristPosition, OutWristRotation);
}
void USGNova2GloveKismetLibrary::CalculateWristLocation_RP_FRotator_RR_TH_bRH_HW_OutWP_OutWR(
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware, const bool bRightHanded, const FString& HardwareVersion,
FVector& OutWristPosition, FRotator& OutWristRotation)
{
USGNova2Glove::CalculateWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware, bRightHanded, HardwareVersion,
OutWristPosition, OutWristRotation);
}
FString USGNova2GloveKismetLibrary::GetStreamByte()
{
return FString::Printf(TEXT("%c"), USGNova2Glove::GetStreamByte());
}
TArray<float> USGNova2GloveKismetLibrary::GetNova2SensorRanges()
{
return USGNova2Glove::GetNova2SensorRanges();
}
TArray<float> USGNova2GloveKismetLibrary::ToNormalizedValues_SD(const USGNova2GloveSensorData* SensorData)
{
return USGNova2Glove::ToNormalizedValues(SensorData);
}
TArray<float> USGNova2GloveKismetLibrary::ToNormalizedValues_SD_OutSN(
UObject* WorldContextObject,
const USGNova2GloveSensorData* SensorData, USGSensorNormalization*& OutSensorNormalizer)
{
return USGNova2Glove::ToNormalizedValues(WorldContextObject, SensorData, OutSensorNormalizer);
}
TArray<FSGVectorArray> USGNova2GloveKismetLibrary::CalculateHandAngles(
const TArray<float>& NormalizedValues, const USGHandInterpolator* Interpolator, const bool bInfluenceIndex)
{
const TArray<FSGVectorArray> HandAngles{
FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(
USGNova2Glove::CalculateHandAngles(NormalizedValues, Interpolator, bInfluenceIndex))
};
return HandAngles;
}
TArray<FSGVectorArray> USGNova2GloveKismetLibrary::ToNormalizedAngles(
const TArray<float>& NormalizedData, const USGNovaGloveInfo* GloveInfo)
{
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(
USGNova2Glove::ToNormalizedAngles(NormalizedData, GloveInfo));
}
ESGDeviceType USGNova2GloveKismetLibrary::GetDeviceType(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->GetDeviceType();
}
FString USGNova2GloveKismetLibrary::GetDeviceId(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->GetDeviceId();
}
FString USGNova2GloveKismetLibrary::GetHardwareVersion(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->GetHardwareVersion();
}
int32 USGNova2GloveKismetLibrary::GetFirmwareVersion(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->GetFirmwareVersion();
}
int32 USGNova2GloveKismetLibrary::GetSubFirmwareVersion(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->GetSubFirmwareVersion();
}
bool USGNova2GloveKismetLibrary::HasBattery(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->HasBattery();
}
bool USGNova2GloveKismetLibrary::IsCharging(USGNova2Glove* Nova2Glove)
{
return Nova2Glove->IsCharging();
}
bool USGNova2GloveKismetLibrary::GetBatteryLevel(USGNova2Glove* Nova2Glove, float& OutBatteryLevel)
{
return Nova2Glove->GetBatteryLevel(OutBatteryLevel);
}
bool USGNova2GloveKismetLibrary::IsRight(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->IsRight();
}
bool USGNova2GloveKismetLibrary::GetImuRotation_FQuat_OutI(USGNova2Glove* Nova2Glove, FQuat& OutImu)
{
return Nova2Glove->GetImuRotation(OutImu);
}
bool USGNova2GloveKismetLibrary::GetImuRotation_FRotator_OutI(USGNova2Glove* Nova2Glove, FRotator& OutImu)
{
return Nova2Glove->GetImuRotation(OutImu);
}
bool USGNova2GloveKismetLibrary::GetHandPose(
UObject* WorldContextObject,
USGNova2Glove* Nova2Glove, const USGBasicHandModel* HandModel, USGHandPose*& OutHandPose)
{
return Nova2Glove->GetHandPose(WorldContextObject, HandModel, OutHandPose);
}
bool USGNova2GloveKismetLibrary::GetHandAngles(const USGNova2Glove* Nova2Glove, TArray<FSGVectorArray>& OutHandAngles)
{
TArray<TArray<FVector>> HandAnglesNestedArray;
const bool bResult = Nova2Glove->GetHandAngles(HandAnglesNestedArray);
OutHandAngles = FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(MoveTemp(HandAnglesNestedArray));
return bResult;
}
ESGHapticGloveCalibrationState USGNova2GloveKismetLibrary::GetCalibrationState(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->GetCalibrationState();
}
void USGNova2GloveKismetLibrary::EndCalibration(USGNova2Glove* Nova2Glove)
{
Nova2Glove->EndCalibration();
}
void USGNova2GloveKismetLibrary::ResetCalibration(USGNova2Glove* Nova2Glove)
{
Nova2Glove->ResetCalibration();
}
void USGNova2GloveKismetLibrary::StopHaptics(USGNova2Glove* Nova2Glove)
{
Nova2Glove->StopHaptics();
}
void USGNova2GloveKismetLibrary::StopVibrations(USGNova2Glove* Nova2Glove)
{
Nova2Glove->StopVibrations();
}
bool USGNova2GloveKismetLibrary::SendHaptics(USGNova2Glove* Nova2Glove)
{
return Nova2Glove->SendHaptics();
}
bool USGNova2GloveKismetLibrary::SupportsCustomWaveform(const USGNova2Glove* Nova2Glove,
const ESGHapticLocation AtLocation)
{
return Nova2Glove->SupportsCustomWaveform(AtLocation);
}
bool USGNova2GloveKismetLibrary::SendCustomWaveform(USGNova2Glove* Nova2Glove,
USGCustomWaveform* OutWaveform, const ESGHapticLocation Location)
{
return Nova2Glove->SendCustomWaveform(OutWaveform, Location);
}
bool USGNova2GloveKismetLibrary::QueueForceFeedbackLevels(USGNova2Glove* Nova2Glove, const TArray<float>& Levels01)
{
return Nova2Glove->QueueForceFeedbackLevels(Levels01);
}
bool USGNova2GloveKismetLibrary::QueueForceFeedbackLevel(
USGNova2Glove* Nova2Glove, const int32 Finger, const float Level01)
{
return Nova2Glove->QueueForceFeedbackLevel(Finger, Level01);
}
bool USGNova2GloveKismetLibrary::QueueVibroLevels(USGNova2Glove* Nova2Glove, const TArray<float>& Amplitudes)
{
return Nova2Glove->QueueVibroLevels(Amplitudes);
}
bool USGNova2GloveKismetLibrary::QueueVibroLevel(USGNova2Glove* Nova2Glove,
const ESGHapticLocation Location, const float Level01)
{
return Nova2Glove->QueueVibroLevel(Location, Level01);
}
void USGNova2GloveKismetLibrary::GetGloveLocation_RP_FQuat_RR_TH_OutGP_FQuat_OutGR(
const USGNova2Glove* Nova2Glove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutGlovePosition, FQuat& OutGloveRotation)
{
Nova2Glove->GetGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutGlovePosition, OutGloveRotation);
}
void USGNova2GloveKismetLibrary::GetGloveLocation_RP_FRotator_RR_TH_OutGP_FRotator_OutGR(
const USGNova2Glove* Nova2Glove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutGlovePosition, FRotator& OutGloveRotation)
{
Nova2Glove->GetGloveLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutGlovePosition, OutGloveRotation);
}
void USGNova2GloveKismetLibrary::GetWristLocation_RP_FQuat_RR_TH_OutWP_FQuat_OutWR(
const USGNova2Glove* Nova2Glove,
const FVector& ReferencePosition, const FQuat& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FQuat& OutWristRotation)
{
Nova2Glove->GetWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutWristPosition, OutWristRotation);
}
void USGNova2GloveKismetLibrary::GetWristLocation_RP_FRotator_RR_TH_OutWP_FRotator_OutWR(
const USGNova2Glove* Nova2Glove,
const FVector& ReferencePosition, const FRotator& ReferenceRotation,
const ESGPositionalTrackingHardware TrackingHardware,
FVector& OutWristPosition, FRotator& OutWristRotation)
{
Nova2Glove->GetWristLocation(ReferencePosition, ReferenceRotation,
TrackingHardware,
OutWristPosition, OutWristRotation);
}
USGNovaGloveInfo* USGNova2GloveKismetLibrary::GetGloveInfo(UObject* WorldContextObject, const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->GetGloveInfo(WorldContextObject);
}
bool USGNova2GloveKismetLibrary::DoesIndexInfluenceOthers(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->DoesIndexInfluenceOthers();
}
void USGNova2GloveKismetLibrary::SetIndexInfluencesOthers(USGNova2Glove* Nova2Glove, const bool bInfluenceOthers)
{
Nova2Glove->SetIndexInfluencesOthers(bInfluenceOthers);
}
bool USGNova2GloveKismetLibrary::SupportsOnBoardNormalization(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->SupportsOnBoardNormalization();
}
bool USGNova2GloveKismetLibrary::GetSensorData(
UObject* WorldContextObject, USGNova2Glove* Nova2Glove, USGNova2GloveSensorData*& OutSensorData)
{
return Nova2Glove->GetSensorData(WorldContextObject, OutSensorData);
}
bool USGNova2GloveKismetLibrary::GetNormalizedInput(const USGNova2Glove* Nova2Glove, TArray<float>& OutNormalizedValues)
{
return Nova2Glove->GetNormalizedInput(OutNormalizedValues);
}
bool USGNova2GloveKismetLibrary::SendRawData(USGNova2Glove* Nova2Glove)
{
return Nova2Glove->SendRawData();
}
bool USGNova2GloveKismetLibrary::SendNormalizedData(USGNova2Glove* Nova2Glove)
{
return Nova2Glove->SendNormalizedData();
}
ESGNova2VibroMotor USGNova2GloveKismetLibrary::ToNovaMotor(const USGNova2Glove* Nova2Glove,
const ESGHapticLocation Location)
{
return Nova2Glove->ToNovaMotor(Location);
}
int32 USGNova2GloveKismetLibrary::ChannelIndex(const USGNova2Glove* Nova2Glove, const ESGNova2VibroMotor Motor)
{
return Nova2Glove->ChannelIndex(Motor);
}
void USGNova2GloveKismetLibrary::ValidateWaveform(const USGNova2Glove* Nova2Glove,
USGCustomWaveform* OutWaveform, const ESGNova2VibroMotor Motor)
{
Nova2Glove->ValidateWaveform(OutWaveform, Motor);
}
bool USGNova2GloveKismetLibrary::SendCustomWaveform_Nova2(
USGNova2Glove* Nova2Glove,
USGCustomWaveform* OutWaveform, const ESGNova2VibroMotor Motor, const bool bValidateWaveform)
{
return Nova2Glove->SendCustomWaveform_Nova2(OutWaveform, Motor, bValidateWaveform);
}
FString USGNova2GloveKismetLibrary::ToString(const USGNova2Glove* Nova2Glove)
{
return Nova2Glove->ToString();
}