C# Class SMBaseAbstract, InteractivePaint

Inheritance: MonoBehaviour
显示文件 Open project: OpenHID/InteractivePaint

Public Properties

Property Type Description
Extents Vector3
FreezeMeshUpdates bool
NumUpdatesBeforeRemoval int
RemovedMeshObjects RemovedSurfaceHolder>.Dictionary
SpatialMeshObjects GameObject>.Dictionary
SphereRadius float
TimeBetweenUpdates float
UseSphereBounds bool

Protected Properties

Property Type Description
LevelOfDetailToTPCM int[]
bakeMeshes bool
bounds Bounds
surfaceObserver UnityEngine.VR.WSA.SurfaceObserver

Protected Methods

Method Description
BoundsContains ( Vector3 position ) : bool

Helper method to determine if the bounds of this component contains the provided coordinate

FinalDestroy ( GameObject surfaceObject ) : void

Destroys the provided GameObject and The MeshFilter.mesh if present

GetDefaultLevelOfDetail ( ) : MeshLevelOfDetail

Gets the default Level of Detail. Subclasses can override to change the default Level of Detail.

HandleAdd ( SurfaceId surfaceId, System updateTime, bool bake ) : void

Handles when a surface is added or updated by either creating the needed components or finding them in either the RemovedMeshObjects collection or the SpatialMeshObjects collection If a surface is contained in the RemovedMeshObjects collection, the enabled state for its MeshCollider or MeshRenderer is restored if appropriate. The GameObject will be moved into SpatialMeshObjects, and the RemovedMeshHolder will be removed from RemovedMeshObject If a surface is not found in either collection, a new GameObject will be created for it and it will be added to SpatialMeshObjects indexed by its id. After the GameObject is handled as appropriately, SurfaceObserver.RequestMeshAsync will be called for the appropriate settings.

HandleDelete ( SurfaceId surfaceId ) : void

Handles cleaning up a known mesh or moving it to the RemovedMeshObjects list If NumUpdatesBeforeRemoval < 1, the mesh will immediately be destroyed upon removal Else we will create a new RemoveSurfaceHolder and add that to the RemovedMeshObjects list to cache the mesh until we believe it should actually be removed

OnDestroy ( ) : void

Standard method called when the component is destroyed. When this component is destroyed, we clean up all of our tracked GameObjects

OnDisable ( ) : void

Standard method called when the component is disabled When this component is disabled, we disable all of the tracked GameObjects

OnEnable ( ) : void

Standard method called when the component is enabled When this component is enabled, we enable all of the tracked GameObjects

ProcessRemoveList ( ) : void

Iterates through the RemovedMeshObjects list and decrements the updates remaining and removes objects if appropriate The criteria for decrementing the update count and removing the entry if appropriate is either - The mesh is not within the observed bounds (so in theory this observer does not actually care to observe it - Or the main camera (user) is within 10m of the surface (if the user is that close to the mesh, the HoloLens is likely actively reporting on that space)

ShouldBeActiveWhileRemoved ( GameObject go ) : bool

Helper to determine if the GameObject should continue to render and/or have physics even if marked for removal by the system An object should render and/or have physics if it is within the bounds of the observer and not parented to the camera

Start ( ) : void

Standard initialization method creating our properties

SurfaceObserver_OnDataReady ( SurfaceData bakedData, bool outputWritten, float elapsedBakeTimeSeconds ) : void

Handler for when the SurfaceObserver completes RequestMeshAsync The base class defines this function to make it easier for subclasses to modify meshes upon completion without needing to handle the actual processing

SurfaceObserver_OnSurfaceChanged ( SurfaceId surfaceId, SurfaceChange changeType, Bounds bounds, System updateTime ) : void

Handler for calling SurfaceObserver.Update which will then handle the changes The actual changes will be handled via HandleAdd (for SurfaceChange.Added and SurfaceChange.Updated) and HandleDelete (for SurfaceChange.Removed)

Update ( ) : void

Standard Update loop During our Update, we update the observed volume for the SurfaceObserver and ensure we do one step of processing

UpdateLoop ( ) : IEnumerator

The Coroutine which actually updates the meshes and processes our removed mesh's list This Coroutine runs forever and checks that the component is enabled and FreezeMeshUpdates has not been specified. If either are not true, we do nothing here and continue waiting.

Private Methods

Method Description
UpdateSurfaceObserverPosition ( ) : void

A helper to correctly update the bounding volume for the SurfaceObserver

Method Details

BoundsContains() protected method

Helper method to determine if the bounds of this component contains the provided coordinate
protected BoundsContains ( Vector3 position ) : bool
position Vector3 The position to test if it is within the current bounds of the component
return bool

FinalDestroy() protected method

Destroys the provided GameObject and The MeshFilter.mesh if present
protected FinalDestroy ( GameObject surfaceObject ) : void
surfaceObject GameObject The GameObject to destroy
return void

GetDefaultLevelOfDetail() protected method

Gets the default Level of Detail. Subclasses can override to change the default Level of Detail.
protected GetDefaultLevelOfDetail ( ) : MeshLevelOfDetail
return MeshLevelOfDetail

HandleAdd() protected method

Handles when a surface is added or updated by either creating the needed components or finding them in either the RemovedMeshObjects collection or the SpatialMeshObjects collection If a surface is contained in the RemovedMeshObjects collection, the enabled state for its MeshCollider or MeshRenderer is restored if appropriate. The GameObject will be moved into SpatialMeshObjects, and the RemovedMeshHolder will be removed from RemovedMeshObject If a surface is not found in either collection, a new GameObject will be created for it and it will be added to SpatialMeshObjects indexed by its id. After the GameObject is handled as appropriately, SurfaceObserver.RequestMeshAsync will be called for the appropriate settings.
protected HandleAdd ( SurfaceId surfaceId, System updateTime, bool bake ) : void
surfaceId UnityEngine.VR.WSA.SurfaceId The id of the surface that was added or updated
updateTime System The time at which the surface was modified
bake bool Whether or not this component should request to back a collider for the surface
return void

HandleDelete() protected method

Handles cleaning up a known mesh or moving it to the RemovedMeshObjects list If NumUpdatesBeforeRemoval < 1, the mesh will immediately be destroyed upon removal Else we will create a new RemoveSurfaceHolder and add that to the RemovedMeshObjects list to cache the mesh until we believe it should actually be removed
protected HandleDelete ( SurfaceId surfaceId ) : void
surfaceId UnityEngine.VR.WSA.SurfaceId
return void

OnDestroy() protected method

Standard method called when the component is destroyed. When this component is destroyed, we clean up all of our tracked GameObjects
protected OnDestroy ( ) : void
return void

OnDisable() protected method

Standard method called when the component is disabled When this component is disabled, we disable all of the tracked GameObjects
protected OnDisable ( ) : void
return void

OnEnable() protected method

Standard method called when the component is enabled When this component is enabled, we enable all of the tracked GameObjects
protected OnEnable ( ) : void
return void

ProcessRemoveList() protected method

Iterates through the RemovedMeshObjects list and decrements the updates remaining and removes objects if appropriate The criteria for decrementing the update count and removing the entry if appropriate is either - The mesh is not within the observed bounds (so in theory this observer does not actually care to observe it - Or the main camera (user) is within 10m of the surface (if the user is that close to the mesh, the HoloLens is likely actively reporting on that space)
protected ProcessRemoveList ( ) : void
return void

ShouldBeActiveWhileRemoved() protected method

Helper to determine if the GameObject should continue to render and/or have physics even if marked for removal by the system An object should render and/or have physics if it is within the bounds of the observer and not parented to the camera
protected ShouldBeActiveWhileRemoved ( GameObject go ) : bool
go GameObject The GameObject in question
return bool

Start() protected method

Standard initialization method creating our properties
protected Start ( ) : void
return void

SurfaceObserver_OnDataReady() protected method

Handler for when the SurfaceObserver completes RequestMeshAsync The base class defines this function to make it easier for subclasses to modify meshes upon completion without needing to handle the actual processing
protected SurfaceObserver_OnDataReady ( SurfaceData bakedData, bool outputWritten, float elapsedBakeTimeSeconds ) : void
bakedData UnityEngine.VR.WSA.SurfaceData The processed SurfaceData
outputWritten bool Whether or not output was written
elapsedBakeTimeSeconds float The time in seconds it took to request and populate the mesh
return void

SurfaceObserver_OnSurfaceChanged() protected method

Handler for calling SurfaceObserver.Update which will then handle the changes The actual changes will be handled via HandleAdd (for SurfaceChange.Added and SurfaceChange.Updated) and HandleDelete (for SurfaceChange.Removed)
protected SurfaceObserver_OnSurfaceChanged ( SurfaceId surfaceId, SurfaceChange changeType, Bounds bounds, System updateTime ) : void
surfaceId UnityEngine.VR.WSA.SurfaceId The identifier of the surface in question
changeType SurfaceChange What type of change this is (add, update, or remove)
bounds Bounds The bounds of the mesh
updateTime System The time the update occurred
return void

Update() protected method

Standard Update loop During our Update, we update the observed volume for the SurfaceObserver and ensure we do one step of processing
protected Update ( ) : void
return void

UpdateLoop() protected method

The Coroutine which actually updates the meshes and processes our removed mesh's list This Coroutine runs forever and checks that the component is enabled and FreezeMeshUpdates has not been specified. If either are not true, we do nothing here and continue waiting.
protected UpdateLoop ( ) : IEnumerator
return IEnumerator

Property Details

Extents public_oe property

The extents of the observation volume.
public Vector3 Extents
return Vector3

FreezeMeshUpdates public_oe property

Toggles whether to stop requesting changes to observed region.
public bool FreezeMeshUpdates
return bool

LevelOfDetailToTPCM protected_oe property

An array that converts the logical level of detail to the Triangles per Cubic Meter needed by the API
protected int[] LevelOfDetailToTPCM
return int[]

NumUpdatesBeforeRemoval public_oe property

Set this value to change how quickly objects will be actually removed from the scene When set to less than 1, objects will immediately be removed even if only transiently removed. When 1 or greater, at least that number of update intervals will occur before objects will actually leave the scene. Update intervals will not be processed if the object is within an observed region and the user is > 10.0 from the center
public int NumUpdatesBeforeRemoval
return int

RemovedMeshObjects public_oe property

The collection of meshes that may have been removed by the system but are being cached currently These objects may have been removed from the system due to being too far away or due to tracking loss as well actually not needing to exist. To disable this behavior, set [SurfaceObserver].NumUpdatesBeforeRemoval = 0 or manually clear this dictionary Surfaces in this collection will move back to the SpatialMeshObjects if they return to the scene before the number of update intervals has elapsed
public Dictionary RemovedMeshObjects
return RemovedSurfaceHolder>.Dictionary

SpatialMeshObjects public_oe property

The collection of all of the active meshes indexed by SurfaceId. The mesh itself can be accessed by getting the MeshFilter off of the GameObject
public Dictionary SpatialMeshObjects
return GameObject>.Dictionary

SphereRadius public_oe property

The radius of the observation sphere volume.
public float SphereRadius
return float

TimeBetweenUpdates public_oe property

How long to wait (in sec) between Spatial Mapping updates.
public float TimeBetweenUpdates
return float

UseSphereBounds public_oe property

Use a sphere as the bounding volume instead of a cube
public bool UseSphereBounds
return bool

bakeMeshes protected_oe property

Whether or not the bake meshes (generate a collider) when processing
protected bool bakeMeshes
return bool

bounds protected_oe property

The bounds described by the extents of the observer This property is used to determine if a mesh is contained within the observed bounds when not using a sphere observed region
protected Bounds bounds
return Bounds

surfaceObserver protected_oe property

The SurfaceObserver we will use to get data about the physical surroundings
protected SurfaceObserver,UnityEngine.VR.WSA surfaceObserver
return UnityEngine.VR.WSA.SurfaceObserver