-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #747 from CesiumGS/tileset-manipulation-refactoring
First round of refactoring for enabling use of cesium-native for loading/manipulating/saving 3D Tiles
- Loading branch information
Showing
77 changed files
with
748 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
add_library(Cesium3DTilesContent "") | ||
configure_cesium_library(Cesium3DTilesContent) | ||
|
||
cesium_glob_files(CESIUM_3DTILES_CONTENT_SOURCES | ||
${CMAKE_CURRENT_LIST_DIR}/src/*.cpp | ||
${CMAKE_CURRENT_LIST_DIR}/generated/src/*.cpp | ||
) | ||
cesium_glob_files(CESIUM_3DTILES_CONTENT_HEADERS | ||
${CMAKE_CURRENT_LIST_DIR}/src/*.h | ||
${CMAKE_CURRENT_LIST_DIR}/generated/src/*.h | ||
) | ||
cesium_glob_files(CESIUM_3DTILES_CONTENT_PUBLIC_HEADERS | ||
${CMAKE_CURRENT_LIST_DIR}/include/Cesium3DTilesContent/*.h | ||
${CMAKE_CURRENT_LIST_DIR}/generated/include/Cesium3DTilesContent/*.h | ||
) | ||
cesium_glob_files(CESIUM_3DTILES_CONTENT_TEST_SOURCES | ||
${CMAKE_CURRENT_LIST_DIR}/test/*.cpp | ||
) | ||
cesium_glob_files(CESIUM_3DTILES_CONTENT_TEST_HEADERS | ||
${CMAKE_CURRENT_LIST_DIR}/test/*.h | ||
) | ||
|
||
set_target_properties(Cesium3DTilesContent | ||
PROPERTIES | ||
TEST_SOURCES "${CESIUM_3DTILES_CONTENT_TEST_SOURCES}" | ||
TEST_HEADERS "${CESIUM_3DTILES_CONTENT_TEST_HEADERS}" | ||
TEST_DATA_DIR ${CMAKE_CURRENT_LIST_DIR}/test/data | ||
) | ||
|
||
set_target_properties(Cesium3DTilesContent | ||
PROPERTIES | ||
PUBLIC_HEADER "${CESIUM_3DTILES_CONTENT_PUBLIC_HEADERS}" | ||
) | ||
|
||
target_sources( | ||
Cesium3DTilesContent | ||
PRIVATE | ||
${CESIUM_3DTILES_CONTENT_SOURCES} | ||
${CESIUM_3DTILES_CONTENT_HEADERS} | ||
PUBLIC | ||
${CESIUM_3DTILES_CONTENT_PUBLIC_HEADERS} | ||
) | ||
|
||
target_include_directories( | ||
Cesium3DTilesContent | ||
SYSTEM PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR}/include | ||
${CMAKE_CURRENT_LIST_DIR}/generated/include | ||
PRIVATE | ||
${CMAKE_CURRENT_LIST_DIR}/src | ||
${CMAKE_CURRENT_LIST_DIR}/generated/src | ||
) | ||
|
||
target_link_libraries(Cesium3DTilesContent | ||
PUBLIC | ||
CesiumAsync | ||
CesiumGeometry | ||
CesiumGeospatial | ||
CesiumGltf | ||
CesiumGltfReader | ||
CesiumUtility | ||
) | ||
|
||
install(TARGETS Cesium3DTilesContent | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Cesium3DTilesContent | ||
) |
7 changes: 4 additions & 3 deletions
7
...DTilesSelection/src/B3dmToGltfConverter.h → ...esium3DTilesContent/B3dmToGltfConverter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
#pragma once | ||
|
||
#include <Cesium3DTilesSelection/GltfConverterResult.h> | ||
#include "GltfConverterResult.h" | ||
|
||
#include <CesiumGltf/Model.h> | ||
#include <CesiumGltfReader/GltfReader.h> | ||
|
||
#include <gsl/span> | ||
|
||
#include <optional> | ||
|
||
namespace Cesium3DTilesSelection { | ||
namespace Cesium3DTilesContent { | ||
struct B3dmToGltfConverter { | ||
static GltfConverterResult convert( | ||
const gsl::span<const std::byte>& b3dmBinary, | ||
const CesiumGltfReader::GltfReaderOptions& options); | ||
}; | ||
} // namespace Cesium3DTilesSelection | ||
} // namespace Cesium3DTilesContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...DTilesSelection/src/CmptToGltfConverter.h → ...esium3DTilesContent/CmptToGltfConverter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
#pragma once | ||
|
||
#include <Cesium3DTilesSelection/GltfConverterResult.h> | ||
#include <Cesium3DTilesContent/GltfConverterResult.h> | ||
#include <CesiumGltfReader/GltfReader.h> | ||
|
||
#include <gsl/span> | ||
|
||
#include <cstddef> | ||
|
||
namespace Cesium3DTilesSelection { | ||
namespace Cesium3DTilesContent { | ||
struct CmptToGltfConverter { | ||
static GltfConverterResult convert( | ||
const gsl::span<const std::byte>& cmptBinary, | ||
const CesiumGltfReader::GltfReaderOptions& options); | ||
}; | ||
} // namespace Cesium3DTilesSelection | ||
} // namespace Cesium3DTilesContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
Cesium3DTilesContent/include/Cesium3DTilesContent/GltfUtilities.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#pragma once | ||
|
||
#include "Library.h" | ||
|
||
#include <CesiumGeospatial/BoundingRegion.h> | ||
#include <CesiumGeospatial/GlobeRectangle.h> | ||
|
||
#include <glm/fwd.hpp> | ||
|
||
#include <string_view> | ||
#include <vector> | ||
|
||
namespace CesiumGltf { | ||
struct Model; | ||
} | ||
|
||
namespace Cesium3DTilesContent { | ||
/** | ||
* A collection of utility functions that are used to process and transform a | ||
* gltf model | ||
*/ | ||
struct CESIUM3DTILESCONTENT_API GltfUtilities { | ||
/** | ||
* @brief Applies the glTF's RTC_CENTER, if any, to the given transform. | ||
* | ||
* If the glTF has a `CESIUM_RTC` extension, this function will multiply the | ||
* given matrix with the (translation) matrix that is created from the | ||
* `RTC_CENTER` in the. If the given model does not have this extension, then | ||
* this function will return the `rootTransform` unchanged. | ||
* | ||
* @param model The glTF model | ||
* @param rootTransform The matrix that will be multiplied with the transform | ||
* @return The result of multiplying the `RTC_CENTER` with the | ||
* `rootTransform`. | ||
*/ | ||
static glm::dmat4x4 applyRtcCenter( | ||
const CesiumGltf::Model& gltf, | ||
const glm::dmat4x4& rootTransform); | ||
|
||
/** | ||
* @brief Applies the glTF's `gltfUpAxis`, if any, to the given transform. | ||
* | ||
* By default, the up-axis of a glTF model will the the Y-axis. | ||
* | ||
* If the tileset that contained the model had the `asset.gltfUpAxis` string | ||
* property, then the information about the up-axis has been stored in as a | ||
* number property called `gltfUpAxis` in the `extras` of the given model. | ||
* | ||
* Depending on whether this value is `CesiumGeometry::Axis::X`, `Y`, or `Z`, | ||
* the given matrix will be multiplied with a matrix that converts the | ||
* respective axis to be the Z-axis, as required by the 3D Tiles standard. | ||
* | ||
* @param model The glTF model | ||
* @param rootTransform The matrix that will be multiplied with the transform | ||
* @return The result of multiplying the `rootTransform` with the | ||
* `gltfUpAxis`. | ||
*/ | ||
static glm::dmat4x4 applyGltfUpAxisTransform( | ||
const CesiumGltf::Model& model, | ||
const glm::dmat4x4& rootTransform); | ||
|
||
/** | ||
* @brief Computes a bounding region from the vertex positions in a glTF | ||
* model. | ||
* | ||
* If the glTF model spans the anti-meridian, the west and east longitude | ||
* values will be in the usual -PI to PI range, but east will have a smaller | ||
* value than west. | ||
* | ||
* If the glTF contains no geometry, the returned region's rectangle | ||
* will be {@link GlobeRectangle::EMPTY}, its minimum height will be 1.0, and | ||
* its maximum height will be -1.0 (the minimum will be greater than the | ||
* maximum). | ||
* | ||
* @param gltf The model. | ||
* @param transform The transform from model coordinates to ECEF coordinates. | ||
* @return The computed bounding region. | ||
*/ | ||
static CesiumGeospatial::BoundingRegion computeBoundingRegion( | ||
const CesiumGltf::Model& gltf, | ||
const glm::dmat4& transform); | ||
|
||
/** | ||
* @brief Parse the copyright field of a glTF model and return the individual | ||
* credits. | ||
* | ||
* Credits are read from the glTF's asset.copyright field. This method assumes | ||
* that individual credits are separated by semicolons. | ||
* | ||
* @param gltf The model. | ||
* @return The credits from the glTF. | ||
*/ | ||
static std::vector<std::string_view> | ||
parseGltfCopyright(const CesiumGltf::Model& gltf); | ||
}; | ||
} // namespace Cesium3DTilesContent |
16 changes: 16 additions & 0 deletions
16
Cesium3DTilesContent/include/Cesium3DTilesContent/Library.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
/** | ||
* @brief Classes that support loading and converting 3D Tiles tile content. | ||
*/ | ||
namespace Cesium3DTilesContent {} | ||
|
||
#if defined(_WIN32) && defined(CESIUM_SHARED) | ||
#ifdef CESIUM3DTILESCONTENT_BUILDING | ||
#define CESIUM3DTILESCONTENT_API __declspec(dllexport) | ||
#else | ||
#define CESIUM3DTILESCONTENT_API __declspec(dllimport) | ||
#endif | ||
#else | ||
#define CESIUM3DTILESCONTENT_API | ||
#endif |
7 changes: 4 additions & 3 deletions
7
...DTilesSelection/src/PntsToGltfConverter.h → ...esium3DTilesContent/PntsToGltfConverter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
#pragma once | ||
|
||
#include <Cesium3DTilesSelection/GltfConverterResult.h> | ||
#include "GltfConverterResult.h" | ||
|
||
#include <CesiumGltf/Model.h> | ||
#include <CesiumGltfReader/GltfReader.h> | ||
|
||
#include <gsl/span> | ||
|
||
#include <optional> | ||
|
||
namespace Cesium3DTilesSelection { | ||
namespace Cesium3DTilesContent { | ||
struct PntsToGltfConverter { | ||
static GltfConverterResult convert( | ||
const gsl::span<const std::byte>& pntsBinary, | ||
const CesiumGltfReader::GltfReaderOptions& options); | ||
}; | ||
} // namespace Cesium3DTilesSelection | ||
} // namespace Cesium3DTilesContent |
Oops, something went wrong.