Esempio n. 1
0
        /// <summary>
        /// Generate quantized mesh tile from the supplied grid
        /// </summary>
        /// <returns></returns>
        public bool BuildQuantizedMeshTile()
        {
            try
            {
                ComputeHeaderInfo();

                // Turn grid into a quantized mesh
                var vertices = MeshBuilder.MakeQuantizedMesh(ref TileData);

                var tileHeader = new TerrainTileHeader()
                {
                    MaximumHeight          = TileData.MaximumHeight,
                    MinimumHeight          = TileData.MinimumHeight,
                    CenterX                = TileData.CenterX,
                    CenterY                = TileData.CenterY,
                    CenterZ                = TileData.CenterZ,
                    BoundingSphereCenterX  = TileData.BoundingSphereCenterX,
                    BoundingSphereCenterY  = TileData.BoundingSphereCenterY,
                    BoundingSphereCenterZ  = TileData.BoundingSphereCenterZ,
                    BoundingSphereRadius   = TileData.BoundingSphereRadius,
                    HorizonOcclusionPointX = TileData.HorizonOcclusionPointX,
                    HorizonOcclusionPointY = TileData.HorizonOcclusionPointY,
                    HorizonOcclusionPointZ = TileData.HorizonOcclusionPointZ
                };

                // This class constructs a tile from the computed mesh
                var tileBuilder = new TileBuilder();
                var tile        = tileBuilder.MakeTile(vertices, ref TileData.VertexNormals, tileHeader, MapUtils.GridSizeToTriangleCount(TileData.GridSize), TileData.GridSize, TileData.HasLighting);
                QuantizedMeshTile = CompressTile ? MapUtils.Compress(tile) : tile;

                BuildTileFaultCode = RequestErrorStatus.OK;
            }
            catch (Exception E)
            {
                Log.LogError(E, "BuildQuantizedMeshTile: Exception:");
                return(false);
            }
            return(true);
        }