/** * @file * * @author Mamadou Babaei * * @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 * * Data class containing all variables to map an input value from one range to * another. */ #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 "SGInterpolationSet.generated.h" class FSGInterpolationSetImpl; /** * Set of variables to map a value from one range to the next. */ UCLASS(BlueprintType) class SENSEGLOVECORE_API USGInterpolationSet final : public UObject { GENERATED_BODY() public: static USGInterpolationSet* NewInterpolationSet( UObject* Outer, const FSGInterpolationSetImpl& InterpolationSetImpl); public: /** * Creates a basic interpolation set, without limits. */ static USGInterpolationSet* NewInterpolationSet(UObject* Outer); /** * Create a new interpolation set without limits. */ static USGInterpolationSet* NewInterpolationSet(UObject* Outer, float From1, float From2, float To1, float To2); /** * Create a new interpolation set with limits. */ static USGInterpolationSet* NewInterpolationSet( UObject* Outer, float From1, float From2, float To1, float To2, float Min, float Max); public: /** * Convert a string notation of an InterpolationSet into a new class instance. */ static USGInterpolationSet* Deserialize(UObject* Outer, const FString& SerializedString); private: struct FImpl; struct FImplDeleter { void operator()(const FImpl* P) const; }; TUniquePtr Pimpl; FImplDeleter PimplDeleter; public: /** * Creates a basic interpolation set, without limits. */ USGInterpolationSet(); /** * Create a new interpolation set without limits. */ USGInterpolationSet(float From1, float From2, float To1, float To2); /** * Create a new interpolation set with limits. */ USGInterpolationSet(float From1, float From2, float To1, float To2, float Min, float Max); public: /** * The cast from underlying type constructor. */ explicit USGInterpolationSet(const FSGInterpolationSetImpl& InterpolationSetImpl); public: /** * The destructor. */ virtual ~USGInterpolationSet() override; protected: /** * Allows to set the underlying object after construction. */ void SetInterpolationSetImpl(const FSGInterpolationSetImpl& InterpolationSetImpl); public: /** * The cast to underlying type method. */ const FSGInterpolationSetImpl& ToInterpolationSetImpl() const; public: /** * First value of input range. */ float GetX0() const; /** * */ void SetX0(float X0); /** * Second value of input range. */ float GetX1() const; /** * */ void SetX1(float X1); /** * First value of output range. */ float GetY0() const; /** * */ void SetY0(float Y0); /** * Second value of output range. */ float GetY1() const; /** * */ void SetY1(float Y1); /** * Minimum range of the output value. */ float GetMin() const; /** * */ void SetMin(float Min); /** * Maximum range of the output value. */ float GetMax() const; /** * */ void SetMax(float Max); public: /** * Calculate an output value in range [x0...x1] to [y0..y1] */ float Get(float Value, bool bLimit, bool bNormalizeAngle = false) const; public: /** * Returns true if this InterpolationSet has the same values as another set. */ bool Equals(const USGInterpolationSet* InterpolationSet) const; public: /** * */ FString ToString() const; /** * */ FString ToString(bool bLimits) const; /** * Convert this InterpolationSet into a string notation so it can be stored on disk. */ FString SGSerialize() const; };