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

213 lines
7.5 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 "UObject/Object.h"
#include "UObject/ObjectMacros.h"
#include "SGCore/SGVectorArray.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGSenseGloveInfo.generated.h"
class FSGSenseGloveInfoImpl;
UCLASS(BlueprintType)
class SENSEGLOVECORE_API USGSenseGloveInfo final : public UObject
{
GENERATED_BODY()
public:
static USGSenseGloveInfo* NewSenseGloveInfo(
UObject* Outer, const FSGSenseGloveInfoImpl& SenseGloveInfoImpl);
public:
static USGSenseGloveInfo* NewSenseGloveInfo(UObject* Outer);
static USGSenseGloveInfo* NewSenseGloveInfo(
UObject* Outer, const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FQuat& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations,
const TArray<TArray<FVector>>& GloveLengths, const TArray<bool>& Functions);
static USGSenseGloveInfo* NewSenseGloveInfo(
UObject* Outer, const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FRotator& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations,
const TArray<TArray<FVector>>& GloveLengths, const TArray<bool>& Functions);
static USGSenseGloveInfo* NewSenseGloveInfo(
UObject* Outer, const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FQuat& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations,
const TArray<FSGVectorArray>& GloveLengths, const TArray<bool>& Functions);
static USGSenseGloveInfo* NewSenseGloveInfo(
UObject* Outer, const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FRotator& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations,
const TArray<FSGVectorArray>& GloveLengths, const TArray<bool>& Functions);
public:
static bool Parse(UObject* Outer, const FString& ConstantsString, USGSenseGloveInfo*& OutGloveInfo,
bool bUpdateOldModels = true);
static USGSenseGloveInfo* Deserialize(UObject* Outer, const FString& SerializedString);
private:
struct FImpl;
struct FImplDeleter
{
void operator()(const FImpl* P) const;
};
TUniquePtr<FImpl, FImplDeleter> Pimpl;
FImplDeleter PimplDeleter;
public:
USGSenseGloveInfo();
USGSenseGloveInfo(const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FQuat& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations,
const TArray<TArray<FVector>>& GloveLengths, const TArray<bool>& Functions);
USGSenseGloveInfo(const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FRotator& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations,
const TArray<TArray<FVector>>& GloveLengths, const TArray<bool>& Functions);
USGSenseGloveInfo(const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FQuat& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FQuat>& StartRotations,
const TArray<FSGVectorArray>& GloveLengths, const TArray<bool>& Functions);
USGSenseGloveInfo(const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion,
bool bRightHanded, int32 NumberOfSensors, const FRotator& ImuCorrection,
const TArray<FVector>& StartPositions, const TArray<FRotator>& StartRotations,
const TArray<FSGVectorArray>& GloveLengths, const TArray<bool>& Functions);
public:
/**
* The cast from underlying type constructor.
*/
explicit USGSenseGloveInfo(const FSGSenseGloveInfoImpl& SenseGloveInfoImpl);
public:
/**
* The destructor.
*/
virtual ~USGSenseGloveInfo() override;
protected:
/**
* Allows to set the underlying object after construction.
*/
void SetSenseGloveInfoImpl(const FSGSenseGloveInfoImpl& SenseGloveInfoImpl);
public:
/**
* The cast to underlying type method.
*/
const FSGSenseGloveInfoImpl& ToSenseGloveInfoImpl() const;
protected:
/**
* The non-const cast to underlying type method.
*/
FSGSenseGloveInfoImpl& ToSenseGloveInfoImpl();
public:
FString GetDeviceId() const;
FString GetHardwareVersion() const;
int32 GetFirmwareVersion() const;
int32 GetSubFirmwareVersion() const;
bool IsRight() const;
int32 GetNumberOfSensors() const;
FQuat GetImuCorrectionQ() const;
FRotator GetImuCorrection() const;
TArray<FVector> GetStartPositions() const;
TArray<FQuat> GetStartRotationsQ() const;
TArray<FRotator> GetStartRotations() const;
TArray<TArray<FVector>> GetGloveLengths() const;
TArray<bool> GetFunctions() const;
public:
FVector GetStartPosition(ESGFinger Finger) const;
FQuat GetStartRotationQ(ESGFinger Finger) const;
FRotator GetStartRotation(ESGFinger Finger) const;
TArray<FVector> GetGloveLengths(ESGFinger Finger) const;
public:
TArray<TArray<FVector>> ToGloveAngles(const TArray<TArray<float>>& SensorAngles) const;
bool Equals(const USGSenseGloveInfo* SenseGloveInfo) const;
public:
FString ToString() const;
FString ToString(bool bShortNotation) const;
FString SGSerialize() const;
};