-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3d tiles writer #306
3d tiles writer #306
Changes from 9 commits
85f122c
1763a24
85e1f20
7bbf270
f81d623
b63e67b
3c1b085
f95391b
cf7962a
f1023ee
f90b027
b35900d
98bcf87
6367c60
3f863bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
add_library(Cesium3DTiles INTERFACE) | ||
|
||
cesium_glob_files(CESIUM_3DTILES_HEADERS src/*.h src/*.hpp) | ||
cesium_glob_files(CESIUM_3DTILES_PUBLIC_HEADERS include/Cesium3DTiles/*.h) | ||
|
||
set_target_properties(Cesium3DTiles | ||
PROPERTIES | ||
PUBLIC_HEADER "${CESIUM_3DTILES_PUBLIC_HEADERS}" | ||
) | ||
|
||
target_include_directories( | ||
Cesium3DTiles | ||
SYSTEM INTERFACE | ||
${CESIUM_NATIVE_RAPIDJSON_INCLUDE_DIR} | ||
${CMAKE_CURRENT_LIST_DIR}/include/ | ||
INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR}/src | ||
) | ||
|
||
install(TARGETS Cesium3DTiles | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Cesium3DTiles | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
// This file was generated by generate-gltf-classes. | ||
// DO NOT EDIT THIS FILE! | ||
#pragma once | ||
|
||
#include "Library.h" | ||
|
||
#include <CesiumUtility/ExtensibleObject.h> | ||
#include <optional> | ||
#include <string> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
#define CODEGEN_API CESIUM3DTILES_API | ||
|
||
namespace Cesium3DTiles { | ||
|
||
struct CODEGEN_API Asset : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "Asset"; | ||
|
||
std::string version; | ||
|
||
std::optional<std::string> tilesetVersion; | ||
}; | ||
|
||
struct CODEGEN_API BoundingVolume : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "BoundingVolume"; | ||
|
||
std::optional<std::vector<double>> box; | ||
|
||
std::optional<std::vector<double>> region; | ||
|
||
std::optional<std::vector<double>> sphere; | ||
}; | ||
|
||
struct CODEGEN_API TileContent : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "TileContent"; | ||
|
||
std::optional<BoundingVolume> boundingVolume; | ||
|
||
std::string uri; | ||
}; | ||
|
||
struct CODEGEN_API Tile : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "Tile"; | ||
|
||
enum class Refine { ADD, REPLACE }; | ||
|
||
BoundingVolume boundingVolume; | ||
|
||
std::optional<BoundingVolume> viewerRequestVolume; | ||
|
||
double geometricError; | ||
|
||
std::optional<Refine> refine; | ||
|
||
std::vector<double> transform = | ||
{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; | ||
|
||
std::optional<TileContent> content; | ||
|
||
std::optional<std::vector<Tile>> children; | ||
}; | ||
|
||
struct CODEGEN_API TilesetProperties : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "TilesetProperties"; | ||
|
||
double maximum; | ||
|
||
double minimum; | ||
}; | ||
|
||
struct CODEGEN_API Tileset : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "Tileset"; | ||
|
||
struct CODEGEN_API Properties : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "Properties"; | ||
|
||
std::unordered_map<std::string, TilesetProperties> additionalProperties; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using unordered_map maybe slower than map when there are very few item |
||
}; | ||
|
||
Asset asset; | ||
|
||
std::optional<Properties> properties; | ||
|
||
double geometricError; | ||
|
||
Tile root; | ||
|
||
std::optional<std::vector<std::string>> extensionsUsed; | ||
|
||
std::optional<std::vector<std::string>> extensionsRequired; | ||
}; | ||
|
||
struct CODEGEN_API FeatureTable : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "FeatureTable"; | ||
|
||
struct CODEGEN_API BinaryBodyReference | ||
: public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "BinaryBodyReference"; | ||
|
||
enum class ComponentType { | ||
BYTE, | ||
UNSIGNED_BYTE, | ||
SHORT, | ||
UNSIGNED_SHORT, | ||
INT, | ||
UNSIGNED_INT, | ||
FLOAT, | ||
DOUBLE | ||
}; | ||
|
||
double byteOffset; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CesiumGltf has int64 for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue is that the 3D Tiles schema has
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should change the spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened CesiumGS/3d-tiles#476. |
||
|
||
std::optional<ComponentType> componentType; | ||
}; | ||
|
||
struct CODEGEN_API Property { | ||
static inline constexpr const char* TypeName = "Property"; | ||
|
||
std::optional<BinaryBodyReference> v0; | ||
std::optional<std::vector<double>> v1; | ||
std::optional<double> v2; | ||
}; | ||
struct CODEGEN_API GlobalPropertyScalar { | ||
static inline constexpr const char* TypeName = "GlobalPropertyScalar"; | ||
|
||
struct CODEGEN_API Variant0 : public CesiumUtility::ExtensibleObject { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kinda know why we use Variant0 naming here since schema doesn't define the name for it. But it still not a good word for API alone There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed but unsure how best to address this - looks like it would be fairly not-easy to override this in generator config |
||
static inline constexpr const char* TypeName = "Variant0"; | ||
|
||
double byteOffset; | ||
}; | ||
|
||
std::optional<Variant0> v0; | ||
std::optional<std::vector<double>> v1; | ||
std::optional<double> v2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may have the same problem with the bounding volume above. The schema specifies GlobalPropertyScalar can only accept one of the properties above. Should using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did consider this, my concern was that the reader becomes much more complicated since it has to "read every alternative at the same time", so
Not opposed to doing it that way, just will take a little more work and be a little STL-heavy. The "multiple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without necessarily understanding the full implications, std::variant sounds right to me. It more closely matches the schema semantics and will be more memory efficient as well. |
||
}; | ||
struct CODEGEN_API GlobalPropertyCartesian3 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick from me, but we should have space between structs |
||
static inline constexpr const char* TypeName = "GlobalPropertyCartesian3"; | ||
|
||
struct CODEGEN_API Variant0 : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "Variant0"; | ||
|
||
double byteOffset; | ||
}; | ||
|
||
std::optional<Variant0> v0; | ||
std::optional<std::vector<double>> v1; | ||
}; | ||
struct CODEGEN_API GlobalPropertyCartesian4 { | ||
static inline constexpr const char* TypeName = "GlobalPropertyCartesian4"; | ||
|
||
struct CODEGEN_API Variant0 : public CesiumUtility::ExtensibleObject { | ||
static inline constexpr const char* TypeName = "Variant0"; | ||
|
||
double byteOffset; | ||
}; | ||
|
||
std::optional<Variant0> v0; | ||
std::optional<std::vector<double>> v1; | ||
}; | ||
|
||
std::unordered_map<std::string, Property> additionalProperties; | ||
}; | ||
|
||
struct CODEGEN_API PntsFeatureTable : public FeatureTable { | ||
static inline constexpr const char* TypeName = "PntsFeatureTable"; | ||
|
||
std::optional<BinaryBodyReference> POSITION; | ||
|
||
std::optional<BinaryBodyReference> POSITION_QUANTIZED; | ||
|
||
std::optional<BinaryBodyReference> RGBA; | ||
|
||
std::optional<BinaryBodyReference> RGB; | ||
|
||
std::optional<BinaryBodyReference> RGB565; | ||
|
||
std::optional<BinaryBodyReference> NORMAL; | ||
|
||
std::optional<BinaryBodyReference> NORMAL_OCT16P; | ||
|
||
std::optional<BinaryBodyReference> BATCH_ID; | ||
|
||
std::optional<GlobalPropertyScalar> POINTS_LENGTH; | ||
|
||
std::optional<GlobalPropertyCartesian3> RTC_CENTER; | ||
|
||
std::optional<GlobalPropertyCartesian3> QUANTIZED_VOLUME_OFFSET; | ||
|
||
std::optional<GlobalPropertyCartesian3> QUANTIZED_VOLUME_SCALE; | ||
|
||
std::optional<GlobalPropertyCartesian4> CONSTANT_RGBA; | ||
|
||
std::optional<GlobalPropertyScalar> BATCH_LENGTH; | ||
}; | ||
|
||
} // namespace Cesium3DTiles | ||
|
||
#undef CODEGEN_API |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
/** | ||
* @brief Classes for working with [glTF](https://www.khronos.org/gltf/) models. | ||
*/ | ||
namespace Cesium3DTiles {} | ||
|
||
#if defined(_WIN32) && defined(CESIUM_SHARED) | ||
#ifdef CESIUM3DTILES_BUILDING | ||
#define CESIUM3DTILES_API __declspec(dllexport) | ||
#else | ||
#define CESIUM3DTILES_API __declspec(dllimport) | ||
#endif | ||
#else | ||
#define CESIUM3DTILES_API | ||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
add_library(Cesium3DTilesWriter "") | ||
|
||
configure_cesium_library(Cesium3DTilesWriter) | ||
|
||
cesium_glob_files(CESIUM_3DTILES_WRITER_SOURCES src/*.cpp generated/*.cpp) | ||
cesium_glob_files(CESIUM_3DTILES_WRITER_HEADERS src/*.h src/*.hpp generated/*.h) | ||
cesium_glob_files(CESIUM_3DTILES_WRITER_PUBLIC_HEADERS include/Cesium3DTiles/*.h) | ||
cesium_glob_files(CESIUM_3DTILES_WRITER_TEST_SOURCES test/*.cpp) | ||
cesium_glob_files(CESIUM_3DTILES_WRITER_TEST_HEADERS test/*.h) | ||
|
||
set_target_properties(Cesium3DTilesWriter | ||
PROPERTIES | ||
TEST_SOURCES "${CESIUM_3DTILES_WRITER_TEST_SOURCES}" | ||
TEST_HEADERS "${CESIUM_3DTILES_WRITER_TEST_HEADERS}" | ||
PUBLIC_HEADER "${CESIUM_3DTILES_WRITER_PUBLIC_HEADERS}" | ||
) | ||
|
||
target_sources( | ||
Cesium3DTilesWriter | ||
PRIVATE | ||
${CESIUM_3DTILES_WRITER_SOURCES} | ||
${CESIUM_3DTILES_WRITER_HEADERS} | ||
PUBLIC | ||
${CESIUM_3DTILES_WRITER_PUBLIC_HEADERS} | ||
) | ||
|
||
target_compile_definitions( | ||
Cesium3DTilesWriter | ||
PRIVATE | ||
${CESIUM_NATIVE_RAPIDJSON_DEFINES} | ||
) | ||
|
||
target_include_directories( | ||
Cesium3DTilesWriter | ||
SYSTEM PUBLIC | ||
${CESIUM_NATIVE_RAPIDJSON_INCLUDE_DIR} | ||
${CMAKE_BINARY_DIR} | ||
${CMAKE_CURRENT_LIST_DIR}/include | ||
PRIVATE | ||
${CMAKE_CURRENT_LIST_DIR}/src | ||
${CMAKE_CURRENT_LIST_DIR}/generated | ||
) | ||
|
||
target_link_libraries(Cesium3DTilesWriter | ||
PUBLIC | ||
Cesium3DTiles | ||
CesiumJsonWriter | ||
) | ||
|
||
install(TARGETS Cesium3DTilesWriter | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Cesium3DTiles | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick from me, it would be nice if this one can be a variant type. Maybe save a little bit of memory. Also it would be nice if we have a Box type that defines the center and half-axis, rather than
vector<double>
. Similar to Region and Sphere. If it's not possible for the generator, I wouldn't worry about itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use a hybrid approach here? For example, we can manually define Box, Sphere, and Region C++ type and all the utility functions. Then, we tell the generator to use those defined type, rather than create it's own. I haven't tried it, so I'm not sure it's worth the effort
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be possible, but I do think the generated code should be as schema-faithful as possible with minimum "customization", with any custom logic done through other means e.g. inheritance, non-member non-friend utility functions. So maybe in this case we provide e.g. a non-member non-friend
BoundingVolume createBox(const glm::dvec3& center, const glm::dvec3& halfSize);
ininclude/Utils.h
andsrc/Utils.cpp
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related discussion in #362