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

220 lines
6.8 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 "HAL/Platform.h"
#include "Math/Quat.h"
#include "Math/Vector.h"
#include "Templates/UniquePtr.h"
#include "UObject/Object.h"
#include "UObject/ObjectMacros.h"
#include "SGCore/SGFloatArray.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGBasicHandModel.generated.h"
class FSGBasicHandModelImpl;
UCLASS(BlueprintType)
class SENSEGLOVECORE_API USGBasicHandModel final : public UObject
{
GENERATED_BODY()
public:
static USGBasicHandModel* NewBasicHandModel(
UObject* Outer, const FSGBasicHandModelImpl& BasicHandModelImpl);
public:
static USGBasicHandModel* NewBasicHandModel(UObject* Outer);
static USGBasicHandModel* NewBasicHandModel(
UObject* Outer,
bool bRightHanded, const TArray<TArray<float>>& Lengths, const TArray<FVector>& StartPositions);
static USGBasicHandModel* NewBasicHandModel(
UObject* Outer,
bool bRightHanded, const TArray<FSGFloatArray>& Lengths, const TArray<FVector>& StartPositions);
static USGBasicHandModel* NewBasicHandModel(
UObject* Outer,
bool bRightHanded, const TArray<TArray<float>>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations);
static USGBasicHandModel* NewBasicHandModel(
UObject* Outer,
bool bRightHanded, const TArray<TArray<float>>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations);
static USGBasicHandModel* NewBasicHandModel(
UObject* Outer,
bool bRightHanded, const TArray<FSGFloatArray>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations);
static USGBasicHandModel* NewBasicHandModel(
UObject* Outer,
bool bRightHanded, const TArray<FSGFloatArray>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations);
public:
static USGBasicHandModel* Default(UObject* Outer, bool bRightHanded);
static USGBasicHandModel* Deserialize(UObject* Outer, const FString& SerializedString);
public:
static TArray<TArray<float>> GetBaseFingerLengths();
static TArray<FVector> GetBaseJointPositions();
static TArray<FVector> GetBaseJointRotations();
private:
struct FImpl;
struct FImplDeleter
{
void operator()(const FImpl* P) const;
};
TUniquePtr<FImpl, FImplDeleter> Pimpl;
FImplDeleter PimplDeleter;
public:
USGBasicHandModel();
USGBasicHandModel(bool bRightHanded, const TArray<TArray<float>>& Lengths,
const TArray<FVector>& StartPositions);
USGBasicHandModel(bool bRightHanded, const TArray<FSGFloatArray>& Lengths,
const TArray<FVector>& StartPositions);
USGBasicHandModel(bool bRightHanded, const TArray<TArray<float>>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations);
USGBasicHandModel(bool bRightHanded, const TArray<TArray<float>>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations);
USGBasicHandModel(bool bRightHanded, const TArray<FSGFloatArray>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations);
USGBasicHandModel(bool bRightHanded, const TArray<FSGFloatArray>& Lengths,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations);
public:
/**
* The cast from underlying type constructor.
*/
explicit USGBasicHandModel(const FSGBasicHandModelImpl& BasicHandModelImpl);
public:
/**
* The destructor.
*/
virtual ~USGBasicHandModel() override;
protected:
/**
* Allows to set the underlying object after construction.
*/
void SetBasicHandModelImpl(const FSGBasicHandModelImpl& BasicHandModelImpl);
public:
/**
* The cast to underlying type method.
*/
const FSGBasicHandModelImpl& ToBasicHandModelImpl() const;
protected:
/**
* The non-const cast to underlying type method.
*/
FSGBasicHandModelImpl& ToBasicHandModelImpl();
public:
bool IsRight() const;
TArray<TArray<float>> GetFingerLengths() const;
TArray<float> GetFingerLengths(ESGFinger Finger) const;
void SetFingerLengths(ESGFinger Finger, const TArray<float>& Lengths);
void SetFingerLengths(uint8 Finger, const TArray<float>& Lengths);
TArray<TArray<float>> GetFingerRatios() const;
TArray<float> GetFingerRatios(ESGFinger Finger) const;
TArray<FVector> GetStartJointPositions() const;
void SetStartJointPosition(ESGFinger Finger, const FVector& Position);
void SetStartJointPosition(uint8 Finger, const FVector& Position);
TArray<FQuat> GetStartJointRotationsQ() const;
TArray<FRotator> GetStartJointRotations() const;
FVector GetJointPosition(ESGFinger Finger) const;
void SetJointPosition(const FVector& NewPosition, ESGFinger Finger);
FQuat GetJointRotationQ(ESGFinger Finger) const;
FRotator GetJointRotation(ESGFinger Finger) const;
void SetJointRotation(const FQuat& NewRotation, ESGFinger Finger);
void SetJointRotation(const FRotator& NewRotation, ESGFinger Finger);
TArray<float> GetTotalLengths() const;
float GetTotalLength(ESGFinger Finger) const;
public:
TArray<FVector> Get3DLengths(ESGFinger Finger) const;
public:
bool Equals(const USGBasicHandModel* BasicHandModel) const;
public:
FString ToString() const;
FString ToString(bool bLengthsOnly) const;
FString SGSerialize() const;
};