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

Deactivating tracking for non-simulator launch

parent 127bab45
Branches
No related tags found
1 merge request!1Fix/loading of simulator
...@@ -19,6 +19,8 @@ The HMD Simulator uses the keyboard and mouse to grab the input that is needed t ...@@ -19,6 +19,8 @@ The HMD Simulator uses the keyboard and mouse to grab the input that is needed t
Do a [VR Preview launch](Resources/VRLaunch.png) and you will see something similar to this: ![](Resources/StandardView.png) Do a [VR Preview launch](Resources/VRLaunch.png) and you will see something similar to this: ![](Resources/StandardView.png)
Currently, the HMD Simulator emulated the two controllers and the position of the HMD. Currently, the HMD Simulator emulated the two controllers and the position of the HMD.
If SteamVR is running and a real HMD is detected it is used instead. If you want to explicitly use the HMDSimulator, switch off your HMD or unplug it and close SteamVR. Then restart Unreal und do a [VR Preview launch](Resources/VRLaunch.png).
### Camera Movement ### Camera Movement
You can move around with the Mouse + WASD You can move around with the Mouse + WASD
...@@ -33,3 +35,6 @@ You can select a controller to control with either LeftShift (Left Controller) o ...@@ -33,3 +35,6 @@ You can select a controller to control with either LeftShift (Left Controller) o
The emulated controllers also offer 3 virtual buttons at the moment. The Trigger, Grab and Menu Button. These can be controlled with T, G or M respectively. If you select a controller (or more) and press one of these keys the controller sends a respective button press to Unreal, that you can use in your Blueprints (ideally via ActionMappings, see Configuration). If setup correctly you can e.g. Grab objects in the world and move them: The emulated controllers also offer 3 virtual buttons at the moment. The Trigger, Grab and Menu Button. These can be controlled with T, G or M respectively. If you select a controller (or more) and press one of these keys the controller sends a respective button press to Unreal, that you can use in your Blueprints (ideally via ActionMappings, see Configuration). If setup correctly you can e.g. Grab objects in the world and move them:
![](Resources/GrabRight.mp4) ![](Resources/GrabRight.mp4)
### Packaging
The HMD Simulator can be packed together with your game and only turns on, if you launch your game in VR mode (commandline parameter `-vr`) and additionally provide the `-hmd-simulator` parameter.
...@@ -48,6 +48,8 @@ public: ...@@ -48,6 +48,8 @@ public:
virtual void OnBeginPlay(FWorldContext& InWorldContext, bool EnableInThisPlay); //Called by simulated HMD virtual void OnBeginPlay(FWorldContext& InWorldContext, bool EnableInThisPlay); //Called by simulated HMD
virtual void OnEndPlay(FWorldContext& InWorldContext); //Called by simulated HMD virtual void OnEndPlay(FWorldContext& InWorldContext); //Called by simulated HMD
bool IsCurrentlyEnabled(){return CurrentlyEnabled;}
private: private:
void BindInputEvents(); void BindInputEvents();
void UnbindInputEvents(); void UnbindInputEvents();
......
...@@ -44,12 +44,12 @@ bool FSimulatedHMD::IsHMDConnected() /* Always connected */ ...@@ -44,12 +44,12 @@ bool FSimulatedHMD::IsHMDConnected() /* Always connected */
return true; return true;
} }
bool FSimulatedHMD::IsHMDEnabled() const /* Always enabled */ bool FSimulatedHMD::IsHMDEnabled() const
{ {
return true; return HMDSimulationManager && HMDSimulationManager->IsCurrentlyEnabled();
} }
void FSimulatedHMD::EnableHMD(bool){} /* Always enabled */ void FSimulatedHMD::EnableHMD(bool){} /* Enabled/Disabled automatically (see CheckActivation) */
bool FSimulatedHMD::GetHMDMonitorInfo(MonitorInfo& MonitorDesc) bool FSimulatedHMD::GetHMDMonitorInfo(MonitorInfo& MonitorDesc)
{ {
...@@ -93,7 +93,7 @@ void FSimulatedHMD::OnBeginPlay(FWorldContext& InWorldContext) ...@@ -93,7 +93,7 @@ void FSimulatedHMD::OnBeginPlay(FWorldContext& InWorldContext)
{ {
const bool Activation = CheckActivation(); const bool Activation = CheckActivation();
UE_LOG(LogTemp, Warning, TEXT("HMDSimulator Activated: %d"), Activation); UE_LOG(LogHMDSimulatiorHMD, Log, TEXT("HMDSimulator Activated: %d"), Activation);
HMDSimulationManager->OnBeginPlay(InWorldContext, Activation); HMDSimulationManager->OnBeginPlay(InWorldContext, Activation);
} }
...@@ -104,7 +104,8 @@ void FSimulatedHMD::OnEndPlay(FWorldContext& InWorldContext) ...@@ -104,7 +104,8 @@ void FSimulatedHMD::OnEndPlay(FWorldContext& InWorldContext)
bool FSimulatedHMD::EnumerateTrackedDevices(TArray<int32>& OutDevices, EXRTrackedDeviceType Type) bool FSimulatedHMD::EnumerateTrackedDevices(TArray<int32>& OutDevices, EXRTrackedDeviceType Type)
{ {
if (Type == EXRTrackedDeviceType::Any || Type == EXRTrackedDeviceType::HeadMountedDisplay) if (HMDSimulationManager && HMDSimulationManager->IsCurrentlyEnabled() &&
(Type == EXRTrackedDeviceType::Any || Type == EXRTrackedDeviceType::HeadMountedDisplay))
{ {
OutDevices.Add(HMDDeviceId); OutDevices.Add(HMDDeviceId);
return true; return true;
...@@ -122,6 +123,8 @@ float FSimulatedHMD::GetInterpupillaryDistance() const ...@@ -122,6 +123,8 @@ float FSimulatedHMD::GetInterpupillaryDistance() const
bool FSimulatedHMD::GetCurrentPose(int32 DeviceId, FQuat& CurrentOrientation, FVector& CurrentPosition) bool FSimulatedHMD::GetCurrentPose(int32 DeviceId, FQuat& CurrentOrientation, FVector& CurrentPosition)
{ {
if(!HMDSimulationManager || !HMDSimulationManager->IsCurrentlyEnabled()) return false;
if(DeviceId == HMDDeviceId) if(DeviceId == HMDDeviceId)
{ {
HMDSimulationManager->GetHeadPose(CurrentOrientation, CurrentPosition); HMDSimulationManager->GetHeadPose(CurrentOrientation, CurrentPosition);
...@@ -410,7 +413,7 @@ void FSimulatedHMD::PreRenderViewFamily_RenderThread(FRHICommandListImmediate&, ...@@ -410,7 +413,7 @@ void FSimulatedHMD::PreRenderViewFamily_RenderThread(FRHICommandListImmediate&,
bool FSimulatedHMD::IsActiveThisFrame(class FViewport* InViewport) const bool FSimulatedHMD::IsActiveThisFrame(class FViewport* InViewport) const
{ {
return GEngine && GEngine->IsStereoscopic3D(InViewport); return GEngine && GEngine->IsStereoscopic3D(InViewport) && HMDSimulationManager && HMDSimulationManager->IsCurrentlyEnabled();
} }
FSimulatedHMD::FSimulatedHMD(const FAutoRegister& AutoRegister) FSimulatedHMD::FSimulatedHMD(const FAutoRegister& AutoRegister)
......
...@@ -57,6 +57,8 @@ void FSimulatedMotionController::SetChannelValues(int32, const FForceFeedbackVal ...@@ -57,6 +57,8 @@ void FSimulatedMotionController::SetChannelValues(int32, const FForceFeedbackVal
void FSimulatedMotionController::EnumerateSources(TArray<FMotionControllerSource>& SourcesOut) const void FSimulatedMotionController::EnumerateSources(TArray<FMotionControllerSource>& SourcesOut) const
{ {
if(!HMDSimulationManager || !HMDSimulationManager->IsCurrentlyEnabled()) return;
SourcesOut.Add(FMotionControllerSource(LeftHandSourceId)); SourcesOut.Add(FMotionControllerSource(LeftHandSourceId));
SourcesOut.Add(FMotionControllerSource(RightHandSourceId)); SourcesOut.Add(FMotionControllerSource(RightHandSourceId));
} }
...@@ -69,6 +71,8 @@ FName FSimulatedMotionController::GetMotionControllerDeviceTypeName() const ...@@ -69,6 +71,8 @@ FName FSimulatedMotionController::GetMotionControllerDeviceTypeName() const
bool FSimulatedMotionController::GetControllerOrientationAndPosition(const int32, const EControllerHand DeviceHand, FRotator& OutOrientation, FVector& OutPosition, float) const bool FSimulatedMotionController::GetControllerOrientationAndPosition(const int32, const EControllerHand DeviceHand, FRotator& OutOrientation, FVector& OutPosition, float) const
{ {
if(!HMDSimulationManager || !HMDSimulationManager->IsCurrentlyEnabled()) return false;
switch(DeviceHand) switch(DeviceHand)
{ {
case EControllerHand::Left: case EControllerHand::Left:
...@@ -83,6 +87,7 @@ bool FSimulatedMotionController::GetControllerOrientationAndPosition(const int32 ...@@ -83,6 +87,7 @@ bool FSimulatedMotionController::GetControllerOrientationAndPosition(const int32
ETrackingStatus FSimulatedMotionController::GetControllerTrackingStatus(const int32, const EControllerHand) const ETrackingStatus FSimulatedMotionController::GetControllerTrackingStatus(const int32, const EControllerHand) const
{ {
if(!HMDSimulationManager || !HMDSimulationManager->IsCurrentlyEnabled()) return ETrackingStatus::NotTracked;
return ETrackingStatus::Tracked; return ETrackingStatus::Tracked;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment