From 2690fffe897165bac391543d2ee66fd00c4dc830 Mon Sep 17 00:00:00 2001 From: acdemiralp <demiralpali@gmail.com> Date: Tue, 4 Dec 2018 01:57:28 +0100 Subject: [PATCH] Added HMD interoperation support. Naming no longer appropriate. --- .../DisplayClusterExtensions.Build.cs | 1 + .../Private/DisplayClusterPawnCAVE.cpp | 14 ++++++++++++++ .../Public/DisplayClusterPawnCAVE.h | 7 +++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs b/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs index 6b3217d6..38f5d20a 100644 --- a/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs +++ b/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs @@ -30,6 +30,7 @@ public class DisplayClusterExtensions : ModuleRules "DisplayCluster", "DisplayClusterInput", "Engine", + "HeadMountedDisplay", "InputCore" } ); diff --git a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp b/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp index c82bbab0..fc9d3e19 100644 --- a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp +++ b/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp @@ -7,6 +7,7 @@ #include "Input/IDisplayClusterInputManager.h" #include "Kismet/GameplayStatics.h" #include "DisplayClusterSettings.h" +#include "HeadMountedDisplayFunctionLibrary.h" #include "IDisplayCluster.h" ADisplayClusterPawnCAVE::ADisplayClusterPawnCAVE(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -21,6 +22,8 @@ ADisplayClusterPawnCAVE::ADisplayClusterPawnCAVE(const FObjectInitializer& Objec RotatingComponent->RotationRate = FRotator::ZeroRotator; TranslationDirection = RootComponent; + + AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events. } void ADisplayClusterPawnCAVE::OnForward_Implementation (float Value) @@ -87,6 +90,17 @@ void ADisplayClusterPawnCAVE::BeginPlay () MovementComponent->Deceleration = Settings->MovementDeceleration; MovementComponent->TurningBoost = Settings->MovementTurningBoost; BaseTurnRate = Settings->RotationSpeed ; + + if (UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled()) + { + LeftMotionControllerComponent = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftMotionControllerComponent")); + LeftMotionControllerComponent->SetTrackingSource (EControllerHand::Left); + LeftMotionControllerComponent->SetShowDeviceModel(true); + + RightMotionControllerComponent = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightMotionControllerComponent")); + RightMotionControllerComponent->SetTrackingSource (EControllerHand::Right); + RightMotionControllerComponent->SetShowDeviceModel(true); + } } void ADisplayClusterPawnCAVE::Tick (float DeltaSeconds) { diff --git a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h b/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h index e2e9b9e6..f2770555 100644 --- a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h +++ b/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h @@ -6,6 +6,7 @@ #include "CoreMinimal.h" #include "DisplayClusterPawn.h" #include "DisplayClusterSceneComponent.h" +#include "MotionControllerComponent.h" #include "DisplayClusterPawnCAVE.generated.h" @@ -35,6 +36,8 @@ protected: virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override; virtual UPawnMovementComponent* GetMovementComponent () const override; - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UFloatingPawnMovement* MovementComponent = nullptr; - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) URotatingMovementComponent* RotatingComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UFloatingPawnMovement* MovementComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) URotatingMovementComponent* RotatingComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UMotionControllerComponent* LeftMotionControllerComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UMotionControllerComponent* RightMotionControllerComponent = nullptr; }; -- GitLab