text stringlengths 0 1.11k |
|---|
When OVRSceneManager instantiates user-supplied prefabs for scene anchors, it creates a hierarchy which uses OVRSceneRoom as the container game object. OVRSceneRooms can be spawned as top-level game objects, or parented to another game object using OVRSceneManager.InitialAnchorParent. You can iterate over scene anchors or scene rooms using the Unity Transform. |
OVRScenePlane |
A scene plane (OVRScenePlane) represents the two-dimensional bounds of a scene anchor. The system automatically adds a scene plane to any scene anchor with a two-dimensional boundary. For example, floors, ceilings, and walls have an OVRScenePlane component, as do surfaces on things like tables and couches. OVRScenePlanes may optionally include a Boundary: floor scene anchors have a boundary which represents the closed polyline of the walls. |
When you instantiate a scene plane, the system sets the localScale of each direct child transform of the prefab according to the 2D extents of the plane. The localScale is set in meters. Setting the localScale enables things like stretching a wall prefab to the actual dimensions of the wall. If an offset exists between the pivot and center of the plane, child transforms may also have their localPosition modified. |
OVRScenePlaneMeshFilter |
Each scene plane has a 2D boundary, accessible via the OVRScenePlaneMeshFilter. This component generates a planar mesh from the 2D boundary, which you can use for rendering, physics, or any other purpose. |
In the case of an OVRScenePlane which has the semantic classification for FLOOR, the Boundary represents the closed polyline of the walls. |
OVRSceneVolume |
A scene volume (OVRSceneVolume) represents the three-dimensional bounds of a scene anchor. The system automatically adds a scene volume to any scene anchor with 3D boundary extents. You can see examples of this functionality in the user-defined volumes labeled OTHER in space setup. |
When you instantiate a scene volume, the system sets the localScale of each direct child transform of the prefab according to the 3D extents of the volume. The localScale is set in meters. During this process, the system will stretch prefabs to the dimensions of the volume. If an offset exists between the pivot and the center point of the top face of the volume, child transforms may also have their localPosition modified. |
OVRSceneVolumeMeshFilter |
A scene anchor may optionally have a triangle mesh representation, accessible via the OVRSceneVolumeMeshFilter. This component populates a Unity MeshFilter component with a Mesh on startup, and optionally bakes a MeshCollider component if it is attached (using the default cooking options). |
Creating the mesh and baking the collider are performed using the Unity job system in order to avoid blocking the main thread due to a large number of triangles. Use the property IsCompleted in order to know when the process has finished. |
Currently, only scene anchors with a semantic classification of GLOBAL_MESH contain a OVRSceneVolumeMeshFilter. |
OVRSemanticClassification |
A scene anchor may have one or more string labels that provide additional semantic information describing the anchor’s object type, for example, COUCH or WALL_FACE. The system automatically adds OVRSemanticClassification to scene anchors that have semantic labels. |
OVRSceneObjectTransformType |
If you want more control over how child objects within a prefab are scaled and offset by OVRScenePlane and OVRSceneVolume, add the OVRSceneObjectTransformType component on the child objects to choose who applies the transform. |
When OVRScenePlane and OVRSceneVolume set the localScale and localPosition of the child objects, they do so in the following order: firstly, by checking whether OVRSceneObjectTransformType is defined on the child; then by seeing whether the OVRSceneVolume is modifying the scale/offset; and lastly, by looking at the OVRScenePlane values for scale and offset. |
Anchor Pivots |
2D planes and 3D volumes use the following pivot rules for each scene anchor. Note that in the design-time scene descriptions below, we place the prefabs at +90 degrees to accommodate the default OpenXR coordinate system (a Cartesian right-handed coordinate system). For more information, see the OpenXR Spec section 2.18, Coordinate System. |
Plane Pivots |
A 2D plane’s pivot is at the center of the plane, with +Z pointing in the direction of the plane’s normal. So, for example, an OVRScenePlane representing a floor will have its +Z pointing up. In the following graphics, the X vector is red, the Y vector is green, and the Z vector is blue. |
2D pivot plane |
Walls are oriented such that +Z points out from the wall and +Y is always up. |
Wall plane |
Volume Pivots |
The pivot for an OVRSceneVolume is in the middle of its top surface. Since the normal of the top surface points upward, +Z is also up in this case. |
Volume pivot |
Composite |
Some objects are represented by both a plane and a volume, such as tables and couches. The plane represents the flat area of the object, such as a couch seat, while the volume corresponds to the bounding box which contains the entire object. The pivot is always at the center of the plane, while an offset is used to capture the difference between the pivot of the plane and pivot of the volume. |
In the case of a table, the plane is at the top face of the volume, resulting in an offset of 0. In the case of a couch, the plane is within the volume, resulting in a non-zero offset for the volume. In this example image, the offset is the difference between the plane pivot axes and the sphere at the center of the volume’s top face. |
Composite pivot |
Scene Mesh |
The Scene Mesh is a low-fidelity, high-coverage artifact which describes the boundary between free and occupied space in a room. It is generated automatically during the space setup experience, and available for applications to query using the OVRSceneManager. If the space setup falls back to the manual mode, then a Scene Mesh will not be in the Scene Model. |
In order to spawn an object for the Scene Mesh, you must use the Prefab Overrides. This is because it is considered neither as a Plane Prefab, nor as a Volume Prefab. Select the label GLOBAL_MESH and add your prefab. |
Accessing the mesh data is done through the OVRSceneVolumeMeshFilter, which populates a Unity MeshFilter at runtime with a mesh retrieved from the system. Optionally, a MeshRenderer needs to be added to visualize this mesh, and a MeshCollider for physics and collisions. |
An example prefab that will retrieve the mesh at runtime, bake it for physics calculations, and render it using the default Unity material. |
Next steps |
Now that you’ve learned how to access the Scene Model in Unity, you have all the necessary tools to work with Scene in Unity. |
To see code examples of Scene being used in various uses, checkout our Samples. |
To see how the user’s privacy is protected through permissions, see Spatial Data Permission. |
To learn about using Scene in practice, see our Best Practices.Access Scene data with OVRAnchor |
Unity |
All-In-One VR |
The platform for which this article is written (Unity) does not match your preferred platform (Nativa). |
Haz clic aquí para ver la página del índice de la documentación para tu plataforma de preferencia. |
In this page, you will learn how to access Scene data directly to recreate your own Scene Manager using the OVRAnchor components. |
What are the OVRAnchor components? |
OVRSceneManager implements the most common use case for Scene data: spawn a Unity prefab for any given Scene element when asked to load. This differs from the lower-level API that more closely resembles the core functionality of how the system represents and exposes the Scene. In order to have more control over what happens in Unity when receiving Scene data, you must use the OVRAnchor API. |
OVRAnchor components are light-weight wrappers around the lower-lever Scene functionality. Since most Scene API functions are asynchronous, you can either access them by calling a non-blocking function, subscribing to an event and putting your logic in event callback, or you can use C#’s async/await functionality, which is how OVRAnchor works. |
How to interact with Scene data |
As the Scene API consists of an ECS-like mechanism, we are mostly interested in either fetching entities, or in getting components that hold data. |
In order to access anchors/entities, you use: |
Find Anchors By Component: all anchors have components. You can get a list of all known anchors that have this specific component (such as find all anchors that have the Room Layout component). In code, this function is OVRAnchor.FetchAnchorsAsync<T>(). |
Find Anchors By UUID: all anchors have a UUID. Use it to retrieve anchors. In code, this function is OVRAnchor.FetchAnchorsAsync(). |
Once you have an anchor, you can retrieve its components and thereby access its data. An anchor can have any number of components, although this can be known ahead of time (see Common Scene Anchors). |
It is important to note that while OVRAnchor APIs are asychronous, the awaiter implementation cannot block the main thread (unlike typical async functions). This is because the events that complete OVRAnchor tasks are only invoked on the main thread. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.