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:
    // properties

    bool GenerateUnityMeshes;
    float MeshingRadius;
    GameObject MeshPrefab;
    GameObject MeshRoot;
    float TargetBlockSize;
    uint TargetFrameRate;
    bool UseInvisibleMaterial;

    // 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 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 GenerateUnityMeshes

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

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).

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.