Skip to content
Snippets Groups Projects
Commit 7d7a9da8 authored by Sebastian Pape's avatar Sebastian Pape
Browse files

Merge branch 'feature/restructure_VRpawn' into 'develop'

Restructure VRPawn

See merge request VR-Group/unreal-development/ndisplayextensions!11
parents e4014704 e085472b
No related branches found
No related tags found
1 merge request!11Restructure VRPawn
...@@ -31,6 +31,10 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial ...@@ -31,6 +31,10 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial
RotatingMovement->PivotTranslation = FVector::ZeroVector; RotatingMovement->PivotTranslation = FVector::ZeroVector;
RotatingMovement->RotationRate = FRotator::ZeroRotator; RotatingMovement->RotationRate = FRotator::ZeroRotator;
Head = CreateDefaultSubobject<USceneComponent>(TEXT("Head"));
RightHand = CreateDefaultSubobject<USceneComponent>(TEXT("RightHand"));
LeftHand = CreateDefaultSubobject<USceneComponent>(TEXT("LeftHand"));
HmdLeftMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("HmdLeftMotionController")); HmdLeftMotionController = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("HmdLeftMotionController"));
HmdLeftMotionController->SetupAttachment(RootComponent); HmdLeftMotionController->SetupAttachment(RootComponent);
HmdLeftMotionController->SetTrackingSource(EControllerHand::Left); HmdLeftMotionController->SetTrackingSource(EControllerHand::Left);
...@@ -149,6 +153,16 @@ UDisplayClusterSceneComponent* AVirtualRealityPawn::GetFlystickComponent() ...@@ -149,6 +153,16 @@ UDisplayClusterSceneComponent* AVirtualRealityPawn::GetFlystickComponent()
return Flystick; return Flystick;
} }
UDisplayClusterSceneComponent* AVirtualRealityPawn::GetRightHandtargetComponent()
{
return RightHandTarget;
}
UDisplayClusterSceneComponent* AVirtualRealityPawn::GetLeftHandtargetComponent()
{
return LeftHandTarget;
}
UMotionControllerComponent* AVirtualRealityPawn::GetHmdLeftMotionControllerComponent() UMotionControllerComponent* AVirtualRealityPawn::GetHmdLeftMotionControllerComponent()
{ {
return HmdLeftMotionController; return HmdLeftMotionController;
...@@ -174,9 +188,9 @@ USceneComponent* AVirtualRealityPawn::GetRightHandComponent() ...@@ -174,9 +188,9 @@ USceneComponent* AVirtualRealityPawn::GetRightHandComponent()
return RightHand; return RightHand;
} }
USceneComponent* AVirtualRealityPawn::GetCaveOriginComponent() USceneComponent* AVirtualRealityPawn::GetTrackingOriginComponent()
{ {
return CaveOrigin; return TrackingOrigin;
} }
USceneComponent* AVirtualRealityPawn::GetCaveCenterComponent() USceneComponent* AVirtualRealityPawn::GetCaveCenterComponent()
...@@ -234,27 +248,31 @@ void AVirtualRealityPawn::BeginPlay() ...@@ -234,27 +248,31 @@ void AVirtualRealityPawn::BeginPlay()
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("TurnRate", EKeys::MouseX)); UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("TurnRate", EKeys::MouseX));
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("LookUpRate", EKeys::MouseY)); UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("LookUpRate", EKeys::MouseY));
InitComponentReferences(); InitRoomMountedComponentReferences();
RootComponent->SetWorldLocation(FVector(0, 2, 0), false, nullptr, ETeleportType::None);
} }
else if (IsHeadMountedMode()) else if (IsHeadMountedMode())
{ {
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("TurnRate", EKeys::MouseX)); UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("TurnRate", EKeys::MouseX));
UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("LookUpRate", EKeys::MouseY)); UInputSettings::GetInputSettings()->RemoveAxisMapping(FInputAxisKeyMapping("LookUpRate", EKeys::MouseY));
HmdLeftMotionController->SetVisibility(true); HmdLeftMotionController->SetVisibility(ShowHMDControllers);
HmdRightMotionController->SetVisibility(true); HmdRightMotionController->SetVisibility(ShowHMDControllers);
LeftHand = HmdLeftMotionController; LeftHand->AttachToComponent(HmdLeftMotionController, FAttachmentTransformRules::KeepRelativeTransform);
RightHand = HmdRightMotionController; RightHand->AttachToComponent(HmdRightMotionController, FAttachmentTransformRules::KeepRelativeTransform);
Head = GetCameraComponent(); Head->AttachToComponent(GetCameraComponent(), FAttachmentTransformRules::KeepRelativeTransform);
} }
else //Desktop else //Desktop
{ {
LeftHand = RootComponent; Head->AttachToComponent(GetCameraComponent(), FAttachmentTransformRules::KeepRelativeTransform);
RightHand = RootComponent;
Head = GetCameraComponent(); //also attach the hands to the camera component so we can use them for interaction
LeftHand->AttachToComponent(GetCameraComponent(), FAttachmentTransformRules::KeepRelativeTransform);
RightHand->AttachToComponent(GetCameraComponent(), FAttachmentTransformRules::KeepRelativeTransform);
//move to eyelevel
GetCameraComponent()->SetRelativeLocation(FVector(0, 0, 160));
} }
//In ADisplayClusterPawn::BeginPlay() input is disabled on all slaves, so we cannot react to button presses, e.g. on the flystick correctly. //In ADisplayClusterPawn::BeginPlay() input is disabled on all slaves, so we cannot react to button presses, e.g. on the flystick correctly.
...@@ -294,7 +312,7 @@ void AVirtualRealityPawn::Tick(float DeltaSeconds) ...@@ -294,7 +312,7 @@ void AVirtualRealityPawn::Tick(float DeltaSeconds)
Super::Tick(DeltaSeconds); Super::Tick(DeltaSeconds);
//Flystick might not be available at start, hence is checked every frame. //Flystick might not be available at start, hence is checked every frame.
InitComponentReferences(); InitRoomMountedComponentReferences();
} }
void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
...@@ -314,24 +332,41 @@ UPawnMovementComponent* AVirtualRealityPawn::GetMovementComponent() const ...@@ -314,24 +332,41 @@ UPawnMovementComponent* AVirtualRealityPawn::GetMovementComponent() const
return Movement; return Movement;
} }
void AVirtualRealityPawn::InitComponentReferences() void AVirtualRealityPawn::InitRoomMountedComponentReferences()
{ {
if (!IsRoomMountedMode()) return; if (!IsRoomMountedMode()) return;
if (!CaveOrigin) CaveOrigin = GetClusterComponent("cave_origin");
//check whether the nodes already exist (otherwise GetClusterComponent() returns nullptr and prints a warning) and assign them
if (!TrackingOrigin) TrackingOrigin = GetClusterComponent("cave_origin");
if (!TrackingOrigin) TrackingOrigin = GetClusterComponent("rolv_origin");
if (!CaveCenter) CaveCenter = GetClusterComponent("cave_center"); if (!CaveCenter) CaveCenter = GetClusterComponent("cave_center");
if (!ShutterGlasses) if (!ShutterGlasses)
{ {
ShutterGlasses = GetClusterComponent("shutter_glasses"); ShutterGlasses = GetClusterComponent("shutter_glasses");
Head = ShutterGlasses; Head->AttachToComponent(ShutterGlasses, FAttachmentTransformRules::KeepRelativeTransform);
} }
if (!Flystick) if (!Flystick)
{ {
Flystick = GetClusterComponent("flystick"); Flystick = GetClusterComponent("flystick");
if (AttachRightHandInCAVE == EAttachementType::AT_FLYSTICK)
LeftHand = Flystick; RightHand->AttachToComponent(Flystick, FAttachmentTransformRules::KeepRelativeTransform);
RightHand = Flystick; if (AttachLeftHandInCAVE == EAttachementType::AT_FLYSTICK)
LeftHand->AttachToComponent(Flystick, FAttachmentTransformRules::KeepRelativeTransform);
} }
if (!LeftHandTarget)
{
LeftHandTarget = GetClusterComponent("left_hand_target");
if (AttachLeftHandInCAVE == EAttachementType::AT_HANDTARGET)
LeftHand->AttachToComponent(LeftHandTarget, FAttachmentTransformRules::KeepRelativeTransform);
} }
if (!RightHandTarget)
{
RightHandTarget = GetClusterComponent("right_hand_target");
if (AttachRightHandInCAVE == EAttachementType::AT_HANDTARGET)
RightHand->AttachToComponent(RightHandTarget, FAttachmentTransformRules::KeepRelativeTransform);
}
}
EEyeType AVirtualRealityPawn::GetNodeEyeType() EEyeType AVirtualRealityPawn::GetNodeEyeType()
{ {
... ...
......
...@@ -26,6 +26,14 @@ enum class EEyeType : uint8 ...@@ -26,6 +26,14 @@ enum class EEyeType : uint8
ET_STEREO_LEFT UMETA(DisplayName = "stereo_left") ET_STEREO_LEFT UMETA(DisplayName = "stereo_left")
}; };
UENUM(BlueprintType)
enum class EAttachementType : uint8
{
AT_NONE UMETA(DisplayName = "not attached"),
AT_HANDTARGET UMETA(DisplayName = "to the right/left hand target"),
AT_FLYSTICK UMETA(DisplayName = "to the Flystick")
};
UCLASS() UCLASS()
class DISPLAYCLUSTEREXTENSIONS_API AVirtualRealityPawn : public ADisplayClusterPawn class DISPLAYCLUSTEREXTENSIONS_API AVirtualRealityPawn : public ADisplayClusterPawn
{ {
...@@ -43,6 +51,7 @@ public: ...@@ -43,6 +51,7 @@ public:
UFUNCTION(BlueprintPure, Category = "Pawn") static bool IsRoomMountedMode(); UFUNCTION(BlueprintPure, Category = "Pawn") static bool IsRoomMountedMode();
UFUNCTION(BlueprintPure, Category = "Pawn") static bool IsHeadMountedMode(); UFUNCTION(BlueprintPure, Category = "Pawn") static bool IsHeadMountedMode();
UFUNCTION(BlueprintPure, Category = "Pawn") static FString GetNodeName(); UFUNCTION(BlueprintPure, Category = "Pawn") static FString GetNodeName();
UFUNCTION(BlueprintPure, Category = "Pawn") static float GetEyeDistance(); UFUNCTION(BlueprintPure, Category = "Pawn") static float GetEyeDistance();
...@@ -54,8 +63,9 @@ public: ...@@ -54,8 +63,9 @@ public:
UFUNCTION(Category = "Pawn") URotatingMovementComponent* GetRotatingMovementComponent(); UFUNCTION(Category = "Pawn") URotatingMovementComponent* GetRotatingMovementComponent();
//Bunch of Getter Functions for components to avoid users having to know the names //Bunch of Getter Functions for components to avoid users having to know the names
UFUNCTION(Category = "Pawn") UDisplayClusterSceneComponent* GetFlystickComponent(); UFUNCTION(Category = "Pawn") UDisplayClusterSceneComponent* GetFlystickComponent();
UFUNCTION(Category = "Pawn") UDisplayClusterSceneComponent* GetRightHandtargetComponent();
UFUNCTION(Category = "Pawn") UDisplayClusterSceneComponent* GetLeftHandtargetComponent();
UFUNCTION(Category = "Pawn") UMotionControllerComponent* GetHmdLeftMotionControllerComponent(); UFUNCTION(Category = "Pawn") UMotionControllerComponent* GetHmdLeftMotionControllerComponent();
UFUNCTION(Category = "Pawn") UMotionControllerComponent* GetHmdRightMotionControllerComponent(); UFUNCTION(Category = "Pawn") UMotionControllerComponent* GetHmdRightMotionControllerComponent();
...@@ -63,10 +73,13 @@ public: ...@@ -63,10 +73,13 @@ public:
UFUNCTION(Category = "Pawn") USceneComponent* GetLeftHandComponent(); UFUNCTION(Category = "Pawn") USceneComponent* GetLeftHandComponent();
UFUNCTION(Category = "Pawn") USceneComponent* GetRightHandComponent(); UFUNCTION(Category = "Pawn") USceneComponent* GetRightHandComponent();
UFUNCTION(Category = "Pawn") USceneComponent* GetCaveOriginComponent(); UFUNCTION(Category = "Pawn") USceneComponent* GetTrackingOriginComponent();
private:
UFUNCTION(Category = "Pawn") USceneComponent* GetCaveCenterComponent(); UFUNCTION(Category = "Pawn") USceneComponent* GetCaveCenterComponent();
UFUNCTION(Category = "Pawn") USceneComponent* GetShutterGlassesComponent(); UFUNCTION(Category = "Pawn") USceneComponent* GetShutterGlassesComponent();
public:
//Get Compenent of Display Cluster by it's name, which is specified in the nDisplay config //Get Compenent of Display Cluster by it's name, which is specified in the nDisplay config
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Pawn") static UDisplayClusterSceneComponent* GetClusterComponent(const FString& Name); UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Pawn") static UDisplayClusterSceneComponent* GetClusterComponent(const FString& Name);
...@@ -95,25 +108,35 @@ protected: ...@@ -95,25 +108,35 @@ protected:
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. CAVE/ROLV flystick. // Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. CAVE/ROLV flystick.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UDisplayClusterSceneComponent* Flystick = nullptr; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UDisplayClusterSceneComponent* Flystick = nullptr;
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. CAVE/ROLV flystick.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UDisplayClusterSceneComponent* RightHandTarget = nullptr;
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. CAVE/ROLV flystick.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UDisplayClusterSceneComponent* LeftHandTarget = nullptr;
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. HMD left motion controller. // Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. HMD left motion controller.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly , Category = "Pawn", meta = (AllowPrivateAccess = "true")) UMotionControllerComponent* HmdLeftMotionController = nullptr; UMotionControllerComponent* HmdLeftMotionController = nullptr;
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. HMD right motion controller. // Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. HMD right motion controller.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly , Category = "Pawn", meta = (AllowPrivateAccess = "true")) UMotionControllerComponent* HmdRightMotionController = nullptr; UMotionControllerComponent* HmdRightMotionController = nullptr;
// PC: Camera, HMD: Camera, CAVE/ROLV: Shutter glasses. // PC: Camera, HMD: Camera, CAVE/ROLV: Shutter glasses.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* Head = nullptr; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* Head = nullptr;
// PC: RootComponent, HMD: HmdLeftMotionController , CAVE/ROLV: Flystick. Useful for line trace (e.g. for holding objects). // PC: RootComponent, HMD: HmdLeftMotionController , CAVE/ROLV: regarding to AttachRightHandInCAVE. Useful for line trace (e.g. for holding objects).
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* LeftHand = nullptr;
// PC: RootComponent, HMD: HmdRightMotionController, CAVE/ROLV: Flystick. Useful for line trace (e.g. for holding objects).
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* RightHand = nullptr; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* RightHand = nullptr;
// PC: RootComponent, HMD: HmdRightMotionController, CAVE/ROLV: regarding to AttachLeftHandInCAVE. Useful for line trace (e.g. for holding objects).
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* LeftHand = nullptr;
// Holding the Cave Origin Component that is attached to this Pawn // Holding the Cave/rolv Origin Component that is attached to this Pawn
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* CaveOrigin = nullptr; UPROPERTY() USceneComponent* TrackingOrigin = nullptr;
// Holding the Cave Center Component that is attached to this Pawn // Holding the Cave Center Component that is attached to this Pawn, it is needed for the internal transform of nDisplay
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* CaveCenter = nullptr; UPROPERTY() USceneComponent* CaveCenter = nullptr;
// Holding the Shutter Glasses Component that is attached to this Pawn // Holding the Shutter Glasses Component that is attached to this Pawn
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) USceneComponent* ShutterGlasses = nullptr; UPROPERTY() USceneComponent* ShutterGlasses = nullptr;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn") bool ShowHMDControllers = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn") EAttachementType AttachRightHandInCAVE = EAttachementType::AT_FLYSTICK;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn") EAttachementType AttachLeftHandInCAVE = EAttachementType::AT_NONE;
private: private:
void InitComponentReferences(); void InitRoomMountedComponentReferences();
}; };
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment