Skip to content

This sample app demonstrates a shared scene experience based on Shared Spatial Anchors, Scene, and Passthrough in Unreal.The Oculus SDK and other supporting material is subject to the Oculus proprietary license.

License

Notifications You must be signed in to change notification settings

oculus-samples/Unreal-SharedSceneSample

Repository files navigation

Shared Scene Sample

This sample app demonstrates a shared scene experience based on Shared Spatial Anchors, Scene, and Passthrough in Unreal.

Project Overview

The sample is built with Blueprint and reuses a significant part of the Shared Spatial Anchors sample and Scene sample. As application starts it loads Lobby level and prompts a user to host or join the session over LAN. Selecting any of these options will load the Shared Spaces level. A host user can:

  • Enter the built-in OS scene capture
  • Create a shared anchor
  • Share scene with other connected users

Joining as a client loads an empty level with Passthrough layer and allows to toggle objects visibility as soon as host shares the scene data.

All Blueprints can be split into the following three categories: User Interface, Spatial Anchors Management, and Scene Reconstruction.

User Interface

User Interface blueprints correspond to menus attached to controllers. These menus are populated in the runtime and are context dependent. Building blocks for those (BP_Menu, BP_MenuItem) are located in the Blueprints/UI folder as well as an anchor info widget (BP_AnchorIInfo). Blueprint of Lobby menu (BP_Lobby_Menu) is more straightforward and is easier to familiarize with the interface implementation.

User interface menu 1{:width="800px"}

Next Event Graph view from BP_Menu_Main demonstrates the Host menu population and alters the content depending on active state (specifically Create, Save, Share).

Host menu{:width="800px"}

It’s important to mention BP_MenuManagerComponent (a component of BP_SharedSpacesPawn) containing basic and utility code to update menu position, navigation, selection, etc. To notify a user of continuous (async) operations the menu provides Start Async and End Async utilities that you can find in other Blueprints.

Spatial Anchors Management

High level Spatial Anchors management blueprint (BP_SpacialAnchorManagementComponent) is also a part of BP_SharedSpacesPawn and provides functionality to create, save, load, share, etc. spatial anchors, it translates calls to lower level API and provides delegates for async operations.The implementation is similar to a dedicated sample of Shared Statial Anchors, and our’s sample features anchors creation, and storing it to a cloud.

Spatial anchors management menu1{:width="800px"}

Spatial anchors management menu2{:width="800px"}

Both operations are asynchronous and trigger corresponding event dispatch handled in BP_MenuManagerComponent with Update Main Menu. Sharing anchor data and retrieving it on a Client are explained in the next section.

Scene Reconstruction

The scene sharing starts with an anchor sharing from BP_SpacialAnchorManagementComponent and follows the scene info serialization. The Host shares the anchor with connected Clients based on available Meta user IDs obtained from Online Subsystem.

Scene reconstruction1{:width="800px"}

Scene info contains ID of the shared anchor, arrays with label, transform in the shared anchor reference frame, and reference to static mesh for each scene object. This structure is defined as BP_Scene in the Blueprints folder.

Scene blueprint folder option

Immediately after serialization this structure is multicasted (with NetMulticast_LoadScene from BP_OculusSceneActor) to all clients to retrieve the anchor and reconstruct the scene. The blueprint function SpawnSceneActors to spawn static mesh actors is also in BP_OculusSceneActor.

Scene reconstruction2{:width="800px"}

As it is obvious from the name BP_OculusSceneActor inherits the OculusSceneActor providing basic Scene API functionality for Host, and is directly placed on the SharedSpaces map.

In addition, semantic labels of the scene actors are stored on Clients to toggle groups visibility from Event Graph of BP_OculusSceneActor with blueprint function ToggleVisibility.

Scene reconstruction3{:width="800px"}

How to Use

Prerequisites

Follow the prerequisites steps described in here in order for the sample to have the required entitlements.

Load the project

First, ensure you have Git LFS installed by running this command:

git lfs install

Then, clone this repo using the "Code" button above, or this command:

git clone https://github.com/oculus-samples/Unreal-SharedSceneSample

Launch the project in the Unreal Editor using one of the following options.

Epic Games Launcher with MetaXR plugin

The easiest way to get started is to use the prebuilt Unreal Engine from the Epic Games Launcher, with MetaXR plugin.

  1. Install the Epic Games Launcher
  2. In the launcher, install UE5 (recommended).
  3. Download and install the MetaXR plugin from the Unreal Engine 5 Integration download page.
  4. Launch the Unreal Editor
  5. From "Recent Projects", click "Browse" and select SharedSceneSample.uproject

Meta fork of Epic’s Unreal Engine

The Meta fork of Epic’s Unreal Engine will give you the most up to date integration of Oculus features. However, you must build the editor from its source.

Follow the instructions on Accessing Unreal Engine source code on GitHub to obtain:

  • an Epic account
  • a GitHub account
  • authorization to access the Unreal Engine source repository Disregard instructions on downloading Epic’s Unreal Engine source code as you will be building the Meta fork of Epic’s Unreal Engine source.

Make sure you have Visual Studio installed properly:

  • Launch the Visual Studio Installer and click Modify for the Visual Studio version you want to use.
  • Under the Workloads tab, click Game development with C++ if it isn’t checked and then click Modify.
  1. Download the source code from the Meta fork of Epic’s Unreal Engine on GitHub.
  2. Open a command prompt in the root of the Unreal, then run this command:
.\GenerateProjectFiles.bat -Game SharedSceneSample -Engine <full path to Unreal-SharedSceneSample directory>\SharedSceneSample.uproject
  1. Open the SharedSceneSample.sln file that has been generated in the Unreal-SharedSceneSample directory.
  2. Set SharedSceneSample as the start-up project and Development Editor as the configuration.
  3. Hit F5 to build and debug the project (and the engine).
    • Depending on your machine, the build may take awhile to complete.

Licenses

The Meta License applies to the SDK and supporting material. The MIT License applies to only certain, clearly marked documents. If an individual file does not indicate which license it is subject to, then the Meta License applies.

About

This sample app demonstrates a shared scene experience based on Shared Spatial Anchors, Scene, and Passthrough in Unreal.The Oculus SDK and other supporting material is subject to the Oculus proprietary license.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •