class ARMeshManager (Niantic.ARDK.Extensions.Meshing.ARMeshManager)

Overview

This helper can be placed in a scene to easily add environment meshes. It reads meshing output from the ARSession, and instantiates mesh prefabs loaded with components and materials for the desired behavior and rendering. Mesh visibility can be toggled on and off, using a depth mask material for occlusion effect. More…

class ARMeshManager: Niantic.ARDK.Extensions.ARSessionListener {
public:
    // enums

    enum MeshingMode;

    // fields

    bool UseCustomMeshingMode = false;

    // properties

    bool BoundedVolumetricRangeEnabled;
    int ColliderUpdateThrottle;
    bool GenerateUnityMeshes;
    MeshObjectsGenerator Generator;
    float MeshDecimationThreshold;
    float MeshingRadius;
    float MeshingRangeMax;
    GameObject MeshPrefab;
    GameObject MeshRoot;
    MeshingMode SelectedMeshingMode;
    float TargetBlockSize;
    uint TargetFrameRate;
    bool UseInvisibleMaterial;
    float VoxelSize;

    // events

    event MeshObjectsCleared();
    event MeshObjectsUpdated();

    // methods

    virtual override void ApplyARConfigurationChange(ARSessionChangesCollector.ARSessionRunProperties properties);
    void ClearMeshObjects();
    bool GetBlockCoords(Vector3 worldCoords, out Vector3Int blockCoords);
    GameObject GetBlockGameObject(Vector3Int blockCoords);
    void SetRendererEnabled(bool isEnabled);
    void SetUseInvisibleMaterial(bool useInvisible);
};

Inherited Members

public:
    // properties

    bool AreFeaturesEnabled;
    bool CanInitialize;
    bool Initialized;

    // methods

    void Deinitialize();
    void DisableFeatures();
    void EnableFeatures();
    void Initialize();
    virtual abstract void ApplyARConfigurationChange(ARSessionChangesCollector.ARSessionRunProperties properties) = 0;

Detailed Documentation

This helper can be placed in a scene to easily add environment meshes. It reads meshing output from the ARSession, and instantiates mesh prefabs loaded with components and materials for the desired behavior and rendering. Mesh visibility can be toggled on and off, using a depth mask material for occlusion effect.

OnEnable/EnableFeatures: If an ARSession is running, meshing will be enabled and the ARSession will be re-run. Else, the next run ARSession will have meshing enabled. OnDisable/DisableFeatures: If an ARSession is running, meshing will be disabled and the ARSession will be re-run. Else, the next run ARSession will have meshing disabled.

Properties

bool BoundedVolumetricRangeEnabled

Whether to cleanup underlying volumetric data out-of-range of the user.

bool GenerateUnityMeshes

When false, mesh block GameObjects will not be updated (a running ARSession will still surface mesh updates).

float MeshDecimationThreshold

The value specifying the distance, in meters, of the meshed surface around the player. Existing mesh blocks are decimated when distance to device is bigger than this threshold. Minimum distance is maximum meshing range.

Note

A value of 0 represents ‘Infinity’

float MeshingRadius

The value specifying the distance, in meters, of the meshed surface around the player. Existing mesh blocks are decimated when distance to device is bigger than this threshold. Minimum distance is maximum meshing range.

Note

A value of 0 represents ‘Infinity’

float MeshingRangeMax

The value specifying the maximum range in meters of a depth measurement / estimation used for meshing.

GameObject MeshPrefab

The prefab to instantiate and update for each mesh block.

Note

This GameObject requires a MeshFilter component, and will update a MeshCollider component if able. A MeshRenderer component is optional, but required for the SetUseInvisibleMaterial method.

GameObject MeshRoot

Parent of every block (piece of mesh). If empty, this is assigned to this component’s GameObject when initialized.

float TargetBlockSize

The value specifying the target size of a mesh block in meters.

uint TargetFrameRate

The value specifying the how many times the meshing routine should target running per second.

bool UseInvisibleMaterial

False if the mesh objects are visible (i.e. it renders using the prefab’s default material) and true if the mesh objects are hidden (i.e. it uses the invisible material).

float VoxelSize

The value specifying the edge length of the meshing voxels in meters.

Events

event MeshObjectsCleared()

Called when all mesh blocks have been cleared.

event MeshObjectsUpdated()

Called when all mesh blocks have been updated with info from the the latest mesh update.

Methods

virtual override void ApplyARConfigurationChange(ARSessionChangesCollector.ARSessionRunProperties properties)

Inheritors should override this to modify session configuration settings based on their script’s needs.

Note

This is executed as a result of the ARSession being run, which may or may not be triggered by a call to RaiseConfigurationChanged().

void ClearMeshObjects()

Clear the mesh, delete all GameObjects under _meshRoot. Sends a MeshCleared event if there’s a listener when it’s done.

bool GetBlockCoords(Vector3 worldCoords, out Vector3Int blockCoords)

Convenience method to convert world coordinates in Unity to integer block coordinates.

GameObject GetBlockGameObject(Vector3Int blockCoords)

Convenience method to get the mesh GameObject at the specified block coordinates. Returns null if no object exists at those coordinates.

void SetUseInvisibleMaterial(bool useInvisible)

Updates the MeshRenderers of all GameObjects in _blocks with either the invisible or the original prefab material. Does nothing if the prefab is null or does not contain a MeshRenderer.