178 lines
4.6 KiB
C++
178 lines
4.6 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2025 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/UnrealString.h"
|
|
#include "Math/Quat.h"
|
|
#include "Math/Vector.h"
|
|
#include "Templates/UniquePtr.h"
|
|
|
|
#include "SGBuildHacks/SGPlatform.h"
|
|
#include "SGTypes/SGCoreTypes.h"
|
|
|
|
namespace SGCore
|
|
{
|
|
namespace Kinematics
|
|
{
|
|
class BasicHandModel;
|
|
}
|
|
}
|
|
|
|
class SENSEGLOVECOREIMPL_API FSGBasicHandModelImpl final
|
|
{
|
|
public:
|
|
typedef SGCore::Kinematics::BasicHandModel FBasicHandModelType;
|
|
|
|
public:
|
|
static FSGBasicHandModelImpl Default(bool bRightHanded);
|
|
|
|
static FSGBasicHandModelImpl Deserialize(const FString& SerializedString);
|
|
|
|
public:
|
|
static const TArray<TArray<float>>& GetBaseFingerLengths();
|
|
|
|
static const TArray<FVector>& GetBaseJointPositions();
|
|
|
|
static const TArray<FVector>& GetBaseJointAngles();
|
|
|
|
private:
|
|
struct FImpl;
|
|
|
|
struct FImplDeleter
|
|
{
|
|
void operator()(const FImpl* P) const;
|
|
};
|
|
|
|
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
|
FImplDeleter PimplDeleter;
|
|
|
|
public:
|
|
FSGBasicHandModelImpl();
|
|
|
|
FSGBasicHandModelImpl(bool bRightHanded, const TArray<TArray<float>>& Lengths,
|
|
const TArray<FVector>& StartPositions);
|
|
|
|
FSGBasicHandModelImpl(bool bRightHanded, const TArray<TArray<float>>& Lengths,
|
|
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations);
|
|
|
|
public:
|
|
/**
|
|
* The cast from underlying type constructor.
|
|
*/
|
|
explicit FSGBasicHandModelImpl(const FBasicHandModelType& BasicHandModel);
|
|
|
|
public:
|
|
/**
|
|
* The copy constructor.
|
|
*/
|
|
FSGBasicHandModelImpl(const FSGBasicHandModelImpl& Rhs);
|
|
|
|
/**
|
|
* The move constructor.
|
|
*/
|
|
FSGBasicHandModelImpl(FSGBasicHandModelImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The destructor.
|
|
*/
|
|
virtual ~FSGBasicHandModelImpl();
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
FSGBasicHandModelImpl& operator=(const FSGBasicHandModelImpl& Rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
FSGBasicHandModelImpl& operator=(FSGBasicHandModelImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The cast to underlying type method.
|
|
*/
|
|
const FBasicHandModelType& ToBasicHandModel() const;
|
|
|
|
public:
|
|
bool IsRight() const;
|
|
|
|
public:
|
|
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;
|
|
|
|
public:
|
|
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> GetStartJointRotations() const;
|
|
|
|
FVector GetJointPosition(ESGFinger Finger) const;
|
|
|
|
void SetJointPosition(const FVector& NewPosition, ESGFinger Finger);
|
|
|
|
FQuat GetJointRotation(ESGFinger Finger) const;
|
|
|
|
void SetJointRotation(const FQuat& NewRotation, ESGFinger Finger);
|
|
|
|
TArray<float> GetTotalLengths() const;
|
|
|
|
float GetTotalLength(ESGFinger Finger) const;
|
|
|
|
public:
|
|
TArray<FVector> Get3DLengths(ESGFinger Finger) const;
|
|
|
|
public:
|
|
bool Equals(const FSGBasicHandModelImpl& BasicHandModelImpl) const;
|
|
|
|
public:
|
|
FString ToString() const;
|
|
|
|
FString ToString(bool bLengthsOnly) const;
|
|
|
|
FString Serialize() const;
|
|
}; |