174 lines
5.2 KiB
C++
174 lines
5.2 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2026 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 "GameFramework/Actor.h"
|
|
#include "HeadMountedDisplayTypes.h"
|
|
#include "Math/Rotator.h"
|
|
#include "Math/Vector.h"
|
|
#include "MotionControllerComponent.h"
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
#include "Templates/UniquePtr.h"
|
|
|
|
#include "SGSettings/SGWristTrackingSettings.h"
|
|
#include "SGSettings/SGWristTrackingSettingsOverrides.h"
|
|
|
|
#include "SGWristTrackerComponent.generated.h"
|
|
|
|
UCLASS(Blueprintable, ClassGroup = MotionController, meta = (BlueprintSpawnableComponent))
|
|
class SENSEGLOVE_API USGWristTrackerComponent : public UMotionControllerComponent
|
|
{
|
|
GENERATED_UCLASS_BODY()
|
|
|
|
public:
|
|
DECLARE_EVENT_OneParam(USGWristTrackerComponent, FWristLocationChangedEvent, const FVector&)
|
|
|
|
FWristLocationChangedEvent& OnWristLocationChanged()
|
|
{
|
|
return WristLocationChangedEvent;
|
|
};
|
|
|
|
DECLARE_EVENT_OneParam(USGWristTrackerComponent, FWristRotationChangedEvent, const FRotator&)
|
|
|
|
FWristRotationChangedEvent& OnWristRotationChanged()
|
|
{
|
|
return WristRotationChangedEvent;
|
|
};
|
|
|
|
DECLARE_EVENT_TwoParams(USGWristTrackerComponent, FWristLocationAndRotationChangedEvent,
|
|
const FVector&, const FRotator&)
|
|
|
|
FWristLocationAndRotationChangedEvent& OnWristLocationAndRotationChanged()
|
|
{
|
|
return WristLocationAndRotationChangedEvent;
|
|
};
|
|
|
|
private:
|
|
FWristLocationChangedEvent WristLocationChangedEvent;
|
|
FWristRotationChangedEvent WristRotationChangedEvent;
|
|
FWristLocationAndRotationChangedEvent WristLocationAndRotationChangedEvent;
|
|
|
|
private:
|
|
struct FImpl;
|
|
|
|
struct FImplDeleter
|
|
{
|
|
void operator()(const FImpl* P) const;
|
|
};
|
|
|
|
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
|
FImplDeleter PimplDeleter;
|
|
|
|
private:
|
|
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
|
|
bool bRight;
|
|
|
|
/**
|
|
* Overrides the plugin's wrist tracking settings.
|
|
*/
|
|
UPROPERTY(EditAnywhere, Category = "SenseGlove", meta=(AllowPrivateAccess="false"))
|
|
FSGWristTrackingSettingsOverrides WristTrackingSettingsOverrides;
|
|
|
|
private:
|
|
UPROPERTY(Transient)
|
|
FVector WristLocation;
|
|
|
|
UPROPERTY(Transient)
|
|
FRotator WristRotation;
|
|
|
|
public:
|
|
FORCEINLINE bool IsLeft() const
|
|
{
|
|
return !IsRight();
|
|
}
|
|
|
|
FORCEINLINE bool IsRight() const
|
|
{
|
|
return bRight;
|
|
}
|
|
|
|
void SetRight(const bool bInRight);
|
|
|
|
FORCEINLINE bool OverridesPluginWristTrackingSettings() const
|
|
{
|
|
return WristTrackingSettingsOverrides.bOverridePluginSettings;
|
|
}
|
|
|
|
FORCEINLINE const FSGWristTrackingSettingsOverrides& GetWristTrackingSettingsOverrides() const
|
|
{
|
|
return WristTrackingSettingsOverrides;
|
|
}
|
|
|
|
void SetWristTrackingSettingsOverrides(const FSGWristTrackingSettingsOverrides& InWristTrackingSettingsOverrides);
|
|
|
|
FSGWristTrackingSettings GetWristTrackingSettings() const;
|
|
|
|
FORCEINLINE const FVector& GetWristLocation() const
|
|
{
|
|
return WristLocation;
|
|
}
|
|
|
|
FORCEINLINE const FRotator& GetWristRotation() const
|
|
{
|
|
return WristRotation;
|
|
}
|
|
|
|
public:
|
|
#if WITH_EDITOR
|
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
|
#endif /* WITH_EDITOR */
|
|
|
|
virtual void InitializeComponent() override;
|
|
|
|
virtual void BeginPlay() override;
|
|
|
|
virtual void TickComponent(float DeltaTime,
|
|
enum ELevelTick TickType,
|
|
FActorComponentTickFunction* ThisTickFunction) override;
|
|
|
|
protected:
|
|
virtual void EditorTick(float DeltaTime,
|
|
enum ELevelTick TickType,
|
|
FActorComponentTickFunction* ThisTickFunction);
|
|
|
|
public:
|
|
UE_DEPRECATED(5.5, "Deprecated by UE 5.5 in favor of GetMotionControllerState and GetHandTrackingState")
|
|
const FXRMotionControllerData& GetMotionControllerData() const;
|
|
|
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
|
const FXRHandTrackingState& GetHandTrackingState() const;
|
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
|
}; |