Skip to content

ctb_quantized mesh分支

>

1. 代码:

https://github.com/ahuarte47/cesium-terrain-builder/tree/master-quantized-mesh

2. ctb-tile

main()>runtile

多线程

cpp
for (int i = 0; i < threadCount ; ++i) {
    packaged_task<int(const char *, TerrainBuild *, Grid *, TerrainMetadata *)> task(runTiler); // wrap the function
    tasks.push_back(task.get_future()); // get a future
    thread(move(task), command.getInputFilename(), &command, &grid, metadata).detach(); // launch on a thread
  }

buildTerrain()->buildMesh()

MeshTiler::createMesh()

cpp
MeshTile *
ctb::MeshTiler::createMesh(GDALDataset *dataset, const TileCoordinate &coord, ctb::GDALDatasetReader *reader) const {
  // Copy the raster data into an array
  float *rasterHeights = reader->readRasterHeights(dataset, coord, mGrid.tileSize(), mGrid.tileSize());

  // Get a mesh tile represented by the tile coordinate
  MeshTile *terrainTile = new MeshTile(coord);
  prepareSettingsOfTile(terrainTile, dataset, coord, rasterHeights, mGrid.tileSize(), mGrid.tileSize());
  CPLFree(rasterHeights);

  return terrainTile;
}

GDALDatasetReaderWithOverviews->readRasterHeights

meshtile写文件操作

MeshTile::writeFile(CTBOutputStream &ostream, bool writeVertexNormals)