diff --git a/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs b/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs index 6b3217d6f6fc3cfb2d7e8b3ca0b81f3b493b7b78..38f5d20a8895f034cc1a9dfa369d067e1d72495a 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/DisplayClusterGameModeCAVE.cpp b/Source/DisplayClusterExtensions/Private/DisplayClusterGameModeCAVE.cpp deleted file mode 100644 index 90f74ef07c5398e35cccdca6eba71554a06aa4f2..0000000000000000000000000000000000000000 --- a/Source/DisplayClusterExtensions/Private/DisplayClusterGameModeCAVE.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "DisplayClusterGameModeCAVE.h" -#include "DisplayClusterPawnCAVE.h" - -ADisplayClusterGameModeCAVE::ADisplayClusterGameModeCAVE() : Super() -{ - if (!bIsDisplayClusterActive) return; - DefaultPawnClass = ADisplayClusterPawnCAVE::StaticClass(); -} diff --git a/Source/DisplayClusterExtensions/Private/VirtualRealityGameMode.cpp b/Source/DisplayClusterExtensions/Private/VirtualRealityGameMode.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d4ba9a7dfd9039d7f2670f8252cd502566f4c908 --- /dev/null +++ b/Source/DisplayClusterExtensions/Private/VirtualRealityGameMode.cpp @@ -0,0 +1,8 @@ +#include "VirtualRealityGameMode.h" +#include "VirtualRealityPawn.h" + +AVirtualRealityGameMode::AVirtualRealityGameMode() : Super() +{ + if (!bIsDisplayClusterActive) return; + DefaultPawnClass = AVirtualRealityPawn::StaticClass(); +} diff --git a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp b/Source/DisplayClusterExtensions/Private/VirtualRealityPawn.cpp similarity index 60% rename from Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp rename to Source/DisplayClusterExtensions/Private/VirtualRealityPawn.cpp index c82bbab0cec6fee56372dde0274f1ec19ffe83fc..1bcdfdec087afd30462f1cc503afd885c200c720 100644 --- a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp +++ b/Source/DisplayClusterExtensions/Private/VirtualRealityPawn.cpp @@ -1,4 +1,4 @@ -#include "DisplayClusterPawnCAVE.h" +#include "VirtualRealityPawn.h" #include "Cluster/IDisplayClusterClusterManager.h" #include "Engine/World.h" @@ -7,9 +7,10 @@ #include "Input/IDisplayClusterInputManager.h" #include "Kismet/GameplayStatics.h" #include "DisplayClusterSettings.h" +#include "HeadMountedDisplayFunctionLibrary.h" #include "IDisplayCluster.h" -ADisplayClusterPawnCAVE::ADisplayClusterPawnCAVE(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) +AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { MovementComponent = CreateDefaultSubobject<UFloatingPawnMovement> (TEXT("MovementComponent0")); MovementComponent->UpdatedComponent = RootComponent; @@ -21,17 +22,19 @@ 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) +void AVirtualRealityPawn::OnForward_Implementation (float Value) { AddMovementInput(TranslationDirection->GetForwardVector(), Value); } -void ADisplayClusterPawnCAVE::OnRight_Implementation (float Value) +void AVirtualRealityPawn::OnRight_Implementation (float Value) { AddMovementInput(TranslationDirection->GetRightVector (), Value); } -void ADisplayClusterPawnCAVE::OnTurnRate_Implementation (float Rate ) +void AVirtualRealityPawn::OnTurnRate_Implementation (float Rate ) { if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster) { @@ -46,7 +49,7 @@ void ADisplayClusterPawnCAVE::OnTurnRate_Implementation (flo AddControllerYawInput(BaseTurnRate * Rate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation); } } -void ADisplayClusterPawnCAVE::OnLookUpRate_Implementation(float Rate ) +void AVirtualRealityPawn::OnLookUpRate_Implementation(float Rate ) { if (IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster) { @@ -57,16 +60,16 @@ void ADisplayClusterPawnCAVE::OnLookUpRate_Implementation(flo AddControllerPitchInput(BaseTurnRate * Rate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation); } } -void ADisplayClusterPawnCAVE::OnFire_Implementation (bool Pressed) +void AVirtualRealityPawn::OnFire_Implementation (bool Pressed) { } -void ADisplayClusterPawnCAVE::OnAction_Implementation (bool Pressed, int32 Index) +void AVirtualRealityPawn::OnAction_Implementation (bool Pressed, int32 Index) { } -void ADisplayClusterPawnCAVE::BeginPlay () +void AVirtualRealityPawn::BeginPlay () { Super::BeginPlay(); @@ -87,8 +90,19 @@ 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) +void AVirtualRealityPawn::Tick (float DeltaSeconds) { Super::Tick(DeltaSeconds); @@ -99,38 +113,38 @@ void ADisplayClusterPawnCAVE::Tick (flo TranslationDirection = Flystick; } } -void ADisplayClusterPawnCAVE::BeginDestroy () +void AVirtualRealityPawn::BeginDestroy () { Super::BeginDestroy(); } -void ADisplayClusterPawnCAVE::SetupPlayerInputComponent (UInputComponent* PlayerInputComponent) +void AVirtualRealityPawn::SetupPlayerInputComponent (UInputComponent* PlayerInputComponent) { check(PlayerInputComponent); Super::SetupPlayerInputComponent(PlayerInputComponent); if (PlayerInputComponent) { - PlayerInputComponent->BindAxis ("MoveForward" , this, &ADisplayClusterPawnCAVE::OnForward ); - PlayerInputComponent->BindAxis ("MoveRight" , this, &ADisplayClusterPawnCAVE::OnRight ); - PlayerInputComponent->BindAxis ("TurnRate" , this, &ADisplayClusterPawnCAVE::OnTurnRate ); - PlayerInputComponent->BindAxis ("LookUpRate" , this, &ADisplayClusterPawnCAVE::OnLookUpRate ); + PlayerInputComponent->BindAxis ("MoveForward" , this, &AVirtualRealityPawn::OnForward ); + PlayerInputComponent->BindAxis ("MoveRight" , this, &AVirtualRealityPawn::OnRight ); + PlayerInputComponent->BindAxis ("TurnRate" , this, &AVirtualRealityPawn::OnTurnRate ); + PlayerInputComponent->BindAxis ("LookUpRate" , this, &AVirtualRealityPawn::OnLookUpRate ); - PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnFire , true ); - PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 1); - PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 2); - PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 3); - PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 4); - PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Pressed , this, &ADisplayClusterPawnCAVE::OnAction , true , 5); + PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Pressed , this, &AVirtualRealityPawn::OnFire , true ); + PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 1); + PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 2); + PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 3); + PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 4); + PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Pressed , this, &AVirtualRealityPawn::OnAction , true , 5); - PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Released, this, &ADisplayClusterPawnCAVE::OnFire , false ); - PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 1); - PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 2); - PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 3); - PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 4); - PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Released, this, &ADisplayClusterPawnCAVE::OnAction , false, 5); + PlayerInputComponent->BindAction<FFireDelegate> ("Fire" , IE_Released, this, &AVirtualRealityPawn::OnFire , false ); + PlayerInputComponent->BindAction<FActionDelegate>("Action1" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 1); + PlayerInputComponent->BindAction<FActionDelegate>("Action2" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 2); + PlayerInputComponent->BindAction<FActionDelegate>("Action3" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 3); + PlayerInputComponent->BindAction<FActionDelegate>("Action4" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 4); + PlayerInputComponent->BindAction<FActionDelegate>("Action5" , IE_Released, this, &AVirtualRealityPawn::OnAction , false, 5); } } -UPawnMovementComponent* ADisplayClusterPawnCAVE::GetMovementComponent () const +UPawnMovementComponent* AVirtualRealityPawn::GetMovementComponent () const { return MovementComponent; } diff --git a/Source/DisplayClusterExtensions/Public/DisplayClusterGameModeCAVE.h b/Source/DisplayClusterExtensions/Public/DisplayClusterGameModeCAVE.h deleted file mode 100644 index 395eba444e2f43b96535d93805cad88ee2e413f3..0000000000000000000000000000000000000000 --- a/Source/DisplayClusterExtensions/Public/DisplayClusterGameModeCAVE.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "CoreMinimal.h" -#include "DisplayClusterGameMode.h" - -#include "DisplayClusterGameModeCAVE.generated.h" - -UCLASS() -class DISPLAYCLUSTEREXTENSIONS_API ADisplayClusterGameModeCAVE : public ADisplayClusterGameMode -{ - GENERATED_BODY() - -public: - ADisplayClusterGameModeCAVE(); -}; \ No newline at end of file diff --git a/Source/DisplayClusterExtensions/Public/VirtualRealityGameMode.h b/Source/DisplayClusterExtensions/Public/VirtualRealityGameMode.h new file mode 100644 index 0000000000000000000000000000000000000000..3a21a7e129eac076c5601eecd32fd38c76ba2f90 --- /dev/null +++ b/Source/DisplayClusterExtensions/Public/VirtualRealityGameMode.h @@ -0,0 +1,15 @@ +#pragma once + +#include "CoreMinimal.h" +#include "DisplayClusterGameMode.h" + +#include "VirtualRealityGameMode.generated.h" + +UCLASS() +class DISPLAYCLUSTEREXTENSIONS_API AVirtualRealityGameMode : public ADisplayClusterGameMode +{ + GENERATED_BODY() + +public: + AVirtualRealityGameMode(); +}; \ No newline at end of file diff --git a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h b/Source/DisplayClusterExtensions/Public/VirtualRealityPawn.h similarity index 78% rename from Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h rename to Source/DisplayClusterExtensions/Public/VirtualRealityPawn.h index e2e9b9e6ada2a5fc1b70c03d1a0429c02eb9f429..8cae171605da946cd8072ee4b70acf591a4f7216 100644 --- a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h +++ b/Source/DisplayClusterExtensions/Public/VirtualRealityPawn.h @@ -6,11 +6,12 @@ #include "CoreMinimal.h" #include "DisplayClusterPawn.h" #include "DisplayClusterSceneComponent.h" +#include "MotionControllerComponent.h" -#include "DisplayClusterPawnCAVE.generated.h" +#include "VirtualRealityPawn.generated.h" UCLASS() -class DISPLAYCLUSTEREXTENSIONS_API ADisplayClusterPawnCAVE : public ADisplayClusterPawn +class DISPLAYCLUSTEREXTENSIONS_API AVirtualRealityPawn : public ADisplayClusterPawn { GENERATED_UCLASS_BODY() @@ -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; };