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

183 lines
6.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 "SGCoreKismet/SGHandPoseKismetLibrary.h"
#include "SGCore/SGBasicHandModel.h"
#include "SGCore/SGHandPose.h"
#include "SGUtils/SGArrayUtils.h"
USGHandPose* USGHandPoseKismetLibrary::MakeHandPose(UObject* WorldContextObject)
{
return USGHandPose::NewHandPose(WorldContextObject);
}
USGHandPose* USGHandPoseKismetLibrary::MakeHandPose_bRH_JP_FSGQuatArray_JR_HA(
UObject* WorldContextObject,
const bool bRightHanded, const TArray<FSGVectorArray>& JointPositions, const TArray<FSGQuatArray>& JointRotations,
const TArray<FSGVectorArray>& HandAngles)
{
return USGHandPose::NewHandPose(WorldContextObject, bRightHanded, JointPositions, JointRotations, HandAngles);
}
USGHandPose* USGHandPoseKismetLibrary::MakeHandPose_bRH_JP_FSGRotatorArray_JR_HA(
UObject* WorldContextObject,
const bool bRightHanded,
const TArray<FSGVectorArray>& JointPositions, const TArray<FSGRotatorArray>& JointRotations,
const TArray<FSGVectorArray>& HandAngles)
{
return USGHandPose::NewHandPose(WorldContextObject, bRightHanded, JointPositions, JointRotations, HandAngles);
}
USGHandPose* USGHandPoseKismetLibrary::Deserialize(UObject* WorldContextObject, const FString& SerializedString)
{
return USGHandPose::Deserialize(WorldContextObject, SerializedString);
}
USGHandPose* USGHandPoseKismetLibrary::FromHandAngles_HA_bRH_HD(
UObject* WorldContextObject,
const TArray<FSGVectorArray>& HandAngles, const bool bRightHanded, const USGBasicHandModel* HandDimensions)
{
TArray<TArray<FVector>> HandAnglesNestedArray{
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
return USGHandPose::FromHandAngles(WorldContextObject, MoveTemp(HandAnglesNestedArray), bRightHanded,
HandDimensions);
}
USGHandPose* USGHandPoseKismetLibrary::FromHandAngles_HA_bRH(
UObject* WorldContextObject, const TArray<FSGVectorArray>& HandAngles, const bool bRightHanded)
{
TArray<TArray<FVector>> HandAnglesNestedArray{
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
return USGHandPose::FromHandAngles(WorldContextObject, MoveTemp(HandAnglesNestedArray), bRightHanded);
}
USGHandPose* USGHandPoseKismetLibrary::DefaultIdle_bRH_HD(
UObject* WorldContextObject, const bool bRightHanded, const USGBasicHandModel* HandDimensions)
{
return USGHandPose::DefaultIdle(WorldContextObject, bRightHanded, HandDimensions);
}
USGHandPose* USGHandPoseKismetLibrary::DefaultIdle_bRH(UObject* WorldContextObject, const bool bRightHanded)
{
return USGHandPose::DefaultIdle(WorldContextObject, bRightHanded);
}
USGHandPose* USGHandPoseKismetLibrary::FlatHand_bRH_HD(
UObject* WorldContextObject, const bool bRightHanded, const USGBasicHandModel* HandDimensions)
{
return USGHandPose::FlatHand(WorldContextObject, bRightHanded, HandDimensions);
}
USGHandPose* USGHandPoseKismetLibrary::FlatHand_bRH(UObject* WorldContextObject, const bool bRightHanded)
{
return USGHandPose::FlatHand(WorldContextObject, bRightHanded);
}
USGHandPose* USGHandPoseKismetLibrary::ThumbsUp_bRH_HD(
UObject* WorldContextObject, const bool bRightHanded, const USGBasicHandModel* HandDimensions)
{
return USGHandPose::ThumbsUp(WorldContextObject, bRightHanded, HandDimensions);
}
USGHandPose* USGHandPoseKismetLibrary::ThumbsUp_bRH(UObject* WorldContextObject, const bool bRightHanded)
{
return USGHandPose::ThumbsUp(WorldContextObject, bRightHanded);
}
USGHandPose* USGHandPoseKismetLibrary::Fist_bRH_HD(
UObject* WorldContextObject, const bool bRightHanded, const USGBasicHandModel* HandDimensions)
{
return USGHandPose::Fist(WorldContextObject, bRightHanded, HandDimensions);
}
USGHandPose* USGHandPoseKismetLibrary::Fist_bRH(UObject* WorldContextObject, const bool bRightHanded)
{
return USGHandPose::Fist(WorldContextObject, bRightHanded);
}
bool USGHandPoseKismetLibrary::IsRight(const USGHandPose* HandPose)
{
return HandPose->IsRight();
}
TArray<FSGVectorArray> USGHandPoseKismetLibrary::GetJointPositions(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(HandPose->GetJointPositions());
}
TArray<FSGQuatArray> USGHandPoseKismetLibrary::GetJointRotationsQ(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToNestedBPArray<FQuat, FSGQuatArray>(HandPose->GetJointRotationsQ());
}
TArray<FSGRotatorArray> USGHandPoseKismetLibrary::GetJointRotations(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToNestedBPArray<FRotator, FSGRotatorArray>(HandPose->GetJointRotations());
}
TArray<FSGVectorArray> USGHandPoseKismetLibrary::GetHandAngles(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(HandPose->GetHandAngles());
}
bool USGHandPoseKismetLibrary::Equals(const USGHandPose* A, const USGHandPose* B)
{
return A->Equals(B);
}
float USGHandPoseKismetLibrary::GetNormalizedFlexion_F_bC01(
const USGHandPose* HandPose, const ESGFinger Finger, const bool bClamp01)
{
return HandPose->GetNormalizedFlexion(Finger, bClamp01);
}
TArray<float> USGHandPoseKismetLibrary::GetNormalizedFlexion_bC01(
const USGHandPose* HandPose, const bool bClamp01)
{
return HandPose->GetNormalizedFlexion(bClamp01);
}
FString USGHandPoseKismetLibrary::ToString(const USGHandPose* HandPose, const bool bShortFormat)
{
return HandPose->ToString(bShortFormat);
}
FString USGHandPoseKismetLibrary::SGSerialize(const USGHandPose* HandPose)
{
return HandPose->SGSerialize();
}