Files
Plugin/Source/SenseGloveCore/Public/SGCore/SGSenseGlovePose.h
T

183 lines
6.2 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
*
*
*/
#pragma once
#include "Containers/Array.h"
#include "Containers/UnrealString.h"
#include "Math/Quat.h"
#include "Math/Vector.h"
#include "Templates/UniquePtr.h"
#include "UObject/Object.h"
#include "UObject/ObjectMacros.h"
#include "SGCore/SGBasicHandModel.h"
#include "SGCore/SGSenseGloveInfo.h"
#include "SGCore/SGSenseGloveHandProfile.h"
#include "SGCore/SGQuatArray.h"
#include "SGCore/SGRotatorArray.h"
#include "SGCore/SGVectorArray.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGSenseGlovePose.generated.h"
class FSGSenseGlovePoseImpl;
UCLASS(BlueprintType)
class SENSEGLOVECORE_API USGSenseGlovePose final : public UObject
{
GENERATED_BODY()
public:
static USGSenseGlovePose* NewSenseGlovePose(
UObject* Outer, const FSGSenseGlovePoseImpl& SenseGlovePoseImpl);
public:
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer);
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded,
const TArray<TArray<FVector>>& JointPositions,
const TArray<TArray<FQuat>>& JointRotations,
const TArray<TArray<FVector>>& GloveAngles);
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded,
const TArray<TArray<FVector>>& JointPositions,
const TArray<TArray<FRotator>>& JointRotations,
const TArray<TArray<FVector>>& GloveAngles);
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded,
const TArray<FSGVectorArray>& JointPositions,
const TArray<FSGQuatArray>& JointRotations,
const TArray<FSGVectorArray>& GloveAngles);
static USGSenseGlovePose* NewSenseGlovePose(UObject* Outer, bool bRightHanded,
const TArray<FSGVectorArray>& JointPositions,
const TArray<FSGRotatorArray>& JointRotations,
const TArray<FSGVectorArray>& GloveAngles);
public:
static USGSenseGlovePose* IdlePose(UObject* Outer, const USGSenseGloveInfo* GloveInfo);
static USGSenseGlovePose* Deserialize(UObject* Outer, const FString& SerializedString);
private:
struct FImpl;
struct FImplDeleter
{
void operator()(const FImpl* P) const;
};
TUniquePtr<FImpl, FImplDeleter> Pimpl;
FImplDeleter PimplDeleter;
public:
USGSenseGlovePose();
USGSenseGlovePose(bool bRightHanded,
const TArray<TArray<FVector>>& JointPositions,
const TArray<TArray<FQuat>>& JointRotations,
const TArray<TArray<FVector>>& GloveAngles);
USGSenseGlovePose(bool bRightHanded,
const TArray<TArray<FVector>>& JointPositions,
const TArray<TArray<FRotator>>& JointRotations,
const TArray<TArray<FVector>>& GloveAngles);
USGSenseGlovePose(bool bRightHanded,
const TArray<FSGVectorArray>& JointPositions,
const TArray<FSGQuatArray>& JointRotations,
const TArray<FSGVectorArray>& GloveAngles);
USGSenseGlovePose(bool bRightHanded,
const TArray<FSGVectorArray>& JointPositions,
const TArray<FSGRotatorArray>& JointRotations,
const TArray<FSGVectorArray>& GloveAngles);
public:
/**
* The cast from underlying type constructor.
*/
explicit USGSenseGlovePose(const FSGSenseGlovePoseImpl& SenseGlovePoseImpl);
public:
/**
* The destructor.
*/
virtual ~USGSenseGlovePose() override;
protected:
/**
* Allows to set the underlying object after construction.
*/
void SetSenseGlovePoseImpl(const FSGSenseGlovePoseImpl& SenseGlovePoseImpl);
public:
/**
* The cast to underlying type method.
*/
const FSGSenseGlovePoseImpl& ToSenseGlovePoseImpl() const;
public:
bool IsRight() const;
TArray<TArray<FVector>> GetJointPositions() const;
TArray<TArray<FQuat>> GetJointRotationsQ() const;
TArray<TArray<FRotator>> GetJointRotations() const;
TArray<TArray<FVector>> GetGloveAngles() const;
public:
TArray<FVector> GetThimblePositions() const;
TArray<FQuat> GetThimbleRotationsQ() const;
TArray<FRotator> GetThimbleRotations() const;
TArray<FVector> GetTotalGloveAngles() const;
TArray<FVector> CalculateFingerTips(const USGSenseGloveHandProfile* SenseGloveHandProfile) const;
TArray<FVector> CalculateFingerTips(const TArray<FVector>& FingerOffsets) const;
bool Equals(const USGSenseGlovePose* SenseGlovePose) const;
public:
FString ToString(bool bShortFormat = false) const;
FString SGSerialize() const;
};