Files
Plugin/Source/SenseGloveCore/Private/SGCore/SGSenseGloveVars.cpp
T
Mamadou Babaei a17b63bb0a * Expose SenseGloveTypes as a public dependency in SenseGloveConnect and
SenseGloveCore modules, so that the C++ users of the API don't need to
 explicitly add it as a dependency
* Clean up the redundant headers/modules dependency from SGCore headers
* Fix RunUAT build issues for Epic Store submission
2022-11-25 15:09:37 +01:00

166 lines
7.7 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @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/SGSenseGloveVars.h"
#include "SGCore/SGSenseGloveInfo.h"
#include "SGCoreImpl/SGExportedFunctions.h"
#include "SGInterop/SGIC_FQuat.h"
#include "SGInterop/SGIC_FSGSenseGloveInfoImpl.h"
#include "SGInterop/SGIC_FString.h"
#include "SGInterop/SGIC_TArray_bool.h"
#include "SGInterop/SGIC_TArray_FQuat.h"
#include "SGInterop/SGIC_TArray_FVector.h"
#include "SGInterop/SGIC_TArray_TArray_FVector.h"
#include "SGUtils/SGArrayUtils.h"
FString FSGSenseGloveVars::GetStandardConstantsString(const FString& HardwareVersion, const float FirmwareVersion,
const bool bRightHanded)
{
FSGIC_FString OutStringContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetStandardConstantsString(&OutStringContainer,
&HardwareVersionContainer, FirmwareVersion,
bRightHanded);
return MoveTemp(OutStringContainer.String);
}
FString FSGSenseGloveVars::GetSensorString(const FString& HardwareVersion, const float FirmwareVersion)
{
FSGIC_FString OutStringContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetSensorString(&OutStringContainer, &HardwareVersionContainer, FirmwareVersion);
return MoveTemp(OutStringContainer.String);
}
TArray<FVector> FSGSenseGloveVars::GetStartPositions(const FString& HardwareVersion, const bool bRightHanded)
{
FSGIC_TArray_FVector OutPositionsContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetStartPositions(&OutPositionsContainer, &HardwareVersionContainer, bRightHanded);
return MoveTemp(OutPositionsContainer.Array);
}
TArray<FQuat> FSGSenseGloveVars::GetStartRotationsQ(const FString& HardwareVersion, const bool bRightHanded)
{
FSGIC_TArray_FQuat OutRotationsContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetStartRotations(&OutRotationsContainer, &HardwareVersionContainer, bRightHanded);
return MoveTemp(OutRotationsContainer.Array);
}
TArray<FRotator> FSGSenseGloveVars::GetStartRotations(const FString& HardwareVersion, const bool bRightHanded)
{
FSGIC_TArray_FQuat OutRotationsContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetStartRotations(&OutRotationsContainer, &HardwareVersionContainer, bRightHanded);
return FSGArrayUtils::QuatsToRotators(OutRotationsContainer.Array);
}
TArray<TArray<FVector>> FSGSenseGloveVars::GetGloveLengths(const FString& HardwareVersion)
{
FSGIC_TArray_TArray_FVector OutLengthsContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetGloveLengths(&OutLengthsContainer, &HardwareVersionContainer);
return MoveTemp(OutLengthsContainer.Array);
}
/*
TArray<FSGVectorArray> FSGSenseGloveVars::GetGloveLengths_BP(const FString& HardwareVersion)
{
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(GetGloveLengths(HardwareVersion));
}
*/
int32 FSGSenseGloveVars::GetSensors(const FString& HardwareVersion)
{
FSGIC_FString HardwareVersionContainer{HardwareVersion};
return SGCoreImpl_FSGSenseGloveVarsImpl_GetSensors(&HardwareVersionContainer);
}
FQuat FSGSenseGloveVars::GetImuCorrectionQ(const FString& HardwareVersion,
const int32 FirmwareVersion, const int32 SubFirmwareVersion)
{
FSGIC_FQuat OutCorrectionContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetImuCorrection(&OutCorrectionContainer,
&HardwareVersionContainer, FirmwareVersion, SubFirmwareVersion);
return MoveTemp(OutCorrectionContainer.Quat);
}
FRotator FSGSenseGloveVars::GetImuCorrection(const FString& HardwareVersion,
const int32 FirmwareVersion, const int32 SubFirmwareVersion)
{
FSGIC_FQuat OutCorrectionContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetImuCorrection(&OutCorrectionContainer,
&HardwareVersionContainer, FirmwareVersion, SubFirmwareVersion);
return OutCorrectionContainer.Quat.Rotator();
}
TArray<bool> FSGSenseGloveVars::GetFunctions(const FString& HardwareVersion,
const int32 FirmwareVersion, const int32 SubFirmwareVersion)
{
FSGIC_TArray_bool OutFunctionsContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GetFunctions(&OutFunctionsContainer,
&HardwareVersionContainer, FirmwareVersion, SubFirmwareVersion);
return MoveTemp(OutFunctionsContainer.Array);
}
USGSenseGloveInfo* FSGSenseGloveVars::GenerateGloveModel(UObject* Outer, const FString& HardwareVersion,
const int32 FirmwareVersion, const int32 SubFirmwareVersion,
const bool bRightHanded)
{
FSGIC_FSGSenseGloveInfoImpl OutModelContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
SGCoreImpl_FSGSenseGloveVarsImpl_GenerateGloveModel_HardwareVersion_FirmwareVersion_SubFirmwareVersion_bRightHanded(
&OutModelContainer, &HardwareVersionContainer, FirmwareVersion, SubFirmwareVersion, bRightHanded);
return USGSenseGloveInfo::NewSenseGloveInfo(Outer, MoveTemp(OutModelContainer.SenseGloveInfoImpl));
}
USGSenseGloveInfo* FSGSenseGloveVars::GenerateGloveModel(UObject* Outer, const FString& HardwareVersion,
const int32 FirmwareVersion, const int32 SubFirmwareVersion,
const bool bRightHanded, const FString& CustomId)
{
FSGIC_FSGSenseGloveInfoImpl OutModelContainer;
FSGIC_FString HardwareVersionContainer{HardwareVersion};
FSGIC_FString CustomIdContainer{CustomId};
SGCoreImpl_FSGSenseGloveVarsImpl_GenerateGloveModel_HardwareVersion_FirmwareVersion_SubFirmwareVersion_bRightHanded_CustomId(
&OutModelContainer, &HardwareVersionContainer, FirmwareVersion, SubFirmwareVersion, bRightHanded,
&CustomIdContainer);
return USGSenseGloveInfo::NewSenseGloveInfo(Outer, MoveTemp(OutModelContainer.SenseGloveInfoImpl));
}