Пример #1
0
        /// <summary>
        /// Maps <see cref="SpatialAwarenessMeshLevelOfDetail"/> to <see cref="TrianglesPerCubicMeter"/>.
        /// </summary>
        /// <param name="levelOfDetail">The desired level of density for the spatial mesh.</param>
        /// <returns>
        /// The number of triangles per cubic meter that will result in the desired level of density.
        /// </returns>
        private int LookupTriangleDensity(SpatialAwarenessMeshLevelOfDetail levelOfDetail)
        {
            int triangleDensity = 0;

            switch (levelOfDetail)
            {
            case SpatialAwarenessMeshLevelOfDetail.Coarse:
                triangleDensity = 0;
                break;

            case SpatialAwarenessMeshLevelOfDetail.Medium:
                triangleDensity = 400;
                break;

            case SpatialAwarenessMeshLevelOfDetail.Fine:
                triangleDensity = 2000;
                break;

            default:
                Debug.LogWarning($"There is no triangle density lookup for {levelOfDetail}, defaulting to Coarse");
                triangleDensity = 0;
                break;
            }

            return(triangleDensity);
        }
Пример #2
0
        /// <inheritdoc />
        protected override int LookupTriangleDensity(SpatialAwarenessMeshLevelOfDetail levelOfDetail)
        {
            // For non-custom levels, the enum value is the appropriate triangles per cubic meter.
            int level = (int)levelOfDetail;

            if (XRSubsystemHelpers.MeshSubsystem != null)
            {
                XRSubsystemHelpers.MeshSubsystem.meshDensity = level / (float)SpatialAwarenessMeshLevelOfDetail.Fine; // For now, map Coarse to 0.0 and Fine to 1.0
            }
            return(level);
        }
Пример #3
0
        /// <inheritdoc />
        protected override int LookupTriangleDensity(SpatialAwarenessMeshLevelOfDetail levelOfDetail)
        {
            // For non-custom levels, the enum value is the appropriate triangles per cubic meter.
            int level = (int)levelOfDetail;

            if (meshSubsystem != null)
            {
                if (levelOfDetail == SpatialAwarenessMeshLevelOfDetail.Unlimited)
                {
                    MeshingSettings.density = meshSubsystem.meshDensity = 1;
                }
                else
                {
                    MeshingSettings.density = meshSubsystem.meshDensity = level / (float)SpatialAwarenessMeshLevelOfDetail.Fine;  // For now, map Coarse to 0.0 and Fine to 1.0
                }
            }
            return(level);
        }
Пример #4
0
        /// <summary>
        /// Converts a MRTK/platform agnostic <see cref="SpatialAwarenessMeshLevelOfDetail"/> to a <see cref="Microsoft.MixedReality.SceneUnderstanding"/> <see cref="SceneMeshLevelOfDetail"/>.
        /// </summary>
        /// <param name="levelofDetail">The <see cref="SpatialAwarenessMeshLevelOfDetail"/> to convert.</param>
        /// <returns>The equivalent <see cref="Microsoft.MixedReality.SceneUnderstanding"/> <see cref="SceneMeshLevelOfDetail"/></returns>
        private SceneMeshLevelOfDetail LevelOfDetailToMeshLOD(SpatialAwarenessMeshLevelOfDetail levelofDetail)
        {
            switch (levelofDetail)
            {
            case SpatialAwarenessMeshLevelOfDetail.Custom:
                Debug.LogWarning("SceneUnderstanding LOD is set to custom, falling back to Medium");
                return(SceneMeshLevelOfDetail.Medium);

            case SpatialAwarenessMeshLevelOfDetail.Coarse:
                return(SceneMeshLevelOfDetail.Coarse);

            case SpatialAwarenessMeshLevelOfDetail.Medium:
                return(SceneMeshLevelOfDetail.Medium);

            case SpatialAwarenessMeshLevelOfDetail.Fine:
                return(SceneMeshLevelOfDetail.Fine);

            case SpatialAwarenessMeshLevelOfDetail.Unlimited:
                return(SceneMeshLevelOfDetail.Unlimited);

            default:
                throw new NotImplementedException();
            }
        }
Пример #5
0
 /// <summary>
 /// Maps <see cref="SpatialAwarenessMeshLevelOfDetail"/> to <see cref="TrianglesPerCubicMeter"/>.
 /// </summary>
 /// <param name="levelOfDetail">The desired level of density for the spatial mesh.</param>
 /// <returns>
 /// The number of triangles per cubic meter that will result in the desired level of density.
 /// </returns>
 protected virtual int LookupTriangleDensity(SpatialAwarenessMeshLevelOfDetail levelOfDetail)
 {
     // By default, returns the existing value. This will be custom defined for each platform, if necessary.
     return(TrianglesPerCubicMeter);
 }