Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RWTH VR Toolkit
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Unreal-Development
Plugins
RWTH VR Toolkit
Commits
726cb4c0
Commit
726cb4c0
authored
5 years ago
by
Sebastian Pape
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into 'master'
Develop See merge request VR-Group/ndisplayextensions!3
parents
6512fd6f
222cc799
Branches
4.21
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/DisplayClusterExtensions/Private/VirtualRealityPawn.cpp
+300
-166
300 additions, 166 deletions
...e/DisplayClusterExtensions/Private/VirtualRealityPawn.cpp
Source/DisplayClusterExtensions/Public/VirtualRealityPawn.h
+94
-33
94 additions, 33 deletions
Source/DisplayClusterExtensions/Public/VirtualRealityPawn.h
with
394 additions
and
199 deletions
Source/DisplayClusterExtensions/Private/VirtualRealityPawn.cpp
+
300
−
166
View file @
726cb4c0
...
@@ -5,178 +5,312 @@
...
@@ -5,178 +5,312 @@
#include
"Game/IDisplayClusterGameManager.h"
#include
"Game/IDisplayClusterGameManager.h"
#include
"GameFramework/InputSettings.h"
#include
"GameFramework/InputSettings.h"
#include
"GameFramework/WorldSettings.h"
#include
"GameFramework/WorldSettings.h"
#include
"Input/IDisplayClusterInputManager.h"
#include
"Kismet/GameplayStatics.h"
#include
"Kismet/GameplayStatics.h"
#include
"DisplayClusterSettings.h"
#include
"DisplayClusterSettings.h"
#include
"
HeadMountedDisplayFunctionLibrary
.h"
#include
"
IDisplayClusterConfigManager
.h"
#include
"IDisplayCluster.h"
#include
"IDisplayCluster.h"
#include
"IXRTrackingSystem.h"
#include
"Engine/Engine.h"
#include
"Camera/CameraComponent.h"
AVirtualRealityPawn
::
AVirtualRealityPawn
(
const
FObjectInitializer
&
ObjectInitializer
)
:
Super
(
ObjectInitializer
)
AVirtualRealityPawn
::
AVirtualRealityPawn
(
const
FObjectInitializer
&
ObjectInitializer
)
:
Super
(
ObjectInitializer
)
{
{
AutoPossessPlayer
=
EAutoReceiveInput
::
Player0
;
// Necessary for receiving motion controller events.
AutoPossessPlayer
=
EAutoReceiveInput
::
Player0
;
// Necessary for receiving motion controller events.
Movement
=
CreateDefaultSubobject
<
UFloatingPawnMovement
>
(
TEXT
(
"Movement"
));
Movement
=
CreateDefaultSubobject
<
UFloatingPawnMovement
>
(
TEXT
(
"Movement"
));
Movement
->
UpdatedComponent
=
RootComponent
;
Movement
->
UpdatedComponent
=
RootComponent
;
RotatingMovement
=
CreateDefaultSubobject
<
URotatingMovementComponent
>
(
TEXT
(
"RotatingMovement"
));
RotatingMovement
=
CreateDefaultSubobject
<
URotatingMovementComponent
>
(
TEXT
(
"RotatingMovement"
));
RotatingMovement
->
UpdatedComponent
=
RootComponent
;
RotatingMovement
->
UpdatedComponent
=
RootComponent
;
RotatingMovement
->
bRotationInLocalSpace
=
false
;
RotatingMovement
->
bRotationInLocalSpace
=
false
;
RotatingMovement
->
PivotTranslation
=
FVector
::
ZeroVector
;
RotatingMovement
->
PivotTranslation
=
FVector
::
ZeroVector
;
RotatingMovement
->
RotationRate
=
FRotator
::
ZeroRotator
;
RotatingMovement
->
RotationRate
=
FRotator
::
ZeroRotator
;
LeftMotionController
=
CreateDefaultSubobject
<
UMotionControllerComponent
>
(
TEXT
(
"LeftMotionController"
));
HmdLeftMotionController
=
CreateDefaultSubobject
<
UMotionControllerComponent
>
(
TEXT
(
"HmdLeftMotionController"
));
LeftMotionController
->
SetupAttachment
(
RootComponent
);
HmdLeftMotionController
->
SetupAttachment
(
RootComponent
);
LeftMotionController
->
SetTrackingSource
(
EControllerHand
::
Left
);
HmdLeftMotionController
->
SetTrackingSource
(
EControllerHand
::
Left
);
LeftMotionController
->
SetShowDeviceModel
(
true
);
HmdLeftMotionController
->
SetShowDeviceModel
(
true
);
LeftMotionController
->
SetVisibility
(
false
);
HmdLeftMotionController
->
SetVisibility
(
false
);
RightMotionController
=
CreateDefaultSubobject
<
UMotionControllerComponent
>
(
TEXT
(
"RightMotionController"
));
HmdRightMotionController
=
CreateDefaultSubobject
<
UMotionControllerComponent
>
(
TEXT
(
"HmdRightMotionController"
));
RightMotionController
->
SetupAttachment
(
RootComponent
);
HmdRightMotionController
->
SetupAttachment
(
RootComponent
);
RightMotionController
->
SetTrackingSource
(
EControllerHand
::
Right
);
HmdRightMotionController
->
SetTrackingSource
(
EControllerHand
::
Right
);
RightMotionController
->
SetShowDeviceModel
(
true
);
HmdRightMotionController
->
SetShowDeviceModel
(
true
);
RightMotionController
->
SetVisibility
(
false
);
HmdRightMotionController
->
SetVisibility
(
false
);
}
}
void
AVirtualRealityPawn
::
OnForward_Implementation
(
float
Value
)
void
AVirtualRealityPawn
::
OnForward_Implementation
(
float
Value
)
{
{
AddMovementInput
(
Forward
->
GetForwardVector
(),
Value
);
// Check if this function triggers correctly on ROLV.
}
if
(
NavigationMode
==
EVRNavigationModes
::
Nav_Mode_Fly
||
IsDesktopMode
()
||
IsHeadMountedMode
())
void
AVirtualRealityPawn
::
OnRight_Implementation
(
float
Value
)
{
{
AddMovementInput
(
RightHand
->
GetForwardVector
(),
Value
);
AddMovementInput
(
Forward
->
GetRightVector
(),
Value
);
}
}
}
void
AVirtualRealityPawn
::
OnTurnRate_Implementation
(
float
Rate
)
{
void
AVirtualRealityPawn
::
OnRight_Implementation
(
float
Value
)
if
(
IDisplayCluster
::
Get
().
GetOperationMode
()
==
EDisplayClusterOperationMode
::
Cluster
)
{
{
if
(
NavigationMode
==
EVRNavigationModes
::
Nav_Mode_Fly
||
IsDesktopMode
()
||
IsHeadMountedMode
())
const
FVector
CameraLocation
=
IDisplayCluster
::
Get
().
GetGameMgr
()
->
GetActiveCamera
()
->
GetComponentLocation
();
{
RotatingMovement
->
PivotTranslation
=
RotatingMovement
->
UpdatedComponent
->
GetComponentTransform
().
InverseTransformPositionNoScale
(
CameraLocation
);
AddMovementInput
(
RightHand
->
GetRightVector
(),
Value
);
RotatingMovement
->
RotationRate
=
FRotator
(
RotatingMovement
->
RotationRate
.
Pitch
,
Rate
*
BaseTurnRate
,
0.0
f
);
}
}
}
else
{
void
AVirtualRealityPawn
::
OnTurnRate_Implementation
(
float
Rate
)
AddControllerYawInput
(
Rate
*
BaseTurnRate
*
GetWorld
()
->
GetDeltaSeconds
()
*
CustomTimeDilation
);
{
}
//if (IsRoomMountedMode())
}
//{
void
AVirtualRealityPawn
::
OnLookUpRate_Implementation
(
float
Rate
)
// //const FVector CameraLocation = IDisplayCluster::Get().GetGameMgr()->GetActiveCamera()->GetComponentLocation();
{
// //RotatingMovement->PivotTranslation = RotatingMovement
if
(
IDisplayCluster
::
Get
().
GetOperationMode
()
==
EDisplayClusterOperationMode
::
Cluster
)
// // ->UpdatedComponent->GetComponentTransform().
{
// // InverseTransformPositionNoScale(CameraLocation);
// User-centered projection causes simulation sickness on look up interaction hence not implemented.
// //RotatingMovement->RotationRate = FRotator(RotatingMovement->RotationRate.Pitch, Rate * BaseTurnRate, 0.0f);
}
else
//}
{
//else
AddControllerPitchInput
(
Rate
*
BaseTurnRate
*
GetWorld
()
->
GetDeltaSeconds
()
*
CustomTimeDilation
);
//{
}
// AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation);
}
//}
void
AVirtualRealityPawn
::
OnFire_Implementation
(
bool
Pressed
)
AddControllerYawInput
(
Rate
*
BaseTurnRate
*
GetWorld
()
->
GetDeltaSeconds
()
*
CustomTimeDilation
);
{
}
}
void
AVirtualRealityPawn
::
OnLookUpRate_Implementation
(
float
Rate
)
void
AVirtualRealityPawn
::
OnAction_Implementation
(
bool
Pressed
,
int32
Index
)
{
{
if
(
IsRoomMountedMode
())
{
}
// User-centered projection causes simulation sickness on look up interaction hence not implemented.
}
void
AVirtualRealityPawn
::
BeginPlay
()
else
{
{
Super
::
BeginPlay
();
AddControllerPitchInput
(
Rate
*
BaseTurnRate
*
GetWorld
()
->
GetDeltaSeconds
()
*
CustomTimeDilation
);
}
bUseControllerRotationYaw
=
true
;
}
bUseControllerRotationPitch
=
true
;
bUseControllerRotationRoll
=
true
;
void
AVirtualRealityPawn
::
OnFire_Implementation
(
bool
Pressed
)
{
// Display cluster settings apply to all setups (PC, HMD, CAVE/ROLV) despite the unfortunate name due to being an UE4 internal.
}
TArray
<
AActor
*>
SettingsActors
;
UGameplayStatics
::
GetAllActorsOfClass
(
GetWorld
(),
ADisplayClusterSettings
::
StaticClass
(),
SettingsActors
);
void
AVirtualRealityPawn
::
OnAction_Implementation
(
bool
Pressed
,
int32
Index
)
if
(
SettingsActors
.
Num
()
>
0
)
{
{
}
ADisplayClusterSettings
*
Settings
=
Cast
<
ADisplayClusterSettings
>
(
SettingsActors
[
0
]);
Movement
->
MaxSpeed
=
Settings
->
MovementMaxSpeed
;
bool
AVirtualRealityPawn
::
IsDesktopMode
()
Movement
->
Acceleration
=
Settings
->
MovementAcceleration
;
{
Movement
->
Deceleration
=
Settings
->
MovementDeceleration
;
return
!
IsRoomMountedMode
()
&&
!
IsHeadMountedMode
();
Movement
->
TurningBoost
=
Settings
->
MovementTurningBoost
;
}
BaseTurnRate
=
Settings
->
RotationSpeed
;
}
bool
AVirtualRealityPawn
::
IsRoomMountedMode
()
{
if
(
IDisplayCluster
::
Get
().
GetOperationMode
()
==
EDisplayClusterOperationMode
::
Cluster
)
return
IDisplayCluster
::
Get
().
GetOperationMode
()
==
EDisplayClusterOperationMode
::
Cluster
;
{
}
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
FName
(
TEXT
(
"TurnRate"
)),
EKeys
::
MouseX
));
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
FName
(
TEXT
(
"LookUpRate"
)),
EKeys
::
MouseY
));
bool
AVirtualRealityPawn
::
IsHeadMountedMode
()
{
// Requires a scene node called flystick in the config.
return
GEngine
->
XRSystem
.
IsValid
()
&&
GEngine
->
XRSystem
->
IsHeadTrackingAllowed
();
Flystick
=
IDisplayCluster
::
Get
().
GetGameMgr
()
->
GetNodeById
(
TEXT
(
"flystick"
));
}
Forward
=
Flystick
;
FString
AVirtualRealityPawn
::
GetNodeName
()
LeftHand
=
Flystick
;
{
RightHand
=
Flystick
;
return
IsRoomMountedMode
()
?
IDisplayCluster
::
Get
().
GetClusterMgr
()
->
GetNodeId
()
:
FString
(
TEXT
(
"Localhost"
));
}
}
else
if
(
UHeadMountedDisplayFunctionLibrary
::
IsHeadMountedDisplayConnected
())
{
float
AVirtualRealityPawn
::
GetEyeDistance
()
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
FName
(
TEXT
(
"TurnRate"
)),
EKeys
::
MouseX
));
{
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
FName
(
TEXT
(
"LookUpRate"
)),
EKeys
::
MouseY
));
return
IDisplayCluster
::
Get
().
GetConfigMgr
()
->
GetConfigStereo
().
EyeDist
;
}
LeftMotionController
->
SetVisibility
(
true
);
RightMotionController
->
SetVisibility
(
true
);
float
AVirtualRealityPawn
::
GetBaseTurnRate
()
const
{
Forward
=
LeftMotionController
;
return
BaseTurnRate
;
LeftHand
=
LeftMotionController
;
}
RightHand
=
RightMotionController
;
}
void
AVirtualRealityPawn
::
SetBaseTurnRate
(
float
Value
)
else
{
{
BaseTurnRate
=
Value
;
Forward
=
RootComponent
;
}
LeftHand
=
RootComponent
;
RightHand
=
RootComponent
;
UFloatingPawnMovement
*
AVirtualRealityPawn
::
GetFloatingPawnMovement
()
}
{
}
return
Movement
;
void
AVirtualRealityPawn
::
Tick
(
float
DeltaSeconds
)
}
URotatingMovementComponent
*
AVirtualRealityPawn
::
GetRotatingMovementComponent
()
{
return
RotatingMovement
;
}
UDisplayClusterSceneComponent
*
AVirtualRealityPawn
::
GetFlystickComponent
()
{
return
Flystick
;
}
UMotionControllerComponent
*
AVirtualRealityPawn
::
GetHmdLeftMotionControllerComponent
()
{
return
HmdLeftMotionController
;
}
UMotionControllerComponent
*
AVirtualRealityPawn
::
GetHmdRightMotionControllerComponent
()
{
return
HmdRightMotionController
;
}
USceneComponent
*
AVirtualRealityPawn
::
GetHeadComponent
()
{
return
Head
;
}
USceneComponent
*
AVirtualRealityPawn
::
GetLeftHandComponent
()
{
return
LeftHand
;
}
USceneComponent
*
AVirtualRealityPawn
::
GetRightHandComponent
()
{
return
RightHand
;
}
USceneComponent
*
AVirtualRealityPawn
::
GetCaveOriginComponent
()
{
return
CaveOrigin
;
}
USceneComponent
*
AVirtualRealityPawn
::
GetCaveCenterComponent
()
{
return
CaveCenter
;
}
USceneComponent
*
AVirtualRealityPawn
::
GetShutterGlassesComponent
()
{
return
ShutterGlasses
;
}
UDisplayClusterSceneComponent
*
AVirtualRealityPawn
::
GetClusterComponent
(
const
FString
&
Name
)
{
return
IDisplayCluster
::
Get
().
GetGameMgr
()
->
GetNodeById
(
Name
);
}
void
AVirtualRealityPawn
::
BeginPlay
()
{
Super
::
BeginPlay
();
bUseControllerRotationYaw
=
true
;
bUseControllerRotationPitch
=
true
;
bUseControllerRotationRoll
=
true
;
// Display cluster settings apply to all setups (PC, HMD, CAVE/ROLV) despite the unfortunate name due to being an UE4 internal.
TArray
<
AActor
*>
SettingsActors
;
UGameplayStatics
::
GetAllActorsOfClass
(
GetWorld
(),
ADisplayClusterSettings
::
StaticClass
(),
SettingsActors
);
if
(
SettingsActors
.
Num
()
>
0
)
{
ADisplayClusterSettings
*
Settings
=
Cast
<
ADisplayClusterSettings
>
(
SettingsActors
[
0
]);
Movement
->
MaxSpeed
=
Settings
->
MovementMaxSpeed
;
Movement
->
Acceleration
=
Settings
->
MovementAcceleration
;
Movement
->
Deceleration
=
Settings
->
MovementDeceleration
;
Movement
->
TurningBoost
=
Settings
->
MovementTurningBoost
;
BaseTurnRate
=
Settings
->
RotationSpeed
;
}
if
(
IsRoomMountedMode
())
{
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
"TurnRate"
,
EKeys
::
MouseX
));
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
"LookUpRate"
,
EKeys
::
MouseY
));
InitComponentReferences
();
RootComponent
->
SetWorldLocation
(
FVector
(
0
,
2
,
0
),
false
,
nullptr
,
ETeleportType
::
None
);
}
else
if
(
IsHeadMountedMode
())
{
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
"TurnRate"
,
EKeys
::
MouseX
));
UInputSettings
::
GetInputSettings
()
->
RemoveAxisMapping
(
FInputAxisKeyMapping
(
"LookUpRate"
,
EKeys
::
MouseY
));
HmdLeftMotionController
->
SetVisibility
(
true
);
HmdRightMotionController
->
SetVisibility
(
true
);
LeftHand
=
HmdLeftMotionController
;
RightHand
=
HmdRightMotionController
;
Head
=
GetCameraComponent
();
}
else
{
LeftHand
=
RootComponent
;
RightHand
=
RootComponent
;
Head
=
GetCameraComponent
();
}
}
void
AVirtualRealityPawn
::
Tick
(
float
DeltaSeconds
)
{
{
Super
::
Tick
(
DeltaSeconds
);
Super
::
Tick
(
DeltaSeconds
);
// Flystick might not be available at start, hence is checked every frame.
// Components might not be available at start, hence is checked every frame.
if
(
IDisplayCluster
::
Get
().
GetOperationMode
()
==
EDisplayClusterOperationMode
::
Cluster
&&
!
Flystick
)
InitComponentReferences
();
{
}
// Requires a scene node called flystick in the config.
Flystick
=
IDisplayCluster
::
Get
().
GetGameMgr
()
->
GetNodeById
(
TEXT
(
"flystick"
));
void
AVirtualRealityPawn
::
BeginDestroy
()
{
Forward
=
Flystick
;
Super
::
BeginDestroy
();
LeftHand
=
Flystick
;
}
RightHand
=
Flystick
;
}
void
AVirtualRealityPawn
::
SetupPlayerInputComponent
(
UInputComponent
*
PlayerInputComponent
)
}
{
void
AVirtualRealityPawn
::
BeginDestroy
()
check
(
PlayerInputComponent
);
{
Super
::
SetupPlayerInputComponent
(
PlayerInputComponent
);
Super
::
BeginDestroy
();
if
(
PlayerInputComponent
)
}
{
PlayerInputComponent
->
BindAxis
(
"MoveForward"
,
this
,
&
AVirtualRealityPawn
::
OnForward
);
void
AVirtualRealityPawn
::
SetupPlayerInputComponent
(
UInputComponent
*
PlayerInputComponent
)
PlayerInputComponent
->
BindAxis
(
"MoveRight"
,
this
,
&
AVirtualRealityPawn
::
OnRight
);
{
PlayerInputComponent
->
BindAxis
(
"TurnRate"
,
this
,
&
AVirtualRealityPawn
::
OnTurnRate
);
check
(
PlayerInputComponent
);
PlayerInputComponent
->
BindAxis
(
"LookUpRate"
,
this
,
&
AVirtualRealityPawn
::
OnLookUpRate
);
Super
::
SetupPlayerInputComponent
(
PlayerInputComponent
);
if
(
PlayerInputComponent
)
// The button names are based on the definitions in aixcave_422.cfg.
{
PlayerInputComponent
->
BindAction
<
FFireDelegate
>
(
"nDisplayButton0"
,
IE_Pressed
,
this
,
PlayerInputComponent
->
BindAxis
(
"MoveForward"
,
this
,
&
AVirtualRealityPawn
::
OnForward
);
&
AVirtualRealityPawn
::
OnFire
,
true
);
PlayerInputComponent
->
BindAxis
(
"MoveRight"
,
this
,
&
AVirtualRealityPawn
::
OnRight
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton1"
,
IE_Pressed
,
this
,
PlayerInputComponent
->
BindAxis
(
"TurnRate"
,
this
,
&
AVirtualRealityPawn
::
OnTurnRate
);
&
AVirtualRealityPawn
::
OnAction
,
true
,
1
);
PlayerInputComponent
->
BindAxis
(
"LookUpRate"
,
this
,
&
AVirtualRealityPawn
::
OnLookUpRate
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton2"
,
IE_Pressed
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
true
,
2
);
PlayerInputComponent
->
BindAction
<
FFireDelegate
>
(
"Fire"
,
IE_Pressed
,
this
,
&
AVirtualRealityPawn
::
OnFire
,
true
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton3"
,
IE_Pressed
,
this
,
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action1"
,
IE_Pressed
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
true
,
1
);
&
AVirtualRealityPawn
::
OnAction
,
true
,
3
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action2"
,
IE_Pressed
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
true
,
2
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton4"
,
IE_Pressed
,
this
,
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action3"
,
IE_Pressed
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
true
,
3
);
&
AVirtualRealityPawn
::
OnAction
,
true
,
4
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action4"
,
IE_Pressed
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
true
,
4
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton5"
,
IE_Pressed
,
this
,
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action5"
,
IE_Pressed
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
true
,
5
);
&
AVirtualRealityPawn
::
OnAction
,
true
,
5
);
PlayerInputComponent
->
BindAction
<
FFireDelegate
>
(
"Fire"
,
IE_Released
,
this
,
&
AVirtualRealityPawn
::
OnFire
,
false
);
PlayerInputComponent
->
BindAction
<
FFireDelegate
>
(
"nDisplayButton0"
,
IE_Released
,
this
,
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action1"
,
IE_Released
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
false
,
1
);
&
AVirtualRealityPawn
::
OnFire
,
false
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action2"
,
IE_Released
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
false
,
2
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton1"
,
IE_Released
,
this
,
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action3"
,
IE_Released
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
false
,
3
);
&
AVirtualRealityPawn
::
OnAction
,
false
,
1
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action4"
,
IE_Released
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
false
,
4
);
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton2"
,
IE_Released
,
this
,
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"Action5"
,
IE_Released
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
false
,
5
);
&
AVirtualRealityPawn
::
OnAction
,
false
,
2
);
}
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton3"
,
IE_Released
,
this
,
}
&
AVirtualRealityPawn
::
OnAction
,
false
,
3
);
UPawnMovementComponent
*
AVirtualRealityPawn
::
GetMovementComponent
()
const
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton4"
,
IE_Released
,
this
,
{
&
AVirtualRealityPawn
::
OnAction
,
false
,
4
);
return
Movement
;
PlayerInputComponent
->
BindAction
<
FActionDelegate
>
(
"nDisplayButton5"
,
IE_Released
,
this
,
&
AVirtualRealityPawn
::
OnAction
,
false
,
5
);
}
}
UPawnMovementComponent
*
AVirtualRealityPawn
::
GetMovementComponent
()
const
{
return
Movement
;
}
void
AVirtualRealityPawn
::
InitComponentReferences
()
{
if
(
!
IsRoomMountedMode
())
return
;
if
(
!
CaveOrigin
)
CaveOrigin
=
GetClusterComponent
(
"cave_origin"
);
if
(
!
CaveCenter
)
CaveCenter
=
GetClusterComponent
(
"cave_center"
);
if
(
!
ShutterGlasses
)
{
ShutterGlasses
=
GetClusterComponent
(
"shutter_glasses"
);
Head
=
ShutterGlasses
;
}
if
(
!
Flystick
)
{
Flystick
=
GetClusterComponent
(
"flystick"
);
LeftHand
=
Flystick
;
RightHand
=
Flystick
;
}
}
}
This diff is collapsed.
Click to expand it.
Source/DisplayClusterExtensions/Public/VirtualRealityPawn.h
+
94
−
33
View file @
726cb4c0
...
@@ -10,44 +10,105 @@
...
@@ -10,44 +10,105 @@
#include
"VirtualRealityPawn.generated.h"
#include
"VirtualRealityPawn.generated.h"
UENUM
(
BlueprintType
)
enum
class
EVRNavigationModes
:
uint8
{
Nav_Mode_None
UMETA
(
DisplayName
=
"Navigation Mode None"
),
Nav_Mode_Fly
UMETA
(
DisplayName
=
"Navigation Mode Fly"
)
};
UCLASS
()
UCLASS
()
class
DISPLAYCLUSTEREXTENSIONS_API
AVirtualRealityPawn
:
public
ADisplayClusterPawn
class
DISPLAYCLUSTEREXTENSIONS_API
AVirtualRealityPawn
:
public
ADisplayClusterPawn
{
{
GENERATED_UCLASS_BODY
()
GENERATED_UCLASS_BODY
()
public:
public:
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnForward
(
float
Value
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnForward
(
float
Value
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnRight
(
float
Value
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnRight
(
float
Value
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnTurnRate
(
float
Rate
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnTurnRate
(
float
Rate
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnLookUpRate
(
float
Rate
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnLookUpRate
(
float
Rate
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnFire
(
bool
Pressed
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnFire
(
bool
Pressed
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnAction
(
bool
Pressed
,
int32
Index
);
UFUNCTION
(
BlueprintNativeEvent
,
BlueprintCallable
,
Category
=
"Pawn"
)
void
OnAction
(
bool
Pressed
,
int32
Index
);
UFUNCTION
(
BlueprintPure
,
Category
=
"Pawn"
)
static
bool
IsDesktopMode
();
UFUNCTION
(
BlueprintPure
,
Category
=
"Pawn"
)
static
bool
IsRoomMountedMode
();
UFUNCTION
(
BlueprintPure
,
Category
=
"Pawn"
)
static
bool
IsHeadMountedMode
();
UFUNCTION
(
BlueprintPure
,
Category
=
"Pawn"
)
static
FString
GetNodeName
();
UFUNCTION
(
BlueprintPure
,
Category
=
"Pawn"
)
static
float
GetEyeDistance
();
UFUNCTION
(
Category
=
"Pawn"
)
float
GetBaseTurnRate
()
const
;
UFUNCTION
(
Category
=
"Pawn"
)
void
SetBaseTurnRate
(
float
Value
);
UFUNCTION
(
Category
=
"Pawn"
)
UFloatingPawnMovement
*
GetFloatingPawnMovement
();
UFUNCTION
(
Category
=
"Pawn"
)
URotatingMovementComponent
*
GetRotatingMovementComponent
();
//Bunch of Getter Functions for components to avoid users having to know the names
UFUNCTION
(
Category
=
"Pawn"
)
UDisplayClusterSceneComponent
*
GetFlystickComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
UMotionControllerComponent
*
GetHmdLeftMotionControllerComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
UMotionControllerComponent
*
GetHmdRightMotionControllerComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
USceneComponent
*
GetHeadComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
USceneComponent
*
GetLeftHandComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
USceneComponent
*
GetRightHandComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
USceneComponent
*
GetCaveOriginComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
USceneComponent
*
GetCaveCenterComponent
();
UFUNCTION
(
Category
=
"Pawn"
)
USceneComponent
*
GetShutterGlassesComponent
();
//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
);
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"Pawn"
)
EVRNavigationModes
NavigationMode
=
EVRNavigationModes
::
Nav_Mode_Fly
;
protected:
protected:
DECLARE_DELEGATE_OneParam
(
FFireDelegate
,
bool
);
DECLARE_DELEGATE_OneParam
(
FFireDelegate
,
bool
);
DECLARE_DELEGATE_TwoParams
(
FActionDelegate
,
bool
,
int32
);
DECLARE_DELEGATE_TwoParams
(
FActionDelegate
,
bool
,
int32
);
virtual
void
BeginPlay
()
override
;
virtual
void
BeginPlay
()
override
;
virtual
void
Tick
(
float
DeltaSeconds
)
override
;
virtual
void
Tick
(
float
DeltaSeconds
)
override
;
virtual
void
BeginDestroy
()
override
;
virtual
void
BeginDestroy
()
override
;
virtual
void
SetupPlayerInputComponent
(
UInputComponent
*
PlayerInputComponent
)
override
;
virtual
void
SetupPlayerInputComponent
(
UInputComponent
*
PlayerInputComponent
)
override
;
virtual
UPawnMovementComponent
*
GetMovementComponent
()
const
override
;
virtual
UPawnMovementComponent
*
GetMovementComponent
()
const
override
;
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
float
BaseTurnRate
=
45.0
f
;
UPROPERTY
(
EditAnywhere
,
BlueprintReadWrite
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
float
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
UFloatingPawnMovement
*
Movement
=
nullptr
;
BaseTurnRate
=
45.0
f
;
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
URotatingMovementComponent
*
RotatingMovement
=
nullptr
;
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
UFloatingPawnMovement
*
Movement
=
nullptr
;
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. CAVE/ROLV flystick.
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
UDisplayClusterSceneComponent
*
Flystick
=
nullptr
;
URotatingMovementComponent
*
RotatingMovement
=
nullptr
;
// 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
*
LeftMotionController
=
nullptr
;
// 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. HMD right motion controller.
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
UMotionControllerComponent
*
RightMotionController
=
nullptr
;
UDisplayClusterSceneComponent
*
Flystick
=
nullptr
;
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. HMD left motion controller.
// PC: RootComponent, HMD: LeftMotionController , CAVE/ROLV: Flystick. Movement follows this component.
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
USceneComponent
*
Forward
=
nullptr
;
UMotionControllerComponent
*
HmdLeftMotionController
=
nullptr
;
// PC: RootComponent, HMD: LeftMotionController , CAVE/ROLV: Flystick. Useful for line trace (e.g. for holding objects).
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. HMD right motion controller.
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
USceneComponent
*
LeftHand
=
nullptr
;
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
// PC: RootComponent, HMD: RightMotionController, CAVE/ROLV: Flystick. Useful for line trace (e.g. for holding objects).
UMotionControllerComponent
*
HmdRightMotionController
=
nullptr
;
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
USceneComponent
*
RightHand
=
nullptr
;
// PC: Camera, HMD: Camera, CAVE/ROLV: Shutter glasses.
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).
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
;
// Holding the Cave Origin Component that is attached to this Pawn
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
USceneComponent
*
CaveOrigin
=
nullptr
;
// Holding the Cave Center Component that is attached to this Pawn
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
USceneComponent
*
CaveCenter
=
nullptr
;
// Holding the Shutter Glasses Component that is attached to this Pawn
UPROPERTY
(
VisibleAnywhere
,
BlueprintReadOnly
,
Category
=
"Pawn"
,
meta
=
(
AllowPrivateAccess
=
"true"
))
USceneComponent
*
ShutterGlasses
=
nullptr
;
private:
void
InitComponentReferences
();
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment