初始提交: UE5.3项目基础框架

This commit is contained in:
2025-10-14 11:14:54 +08:00
commit 721d9fd98e
5334 changed files with 316782 additions and 0 deletions

View File

@ -0,0 +1,51 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <optional>
#include <string>
namespace Cesium3DTiles {
/**
* @brief Metadata about the entire tileset.
*/
struct CESIUM3DTILES_API Asset final : public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Asset";
/**
* @brief The 3D Tiles version. The version defines the JSON schema for the
* tileset JSON and the base set of tile formats.
*/
std::string version;
/**
* @brief Application-specific version of this tileset, e.g., for when an
* existing tileset is updated.
*/
std::optional<std::string> tilesetVersion;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Asset));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(this->version.capacity() * sizeof(char));
if (this->tilesetVersion) {
accum += int64_t(this->tilesetVersion->capacity() * sizeof(char));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
namespace Cesium3DTiles {
/**
* @brief An object describing the availability of a set of elements.
*/
struct CESIUM3DTILES_API Availability final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Availability";
/**
* @brief Known values for Integer indicating whether all of the elements are
* available (1) or all are unavailable (0).
*/
struct Constant {
/** @brief UNAVAILABLE (`0`) */
static constexpr int32_t UNAVAILABLE = 0;
/** @brief AVAILABLE (`1`) */
static constexpr int32_t AVAILABLE = 1;
};
/**
* @brief Index of a buffer view that indicates whether each element is
* available. The bitstream conforms to the boolean array encoding described
* in the 3D Metadata specification. If an element is available, its bit is 1,
* and if it is unavailable, its bit is 0.
*/
std::optional<int64_t> bitstream;
/**
* @brief A number indicating how many 1 bits exist in the availability
* bitstream.
*/
std::optional<int64_t> availableCount;
/**
* @brief Integer indicating whether all of the elements are available (1) or
* all are unavailable (0).
*
* Known values are defined in {@link Constant}.
*
*/
std::optional<int32_t> constant;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Availability));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,70 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <vector>
namespace Cesium3DTiles {
/**
* @brief A bounding volume that encloses a tile or its content. At least one
* bounding volume property is required. Bounding volumes include `box`,
* `region`, or `sphere`.
*/
struct CESIUM3DTILES_API BoundingVolume final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "BoundingVolume";
/**
* @brief An array of 12 numbers that define an oriented bounding box. The
* first three elements define the x, y, and z values for the center of the
* box. The next three elements (with indices 3, 4, and 5) define the x axis
* direction and half-length. The next three elements (indices 6, 7, and 8)
* define the y axis direction and half-length. The last three elements
* (indices 9, 10, and 11) define the z axis direction and half-length.
*/
std::vector<double> box;
/**
* @brief An array of six numbers that define a bounding geographic region in
* EPSG:4979 coordinates with the order [west, south, east, north, minimum
* height, maximum height]. Longitudes and latitudes are in radians. The range
* for latitudes is [-PI/2,PI/2]. The range for longitudes is [-PI,PI]. The
* value that is given as the 'south' of the region shall not be larger than
* the value for the 'north' of the region. The heights are in meters above
* (or below) the WGS84 ellipsoid. The 'minimum height' shall not be larger
* than the 'maximum height'.
*/
std::vector<double> region;
/**
* @brief An array of four numbers that define a bounding sphere. The first
* three elements define the x, y, and z values for the center of the sphere.
* The last element (with index 3) defines the radius in meters. The radius
* shall not be negative.
*/
std::vector<double> sphere;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(BoundingVolume));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(sizeof(double) * this->box.capacity());
accum += int64_t(sizeof(double) * this->region.capacity());
accum += int64_t(sizeof(double) * this->sphere.capacity());
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,18 @@
#pragma once
#include <Cesium3DTiles/BufferCesium.h>
#include <Cesium3DTiles/BufferSpec.h>
#include <Cesium3DTiles/Library.h>
namespace Cesium3DTiles {
/** @copydoc BufferSpec */
struct CESIUM3DTILES_API Buffer final : public BufferSpec {
Buffer() = default;
/**
* @brief Holds properties that are specific to the 3D Tiles loader rather
* than part of the 3D Tiles spec.
*/
BufferCesium cesium;
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,19 @@
#pragma once
#include <Cesium3DTiles/Library.h>
#include <cstddef>
#include <vector>
namespace Cesium3DTiles {
/**
* @brief Holds {@link Buffer} properties that are specific to the 3D Tiles loader
* rather than part of the 3D Tiles spec.
*/
struct CESIUM3DTILES_API BufferCesium final {
/**
* @brief The buffer's data.
*/
std::vector<std::byte> data;
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,69 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <string>
namespace Cesium3DTiles {
/**
* @brief A buffer is a binary blob. It is either the binary chunk of the
* subtree file, or an external buffer referenced by a URI.
*/
struct CESIUM3DTILES_API BufferSpec : public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Buffer";
/**
* @brief The URI (or IRI) of the file that contains the binary buffer data.
* Relative paths are relative to the file containing the buffer JSON. `uri`
* is required when using the JSON subtree format and not required when using
* the binary subtree format - when omitted the buffer refers to the binary
* chunk of the subtree file. Data URIs are not allowed.
*/
std::optional<std::string> uri;
/**
* @brief The length of the buffer in bytes.
*/
int64_t byteLength = int64_t();
/**
* @brief The name of the buffer.
*/
std::optional<std::string> name;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(BufferSpec));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
if (this->uri) {
accum += int64_t(this->uri->capacity() * sizeof(char));
}
if (this->name) {
accum += int64_t(this->name->capacity() * sizeof(char));
}
return accum;
}
protected:
/**
* @brief This class is not meant to be instantiated directly. Use {@link Buffer} instead.
*/
BufferSpec() = default;
friend struct Buffer;
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,60 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <string>
namespace Cesium3DTiles {
/**
* @brief A contiguous subset of a buffer
*/
struct CESIUM3DTILES_API BufferView final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "BufferView";
/**
* @brief The index of the buffer.
*/
int64_t buffer = int64_t();
/**
* @brief The offset into the buffer in bytes.
*/
int64_t byteOffset = int64_t();
/**
* @brief The total byte length of the buffer view.
*/
int64_t byteLength = int64_t();
/**
* @brief The name of the `bufferView`.
*/
std::optional<std::string> name;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(BufferView));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
if (this->name) {
accum += int64_t(this->name->capacity() * sizeof(char));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,67 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/ClassProperty.h>
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <optional>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief A class containing a set of properties.
*/
struct CESIUM3DTILES_API Class final : public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Class";
/**
* @brief The name of the class, e.g. for display purposes.
*/
std::optional<std::string> name;
/**
* @brief The description of the class.
*/
std::optional<std::string> description;
/**
* @brief A dictionary, where each key is a property ID and each value is an
* object defining the property. Property IDs shall be alphanumeric
* identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`.
*/
std::unordered_map<std::string, Cesium3DTiles::ClassProperty> properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Class));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
if (this->name) {
accum += int64_t(this->name->capacity() * sizeof(char));
}
if (this->description) {
accum += int64_t(this->description->capacity() * sizeof(char));
}
accum += int64_t(
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::ClassProperty)));
for (const auto& [k, v] : this->properties) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum += v.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::ClassProperty));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,241 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <CesiumUtility/JsonValue.h>
#include <cstdint>
#include <optional>
#include <string>
namespace Cesium3DTiles {
/**
* @brief A single property of a metadata class.
*/
struct CESIUM3DTILES_API ClassProperty final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "ClassProperty";
/**
* @brief Known values for The element type.
*/
struct Type {
/** @brief `SCALAR` */
inline static const std::string SCALAR = "SCALAR";
/** @brief `VEC2` */
inline static const std::string VEC2 = "VEC2";
/** @brief `VEC3` */
inline static const std::string VEC3 = "VEC3";
/** @brief `VEC4` */
inline static const std::string VEC4 = "VEC4";
/** @brief `MAT2` */
inline static const std::string MAT2 = "MAT2";
/** @brief `MAT3` */
inline static const std::string MAT3 = "MAT3";
/** @brief `MAT4` */
inline static const std::string MAT4 = "MAT4";
/** @brief `STRING` */
inline static const std::string STRING = "STRING";
/** @brief `BOOLEAN` */
inline static const std::string BOOLEAN = "BOOLEAN";
/** @brief `ENUM` */
inline static const std::string ENUM = "ENUM";
};
/**
* @brief Known values for The datatype of the element's components. Required
* for `SCALAR`, `VECN`, and `MATN` types, and disallowed for other types.
*/
struct ComponentType {
/** @brief `INT8` */
inline static const std::string INT8 = "INT8";
/** @brief `UINT8` */
inline static const std::string UINT8 = "UINT8";
/** @brief `INT16` */
inline static const std::string INT16 = "INT16";
/** @brief `UINT16` */
inline static const std::string UINT16 = "UINT16";
/** @brief `INT32` */
inline static const std::string INT32 = "INT32";
/** @brief `UINT32` */
inline static const std::string UINT32 = "UINT32";
/** @brief `INT64` */
inline static const std::string INT64 = "INT64";
/** @brief `UINT64` */
inline static const std::string UINT64 = "UINT64";
/** @brief `FLOAT32` */
inline static const std::string FLOAT32 = "FLOAT32";
/** @brief `FLOAT64` */
inline static const std::string FLOAT64 = "FLOAT64";
};
/**
* @brief The name of the property, e.g. for display purposes.
*/
std::optional<std::string> name;
/**
* @brief The description of the property.
*/
std::optional<std::string> description;
/**
* @brief The element type.
*
* Known values are defined in {@link Type}.
*
*/
std::string type = Type::SCALAR;
/**
* @brief The datatype of the element's components. Required for `SCALAR`,
* `VECN`, and `MATN` types, and disallowed for other types.
*
* Known values are defined in {@link ComponentType}.
*
*/
std::optional<std::string> componentType;
/**
* @brief Enum ID as declared in the `enums` dictionary. Required when `type`
* is `ENUM`. Disallowed when `type` is not `ENUM`
*/
std::optional<std::string> enumType;
/**
* @brief Whether the property is an array. When `count` is defined the
* property is a fixed-length array. Otherwise the property is a
* variable-length array.
*/
bool array = false;
/**
* @brief The number of array elements. May only be defined when `array` is
* `true`.
*/
std::optional<int64_t> count;
/**
* @brief Specifies whether integer values are normalized. Only applicable to
* `SCALAR`, `VECN`, and `MATN` types with integer component types. For
* unsigned integer component types, values are normalized between
* `[0.0, 1.0]`. For signed integer component types, values are normalized
* between `[-1.0, 1.0]`. For all other component types, this property shall
* be false.
*/
bool normalized = false;
/**
* @brief An offset to apply to property values. Only applicable to `SCALAR`,
* `VECN`, and `MATN` types when the component type is `FLOAT32` or `FLOAT64`,
* or when the property is `normalized`. Not applicable to variable-length
* arrays.
*/
std::optional<CesiumUtility::JsonValue> offset;
/**
* @brief A scale to apply to property values. Only applicable to `SCALAR`,
* `VECN`, and `MATN` types when the component type is `FLOAT32` or `FLOAT64`,
* or when the property is `normalized`. Not applicable to variable-length
* arrays.
*/
std::optional<CesiumUtility::JsonValue> scale;
/**
* @brief Maximum allowed value for the property. Only applicable to `SCALAR`,
* `VECN`, and `MATN` types. This is the maximum of all property values, after
* the transforms based on the `normalized`, `offset`, and `scale` properties
* have been applied. Not applicable to variable-length arrays.
*/
std::optional<CesiumUtility::JsonValue> max;
/**
* @brief Minimum allowed value for the property. Only applicable to `SCALAR`,
* `VECN`, and `MATN` types. This is the minimum of all property values, after
* the transforms based on the `normalized`, `offset`, and `scale` properties
* have been applied. Not applicable to variable-length arrays.
*/
std::optional<CesiumUtility::JsonValue> min;
/**
* @brief If required, the property shall be present in every entity
* conforming to the class. If not required, individual entities may include
* `noData` values, or the entire property may be omitted. As a result,
* `noData` has no effect on a required property. Client implementations may
* use required properties to make performance optimizations.
*/
bool required = false;
/**
* @brief A `noData` value represents missing data — also known as a sentinel
* value — wherever it appears. `BOOLEAN` properties may not specify `noData`
* values. This is given as the plain property value, without the transforms
* from the `normalized`, `offset`, and `scale` properties. Shall not be
* defined if `required` is true.
*/
std::optional<CesiumUtility::JsonValue> noData;
/**
* @brief A default value to use when encountering a `noData` value or an
* omitted property. The value is given in its final form, taking the effect
* of `normalized`, `offset`, and `scale` properties into account. Shall not
* be defined if `required` is true.
*/
std::optional<CesiumUtility::JsonValue> defaultProperty;
/**
* @brief An identifier that describes how this property should be
* interpreted. The semantic cannot be used by other properties in the class.
*/
std::optional<std::string> semantic;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(ClassProperty));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
if (this->name) {
accum += int64_t(this->name->capacity() * sizeof(char));
}
if (this->description) {
accum += int64_t(this->description->capacity() * sizeof(char));
}
if (this->enumType) {
accum += int64_t(this->enumType->capacity() * sizeof(char));
}
if (this->semantic) {
accum += int64_t(this->semantic->capacity() * sizeof(char));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,60 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/PropertyStatistics.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief Statistics about entities that conform to a class that was defined in
* a metadata schema.
*/
struct CESIUM3DTILES_API ClassStatistics final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "ClassStatistics";
/**
* @brief The number of entities that conform to the class.
*/
std::optional<int64_t> count;
/**
* @brief A dictionary, where each key corresponds to a property ID in the
* class' `properties` dictionary and each value is an object containing
* statistics about property values.
*/
std::unordered_map<std::string, Cesium3DTiles::PropertyStatistics> properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(ClassStatistics));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::PropertyStatistics)));
for (const auto& [k, v] : this->properties) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum +=
v.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::PropertyStatistics));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,73 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/BoundingVolume.h>
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/MetadataEntity.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <string>
namespace Cesium3DTiles {
/**
* @brief Metadata about the tile's content and a link to the content.
*/
struct CESIUM3DTILES_API Content final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Content";
/**
* @brief An optional bounding volume that tightly encloses tile content.
* tile.boundingVolume provides spatial coherence and
* tile.content.boundingVolume enables tight view frustum culling. When this
* is omitted, tile.boundingVolume is used.
*/
std::optional<Cesium3DTiles::BoundingVolume> boundingVolume;
/**
* @brief A uri that points to tile content. When the uri is relative, it is
* relative to the referring tileset JSON file.
*/
std::string uri;
/**
* @brief Metadata that is associated with this content.
*/
std::optional<Cesium3DTiles::MetadataEntity> metadata;
/**
* @brief The group this content belongs to. The value is an index into the
* array of `groups` that is defined for the containing tileset.
*/
std::optional<int64_t> group;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Content));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
if (this->boundingVolume) {
accum += this->boundingVolume->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::BoundingVolume));
}
accum += int64_t(this->uri.capacity() * sizeof(char));
if (this->metadata) {
accum += this->metadata->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::MetadataEntity));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,101 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/EnumValue.h>
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <optional>
#include <string>
#include <vector>
namespace Cesium3DTiles {
/**
* @brief An object defining the values of an enum.
*/
struct CESIUM3DTILES_API Enum final : public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Enum";
/**
* @brief Known values for The type of the integer enum value.
*/
struct ValueType {
/** @brief `INT8` */
inline static const std::string INT8 = "INT8";
/** @brief `UINT8` */
inline static const std::string UINT8 = "UINT8";
/** @brief `INT16` */
inline static const std::string INT16 = "INT16";
/** @brief `UINT16` */
inline static const std::string UINT16 = "UINT16";
/** @brief `INT32` */
inline static const std::string INT32 = "INT32";
/** @brief `UINT32` */
inline static const std::string UINT32 = "UINT32";
/** @brief `INT64` */
inline static const std::string INT64 = "INT64";
/** @brief `UINT64` */
inline static const std::string UINT64 = "UINT64";
};
/**
* @brief The name of the enum, e.g. for display purposes.
*/
std::optional<std::string> name;
/**
* @brief The description of the enum.
*/
std::optional<std::string> description;
/**
* @brief The type of the integer enum value.
*
* Known values are defined in {@link ValueType}.
*
*/
std::string valueType = ValueType::UINT16;
/**
* @brief An array of enum values. Duplicate names or duplicate integer values
* are not allowed.
*/
std::vector<Cesium3DTiles::EnumValue> values;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Enum));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
if (this->name) {
accum += int64_t(this->name->capacity() * sizeof(char));
}
if (this->description) {
accum += int64_t(this->description->capacity() * sizeof(char));
}
accum +=
int64_t(sizeof(Cesium3DTiles::EnumValue) * this->values.capacity());
for (const Cesium3DTiles::EnumValue& value : this->values) {
accum += value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::EnumValue));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,56 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <string>
namespace Cesium3DTiles {
/**
* @brief An enum value.
*/
struct CESIUM3DTILES_API EnumValue final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "EnumValue";
/**
* @brief The name of the enum value.
*/
std::string name;
/**
* @brief The description of the enum value.
*/
std::optional<std::string> description;
/**
* @brief The integer enum value.
*/
int64_t value = int64_t();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(EnumValue));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(this->name.capacity() * sizeof(char));
if (this->description) {
accum += int64_t(this->description->capacity() * sizeof(char));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,58 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <string>
namespace Cesium3DTiles {
/**
* @brief 3D Tiles extension for S2 bounding volumes.
*/
struct CESIUM3DTILES_API Extension3dTilesBoundingVolumeS2 final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Extension3dTilesBoundingVolumeS2";
/** @brief The official name of the extension. This should be the same as its
* key in the `extensions` object. */
static constexpr const char* ExtensionName = "3DTILES_bounding_volume_S2";
/**
* @brief A hexadecimal representation of the S2CellId. Tokens shall be
* lower-case, shall not contain whitespace and shall have trailing zeros
* stripped.
*/
std::string token;
/**
* @brief The minimum height of the tile, specified in meters above (or below)
* the WGS84 ellipsoid.
*/
double minimumHeight = double();
/**
* @brief The maximum height of the tile, specified in meters above (or below)
* the WGS84 ellipsoid.
*/
double maximumHeight = double();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Extension3dTilesBoundingVolumeS2));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(this->token.capacity() * sizeof(char));
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,32 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/MetadataEntity.h>
namespace Cesium3DTiles {
/**
* @brief An object containing metadata about a group.
*/
struct CESIUM3DTILES_API GroupMetadata final : public MetadataEntity {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "GroupMetadata";
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(GroupMetadata));
accum += MetadataEntity::getSizeBytes() - int64_t(sizeof(MetadataEntity));
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,78 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/Subtrees.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <string>
namespace Cesium3DTiles {
/**
* @brief This object allows a tile to be implicitly subdivided. Tile and
* content availability and metadata is stored in subtrees which are referenced
* externally.
*/
struct CESIUM3DTILES_API ImplicitTiling final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "ImplicitTiling";
/**
* @brief Known values for A string describing the subdivision scheme used
* within the tileset.
*/
struct SubdivisionScheme {
/** @brief `QUADTREE` */
inline static const std::string QUADTREE = "QUADTREE";
/** @brief `OCTREE` */
inline static const std::string OCTREE = "OCTREE";
};
/**
* @brief A string describing the subdivision scheme used within the tileset.
*
* Known values are defined in {@link SubdivisionScheme}.
*
*/
std::string subdivisionScheme = SubdivisionScheme::QUADTREE;
/**
* @brief The number of distinct levels in each subtree. For example, a
* quadtree with `subtreeLevels = 2` will have subtrees with 5 nodes (one root
* and 4 children).
*/
int64_t subtreeLevels = int64_t();
/**
* @brief The numbers of the levels in the tree with available tiles.
*/
int64_t availableLevels = int64_t();
/**
* @brief An object describing the location of subtree files.
*/
Cesium3DTiles::Subtrees subtrees;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(ImplicitTiling));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += this->subtrees.getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::Subtrees));
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,18 @@
#pragma once
/**
* @brief Classes for using [3D Tiles](https://github.com/CesiumGS/3d-tiles).
*
* @mermaid-interactive{dependencies/Cesium3DTiles}
*/
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

View File

@ -0,0 +1,64 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <CesiumUtility/JsonValue.h>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief An object containing a reference to a class from a metadata schema,
* and property values that conform to the properties of that class.
*/
struct CESIUM3DTILES_API MetadataEntity
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "MetadataEntity";
/**
* @brief The class that property values conform to. The value shall be a
* class ID declared in the `classes` dictionary of the metadata schema.
*/
std::string classProperty;
/**
* @brief A dictionary, where each key corresponds to a property ID in the
* class' `properties` dictionary and each value contains the property values.
* The type of the value shall match the property definition: For `BOOLEAN`
* use `true` or `false`. For `STRING` use a JSON string. For numeric types
* use a JSON number. For `ENUM` use a valid enum `name`, not an integer
* value. For `ARRAY`, `VECN`, and `MATN` types use a JSON array containing
* values matching the `componentType`. Required properties shall be included
* in this dictionary.
*/
std::unordered_map<std::string, CesiumUtility::JsonValue> properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(MetadataEntity));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(this->classProperty.capacity() * sizeof(char));
accum += int64_t(
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(CesiumUtility::JsonValue)));
for (const auto& [k, v] : this->properties) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum += int64_t(sizeof(CesiumUtility::JsonValue));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,74 @@
#pragma once
#include <Cesium3DTiles/MetadataEntity.h>
#include <Cesium3DTiles/Schema.h>
#include <CesiumUtility/JsonValue.h>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief Holds the details of a found property in a {@link MetadataEntity}.
*
* Because this structure holds _references_ to the original {@link Schema} and
* {@link MetadataEntity} instances, it will be invalided if either are
* destroyed or modified. Continuing to access this result in that scenario will
* result in undefined behavior.
*/
struct CESIUM3DTILES_API FoundMetadataProperty {
/**
* @brief A reference to the identifier of the class that contains the found
* property within the {@link Schema}.
*/
const std::string& classIdentifier;
/**
* @brief A reference to the {@link Class} that contains the found property
* within the {@link Schema}.
*/
const Class& classDefinition;
/**
* @brief A reference to the identifier of the found property within the
* {@link Schema}.
*/
const std::string& propertyIdentifier;
/**
* @brief A reference to the {@link ClassProperty} describing the found
* property within the {@link Schema}.
*/
const ClassProperty& propertyDefinition;
/**
* @brief A reference to the value of the found property within the
* {@link MetadataEntity}.
*/
const CesiumUtility::JsonValue& propertyValue;
};
/**
* @brief Convenience functions for querying {@link MetadataEntity} instances.
*/
class CESIUM3DTILES_API MetadataQuery {
public:
/**
* @brief Gets the first property with a given
* {@link ClassProperty::semantic}.
*
* @param schema The schema to use to look up semantics.
* @param entity The metadata entity to search for a property with the
* semantic.
* @param semantic The semantic to find.
* @return The details of the found property, or `std::nullopt` if a property
* with the given semantic does not exist.
*/
static std::optional<FoundMetadataProperty> findFirstPropertyWithSemantic(
const Schema& schema,
const MetadataEntity& entity,
const std::string& semantic);
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,46 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
namespace Cesium3DTiles {
/**
* @brief A dictionary object of metadata about per-feature properties.
*/
struct CESIUM3DTILES_API Properties final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Properties";
/**
* @brief The maximum value of this property of all the features in the
* tileset. The maximum value shall not be smaller than the minimum value.
*/
double maximum = double();
/**
* @brief The minimum value of this property of all the features in the
* tileset. The maximum value shall not be smaller than the minimum value.
*/
double minimum = double();
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Properties));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,109 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <CesiumUtility/JsonValue.h>
#include <optional>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief Statistics about property values.
*/
struct CESIUM3DTILES_API PropertyStatistics final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "PropertyStatistics";
/**
* @brief The minimum property value occurring in the tileset. Only applicable
* to `SCALAR`, `VECN`, and `MATN` types. This is the minimum of all property
* values, after the transforms based on the `normalized`, `offset`, and
* `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> min;
/**
* @brief The maximum property value occurring in the tileset. Only applicable
* to `SCALAR`, `VECN`, and `MATN` types. This is the maximum of all property
* values, after the transforms based on the `normalized`, `offset`, and
* `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> max;
/**
* @brief The arithmetic mean of property values occurring in the tileset.
* Only applicable to `SCALAR`, `VECN`, and `MATN` types. This is the mean of
* all property values, after the transforms based on the `normalized`,
* `offset`, and `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> mean;
/**
* @brief The median of property values occurring in the tileset. Only
* applicable to `SCALAR`, `VECN`, and `MATN` types. This is the median of all
* property values, after the transforms based on the `normalized`, `offset`,
* and `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> median;
/**
* @brief The standard deviation of property values occurring in the tileset.
* Only applicable to `SCALAR`, `VECN`, and `MATN` types. This is the standard
* deviation of all property values, after the transforms based on the
* `normalized`, `offset`, and `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> standardDeviation;
/**
* @brief The variance of property values occurring in the tileset. Only
* applicable to `SCALAR`, `VECN`, and `MATN` types. This is the variance of
* all property values, after the transforms based on the `normalized`,
* `offset`, and `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> variance;
/**
* @brief The sum of property values occurring in the tileset. Only applicable
* to `SCALAR`, `VECN`, and `MATN` types. This is the sum of all property
* values, after the transforms based on the `normalized`, `offset`, and
* `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> sum;
/**
* @brief A dictionary, where each key corresponds to an enum `name` and each
* value is the number of occurrences of that enum. Only applicable when
* `type` is `ENUM`. For fixed-length arrays, this is an array of
* component-wise occurrences.
*/
std::unordered_map<std::string, CesiumUtility::JsonValue> occurrences;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(PropertyStatistics));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(
this->occurrences.bucket_count() *
(sizeof(std::string) + sizeof(CesiumUtility::JsonValue)));
for (const auto& [k, v] : this->occurrences) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum += int64_t(sizeof(CesiumUtility::JsonValue));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,77 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/PropertyTableProperty.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief Properties conforming to a class, organized as property values stored
* in binary columnar arrays.
*/
struct CESIUM3DTILES_API PropertyTable final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "PropertyTable";
/**
* @brief The name of the property table, e.g. for display purposes.
*/
std::optional<std::string> name;
/**
* @brief The class that property values conform to. The value shall be a
* class ID declared in the `classes` dictionary.
*/
std::string classProperty;
/**
* @brief The number of elements in each property array.
*/
int64_t count = int64_t();
/**
* @brief A dictionary, where each key corresponds to a property ID in the
* class' `properties` dictionary and each value is an object describing where
* property values are stored. Required properties shall be included in this
* dictionary.
*/
std::unordered_map<std::string, Cesium3DTiles::PropertyTableProperty>
properties;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(PropertyTable));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
if (this->name) {
accum += int64_t(this->name->capacity() * sizeof(char));
}
accum += int64_t(this->classProperty.capacity() * sizeof(char));
accum += int64_t(
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::PropertyTableProperty)));
for (const auto& [k, v] : this->properties) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum += v.getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::PropertyTableProperty));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,164 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <CesiumUtility/JsonValue.h>
#include <cstdint>
#include <optional>
#include <string>
namespace Cesium3DTiles {
/**
* @brief An array of binary property values. This represents one column of a
* property table, and contains one value of a certain property for each
* metadata entity.
*/
struct CESIUM3DTILES_API PropertyTableProperty final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "PropertyTableProperty";
/**
* @brief Known values for The type of values in `arrayOffsets`.
*/
struct ArrayOffsetType {
/** @brief `UINT8` */
inline static const std::string UINT8 = "UINT8";
/** @brief `UINT16` */
inline static const std::string UINT16 = "UINT16";
/** @brief `UINT32` */
inline static const std::string UINT32 = "UINT32";
/** @brief `UINT64` */
inline static const std::string UINT64 = "UINT64";
};
/**
* @brief Known values for The type of values in `stringOffsets`.
*/
struct StringOffsetType {
/** @brief `UINT8` */
inline static const std::string UINT8 = "UINT8";
/** @brief `UINT16` */
inline static const std::string UINT16 = "UINT16";
/** @brief `UINT32` */
inline static const std::string UINT32 = "UINT32";
/** @brief `UINT64` */
inline static const std::string UINT64 = "UINT64";
};
/**
* @brief The index of the buffer view containing property values. The data
* type of property values is determined by the property definition: When
* `type` is `BOOLEAN` values are packed into a bitstream. When `type` is
* `STRING` values are stored as byte sequences and decoded as UTF-8 strings.
* When `type` is `SCALAR`, `VECN`, or `MATN` the values are stored as the
* provided `componentType` and the buffer view `byteOffset` shall be aligned
* to a multiple of the `componentType` size. When `type` is `ENUM` values are
* stored as the enum's `valueType` and the buffer view `byteOffset` shall be
* aligned to a multiple of the `valueType` size. Each enum value in the array
* shall match one of the allowed values in the enum definition.
* `arrayOffsets` is required for variable-length arrays and `stringOffsets`
* is required for strings (for variable-length arrays of strings, both are
* required).
*/
int64_t values = int64_t();
/**
* @brief The index of the buffer view containing offsets for variable-length
* arrays. The number of offsets is equal to the property table `count` plus
* one. The offsets represent the start positions of each array, with the last
* offset representing the position after the last array. The array length is
* computed using the difference between the subsequent offset and the current
* offset. If `type` is `STRING` the offsets index into the string offsets
* array (stored in `stringOffsets`), otherwise they index into the property
* array (stored in `values`). The data type of these offsets is determined by
* `arrayOffsetType`. The buffer view `byteOffset` shall be aligned to a
* multiple of the `arrayOffsetType` size.
*/
std::optional<int64_t> arrayOffsets;
/**
* @brief The index of the buffer view containing offsets for strings. The
* number of offsets is equal to the number of string elements plus one. The
* offsets represent the byte offsets of each string in the property array
* (stored in `values`), with the last offset representing the byte offset
* after the last string. The string byte length is computed using the
* difference between the subsequent offset and the current offset. The data
* type of these offsets is determined by `stringOffsetType`. The buffer view
* `byteOffset` shall be aligned to a multiple of the `stringOffsetType` size.
*/
std::optional<int64_t> stringOffsets;
/**
* @brief The type of values in `arrayOffsets`.
*
* Known values are defined in {@link ArrayOffsetType}.
*
*/
std::string arrayOffsetType = ArrayOffsetType::UINT32;
/**
* @brief The type of values in `stringOffsets`.
*
* Known values are defined in {@link StringOffsetType}.
*
*/
std::string stringOffsetType = StringOffsetType::UINT32;
/**
* @brief An offset to apply to property values. Only applicable when the
* component type is `FLOAT32` or `FLOAT64`, or when the property is
* `normalized`. Overrides the class property's `offset` if both are defined.
*/
std::optional<CesiumUtility::JsonValue> offset;
/**
* @brief A scale to apply to property values. Only applicable when the
* component type is `FLOAT32` or `FLOAT64`, or when the property is
* `normalized`. Overrides the class property's `scale` if both are defined.
*/
std::optional<CesiumUtility::JsonValue> scale;
/**
* @brief Maximum value present in the property values. Only applicable to
* `SCALAR`, `VECN`, and `MATN` types. This is the maximum of all property
* values, after the transforms based on the `normalized`, `offset`, and
* `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> max;
/**
* @brief Minimum value present in the property values. Only applicable to
* `SCALAR`, `VECN`, and `MATN` types. This is the minimum of all property
* values, after the transforms based on the `normalized`, `offset`, and
* `scale` properties have been applied.
*/
std::optional<CesiumUtility::JsonValue> min;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(PropertyTableProperty));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,97 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Class.h>
#include <Cesium3DTiles/Enum.h>
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <optional>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief An object defining classes and enums.
*/
struct CESIUM3DTILES_API Schema final : public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Schema";
/**
* @brief Unique identifier for the schema. Schema IDs shall be alphanumeric
* identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`.
*/
std::string id;
/**
* @brief The name of the schema, e.g. for display purposes.
*/
std::optional<std::string> name;
/**
* @brief The description of the schema.
*/
std::optional<std::string> description;
/**
* @brief Application-specific version of the schema.
*/
std::optional<std::string> version;
/**
* @brief A dictionary, where each key is a class ID and each value is an
* object defining the class. Class IDs shall be alphanumeric identifiers
* matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`.
*/
std::unordered_map<std::string, Cesium3DTiles::Class> classes;
/**
* @brief A dictionary, where each key is an enum ID and each value is an
* object defining the values for the enum. Enum IDs shall be alphanumeric
* identifiers matching the regular expression `^[a-zA-Z_][a-zA-Z0-9_]*$`.
*/
std::unordered_map<std::string, Cesium3DTiles::Enum> enums;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Schema));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(this->id.capacity() * sizeof(char));
if (this->name) {
accum += int64_t(this->name->capacity() * sizeof(char));
}
if (this->description) {
accum += int64_t(this->description->capacity() * sizeof(char));
}
if (this->version) {
accum += int64_t(this->version->capacity() * sizeof(char));
}
accum += int64_t(
this->classes.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::Class)));
for (const auto& [k, v] : this->classes) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum += v.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Class));
}
accum += int64_t(
this->enums.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::Enum)));
for (const auto& [k, v] : this->enums) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum += v.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Enum));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,53 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/ClassStatistics.h>
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <string>
#include <unordered_map>
namespace Cesium3DTiles {
/**
* @brief Statistics about entities.
*/
struct CESIUM3DTILES_API Statistics final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Statistics";
/**
* @brief A dictionary, where each key corresponds to a class ID in the
* `classes` dictionary of the metatata schema that was defined for the
* tileset that contains these statistics. Each value is an object containing
* statistics about entities that conform to the class.
*/
std::unordered_map<std::string, Cesium3DTiles::ClassStatistics> classes;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Statistics));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(
this->classes.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::ClassStatistics)));
for (const auto& [k, v] : this->classes) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum +=
v.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::ClassStatistics));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,151 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Availability.h>
#include <Cesium3DTiles/Buffer.h>
#include <Cesium3DTiles/BufferView.h>
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/MetadataEntity.h>
#include <Cesium3DTiles/PropertyTable.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <cstdint>
#include <optional>
#include <vector>
namespace Cesium3DTiles {
/**
* @brief An object describing the availability of tiles and content in a
* subtree, as well as availability of children subtrees. May also store
* metadata for available tiles and content.
*/
struct CESIUM3DTILES_API Subtree final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Subtree";
/**
* @brief An array of buffers.
*/
std::vector<Cesium3DTiles::Buffer> buffers;
/**
* @brief An array of buffer views.
*/
std::vector<Cesium3DTiles::BufferView> bufferViews;
/**
* @brief An array of property tables.
*/
std::vector<Cesium3DTiles::PropertyTable> propertyTables;
/**
* @brief The availability of tiles in the subtree. The availability bitstream
* is a 1D boolean array where tiles are ordered by their level in the subtree
* and Morton index within that level. A tile's availability is determined by
* a single bit, 1 meaning a tile exists at that spatial index, and 0 meaning
* it does not. The number of elements in the array is `(N^subtreeLevels -
* 1)/(N - 1)` where N is 4 for subdivision scheme `QUADTREE` and 8 for
* `OCTREE`. Availability may be stored in a buffer view or as a constant
* value that applies to all tiles. If a non-root tile's availability is 1 its
* parent tile's availability shall also be 1. `tileAvailability.constant: 0`
* is disallowed, as subtrees shall have at least one tile.
*/
Cesium3DTiles::Availability tileAvailability;
/**
* @brief An array of content availability objects. If the tile has a single
* content this array will have one element; if the tile has multiple contents
* - as supported by 3DTILES_multiple_contents and 3D Tiles 1.1 - this array
* will have multiple elements.
*/
std::vector<Cesium3DTiles::Availability> contentAvailability;
/**
* @brief The availability of children subtrees. The availability bitstream is
* a 1D boolean array where subtrees are ordered by their Morton index in the
* level of the tree immediately below the bottom row of the subtree. A child
* subtree's availability is determined by a single bit, 1 meaning a subtree
* exists at that spatial index, and 0 meaning it does not. The number of
* elements in the array is `N^subtreeLevels` where N is 4 for subdivision
* scheme `QUADTREE` and 8 for `OCTREE`. Availability may be stored in a
* buffer view or as a constant value that applies to all child subtrees. If
* availability is 0 for all child subtrees, then the tileset does not
* subdivide further.
*/
Cesium3DTiles::Availability childSubtreeAvailability;
/**
* @brief Index of the property table containing tile metadata. Tile metadata
* only exists for available tiles and is tightly packed by increasing tile
* index. To access individual tile metadata, implementations may create a
* mapping from tile indices to tile metadata indices.
*/
std::optional<int64_t> tileMetadata;
/**
* @brief An array of indexes to property tables containing content metadata.
* If the tile has a single content this array will have one element; if the
* tile has multiple contents - as supported by 3DTILES_multiple_contents and
* 3D Tiles 1.1 - this array will have multiple elements. Content metadata
* only exists for available contents and is tightly packed by increasing tile
* index. To access individual content metadata, implementations may create a
* mapping from tile indices to content metadata indices.
*/
std::vector<int64_t> contentMetadata;
/**
* @brief Subtree metadata encoded in JSON.
*/
std::optional<Cesium3DTiles::MetadataEntity> subtreeMetadata;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Subtree));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(sizeof(Cesium3DTiles::Buffer) * this->buffers.capacity());
for (const Cesium3DTiles::Buffer& value : this->buffers) {
accum += value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Buffer));
}
accum += int64_t(
sizeof(Cesium3DTiles::BufferView) * this->bufferViews.capacity());
for (const Cesium3DTiles::BufferView& value : this->bufferViews) {
accum +=
value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::BufferView));
}
accum += int64_t(
sizeof(Cesium3DTiles::PropertyTable) * this->propertyTables.capacity());
for (const Cesium3DTiles::PropertyTable& value : this->propertyTables) {
accum +=
value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::PropertyTable));
}
accum += this->tileAvailability.getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::Availability));
accum += int64_t(
sizeof(Cesium3DTiles::Availability) *
this->contentAvailability.capacity());
for (const Cesium3DTiles::Availability& value : this->contentAvailability) {
accum +=
value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Availability));
}
accum += this->childSubtreeAvailability.getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::Availability));
accum += int64_t(sizeof(int64_t) * this->contentMetadata.capacity());
if (this->subtreeMetadata) {
accum += this->subtreeMetadata->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::MetadataEntity));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,41 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Library.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <string>
namespace Cesium3DTiles {
/**
* @brief An object describing the location of subtree files.
*/
struct CESIUM3DTILES_API Subtrees final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Subtrees";
/**
* @brief A URI with embedded expressions that describes the resource that is associated with an implicit tile in an implicit tileset. Allowed expressions are `{level}`, `{x}`, `{y}`, and `{z}`. `{level}` is substituted with the level of the node, `{x}` is substituted with the x index of the node within the level, and `{y}` is substituted with the y index of the node within the level. `{z}` may only be given when the subdivision scheme is `OCTREE`, and it is substituted with the z index of the node within the level.
*/
std::string uri;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Subtrees));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += int64_t(this->uri.capacity() * sizeof(char));
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,157 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/BoundingVolume.h>
#include <Cesium3DTiles/Content.h>
#include <Cesium3DTiles/ImplicitTiling.h>
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/MetadataEntity.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <optional>
#include <string>
#include <vector>
namespace Cesium3DTiles {
/**
* @brief A tile in a 3D Tiles tileset.
*/
struct CESIUM3DTILES_API Tile final : public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Tile";
/**
* @brief Known values for Specifies if additive or replacement refinement is
* used when traversing the tileset for rendering. This property is required
* for the root tile of a tileset; it is optional for all other tiles. The
* default is to inherit from the parent tile.
*/
struct Refine {
/** @brief `ADD` */
inline static const std::string ADD = "ADD";
/** @brief `REPLACE` */
inline static const std::string REPLACE = "REPLACE";
};
/**
* @brief The bounding volume that encloses the tile.
*/
Cesium3DTiles::BoundingVolume boundingVolume;
/**
* @brief Optional bounding volume that defines the volume the viewer shall be
* inside of before the tile's content will be requested and before the tile
* will be refined based on geometricError.
*/
std::optional<Cesium3DTiles::BoundingVolume> viewerRequestVolume;
/**
* @brief The error, in meters, introduced if this tile is rendered and its
* children are not. At runtime, the geometric error is used to compute screen
* space error (SSE), i.e., the error measured in pixels.
*/
double geometricError = double();
/**
* @brief Specifies if additive or replacement refinement is used when
* traversing the tileset for rendering. This property is required for the
* root tile of a tileset; it is optional for all other tiles. The default is
* to inherit from the parent tile.
*
* Known values are defined in {@link Refine}.
*
*/
std::optional<std::string> refine;
/**
* @brief A floating-point 4x4 affine transformation matrix, stored in
* column-major order, that transforms the tile's content--i.e., its features
* as well as content.boundingVolume, boundingVolume, and
* viewerRequestVolume--from the tile's local coordinate system to the parent
* tile's coordinate system, or, in the case of a root tile, from the tile's
* local coordinate system to the tileset's coordinate system. `transform`
* does not apply to any volume property when the volume is a region, defined
* in EPSG:4979 coordinates. `transform` scales the `geometricError` by the
* maximum scaling factor from the matrix.
*/
std::vector<double> transform =
{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
/**
* @brief Metadata about the tile's content and a link to the content. When
* this is omitted the tile is just used for culling. When this is defined,
* then `contents` shall be undefined.
*/
std::optional<Cesium3DTiles::Content> content;
/**
* @brief An array of contents. When this is defined, then `content` shall be
* undefined.
*/
std::vector<Cesium3DTiles::Content> contents;
/**
* @brief A metadata entity that is associated with this tile.
*/
std::optional<Cesium3DTiles::MetadataEntity> metadata;
/**
* @brief An object that describes the implicit subdivision of this tile.
*/
std::optional<Cesium3DTiles::ImplicitTiling> implicitTiling;
/**
* @brief An array of objects that define child tiles. Each child tile content
* is fully enclosed by its parent tile's bounding volume and, generally, has
* a geometricError less than its parent tile's geometricError. For leaf
* tiles, there are no children, and this property may not be defined.
*/
std::vector<Cesium3DTiles::Tile> children;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Tile));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += this->boundingVolume.getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::BoundingVolume));
if (this->viewerRequestVolume) {
accum += this->viewerRequestVolume->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::BoundingVolume));
}
accum += int64_t(sizeof(double) * this->transform.capacity());
if (this->content) {
accum += this->content->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::Content));
}
accum +=
int64_t(sizeof(Cesium3DTiles::Content) * this->contents.capacity());
for (const Cesium3DTiles::Content& value : this->contents) {
accum += value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Content));
}
if (this->metadata) {
accum += this->metadata->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::MetadataEntity));
}
if (this->implicitTiling) {
accum += this->implicitTiling->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::ImplicitTiling));
}
accum += int64_t(sizeof(Cesium3DTiles::Tile) * this->children.capacity());
for (const Cesium3DTiles::Tile& value : this->children) {
accum += value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Tile));
}
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,139 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Asset.h>
#include <Cesium3DTiles/GroupMetadata.h>
#include <Cesium3DTiles/Library.h>
#include <Cesium3DTiles/MetadataEntity.h>
#include <Cesium3DTiles/Properties.h>
#include <Cesium3DTiles/Schema.h>
#include <Cesium3DTiles/Statistics.h>
#include <Cesium3DTiles/Tile.h>
#include <CesiumUtility/ExtensibleObject.h>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
namespace Cesium3DTiles {
/**
* @brief A 3D Tiles tileset.
*/
struct CESIUM3DTILES_API Tileset final
: public CesiumUtility::ExtensibleObject {
/**
* @brief The original name of this type.
*/
static constexpr const char* TypeName = "Tileset";
/**
* @brief Metadata about the entire tileset.
*/
Cesium3DTiles::Asset asset;
/**
* @brief A dictionary object of metadata about per-feature properties.
*/
std::unordered_map<std::string, Cesium3DTiles::Properties> properties;
/**
* @brief An object defining the structure of metadata classes and enums. When
* this is defined, then `schemaUri` shall be undefined.
*/
std::optional<Cesium3DTiles::Schema> schema;
/**
* @brief The URI (or IRI) of the external schema file. When this is defined,
* then `schema` shall be undefined.
*/
std::optional<std::string> schemaUri;
/**
* @brief An object containing statistics about metadata entities.
*/
std::optional<Cesium3DTiles::Statistics> statistics;
/**
* @brief An array of groups that tile content may belong to. Each element of
* this array is a metadata entity that describes the group. The tile content
* `group` property is an index into this array.
*/
std::vector<Cesium3DTiles::GroupMetadata> groups;
/**
* @brief A metadata entity that is associated with this tileset.
*/
std::optional<Cesium3DTiles::MetadataEntity> metadata;
/**
* @brief The error, in meters, introduced if this tileset is not rendered. At
* runtime, the geometric error is used to compute screen space error (SSE),
* i.e., the error measured in pixels.
*/
double geometricError = double();
/**
* @brief The root tile.
*/
Cesium3DTiles::Tile root;
/**
* @brief Names of 3D Tiles extensions used somewhere in this tileset.
*/
std::vector<std::string> extensionsUsed;
/**
* @brief Names of 3D Tiles extensions required to properly load this tileset.
* Each element of this array shall also be contained in `extensionsUsed`.
*/
std::vector<std::string> extensionsRequired;
/**
* @brief Calculates the size in bytes of this object, including the contents
* of all collections, pointers, and strings. This will NOT include the size
* of any extensions attached to the object. Calling this method may be slow
* as it requires traversing the object's entire structure.
*/
int64_t getSizeBytes() const {
int64_t accum = 0;
accum += int64_t(sizeof(Tileset));
accum += CesiumUtility::ExtensibleObject::getSizeBytes() -
int64_t(sizeof(CesiumUtility::ExtensibleObject));
accum += this->asset.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Asset));
accum += int64_t(
this->properties.bucket_count() *
(sizeof(std::string) + sizeof(Cesium3DTiles::Properties)));
for (const auto& [k, v] : this->properties) {
accum += int64_t(k.capacity() * sizeof(char) - sizeof(std::string));
accum += v.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Properties));
}
if (this->schema) {
accum +=
this->schema->getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Schema));
}
if (this->schemaUri) {
accum += int64_t(this->schemaUri->capacity() * sizeof(char));
}
if (this->statistics) {
accum += this->statistics->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::Statistics));
}
accum +=
int64_t(sizeof(Cesium3DTiles::GroupMetadata) * this->groups.capacity());
for (const Cesium3DTiles::GroupMetadata& value : this->groups) {
accum +=
value.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::GroupMetadata));
}
if (this->metadata) {
accum += this->metadata->getSizeBytes() -
int64_t(sizeof(Cesium3DTiles::MetadataEntity));
}
accum += this->root.getSizeBytes() - int64_t(sizeof(Cesium3DTiles::Tile));
accum += int64_t(sizeof(std::string) * this->extensionsUsed.capacity());
accum += int64_t(sizeof(std::string) * this->extensionsRequired.capacity());
return accum;
}
};
} // namespace Cesium3DTiles

View File

@ -0,0 +1,36 @@
#pragma once
#include "GltfConverterResult.h"
#include <CesiumAsync/Future.h>
#include <CesiumGltf/Model.h>
#include <CesiumGltfReader/GltfReader.h>
#include <optional>
#include <span>
namespace Cesium3DTilesContent {
struct AssetFetcher;
/**
* @brief Converts a b3dm (Batched 3D Model) file to a glTF.
*
* For more information on the b3dm format, see
* https://github.com/CesiumGS/3d-tiles/blob/main/specification/TileFormats/Batched3DModel/README.adoc
*/
struct B3dmToGltfConverter {
/**
* @brief Converts a b3dm binary file to a glTF model.
*
* @param b3dmBinary The bytes loaded for the b3dm model.
* @param options Options for how the glTF should be loaded.
* @param assetFetcher The \ref AssetFetcher containing information used by
* loaded assets.
* @returns A future that resolves to a \ref GltfConverterResult.
*/
static CesiumAsync::Future<GltfConverterResult> convert(
const std::span<const std::byte>& b3dmBinary,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,39 @@
#pragma once
#include <Cesium3DTilesContent/GltfConverterResult.h>
#include <CesiumAsync/Future.h>
#include <CesiumGltfReader/GltfReader.h>
#include <cstddef>
#include <span>
namespace Cesium3DTilesContent {
struct AssetFetcher;
/**
* @brief Converts a binary glTF model (glb) to a \ref CesiumGltf::Model.
*/
struct BinaryToGltfConverter {
public:
/**
* @brief Converts a glb binary file to a glTF model.
*
* @param gltfBinary The bytes loaded for the glb model.
* @param options Options for how the glTF should be loaded.
* @param assetFetcher The \ref AssetFetcher containing information used by
* loaded assets.
* @returns A future that resolves to a \ref GltfConverterResult.
*/
static CesiumAsync::Future<GltfConverterResult> convert(
const std::span<const std::byte>& gltfBinary,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
private:
static GltfConverterResult convertImmediate(
const std::span<const std::byte>& gltfBinary,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
static CesiumGltfReader::GltfReader _gltfReader;
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,34 @@
#pragma once
#include <Cesium3DTilesContent/GltfConverterResult.h>
#include <CesiumAsync/Future.h>
#include <CesiumGltfReader/GltfReader.h>
#include <cstddef>
#include <span>
namespace Cesium3DTilesContent {
struct AssetFetcher;
/**
* @brief Converts a cmpt (Composite) file into a glTF model.
*
* For more information on the Composite format, see
* https://github.com/CesiumGS/3d-tiles/blob/main/specification/TileFormats/Composite/README.adoc
*/
struct CmptToGltfConverter {
/**
* @brief Converts a cmpt binary file to a glTF model.
*
* @param cmptBinary The bytes loaded for the cmpt model.
* @param options Options for how the glTF should be loaded.
* @param assetFetcher The \ref AssetFetcher containing information used by
* loaded assets.
* @returns A future that resolves to a \ref GltfConverterResult.
*/
static CesiumAsync::Future<GltfConverterResult> convert(
const std::span<const std::byte>& cmptBinary,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,35 @@
#pragma once
#include "Library.h"
#include <CesiumGltf/Model.h>
#include <CesiumUtility/ErrorList.h>
#include <glm/common.hpp>
#include <optional>
#include <string>
#include <vector>
namespace Cesium3DTilesContent {
/**
* @brief The result of converting a binary content to gltf model.
*
* Instances of this structure are created internally, by the
* {@link GltfConverters}, when the response to a network request for
* loading the tile content was received.
*/
struct CESIUM3DTILESCONTENT_API GltfConverterResult {
/**
* @brief The gltf model converted from a binary content. This is empty if
* there are errors during the conversion
*/
std::optional<CesiumGltf::Model> model;
/**
* @brief The error and warning list when converting a binary content to gltf
* model. This is empty if there are no errors during the conversion
*/
CesiumUtility::ErrorList errors;
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,132 @@
#pragma once
#include <Cesium3DTilesContent/GltfConverters.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumAsync/IAssetRequest.h>
#include <CesiumGltf/AccessorView.h>
#include <CesiumGltf/PropertyTransformations.h>
#include <CesiumUtility/ErrorList.h>
#include <glm/fwd.hpp>
#include <rapidjson/document.h>
#include <cstdint>
#include <optional>
#include <vector>
namespace CesiumGltf {
struct Model;
struct Buffer;
} // namespace CesiumGltf
namespace Cesium3DTilesContent {
namespace GltfConverterUtility {
std::optional<uint32_t> parseOffsetForSemantic(
const rapidjson::Document& document,
const char* semantic,
CesiumUtility::ErrorList& errorList);
typedef bool (rapidjson::Value::*ValuePredicate)() const;
template <typename T> bool isValue(const rapidjson::Value& value);
template <typename T> T getValue(const rapidjson::Value& value);
template <typename T>
std::optional<T> getOptional(const rapidjson::Value& value) {
if (isValue<T>(value)) {
return std::make_optional(getValue<T>(value));
}
return {};
}
template <typename T>
std::optional<T>
getValue(const rapidjson::Document& document, const char* semantic) {
const auto valueIt = document.FindMember(semantic);
if (valueIt == document.MemberEnd() || !isValue<T>(valueIt->value)) {
return {};
}
return std::make_optional(getValue<T>(valueIt->value));
}
template <> inline bool isValue<bool>(const rapidjson::Value& value) {
return value.IsBool();
}
template <> inline bool getValue<bool>(const rapidjson::Value& value) {
return value.GetBool();
}
template <> inline bool isValue<uint32_t>(const rapidjson::Value& value) {
return value.IsUint();
}
template <> inline uint32_t getValue<uint32_t>(const rapidjson::Value& value) {
return value.GetUint();
}
bool validateJsonArrayValues(
const rapidjson::Value& arrayValue,
uint32_t expectedLength,
ValuePredicate predicate);
std::optional<glm::dvec3>
parseArrayValueDVec3(const rapidjson::Value& arrayValue);
std::optional<glm::dvec3>
parseArrayValueDVec3(const rapidjson::Document& document, const char* name);
int32_t
createBufferInGltf(CesiumGltf::Model& gltf, std::vector<std::byte> buffer = {});
int32_t createBufferViewInGltf(
CesiumGltf::Model& gltf,
const int32_t bufferId,
const int64_t byteLength,
const int64_t byteStride);
int32_t createAccessorInGltf(
CesiumGltf::Model& gltf,
const int32_t bufferViewId,
const int32_t componentType,
const int64_t count,
const std::string type);
/**
* Applies the given relative-to-center (RTC) translation to the transforms of
* all nodes in the glTF. This is useful in converting i3dm files, where the RTC
* translation must be applied to the model before the i3dm instance
* transform. It's also the 3D Tiles 1.1 "way" to do away with RTC and encode it
* directly in the glTF.
*/
void applyRtcToNodes(CesiumGltf::Model& gltf, const glm::dvec3& rtc);
template <typename GlmType, typename GLTFType>
GlmType toGlm(const GLTFType& gltfVal);
template <typename GlmType, typename ComponentType>
GlmType toGlm(const CesiumGltf::AccessorTypes::VEC3<ComponentType>& gltfVal) {
return GlmType(gltfVal.value[0], gltfVal.value[1], gltfVal.value[2]);
}
template <typename GlmType, typename ComponentType>
GlmType
toGlmQuat(const CesiumGltf::AccessorTypes::VEC4<ComponentType>& gltfVal) {
if constexpr (std::is_same<ComponentType, float>()) {
return GlmType(
gltfVal.value[3],
gltfVal.value[0],
gltfVal.value[1],
gltfVal.value[2]);
} else {
return GlmType(
CesiumGltf::normalize(gltfVal.value[3]),
CesiumGltf::normalize(gltfVal.value[0]),
CesiumGltf::normalize(gltfVal.value[1]),
CesiumGltf::normalize(gltfVal.value[2]));
}
}
} // namespace GltfConverterUtility
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,267 @@
#pragma once
#include "Library.h"
#include <Cesium3DTilesContent/GltfConverterResult.h>
#include <CesiumAsync/Future.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeometry/Axis.h>
#include <CesiumGltfReader/GltfReader.h>
#include <optional>
#include <span>
#include <string>
#include <string_view>
namespace Cesium3DTilesContent {
/**
* @brief The result of an \ref AssetFetcher::get call.
*/
struct AssetFetcherResult {
/**
* @brief The byte buffer obtained from a URL. This will be empty if fetching
* the asset failed.
*/
std::vector<std::byte> bytes;
/**
* @brief The errors and warnings reported while fetching the asset.
*/
CesiumUtility::ErrorList errorList;
};
/**
* Object that makes a recursive request to fetch an asset, mostly for the
* benefit of i3dm files.
*/
struct CESIUM3DTILESCONTENT_API AssetFetcher {
/**
* @brief Creates an \ref AssetFetcher with the given base URL and settings.
*
* @param asyncSystem_ The \ref CesiumAsync::AsyncSystem used for fetching
* assets asynchronously.
* @param pAssetAccessor_ The \ref CesiumAsync::IAssetAccessor providing the
* implementation for fetching assets from a remote server.
* @param baseUrl_ The base URL that relative URLs passed to \ref get will be
* relative to.
* @param tileTransform_ A transformation matrix applied to this tile.
* @param requestHeaders_ The headers to be used for a request made with the
* \ref AssetFetcher.
* @param upAxis_ The `gltfUpAxis` property to be set on loaded glTFs.
*/
AssetFetcher(
const CesiumAsync::AsyncSystem& asyncSystem_,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor_,
const std::string& baseUrl_,
const glm::dmat4 tileTransform_,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders_,
CesiumGeometry::Axis upAxis_)
: asyncSystem(asyncSystem_),
pAssetAccessor(pAssetAccessor_),
baseUrl(baseUrl_),
tileTransform(tileTransform_),
requestHeaders(requestHeaders_),
upAxis(upAxis_) {}
/**
* @brief Gets a buffer of bytes from the given relative URL.
*
* @param relativeUrl The URL of the asset to fetch, relative to the \ref
* baseUrl property.
* @returns A future that resolves into an \ref AssetFetcherResult.
*/
CesiumAsync::Future<AssetFetcherResult>
get(const std::string& relativeUrl) const;
/**
* @brief The \ref CesiumAsync::AsyncSystem used for this \ref AssetFetcher.
*/
CesiumAsync::AsyncSystem asyncSystem;
/**
* @brief The \ref CesiumAsync::IAssetAccessor used for this \ref
* AssetFetcher.
*/
std::shared_ptr<CesiumAsync::IAssetAccessor> pAssetAccessor;
/**
* @brief The base URL that this \ref AssetFetcher's requests will be relative
* to.
*/
std::string baseUrl;
/**
* @brief The transformation matrix applied to this tile. Used for
* East-North-Up transforms in i3dm.
*/
glm::dmat4 tileTransform;
/**
* @brief Headers that will be attached to each request made with this \ref
* AssetFetcher.
*/
std::vector<CesiumAsync::IAssetAccessor::THeader> requestHeaders;
/**
* @brief The `gltfUpAxis` property that will be specified for loaded assets.
*/
CesiumGeometry::Axis upAxis;
};
/**
* @brief Creates {@link GltfConverterResult} objects from a
* a binary content.
*
* The class offers a lookup functionality for registering
* {@link ConverterFunction} instances that can create
* {@link GltfConverterResult} instances from a binary content.
*
* The loaders are registered based on the magic header or the file extension
* of the input data. The binary data is usually received as a response to a
* network request, and the first four bytes of the raw data form the magic
* header. Based on this header or the file extension of the network response,
* the loader that will be used for processing the input can be looked up.
*/
class CESIUM3DTILESCONTENT_API GltfConverters {
public:
/**
* @brief A function pointer that can create a {@link GltfConverterResult} from a
* tile binary content.
*/
using ConverterFunction = CesiumAsync::Future<GltfConverterResult> (*)(
const std::span<const std::byte>& content,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& subprocessor);
/**
* @brief Register the given function for the given magic header.
*
* The given magic header is a 4-character string. It will be compared
* to the first 4 bytes of the raw input data, to decide whether the
* given factory function should be used to create the
* {@link GltfConverterResult} from the input data.
*
* @param magic The string describing the magic header.
* @param converter The converter that will be used to create the tile gltf
* content.
*/
static void
registerMagic(const std::string& magic, ConverterFunction converter);
/**
* @brief Register the given function for the given file extension.
*
* The given string is a file extension including the "." (e.g. ".ext"). It
* is used for deciding whether the given factory function should be used to
* create the
* {@link GltfConverterResult} from the input data with the
* same file extension in its url.
*
* @param fileExtension The file extension.
* @param converter The converter that will be used to create the tile gltf
* content
*/
static void registerFileExtension(
const std::string& fileExtension,
ConverterFunction converter);
/**
* @brief Retrieve the converter function that is already registered for the
* given file extension. If no such function is found, nullptr will be
* returned
*
* @param filePath The file path that contains the file extension.
* @return The {@link ConverterFunction} that is registered with the file extension.
*/
static ConverterFunction
getConverterByFileExtension(const std::string& filePath);
/**
* @brief Retrieve the converter function that is registered for the given
* magic header. If no such function is found, nullptr will be returned
*
* The given magic header is a 4-character string. It will be compared
* to the first 4 bytes of the raw input data, to decide whether the
* given factory function should be used to create the
* {@link GltfConverterResult} from the input data.
*
* @param content The binary tile content that contains the magic header.
* @return The {@link ConverterFunction} that is registered with the magic header.
*/
static ConverterFunction
getConverterByMagic(const std::span<const std::byte>& content);
/**
* @brief Creates the {@link GltfConverterResult} from the given
* binary content.
*
* This will look up the {@link ConverterFunction} that can be used to
* process the given input data, based on all loaders that
* have been registered with {@link GltfConverters::registerMagic}
* or {@link GltfConverters::registerFileExtension}.
*
* It will first try to find a loader based on the magic header
* of the `content` in the given input. If no matching loader is found, then
* it will look up a loader based on the file extension of `filePath` of the
* given input.
*
* If no such loader is found then an empty `GltfConverterResult` is returned.
*
* If a matching loader is found, it will be applied to the given
* input, and the result will be returned.
*
* @param filePath The file path that contains the file extension to look up
* the converter.
* @param content The tile binary content that may contains the magic header
* to look up the converter and is used to convert to gltf model.
* @param options The {@link CesiumGltfReader::GltfReaderOptions} for how to
* read a glTF.
* @param assetFetcher An object that can perform recursive asset requests.
* @return The {@link GltfConverterResult} that stores the gltf model converted from the binary data.
*/
static CesiumAsync::Future<GltfConverterResult> convert(
const std::string& filePath,
const std::span<const std::byte>& content,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
/**
* @brief Creates the {@link GltfConverterResult} from the given
* binary content.
*
* This will look up the {@link ConverterFunction} that can be used to
* process the given input data, based on all loaders that
* have been registered with {@link GltfConverters::registerMagic}.
*
* It will try to find a loader based on the magic header
* of the `content` in the given input. If no such loader is found then an
* empty `GltfConverterResult` is returned.
*
* If a matching loader is found, it will be applied to the given
* input, and the result will be returned.
*
* @param content The tile binary content that may contains the magic header
* to look up the converter and is used to convert to gltf model.
* @param options The {@link CesiumGltfReader::GltfReaderOptions} for how to
* read a glTF.
* @param assetFetcher An object that can perform recursive asset requests.
* @return The {@link GltfConverterResult} that stores the gltf model converted from the binary data.
*/
static CesiumAsync::Future<GltfConverterResult> convert(
const std::span<const std::byte>& content,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
private:
static std::string toLowerCase(const std::string_view& str);
static std::string getFileExtension(const std::string_view& filePath);
static ConverterFunction getConverterByFileExtension(
const std::string& filePath,
std::string& fileExtension);
static ConverterFunction getConverterByMagic(
const std::span<const std::byte>& content,
std::string& magic);
static std::unordered_map<std::string, ConverterFunction> _loadersByMagic;
static std::unordered_map<std::string, ConverterFunction>
_loadersByFileExtension;
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,35 @@
#pragma once
#include <Cesium3DTilesContent/GltfConverterResult.h>
#include <CesiumAsync/Future.h>
#include <CesiumGltf/Model.h>
#include <CesiumGltfReader/GltfReader.h>
#include <optional>
#include <span>
namespace Cesium3DTilesContent {
struct AssetFetcher;
/**
* @brief Converts an i3dm (Instanced 3D Model) file to a glTF model.
*
* For more information on the i3dm format, see
* https://github.com/CesiumGS/3d-tiles/blob/main/specification/TileFormats/Instanced3DModel/README.adoc
*/
struct I3dmToGltfConverter {
/**
* @brief Converts an i3dm binary file to a glTF model.
*
* @param instancesBinary The bytes loaded for the i3dm model.
* @param options Options for how the glTF should be loaded.
* @param assetFetcher The \ref AssetFetcher containing information used by
* loaded assets.
* @returns A future that resolves to a \ref GltfConverterResult.
*/
static CesiumAsync::Future<GltfConverterResult> convert(
const std::span<const std::byte>& instancesBinary,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,523 @@
#pragma once
#include <CesiumGeometry/OctreeTileID.h>
#include <CesiumGeometry/QuadtreeTileID.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <array>
#include <iterator>
#include <string>
namespace CesiumGeospatial {
class BoundingRegion;
class S2CellBoundingVolume;
} // namespace CesiumGeospatial
namespace CesiumGeometry {
class OrientedBoundingBox;
}
namespace Cesium3DTiles {
struct BoundingVolume;
}
namespace Cesium3DTilesContent {
/**
* @brief A lightweight virtual container enumerating the quadtree IDs of the
* children of a given quadtree tile.
*/
class QuadtreeChildren {
public:
/**
* @brief An STL-compatible iterator over the children of a quadtree tile.
*/
class iterator {
public:
/**
* @brief The iterator category tag denoting this is a forward iterator.
*/
using iterator_category = std::forward_iterator_tag;
/**
* @brief The type of value that is being iterated over.
*/
using value_type = CesiumGeometry::QuadtreeTileID;
/**
* @brief The type used to identify distance between iterators.
*
* This is `void` as the distance between two QuadtreeTileIDs isn't
* particularly useful.
*/
using difference_type = void;
/**
* @brief A pointer to the type being iterated over.
*/
using pointer = CesiumGeometry::QuadtreeTileID*;
/**
* @brief A reference to the type being iterated over.
*/
using reference = CesiumGeometry::QuadtreeTileID&;
/**
* @brief Creates a new iterator over the children of a quadtree tile.
*
* @param parentTileID The \ref CesiumGeometry::QuadtreeTileID of the parent
* tile whose children will be iterated over.
* @param isEnd If true, this iterator will start at the end of the data
* it's iterating over.
*/
explicit iterator(
const CesiumGeometry::QuadtreeTileID& parentTileID,
bool isEnd) noexcept;
/**
* @brief Returns a reference to the current \ref
* CesiumGeometry::QuadtreeTileID being iterated.
*/
const CesiumGeometry::QuadtreeTileID& operator*() const {
return this->_current;
}
/**
* @brief Returns a pointer to the current \ref
* CesiumGeometry::QuadtreeTileID being iterated.
*/
const CesiumGeometry::QuadtreeTileID* operator->() const {
return &this->_current;
}
/**
* @brief Advances the iterator to the next child.
*/
iterator& operator++();
/**
* @brief Advances the iterator to the next child.
*/
iterator operator++(int);
/** @brief Checks if two iterators are at the same child. */
bool operator==(const iterator& rhs) const noexcept;
/** @brief Checks if two iterators are NOT at the same child. */
bool operator!=(const iterator& rhs) const noexcept;
private:
CesiumGeometry::QuadtreeTileID _current;
};
/** @brief A const equivalent to `iterator`. */
using const_iterator = iterator;
/**
* @brief Creates a \ref QuadtreeChildren instance from the provided parent
* tile.
*/
QuadtreeChildren(const CesiumGeometry::QuadtreeTileID& tileID) noexcept
: _tileID(tileID) {}
/** @brief Returns an iterator starting at the first child. */
iterator begin() const noexcept;
/** @brief Returns an iterator starting at the last child. */
iterator end() const noexcept;
/**
* @brief Returns the total number of \ref CesiumGeometry::QuadtreeTileID
* children for this tile, which will always be four.
*/
constexpr int64_t size() const noexcept { return 4; }
private:
CesiumGeometry::QuadtreeTileID _tileID;
};
/**
* @brief A lightweight virtual container enumerating the octree IDs of the
* children of a given octree tile.
*/
class OctreeChildren {
public:
/**
* @brief An STL-compatible iterator over the children of an octree tile.
*/
class iterator {
public:
/**
* @brief The iterator category tag denoting this is a forward iterator.
*/
using iterator_category = std::forward_iterator_tag;
/**
* @brief The type of value that is being iterated over.
*/
using value_type = CesiumGeometry::OctreeTileID;
/**
* @brief The type used to identify distance between iterators.
*
* This is `void` as the distance between two OctreeTileIDs isn't
* particularly useful.
*/
using difference_type = void;
/**
* @brief A pointer to the type being iterated over.
*/
using pointer = CesiumGeometry::OctreeTileID*;
/**
* @brief A reference to the type being iterated over.
*/
using reference = CesiumGeometry::OctreeTileID&;
/**
* @brief Creates a new iterator over the children of a octree tile.
*
* @param parentTileID The \ref CesiumGeometry::OctreeTileID of the parent
* tile whose children will be iterated over.
* @param isEnd If true, this iterator will start at the end of the data
* it's iterating over.
*/
explicit iterator(
const CesiumGeometry::OctreeTileID& parentTileID,
bool isEnd) noexcept;
/**
* @brief Returns a reference to the current \ref
* CesiumGeometry::OctreeTileID being iterated.
*/
const CesiumGeometry::OctreeTileID& operator*() const {
return this->_current;
}
/**
* @brief Returns a pointer to the current \ref
* CesiumGeometry::OctreeTileID being iterated.
*/
const CesiumGeometry::OctreeTileID* operator->() const {
return &this->_current;
}
/**
* @brief Advances the iterator to the next child.
*/
iterator& operator++();
/**
* @brief Advances the iterator to the next child.
*/
iterator operator++(int);
/** @brief Checks if two iterators are at the same child. */
bool operator==(const iterator& rhs) const noexcept;
/** @brief Checks if two iterators are NOT at the same child. */
bool operator!=(const iterator& rhs) const noexcept;
private:
CesiumGeometry::OctreeTileID _current;
};
/** @brief A const equivalent to `iterator`. */
using const_iterator = iterator;
/**
* @brief Creates a \ref OctreeChildren instance from the provided parent
* tile.
*/
OctreeChildren(const CesiumGeometry::OctreeTileID& tileID) noexcept
: _tileID(tileID) {}
/** @brief Returns an iterator starting at the first child. */
iterator begin() const noexcept;
/** @brief Returns an iterator starting at the last child. */
iterator end() const noexcept;
/**
* @brief Returns the total number of \ref CesiumGeometry::OctreeTileID
* children for this tile, which will always be eight.
*/
constexpr int64_t size() const noexcept { return 8; }
private:
CesiumGeometry::OctreeTileID _tileID;
};
/**
* @brief Helper functions for working with 3D Tiles implicit tiling.
*/
class ImplicitTilingUtilities {
public:
/**
* @brief Resolves a templatized implicit tiling URL with a quadtree tile ID.
*
* @param baseUrl The base URL that is used to resolve the urlTemplate if it
* is a relative path.
* @param urlTemplate The templatized URL.
* @param quadtreeID The quadtree ID to use in resolving the parameters in the
* URL template.
* @return The resolved URL.
*/
static std::string resolveUrl(
const std::string& baseUrl,
const std::string& urlTemplate,
const CesiumGeometry::QuadtreeTileID& quadtreeID);
/**
* @brief Resolves a templatized implicit tiling URL with an octree tile ID.
*
* @param baseUrl The base URL that is used to resolve the urlTemplate if it
* is a relative path.
* @param urlTemplate The templatized URL.
* @param octreeID The octree ID to use in resolving the parameters in the
* URL template.
* @return The resolved URL.
*/
static std::string resolveUrl(
const std::string& baseUrl,
const std::string& urlTemplate,
const CesiumGeometry::OctreeTileID& octreeID);
/**
* @brief Computes the denominator for a given implicit tile level.
*
* Divide the root tile's geometric error by this value to get the standard
* geometric error for tiles on the level. Or divide each component of a
* bounding volume by this factor to get the size of the bounding volume along
* that axis for tiles of this level.
*
* @param level The tile level.
* @return The denominator for the level.
*/
static double computeLevelDenominator(uint32_t level) noexcept;
/**
* @brief Computes the Morton index for a given quadtree tile within its
* level.
*
* @param tileID The ID of the tile.
* @return The Morton index.
*/
static uint64_t
computeMortonIndex(const CesiumGeometry::QuadtreeTileID& tileID);
/**
* @brief Computes the Morton index for a given octree tile within its level.
*
* @param tileID The ID of the tile.
* @return The Morton index.
*/
static uint64_t
computeMortonIndex(const CesiumGeometry::OctreeTileID& tileID);
/**
* @brief Computes the relative Morton index for a given quadtree tile within
* its level of a subtree root at the tile with the given quadtree ID.
*
* @param subtreeID The ID of the subtree the contains the tile.
* @param tileID The ID of the tile.
* @return The relative Morton index.
*/
static uint64_t computeRelativeMortonIndex(
const CesiumGeometry::QuadtreeTileID& subtreeID,
const CesiumGeometry::QuadtreeTileID& tileID);
/**
* @brief Computes the relative Morton index for a given octree tile within
* its level of a subtree rooted at the tile with the given octree ID.
*
* @param subtreeRootID The ID of the subtree the contains the tile.
* @param tileID The ID of the tile.
* @return The relative Morton index.
*/
static uint64_t computeRelativeMortonIndex(
const CesiumGeometry::OctreeTileID& subtreeRootID,
const CesiumGeometry::OctreeTileID& tileID);
/**
* @brief Gets the ID of the root tile of the subtree that contains a given
* tile.
*
* @param subtreeLevels The number of levels in each sub-tree. For example, if
* this parameter is 4, then the first subtree starts at level 0 and
* contains tiles in levels 0 through 3, and the next subtree starts at
* level 4 and contains tiles in levels 4 through 7.
* @param tileID The tile ID for each to find the subtree root.
* @return The ID of the root tile of the subtree.
*/
static CesiumGeometry::QuadtreeTileID getSubtreeRootID(
uint32_t subtreeLevels,
const CesiumGeometry::QuadtreeTileID& tileID) noexcept;
/**
* @brief Gets the ID of the root tile of the subtree that contains a given
* tile.
*
* @param subtreeLevels The number of levels in each sub-tree. For example, if
* this parameter is 4, then the first subtree starts at level 0 and
* contains tiles in levels 0 through 3, and the next subtree starts at
* level 4 and contains tiles in levels 4 through 7.
* @param tileID The tile ID for each to find the subtree root.
* @return The ID of the root tile of the subtree.
*/
static CesiumGeometry::OctreeTileID getSubtreeRootID(
uint32_t subtreeLevels,
const CesiumGeometry::OctreeTileID& tileID) noexcept;
/**
* @brief Converts an absolute tile ID to a tile ID relative to a given root
* tile.
*
* For example, if `rootID` and `tileID` are the same, this method returns
* `QuadtreeTileID(0, 0, 0)`.
*
* @param rootID The ID of the root tile that the returned ID should be
* relative to.
* @param tileID The absolute ID of the tile to compute a relative ID for.
* @return The relative tile ID.
*/
static CesiumGeometry::QuadtreeTileID absoluteTileIDToRelative(
const CesiumGeometry::QuadtreeTileID& rootID,
const CesiumGeometry::QuadtreeTileID& tileID) noexcept;
/**
* @brief Converts an absolute tile ID to a tile ID relative to a given root
* tile.
*
* For example, if `rootID` and `tileID` are the same, this method returns
* `OctreeTileID(0, 0, 0, 0)`.
*
* @param rootID The ID of the root tile that the returned ID should be
* relative to.
* @param tileID The absolute ID of the tile to compute a relative ID for.
* @return The relative tile ID.
*/
static CesiumGeometry::OctreeTileID absoluteTileIDToRelative(
const CesiumGeometry::OctreeTileID& rootID,
const CesiumGeometry::OctreeTileID& tileID) noexcept;
/**
* @brief Gets a lightweight virtual container for enumerating the quadtree
* IDs of the children of a given quadtree tile.
*
* @param tileID The tile ID of the parent tile for which to get children.
* @return The children.
*/
static QuadtreeChildren
getChildren(const CesiumGeometry::QuadtreeTileID& tileID) noexcept {
return QuadtreeChildren{tileID};
}
/**
* @brief Gets a lightweight virtual container for enumerating the octree
* IDs of the children of a given octree tile.
*
* @param tileID The tile ID of the parent tile for which to get children.
* @return The children.
*/
static OctreeChildren
getChildren(const CesiumGeometry::OctreeTileID& tileID) noexcept {
return OctreeChildren{tileID};
}
/**
* @brief Computes the bounding volume for an implicit quadtree tile with the
* given ID as a {@link Cesium3DTiles::BoundingVolume}.
*
* @param rootBoundingVolume The bounding volume of the root tile.
* @param tileID The tile ID for which to compute the bounding volume.
* @param ellipsoid The ellipsoid to use for this calculation.
* @return The bounding volume for the given implicit tile.
*/
static Cesium3DTiles::BoundingVolume computeBoundingVolume(
const Cesium3DTiles::BoundingVolume& rootBoundingVolume,
const CesiumGeometry::QuadtreeTileID& tileID,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) noexcept;
/**
* @brief Computes the bounding volume for an implicit octree tile with the
* given ID as a {@link Cesium3DTiles::BoundingVolume}.
*
* @param rootBoundingVolume The bounding volume of the root tile.
* @param tileID The tile ID for which to compute the bounding volume.
* @param ellipsoid The ellipsoid to use for this calculation.
* @return The bounding volume for the given implicit tile.
*/
static Cesium3DTiles::BoundingVolume computeBoundingVolume(
const Cesium3DTiles::BoundingVolume& rootBoundingVolume,
const CesiumGeometry::OctreeTileID& tileID,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) noexcept;
/**
* @brief Computes the bounding volume for an implicit quadtree tile with the
* given ID as a bounding region.
*
* @param rootBoundingVolume The bounding region of the root tile.
* @param tileID The tile ID for which to compute the bounding region.
* @param ellipsoid The ellipsoid to use for this calculation.
* @return The bounding region for the given implicit tile.
*/
static CesiumGeospatial::BoundingRegion computeBoundingVolume(
const CesiumGeospatial::BoundingRegion& rootBoundingVolume,
const CesiumGeometry::QuadtreeTileID& tileID,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) noexcept;
/**
* @brief Computes the bounding volume for an implicit octree tile with the
* given ID as a bounding region.
*
* @param rootBoundingVolume The bounding region of the root tile.
* @param tileID The tile ID for which to compute the bounding region.
* @param ellipsoid The ellipsoid to use for this calculation.
* @return The bounding region for the given implicit tile.
*/
static CesiumGeospatial::BoundingRegion computeBoundingVolume(
const CesiumGeospatial::BoundingRegion& rootBoundingVolume,
const CesiumGeometry::OctreeTileID& tileID,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) noexcept;
/**
* @brief Computes the bounding volume for an implicit quadtree tile
* with the given ID as an oriented bounding box.
*
* @param rootBoundingVolume The oriented bounding box of the root tile.
* @param tileID The tile ID for which to compute the oriented bounding box.
* @return The oriented bounding box for the given implicit tile.
*/
static CesiumGeometry::OrientedBoundingBox computeBoundingVolume(
const CesiumGeometry::OrientedBoundingBox& rootBoundingVolume,
const CesiumGeometry::QuadtreeTileID& tileID) noexcept;
/**
* @brief Computes the bounding volume for an implicit octree tile with
* the given ID as an oriented bounding box.
*
* @param rootBoundingVolume The oriented bounding box of the root tile.
* @param tileID The tile ID for which to compute the oriented bounding box.
* @return The oriented bounding box for the given implicit tile.
*/
static CesiumGeometry::OrientedBoundingBox computeBoundingVolume(
const CesiumGeometry::OrientedBoundingBox& rootBoundingVolume,
const CesiumGeometry::OctreeTileID& tileID) noexcept;
/**
* @brief Computes the bounding volume for an implicit quadtree tile
* with the given ID as an S2 cell bounding volume.
*
* @param rootBoundingVolume The S2 cell bounding volume of the root tile.
* @param tileID The tile ID for which to compute the S2 cell bounding volume.
* @param ellipsoid The ellipsoid to use for this calculation.
* @return The S2 cell bounding volume for the given implicit tile.
*/
static CesiumGeospatial::S2CellBoundingVolume computeBoundingVolume(
const CesiumGeospatial::S2CellBoundingVolume& rootBoundingVolume,
const CesiumGeometry::QuadtreeTileID& tileID,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) noexcept;
/**
* @brief Computes the bounding volume for an implicit octree tile
* with the given ID as an S2 cell bounding volume.
*
* @param rootBoundingVolume The S2 cell bounding volume of the root tile.
* @param tileID The tile ID for which to compute the S2 cell bounding volume.
* @param ellipsoid The ellipsoid to use for this calculation.
* @return The S2 cell bounding volume for the given implicit tile.
*/
static CesiumGeospatial::S2CellBoundingVolume computeBoundingVolume(
const CesiumGeospatial::S2CellBoundingVolume& rootBoundingVolume,
const CesiumGeometry::OctreeTileID& tileID,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) noexcept;
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,18 @@
#pragma once
/**
* @brief Classes that support loading and converting 3D Tiles tile content.
*
* @mermaid-interactive{dependencies/Cesium3DTilesContent}
*/
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

View File

@ -0,0 +1,36 @@
#pragma once
#include "GltfConverterResult.h"
#include <CesiumAsync/Future.h>
#include <CesiumGltf/Model.h>
#include <CesiumGltfReader/GltfReader.h>
#include <optional>
#include <span>
namespace Cesium3DTilesContent {
struct AssetFetcher;
/**
* @brief Converts a pnts (Point Cloud) file to a glTF model.
*
* For more information on the pnts format, see
* https://github.com/CesiumGS/3d-tiles/blob/main/specification/TileFormats/PointCloud/README.adoc
*/
struct PntsToGltfConverter {
/**
* @brief Converts an pnts binary file to a glTF model.
*
* @param pntsBinary The bytes loaded for the pnts model.
* @param options Options for how the glTF should be loaded.
* @param assetFetcher The \ref AssetFetcher containing information used by
* loaded assets.
* @returns A future that resolves to a \ref GltfConverterResult.
*/
static CesiumAsync::Future<GltfConverterResult> convert(
const std::span<const std::byte>& pntsBinary,
const CesiumGltfReader::GltfReaderOptions& options,
const AssetFetcher& assetFetcher);
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,442 @@
#pragma once
#include <Cesium3DTiles/Subtree.h>
#include <CesiumAsync/Future.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <optional>
namespace CesiumGeometry {
struct QuadtreeTileID;
struct OctreeTileID;
} // namespace CesiumGeometry
namespace Cesium3DTiles {
struct ImplicitTiling;
} // namespace Cesium3DTiles
namespace Cesium3DTilesContent {
/**
* @brief Indicates how an implicit tile is subdivided.
*/
enum class ImplicitTileSubdivisionScheme {
/**
* @brief Implicit tiles are divided into four children, forming a quadree.
*/
Quadtree,
/**
* @brief Implicit tiles are divided into eight children, forming an octree.
*/
Octree
};
/**
* @brief Supports querying and modifying the various types of availablity
* information included in a {@link Cesium3DTiles::Subtree}.
*/
class SubtreeAvailability {
public:
/**
* @brief Creates an instance from a `Subtree`.
*
* @param subdivisionScheme The subdivision scheme of the subtree (quadtree or
* octree).
* @param levelsInSubtree The number of levels in this subtree.
* @param subtree The subtree.
* @return The subtree availability, or std::nullopt if the subtree definition
* is invalid.
*/
static std::optional<SubtreeAvailability> fromSubtree(
ImplicitTileSubdivisionScheme subdivisionScheme,
uint32_t levelsInSubtree,
Cesium3DTiles::Subtree&& subtree) noexcept;
/**
* @brief Creates an empty instance with all tiles initially available, while
* all content and subtrees are initially unavailable.
*
* @param subdivisionScheme The subdivision scheme of the subtree (quadtree or
* octree).
* @param levelsInSubtree The number of levels in this subtree.
* @return The subtree availability, or std::nullopt if the subtree definition
* is invalid.
*/
static std::optional<SubtreeAvailability> createEmpty(
ImplicitTileSubdivisionScheme subdivisionScheme,
uint32_t levelsInSubtree) noexcept;
/**
* @brief Asynchronously loads a subtree from a URL. The resource downloaded
* from the URL may be either a JSON or a binary subtree file.
*
* @param subdivisionScheme The subdivision scheme of the subtree (quadtree or
* octree).
* @param levelsInSubtree The number of levels in this subtree.
* @param asyncSystem The async system with which to do background work.
* @param pAssetAccessor The asset accessor to use to retrieve the subtree
* resource from the URL.
* @param pLogger The logger to which to load errors and warnings that occur
* during subtree load.
* @param subtreeUrl The URL from which to retrieve the subtree file.
* @param requestHeaders HTTP headers to include in the request for the
* subtree file.
* @return A future that resolves to a `SubtreeAvailability` instance for the
* subtree file, or std::nullopt if something goes wrong.
*/
static CesiumAsync::Future<std::optional<SubtreeAvailability>> loadSubtree(
ImplicitTileSubdivisionScheme subdivisionScheme,
uint32_t levelsInSubtree,
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::shared_ptr<spdlog::logger>& pLogger,
const std::string& subtreeUrl,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders);
/**
* @brief An AvailibilityView that indicates that either all tiles are
* available or all tiles are unavailable.
*/
struct SubtreeConstantAvailability {
/**
* @brief True if all tiles are availabile, false if all tiles are
* unavailable.
*/
bool constant;
};
/**
* @brief An AvailabilityView that accesses availability information from a
* bitstream.
*/
struct SubtreeBufferViewAvailability {
/**
* @brief The buffer from which to read and write availability information.
*/
std::span<std::byte> view;
};
/**
* @brief A mechanism for accessing availability information. It may be a
* constant value, or it may be read from a bitstream.
*/
using AvailabilityView =
std::variant<SubtreeConstantAvailability, SubtreeBufferViewAvailability>;
/**
* @brief Constructs a new instance.
*
* @param subdivisionScheme The subdivision scheme of the subtree (quadtree or
* octree).
* @param levelsInSubtree The number of levels in this subtree.
* @param tileAvailability A view on the tile availability. If backed by a
* buffer, the buffer is expected to be in `subtree`.
* @param subtreeAvailability A view on the subtree availability. If backed by
* a buffer, the buffer is expected to be in `subtree`.
* @param contentAvailability A view on the content availability. If backed by
* a buffer, the buffer is expected to be in `subtree`.
* @param subtree The subtree with which this instance queries and modifies
* availability information.
*/
SubtreeAvailability(
ImplicitTileSubdivisionScheme subdivisionScheme,
uint32_t levelsInSubtree,
AvailabilityView tileAvailability,
AvailabilityView subtreeAvailability,
std::vector<AvailabilityView>&& contentAvailability,
Cesium3DTiles::Subtree&& subtree);
/**
* @brief Determines if a given tile in the quadtree is available.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile to query.
* @return True if the tile is available; otherwise, false.
*/
bool isTileAvailable(
const CesiumGeometry::QuadtreeTileID& subtreeId,
const CesiumGeometry::QuadtreeTileID& tileId) const noexcept;
/**
* @brief Determines if a given tile in the octree is available.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile to query.
* @return True if the tile is available; otherwise, false.
*/
bool isTileAvailable(
const CesiumGeometry::OctreeTileID& subtreeId,
const CesiumGeometry::OctreeTileID& tileId) const noexcept;
/**
* @brief Determines if a given tile in the subtree is available.
*
* @param relativeTileLevel The level of the tile to query, relative to the
* root of the subtree.
* @param relativeTileMortonId The Morton ID of the tile to query. See
* {@link ImplicitTilingUtilities::computeRelativeMortonIndex}.
* @return True if the tile is available; otherwise, false.
*/
bool isTileAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId) const noexcept;
/**
* @brief Sets the availability state of a given tile in the quadtree.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile for which to set availability.
* @param isAvailable The new availability state for the tile.
*/
void setTileAvailable(
const CesiumGeometry::QuadtreeTileID& subtreeId,
const CesiumGeometry::QuadtreeTileID& tileId,
bool isAvailable) noexcept;
/**
* @brief Sets the availability state of a given tile in the octree.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile for which to set availability.
* @param isAvailable The new availability state for the tile.
*/
void setTileAvailable(
const CesiumGeometry::OctreeTileID& subtreeId,
const CesiumGeometry::OctreeTileID& tileId,
bool isAvailable) noexcept;
/**
* @brief Sets the availability state of a given tile in the subtree.
*
* @param relativeTileLevel The level of the tile for which to set
* availability, relative to the root of the subtree.
* @param relativeTileMortonId The Morton ID of the tile for which to set
* availability. See
* {@link ImplicitTilingUtilities::computeRelativeMortonIndex}.
* @param isAvailable The new availability state of the tile.
*/
void setTileAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId,
bool isAvailable) noexcept;
/**
* @brief Determines if content for a given tile in the quadtree is available.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile to query.
* @param contentId The ID of the content to query.
* @return True if the tile's content is available; otherwise, false.
*/
bool isContentAvailable(
const CesiumGeometry::QuadtreeTileID& subtreeId,
const CesiumGeometry::QuadtreeTileID& tileId,
uint64_t contentId) const noexcept;
/**
* @brief Determines if content for a given tile in the octree is available.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile to query.
* @param contentId The ID of the content to query.
* @return True if the tile's content is available; otherwise, false.
*/
bool isContentAvailable(
const CesiumGeometry::OctreeTileID& subtreeId,
const CesiumGeometry::OctreeTileID& tileId,
uint64_t contentId) const noexcept;
/**
* @brief Determines if content for a given tile in the subtree is available.
*
* @param relativeTileLevel The level of the tile to query, relative to the
* root of the subtree.
* @param relativeTileMortonId The Morton ID of the tile to query. See
* {@link ImplicitTilingUtilities::computeRelativeMortonIndex}.
* @param contentId The ID of the content to query.
* @return True if the tile's content is available; otherwise, false.
*/
bool isContentAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId,
uint64_t contentId) const noexcept;
/**
* @brief Sets the availability state of the content for a given tile in the
* quadtree.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile for which to set content availability.
* @param contentId The ID of the content to query.
* @param isAvailable The new availability state for the tile's content.
*/
void setContentAvailable(
const CesiumGeometry::QuadtreeTileID& subtreeId,
const CesiumGeometry::QuadtreeTileID& tileId,
uint64_t contentId,
bool isAvailable) noexcept;
/**
* @brief Sets the availability state of the content for a given tile in the
* octree.
*
* @param subtreeId The ID of the root tile of the subtree.
* @param tileId The ID of the tile for which to set content availability.
* @param contentId The ID of the content to query.
* @param isAvailable The new availability state for the tile's content.
*/
void setContentAvailable(
const CesiumGeometry::OctreeTileID& subtreeId,
const CesiumGeometry::OctreeTileID& tileId,
uint64_t contentId,
bool isAvailable) noexcept;
/**
* @brief Sets the availability state of the content for a given tile in the
* subtree.
*
* @param relativeTileLevel The level of the tile for which to set
* content availability, relative to the root of the subtree.
* @param relativeTileMortonId The Morton ID of the tile for which to set
* content availability. See
* {@link ImplicitTilingUtilities::computeRelativeMortonIndex}.
* @param contentId The ID of the content to query.
* @param isAvailable The new availability state for the tile's content.
*/
void setContentAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId,
uint64_t contentId,
bool isAvailable) noexcept;
/**
* @brief Determines if the subtree rooted at the given tile is available.
*
* The provided `checkSubtreeID` must be a child of the leaves of this
* subtree.
*
* @param thisSubtreeID The ID of the root tile of this subtree.
* @param checkSubtreeID The ID of the tile to query to see if its subtree is
* available.
* @return True if the subtree is available; otherwise, false.
*/
bool isSubtreeAvailable(
const CesiumGeometry::QuadtreeTileID& thisSubtreeID,
const CesiumGeometry::QuadtreeTileID& checkSubtreeID) const noexcept;
/**
* @brief Determines if the subtree rooted at the given tile is available.
*
* The provided `checkSubtreeID` must be a child of the leaves of this
* subtree.
*
* @param thisSubtreeID The ID of the root tile of this subtree.
* @param checkSubtreeID The ID of the tile to query to see if its subtree is
* available.
* @return True if the subtree is available; otherwise, false.
*/
bool isSubtreeAvailable(
const CesiumGeometry::OctreeTileID& thisSubtreeID,
const CesiumGeometry::OctreeTileID& checkSubtreeID) const noexcept;
/**
* @brief Determines if the subtree rooted at the given tile is available.
*
* The provided `relativeSubtreeMortonId` must refer to a child of the leaves
* of this subtree.
*
* @param relativeSubtreeMortonId The Morton ID of the tile for which to check
* subtree availability. See
* {@link ImplicitTilingUtilities::computeRelativeMortonIndex}.
* @return True if the subtree is available; otherwise, false.
*/
bool isSubtreeAvailable(uint64_t relativeSubtreeMortonId) const noexcept;
/**
* @brief Sets the availability state of the child quadtree rooted at the
* given tile.
*
* The provided `setSubtreeID` must be a child of the leaves of this
* subtree.
*
* @param thisSubtreeID The ID of the root tile of this subtree.
* @param setSubtreeID The ID of the tile to query to see if its subtree is
* available.
* @param isAvailable The new availability state for the subtree.
*/
void setSubtreeAvailable(
const CesiumGeometry::QuadtreeTileID& thisSubtreeID,
const CesiumGeometry::QuadtreeTileID& setSubtreeID,
bool isAvailable) noexcept;
/**
* @brief Sets the availability state of the child octree rooted at the given
* tile.
*
* The provided `setSubtreeID` must be a child of the leaves of this
* subtree.
*
* @param thisSubtreeID The ID of the root tile of this subtree.
* @param setSubtreeID The ID of the tile to query to see if its subtree is
* available.
* @param isAvailable The new availability state for the subtree.
*/
void setSubtreeAvailable(
const CesiumGeometry::OctreeTileID& thisSubtreeID,
const CesiumGeometry::OctreeTileID& setSubtreeID,
bool isAvailable) noexcept;
/**
* @brief Sets the availability state of the child subtree rooted at the given
* tile.
*
* The provided `relativeSubtreeMortonId` must refer to a child of the leaves
* of this subtree.
*
* @param relativeSubtreeMortonId The Morton ID of the tile for which to set
* subtree availability. See
* {@link ImplicitTilingUtilities::computeRelativeMortonIndex}.
* @param isAvailable The new availability state.
*/
void setSubtreeAvailable(
uint64_t relativeSubtreeMortonId,
bool isAvailable) noexcept;
/**
* @brief Gets the subtree that this instance queries and modifies.
*/
const Cesium3DTiles::Subtree& getSubtree() const noexcept {
return this->_subtree;
}
private:
bool isAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId,
const AvailabilityView& availabilityView) const noexcept;
void setAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId,
AvailabilityView& availabilityView,
bool isAvailable) noexcept;
bool isAvailableUsingBufferView(
uint64_t numOfTilesFromRootToParentLevel,
uint64_t relativeTileMortonId,
const AvailabilityView& availabilityView) const noexcept;
void setAvailableUsingBufferView(
uint64_t numOfTilesFromRootToParentLevel,
uint64_t relativeTileMortonId,
AvailabilityView& availabilityView,
bool isAvailable) noexcept;
uint32_t _powerOf2;
uint32_t _levelsInSubtree;
Cesium3DTiles::Subtree _subtree;
uint32_t _childCount;
AvailabilityView _tileAvailability;
AvailabilityView _subtreeAvailability;
std::vector<AvailabilityView> _contentAvailability;
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,129 @@
#pragma once
#include <CesiumGeometry/BoundingSphere.h>
#include <CesiumGeometry/OrientedBoundingBox.h>
#include <CesiumGeospatial/BoundingRegion.h>
#include <CesiumGeospatial/S2CellBoundingVolume.h>
#include <optional>
namespace Cesium3DTiles {
struct BoundingVolume;
}
namespace Cesium3DTilesContent {
/**
* @brief Provides functions for extracting bounding volumes types from the
* vectors stored in {@link Cesium3DTiles::BoundingVolume}.
*/
class TileBoundingVolumes {
public:
/**
* @brief Gets the bounding box defined in a
* {@link Cesium3DTiles::BoundingVolume}, if any.
*
* @param boundingVolume The bounding volume from which to get the box.
* @return The box, or `std::nullopt` if the bounding volume does not
* define a box. The box is defined in the tile's coordinate system.
*/
static std::optional<CesiumGeometry::OrientedBoundingBox>
getOrientedBoundingBox(const Cesium3DTiles::BoundingVolume& boundingVolume);
/**
* @brief Sets the `box` property in a {@link Cesium3DTiles::BoundingVolume}
* based on an {@link CesiumGeometry::OrientedBoundingBox}.
*
* Other bounding volume types, if any, are not modified.
*
* @param boundingVolume The bounding volume to set.
* @param boundingBox The bounding box with which to set the property.
*/
static void setOrientedBoundingBox(
Cesium3DTiles::BoundingVolume& boundingVolume,
const CesiumGeometry::OrientedBoundingBox& boundingBox);
/**
* @brief Gets the bounding region defined in a
* {@link Cesium3DTiles::BoundingVolume}, if any.
*
* @param boundingVolume The bounding volume from which to get the region.
* @param ellipsoid The ellipsoid on which the region should be defined.
* @return The region, or `std::nullopt` if the bounding volume does not
* define a region. The region is defined in geographic coordinates.
*/
static std::optional<CesiumGeospatial::BoundingRegion> getBoundingRegion(
const Cesium3DTiles::BoundingVolume& boundingVolume,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
/**
* @brief Sets the `region` property in a {@link Cesium3DTiles::BoundingVolume}
* based on a {@link CesiumGeospatial::BoundingRegion}.
*
* Other bounding volume types, if any, are not modified.
*
* @param boundingVolume The bounding volume to set.
* @param boundingRegion The bounding region with which to set the property.
*/
static void setBoundingRegion(
Cesium3DTiles::BoundingVolume& boundingVolume,
const CesiumGeospatial::BoundingRegion& boundingRegion);
/**
* @brief Gets the bounding sphere defined in a
* {@link Cesium3DTiles::BoundingVolume}, if any.
*
* @param boundingVolume The bounding volume from which to get the sphere.
* @return The sphere, or `std::nullopt` if the bounding volume does not
* define a sphere. The sphere is defined in the tile's coordinate system.
*/
static std::optional<CesiumGeometry::BoundingSphere>
getBoundingSphere(const Cesium3DTiles::BoundingVolume& boundingVolume);
/**
* @brief Sets the `sphere` property in a {@link Cesium3DTiles::BoundingVolume}
* based on a {@link CesiumGeometry::BoundingSphere}.
*
* Other bounding volume types, if any, are not modified.
*
* @param boundingVolume The bounding volume to set.
* @param boundingSphere The bounding sphere with which to set the property.
*/
static void setBoundingSphere(
Cesium3DTiles::BoundingVolume& boundingVolume,
const CesiumGeometry::BoundingSphere& boundingSphere);
/**
* @brief Gets the S2 cell bounding volume defined in the
* `3DTILES_bounding_volume_S2` extension of a
* {@link Cesium3DTiles::BoundingVolume}, if any.
*
* @param boundingVolume The bounding volume from which to get the S2 cell
* bounding volume.
* @param ellipsoid The ellipsoid on which the S2 cell should be defined.
* @return The S2 cell bounding volume, or `std::nullopt` if the bounding
* volume does not define an S2 cell bounding volume. The S2 cell bounding
* volume is defined in geographic coordinates.
*/
static std::optional<CesiumGeospatial::S2CellBoundingVolume>
getS2CellBoundingVolume(
const Cesium3DTiles::BoundingVolume& boundingVolume,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
/**
* @brief Adds the `3DTILES_bounding_volume_S2` extension to a
* {@link Cesium3DTiles::BoundingVolume} based on a
* {@link CesiumGeospatial::S2CellBoundingVolume}.
*
* Other bounding volume types, if any, are not modified.
*
* @param boundingVolume The bounding volume to set.
* @param s2BoundingVolume The S2 bounding volume with which to set the
* property.
*/
static void setS2CellBoundingVolume(
Cesium3DTiles::BoundingVolume& boundingVolume,
const CesiumGeospatial::S2CellBoundingVolume& s2BoundingVolume);
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,44 @@
#pragma once
#include <glm/fwd.hpp>
#include <optional>
namespace Cesium3DTiles {
struct Tile;
}
namespace Cesium3DTilesContent {
/**
* @brief Convenience functions for getting and setting
* {@link Cesium3DTiles::Tile::transform} as a `glm::dmat4`.
*/
class TileTransform {
public:
/**
* @brief Gets the tile's transform as a `glm::dmat4`.
*
* If the tile's transform array has more than 16 elements, the extras are
* silently ignored.
*
* @param tile The tile from which to get the transform.
* @return The transform, or `std::nullopt` if the
* {@link Cesium3DTiles::Tile::transform} has less than 16 elements.
*/
static std::optional<glm::dmat4>
getTransform(const Cesium3DTiles::Tile& tile);
/**
* @brief Sets the tile's transform using the values of a `glm::dmat4`.
*
* The existing value of the tile's transform property, if any, is replaced.
*
* @param tile The tile on which to set the transform.
* @param newTransform The new transform.
*/
static void
setTransform(Cesium3DTiles::Tile& tile, const glm::dmat4& newTransform);
};
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,15 @@
#include "Library.h"
namespace Cesium3DTilesContent {
/**
* @brief Register all \ref Cesium3DTilesSelection::Tile "Tile" content types
* that can be loaded.
*
* This is supposed to be called during the initialization, before
* any \ref Cesium3DTilesSelection::Tileset "Tileset" is loaded. It will
* register loaders for the different types of tiles that can be encountered.
*/
CESIUM3DTILESCONTENT_API void registerAllTileContentTypes();
} // namespace Cesium3DTilesContent

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Asset.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Asset;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Asset "Asset" instances from JSON.
*/
class CESIUM3DTILESREADER_API AssetReader {
public:
/**
* @brief Constructs a new instance.
*/
AssetReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Asset from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Asset>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Asset from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Asset>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Asset from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Asset>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,73 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Availability.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Availability;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Availability "Availability" instances from
* JSON.
*/
class CESIUM3DTILESREADER_API AvailabilityReader {
public:
/**
* @brief Constructs a new instance.
*/
AvailabilityReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Availability from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Availability>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Availability from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Availability>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Availability from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Availability>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/BoundingVolume.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct BoundingVolume;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::BoundingVolume "BoundingVolume" instances
* from JSON.
*/
class CESIUM3DTILESREADER_API BoundingVolumeReader {
public:
/**
* @brief Constructs a new instance.
*/
BoundingVolumeReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of BoundingVolume from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::BoundingVolume>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of BoundingVolume from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::BoundingVolume>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of BoundingVolume from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::BoundingVolume>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Buffer.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Buffer;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Buffer "Buffer" instances from JSON.
*/
class CESIUM3DTILESREADER_API BufferReader {
public:
/**
* @brief Constructs a new instance.
*/
BufferReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Buffer from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Buffer>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Buffer from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Buffer>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Buffer from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Buffer>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/BufferView.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct BufferView;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::BufferView "BufferView" instances from JSON.
*/
class CESIUM3DTILESREADER_API BufferViewReader {
public:
/**
* @brief Constructs a new instance.
*/
BufferViewReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of BufferView from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::BufferView>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of BufferView from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::BufferView>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of BufferView from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::BufferView>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/ClassProperty.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct ClassProperty;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::ClassProperty "ClassProperty" instances from
* JSON.
*/
class CESIUM3DTILESREADER_API ClassPropertyReader {
public:
/**
* @brief Constructs a new instance.
*/
ClassPropertyReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of ClassProperty from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::ClassProperty>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of ClassProperty from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::ClassProperty>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of ClassProperty from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::ClassProperty>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Class.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Class;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Class "Class" instances from JSON.
*/
class CESIUM3DTILESREADER_API ClassReader {
public:
/**
* @brief Constructs a new instance.
*/
ClassReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Class from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Class>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Class from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Class>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Class from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Class>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/ClassStatistics.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct ClassStatistics;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::ClassStatistics "ClassStatistics" instances
* from JSON.
*/
class CESIUM3DTILESREADER_API ClassStatisticsReader {
public:
/**
* @brief Constructs a new instance.
*/
ClassStatisticsReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of ClassStatistics from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::ClassStatistics>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of ClassStatistics from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::ClassStatistics>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of ClassStatistics from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::ClassStatistics>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Content.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Content;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Content "Content" instances from JSON.
*/
class CESIUM3DTILESREADER_API ContentReader {
public:
/**
* @brief Constructs a new instance.
*/
ContentReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Content from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Content>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Content from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Content>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Content from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Content>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Enum.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Enum;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Enum "Enum" instances from JSON.
*/
class CESIUM3DTILESREADER_API EnumReader {
public:
/**
* @brief Constructs a new instance.
*/
EnumReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Enum from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Enum>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Enum from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Enum>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Enum from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Enum>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/EnumValue.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct EnumValue;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::EnumValue "EnumValue" instances from JSON.
*/
class CESIUM3DTILESREADER_API EnumValueReader {
public:
/**
* @brief Constructs a new instance.
*/
EnumValueReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of EnumValue from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::EnumValue>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of EnumValue from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::EnumValue>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of EnumValue from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::EnumValue>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,79 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Extension3dTilesBoundingVolumeS2.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Extension3dTilesBoundingVolumeS2;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Extension3dTilesBoundingVolumeS2
* "Extension3dTilesBoundingVolumeS2" instances from JSON.
*/
class CESIUM3DTILESREADER_API Extension3dTilesBoundingVolumeS2Reader {
public:
/**
* @brief Constructs a new instance.
*/
Extension3dTilesBoundingVolumeS2Reader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Extension3dTilesBoundingVolumeS2 from a byte
* buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<
Cesium3DTiles::Extension3dTilesBoundingVolumeS2>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Extension3dTilesBoundingVolumeS2 from a
* rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<
Cesium3DTiles::Extension3dTilesBoundingVolumeS2>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Extension3dTilesBoundingVolumeS2 from
* a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<
std::vector<Cesium3DTiles::Extension3dTilesBoundingVolumeS2>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/GroupMetadata.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct GroupMetadata;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::GroupMetadata "GroupMetadata" instances from
* JSON.
*/
class CESIUM3DTILESREADER_API GroupMetadataReader {
public:
/**
* @brief Constructs a new instance.
*/
GroupMetadataReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of GroupMetadata from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::GroupMetadata>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of GroupMetadata from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::GroupMetadata>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of GroupMetadata from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::GroupMetadata>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/ImplicitTiling.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct ImplicitTiling;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::ImplicitTiling "ImplicitTiling" instances
* from JSON.
*/
class CESIUM3DTILESREADER_API ImplicitTilingReader {
public:
/**
* @brief Constructs a new instance.
*/
ImplicitTilingReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of ImplicitTiling from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::ImplicitTiling>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of ImplicitTiling from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::ImplicitTiling>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of ImplicitTiling from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::ImplicitTiling>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,18 @@
#pragma once
/**
* @brief Classes for reading [3D Tiles](https://github.com/CesiumGS/3d-tiles).
*
* @mermaid-interactive{dependencies/Cesium3DTilesReader}
*/
namespace Cesium3DTilesReader {}
#if defined(_WIN32) && defined(CESIUM_SHARED)
#ifdef CESIUM3DTILESREADER_BUILDING
#define CESIUM3DTILESREADER_API __declspec(dllexport)
#else
#define CESIUM3DTILESREADER_API __declspec(dllimport)
#endif
#else
#define CESIUM3DTILESREADER_API
#endif

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/MetadataEntity.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct MetadataEntity;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::MetadataEntity "MetadataEntity" instances
* from JSON.
*/
class CESIUM3DTILESREADER_API MetadataEntityReader {
public:
/**
* @brief Constructs a new instance.
*/
MetadataEntityReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of MetadataEntity from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::MetadataEntity>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of MetadataEntity from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::MetadataEntity>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of MetadataEntity from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::MetadataEntity>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Properties.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Properties;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Properties "Properties" instances from JSON.
*/
class CESIUM3DTILESREADER_API PropertiesReader {
public:
/**
* @brief Constructs a new instance.
*/
PropertiesReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Properties from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Properties>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Properties from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Properties>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Properties from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Properties>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,75 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/PropertyStatistics.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct PropertyStatistics;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::PropertyStatistics "PropertyStatistics"
* instances from JSON.
*/
class CESIUM3DTILESREADER_API PropertyStatisticsReader {
public:
/**
* @brief Constructs a new instance.
*/
PropertyStatisticsReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of PropertyStatistics from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::PropertyStatistics>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of PropertyStatistics from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::PropertyStatistics>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of PropertyStatistics from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<
std::vector<Cesium3DTiles::PropertyStatistics>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,75 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/PropertyTableProperty.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct PropertyTableProperty;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::PropertyTableProperty
* "PropertyTableProperty" instances from JSON.
*/
class CESIUM3DTILESREADER_API PropertyTablePropertyReader {
public:
/**
* @brief Constructs a new instance.
*/
PropertyTablePropertyReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of PropertyTableProperty from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::PropertyTableProperty>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of PropertyTableProperty from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::PropertyTableProperty>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of PropertyTableProperty from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<
std::vector<Cesium3DTiles::PropertyTableProperty>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,74 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/PropertyTable.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct PropertyTable;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::PropertyTable "PropertyTable" instances from
* JSON.
*/
class CESIUM3DTILESREADER_API PropertyTableReader {
public:
/**
* @brief Constructs a new instance.
*/
PropertyTableReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of PropertyTable from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::PropertyTable>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of PropertyTable from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::PropertyTable>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of PropertyTable from a
* rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::PropertyTable>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Schema.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Schema;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Schema "Schema" instances from JSON.
*/
class CESIUM3DTILESREADER_API SchemaReader {
public:
/**
* @brief Constructs a new instance.
*/
SchemaReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Schema from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Schema>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Schema from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Schema>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Schema from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Schema>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Statistics.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Statistics;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Statistics "Statistics" instances from JSON.
*/
class CESIUM3DTILESREADER_API StatisticsReader {
public:
/**
* @brief Constructs a new instance.
*/
StatisticsReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Statistics from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Statistics>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Statistics from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Statistics>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Statistics from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Statistics>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,141 @@
#pragma once
#include <Cesium3DTilesReader/Library.h>
#include <Cesium3DTilesReader/SubtreeReader.h>
#include <CesiumAsync/AsyncSystem.h>
#include <CesiumAsync/Future.h>
#include <CesiumAsync/IAssetAccessor.h>
namespace Cesium3DTilesReader {
/**
* @brief Reads 3D Tiles subtrees from a binary or JSON subtree file.
*
* While {@link SubtreeReader} can parse a {@link Cesium3DTiles::Subtree} from
* a binary buffer as well, `SubtreeFileReader` additionally supports:
*
* 1. Loading binary subtree files.
* 2. Loading external buffers asynchronously.
* 3. Decoding buffers from data URIs.
*
* The subtree file need not be an actual file on disk.
*/
class CESIUM3DTILESREADER_API SubtreeFileReader {
public:
/**
* @brief Constructs a new instance.
*/
SubtreeFileReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Asynchronously loads a subtree from a URL.
*
* \attention Please note that the `SubtreeFileReader` instance must remain
* valid until the returned future resolves or rejects. Destroying it earlier
* will result in undefined behavior. One easy way to achieve this is to
* construct the reader with `std::make_shared` and capture the
* `std::shared_ptr` in the continuation lambda.
*
* @param asyncSystem The AsyncSystem used to do asynchronous work.
* @param pAssetAccessor The accessor used to retrieve the URL and any other
* required resources.
* @param url The URL from which to get the subtree file.
* @param headers Headers to include in the request for the initial subtree
* file and any additional resources that are required.
* @return A future that resolves to the result of loading the subtree.
*/
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
load(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& headers = {})
const noexcept;
/**
* @brief Asynchronously loads a subtree from a request.
*
* \attention Please note that the `SubtreeFileReader` instance must remain
* valid until the returned future resolves or rejects. Destroying it earlier
* will result in undefined behavior. One easy way to achieve this is to
* construct the reader with `std::make_shared` and capture the
* `std::shared_ptr` in the continuation lambda.
*
* @param asyncSystem The AsyncSystem used to do asynchronous work.
* @param pAssetAccessor The accessor used to retrieve the URL and any other
* required resources.
* @param pRequest The request to get the subtree file.
* @return A future that resolves to the result of loading the subtree.
*/
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
load(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::shared_ptr<CesiumAsync::IAssetRequest>& pRequest)
const noexcept;
/**
* @brief Asynchronously loads loads a subtree from data obtained from a URL.
*
* \attention Please note that the `SubtreeFileReader` instance must remain
* valid until the returned future resolves or rejects. Destroying it earlier
* will result in undefined behavior. One easy way to achieve this is to
* construct the reader with `std::make_shared` and capture the
* `std::shared_ptr` in the continuation lambda.
*
* @param asyncSystem The AsyncSystem used to do asynchronous work.
* @param pAssetAccessor The accessor used to retrieve the URL and any other
* required resources.
* @param url The URL from which the subtree file was obtained.
* @param requestHeaders Headers that were included in the request for the
* initial subtree file and should be included for any additional resources
* that are required.
* @param data The subtree file data that was obtained.
* @return A future that resolves to the result of loading the subtree.
*/
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
load(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const std::span<const std::byte>& data) const noexcept;
private:
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
loadBinary(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const std::span<const std::byte>& data) const noexcept;
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
loadJson(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const std::span<const std::byte>& data) const noexcept;
CesiumAsync::Future<CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>>
postprocess(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::string& url,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>&& loaded)
const noexcept;
SubtreeReader _reader;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Subtree.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Subtree;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Subtree "Subtree" instances from JSON.
*/
class CESIUM3DTILESREADER_API SubtreeReader {
public:
/**
* @brief Constructs a new instance.
*/
SubtreeReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Subtree from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Subtree from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtree>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Subtree from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Subtree>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Subtrees.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Subtrees;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Subtrees "Subtrees" instances from JSON.
*/
class CESIUM3DTILESREADER_API SubtreesReader {
public:
/**
* @brief Constructs a new instance.
*/
SubtreesReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Subtrees from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtrees>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Subtrees from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Subtrees>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Subtrees from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Subtrees>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Tile.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Tile;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Tile "Tile" instances from JSON.
*/
class CESIUM3DTILESREADER_API TileReader {
public:
/**
* @brief Constructs a new instance.
*/
TileReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Tile from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Tile>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Tile from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Tile>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Tile from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Tile>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,72 @@
// This file was generated by generate-classes.
// DO NOT EDIT THIS FILE!
#pragma once
#include <Cesium3DTiles/Tileset.h>
#include <Cesium3DTilesReader/Library.h>
#include <CesiumJsonReader/JsonReader.h>
#include <CesiumJsonReader/JsonReaderOptions.h>
#include <rapidjson/fwd.h>
#include <span>
#include <vector>
namespace Cesium3DTiles {
struct Tileset;
} // namespace Cesium3DTiles
namespace Cesium3DTilesReader {
/**
* @brief Reads \ref Cesium3DTiles::Tileset "Tileset" instances from JSON.
*/
class CESIUM3DTILESREADER_API TilesetReader {
public:
/**
* @brief Constructs a new instance.
*/
TilesetReader();
/**
* @brief Gets the options controlling how the JSON is read.
*/
CesiumJsonReader::JsonReaderOptions& getOptions();
/**
* @brief Gets the options controlling how the JSON is read.
*/
const CesiumJsonReader::JsonReaderOptions& getOptions() const;
/**
* @brief Reads an instance of Tileset from a byte buffer.
*
* @param data The buffer from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Tileset>
readFromJson(const std::span<const std::byte>& data) const;
/**
* @brief Reads an instance of Tileset from a rapidJson::Value.
*
* @param value The value from which to read the instance.
* @return The result of reading the instance.
*/
CesiumJsonReader::ReadJsonResult<Cesium3DTiles::Tileset>
readFromJson(const rapidjson::Value& value) const;
/**
* @brief Reads an array of instances of Tileset from a rapidJson::Value.
*
* @param value The value from which to read the array of instances.
* @return The result of reading the array of instances.
*/
CesiumJsonReader::ReadJsonResult<std::vector<Cesium3DTiles::Tileset>>
readArrayFromJson(const rapidjson::Value& value) const;
private:
CesiumJsonReader::JsonReaderOptions _options;
};
} // namespace Cesium3DTilesReader

View File

@ -0,0 +1,97 @@
#pragma once
#include "Library.h"
#include <CesiumGeometry/BoundingSphere.h>
#include <CesiumGeometry/OrientedBoundingBox.h>
#include <CesiumGeospatial/BoundingRegion.h>
#include <CesiumGeospatial/BoundingRegionWithLooseFittingHeights.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGeospatial/GlobeRectangle.h>
#include <CesiumGeospatial/S2CellBoundingVolume.h>
#include <optional>
#include <variant>
namespace Cesium3DTilesSelection {
/**
* @brief A bounding volume.
*
* This is a `std::variant` for different types of bounding volumes.
*
* @see CesiumGeometry::BoundingSphere
* @see CesiumGeometry::OrientedBoundingBox
* @see CesiumGeospatial::BoundingRegion
* @see CesiumGeospatial::BoundingRegionWithLooseFittingHeights
* @see CesiumGeospatial::S2CellBoundingVolume
*/
typedef std::variant<
CesiumGeometry::BoundingSphere,
CesiumGeometry::OrientedBoundingBox,
CesiumGeospatial::BoundingRegion,
CesiumGeospatial::BoundingRegionWithLooseFittingHeights,
CesiumGeospatial::S2CellBoundingVolume>
BoundingVolume;
/**
* @brief Transform the given {@link BoundingVolume} with the given matrix.
*
* If the given bounding volume is a {@link CesiumGeometry::BoundingSphere}
* or {@link CesiumGeometry::OrientedBoundingBox}, then it will be transformed
* with the given matrix. Bounding regions will not be transformed.
*
* @param transform The transform matrix.
* @param boundingVolume The bounding volume.
* @return The transformed bounding volume.
*/
CESIUM3DTILESSELECTION_API BoundingVolume transformBoundingVolume(
const glm::dmat4x4& transform,
const BoundingVolume& boundingVolume);
/**
* @brief Returns the center of the given {@link BoundingVolume}.
*
* @param boundingVolume The bounding volume.
* @return The center point.
*/
CESIUM3DTILESSELECTION_API glm::dvec3
getBoundingVolumeCenter(const BoundingVolume& boundingVolume);
/**
* @brief Estimates the bounding {@link CesiumGeospatial::GlobeRectangle} of the
* given {@link BoundingVolume}.
*
* @param boundingVolume The bounding volume.
* @param ellipsoid The ellipsoid to use for globe calculations.
* @return The bounding {@link CesiumGeospatial::GlobeRectangle}.
*/
CESIUM3DTILESSELECTION_API std::optional<CesiumGeospatial::GlobeRectangle>
estimateGlobeRectangle(
const BoundingVolume& boundingVolume,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
/**
* @brief Returns the bounding region if the bounding volume is a
* {@link CesiumGeospatial::BoundingRegion} or a {@link CesiumGeospatial::BoundingRegionWithLooseFittingHeights}.
*
* @param boundingVolume The bounding volume.
* @return A pointer to the bounding region, or nullptr is the bounding volume
* is not a bounding region.
*/
CESIUM3DTILESSELECTION_API const CesiumGeospatial::BoundingRegion*
getBoundingRegionFromBoundingVolume(const BoundingVolume& boundingVolume);
/**
* @brief Returns an oriented bounding box that contains the given {@link BoundingVolume}.
*
* @param boundingVolume The bounding volume.
* @param ellipsoid The ellipsoid used for this {@link BoundingVolume}.
* @return The oriented bounding box.
*/
CESIUM3DTILESSELECTION_API CesiumGeometry::OrientedBoundingBox
getOrientedBoundingBoxFromBoundingVolume(
const BoundingVolume& boundingVolume,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,48 @@
#pragma once
#include <memory>
#include <string>
namespace Cesium3DTilesSelection {
class Tile;
class Tileset;
/**
* @brief Helps debug the tile selection algorithm by recording the state of
* tiles each frame to a SQLite database.
*/
class DebugTileStateDatabase {
public:
/**
* @brief Creates a new instance.
*
* @param databaseFilename The full path and filename of the output SQLite
* database.
*/
DebugTileStateDatabase(const std::string& databaseFilename);
~DebugTileStateDatabase() noexcept;
/**
* @brief Records the state of all tiles that are currently loaded by the
* given tileset.
*
* @param frameNumber The current frame number.
* @param tileset The tileset.
*/
void recordAllTileStates(int32_t frameNumber, const Tileset& tileset);
/**
* @brief Records the state of a given tile.
*
* @param frameNumber The current frame number.
* @param tile The tile.
*/
void recordTileState(int32_t frameNumber, const Tile& tile);
private:
struct Impl;
std::unique_ptr<Impl> _pImpl;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,67 @@
#pragma once
#include "ITilesetHeightSampler.h"
#include <Cesium3DTilesSelection/Tileset.h>
#include <CesiumGeometry/QuadtreeTilingScheme.h>
namespace Cesium3DTilesSelection {
/**
* @brief A loader that will generate a tileset by tesselating the surface of an
* ellipsoid, producing a simple globe tileset without any terrain features.
*/
class EllipsoidTilesetLoader : public TilesetContentLoader,
public ITilesetHeightSampler {
public:
/**
* @brief Constructs a new instance.
*
* @param ellipsoid The {@link CesiumGeospatial::Ellipsoid}.
*/
EllipsoidTilesetLoader(
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
/**
* @brief Creates a new tileset with this loader.
*
* @param externals The external interfaces to use.
* @param options Additional options for the tileset.
*/
static std::unique_ptr<Tileset> createTileset(
const TilesetExternals& externals,
const TilesetOptions& options = TilesetOptions{});
CesiumAsync::Future<TileLoadResult>
loadTileContent(const TileLoadInput& input) override;
TileChildrenResult createTileChildren(
const Tile& tile,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) override;
ITilesetHeightSampler* getHeightSampler() override;
CesiumAsync::Future<SampleHeightResult> sampleHeights(
const CesiumAsync::AsyncSystem& asyncSystem,
std::vector<CesiumGeospatial::Cartographic>&& positions) override;
private:
struct Geometry {
std::vector<uint16_t> indices;
std::vector<glm::vec3> vertices;
std::vector<glm::vec3> normals;
};
void createChildTile(
const Tile& parent,
std::vector<Tile>& children,
const CesiumGeometry::QuadtreeTileID& childID) const;
CesiumGeospatial::BoundingRegion
createBoundingRegion(const CesiumGeometry::QuadtreeTileID& quadtreeID) const;
Geometry createGeometry(const Tile& tile) const;
CesiumGltf::Model createModel(const Geometry& geometry) const;
CesiumGeospatial::GeographicProjection _projection;
CesiumGeometry::QuadtreeTilingScheme _tilingScheme;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,177 @@
#pragma once
#include "Library.h"
#include "TileLoadResult.h"
#include <CesiumAsync/Future.h>
#include <CesiumRasterOverlays/IPrepareRasterOverlayRendererResources.h>
#include <glm/vec2.hpp>
#include <any>
#include <span>
namespace CesiumAsync {
class AsyncSystem;
}
namespace CesiumGeometry {
struct Rectangle;
}
namespace CesiumGltf {
struct Model;
} // namespace CesiumGltf
namespace CesiumRasterOverlays {
class RasterOverlayTile;
}
namespace Cesium3DTilesSelection {
class Tile;
/**
* The data of a loaded tile together with a pointer to "render resources" data
* representing the result of \ref
* IPrepareRendererResources::prepareInLoadThread "prepareInLoadThread".
*/
struct TileLoadResultAndRenderResources {
/**
* @brief The \ref TileLoadResult passed to \ref
* IPrepareRendererResources::prepareInLoadThread "prepareInLoadThread" in the
* first place.
*/
TileLoadResult result;
/**
* @brief A pointer to the render resources for this tile.
* Cesium Native doesn't know what this pointer means, and doesn't need to
* know what it means. This pointer is stored in a tile's content as a \ref
* TileRenderContent only so that it can be returned to the implementing
* application as needed and used for rendering there.
*/
void* pRenderResources{nullptr};
};
/**
* @brief When implemented for a rendering engine, allows renderer resources to
* be created and destroyed under the control of a {@link Tileset}.
*
* It is not supposed to be used directly by clients. It is implemented
* for specific rendering engines to provide an infrastructure for preparing the
* data of a {@link Tile} so that it can be used for rendering.
*
* Instances of this class are associated with a {@link Tileset}, in the
* {@link TilesetExternals} structure that is passed to the constructor.
*/
class CESIUM3DTILESSELECTION_API IPrepareRendererResources
: public CesiumRasterOverlays::IPrepareRasterOverlayRendererResources {
public:
virtual ~IPrepareRendererResources() = default;
/**
* @brief Prepares renderer resources for the given tile. This method is
* invoked in the load thread.
*
* @param asyncSystem The AsyncSystem used to do work in threads.
* @param tileLoadResult The tile data loaded so far.
* @param transform The tile's transformation.
* @param rendererOptions Renderer options associated with the tile from
* {@link TilesetOptions::rendererOptions}.
* @returns A future that resolves to the loaded tile data along with
* arbitrary "render resources" data representing the result of the load
* process. The loaded data may be the same as was originally given to this
* method, or it may be modified. The render resources are passed to
* {@link prepareInMainThread} as the `pLoadThreadResult` parameter.
*/
virtual CesiumAsync::Future<TileLoadResultAndRenderResources>
prepareInLoadThread(
const CesiumAsync::AsyncSystem& asyncSystem,
TileLoadResult&& tileLoadResult,
const glm::dmat4& transform,
const std::any& rendererOptions) = 0;
/**
* @brief Further prepares renderer resources.
*
* This is called after {@link prepareInLoadThread}, and unlike that method,
* this one is called from the same thread that called
* {@link Tileset::updateView}.
*
* @param tile The tile to prepare.
* @param pLoadThreadResult The value returned from
* {@link prepareInLoadThread}.
* @returns Arbitrary data representing the result of the load process.
* Note that the value returned by {@link prepareInLoadThread} will _not_ be
* automatically preserved and passed to {@link free}. If you need to free
* that value, do it in this method before returning. If you need that value
* later, add it to the object returned from this method.
*/
virtual void* prepareInMainThread(Tile& tile, void* pLoadThreadResult) = 0;
/**
* @brief Frees previously-prepared renderer resources.
*
* This method is always called from the thread that called
* {@link Tileset::updateView} or deleted the tileset.
*
* @param tile The tile for which to free renderer resources.
* @param pLoadThreadResult The result returned by
* {@link prepareInLoadThread}. If {@link prepareInMainThread} has
* already been called, this parameter will be `nullptr`.
* @param pMainThreadResult The result returned by
* {@link prepareInMainThread}. If {@link prepareInMainThread} has
* not yet been called, this parameter will be `nullptr`.
*/
virtual void free(
Tile& tile,
void* pLoadThreadResult,
void* pMainThreadResult) noexcept = 0;
/**
* @brief Attaches a raster overlay tile to a geometry tile.
*
* @param tile The geometry tile.
* @param overlayTextureCoordinateID The ID of the overlay texture coordinate
* set to use.
* @param rasterTile The raster overlay tile to add. The raster tile will have
* been previously prepared with a call to {@link prepareRasterInLoadThread}
* followed by {@link prepareRasterInMainThread}.
* @param pMainThreadRendererResources The renderer resources for this raster
* tile, as created and returned by {@link prepareRasterInMainThread}.
* @param translation The translation to apply to the texture coordinates
* identified by `overlayTextureCoordinateID`. The texture coordinates to use
* to sample the raster image are computed as `overlayTextureCoordinates *
* scale + translation`.
* @param scale The scale to apply to the texture coordinates identified by
* `overlayTextureCoordinateID`. The texture coordinates to use to sample the
* raster image are computed as `overlayTextureCoordinates * scale +
* translation`.
*/
virtual void attachRasterInMainThread(
const Tile& tile,
int32_t overlayTextureCoordinateID,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pMainThreadRendererResources,
const glm::dvec2& translation,
const glm::dvec2& scale) = 0;
/**
* @brief Detaches a raster overlay tile from a geometry tile.
*
* @param tile The geometry tile.
* @param overlayTextureCoordinateID The ID of the overlay texture coordinate
* set to which the raster tile was previously attached.
* @param rasterTile The raster overlay tile to remove.
* @param pMainThreadRendererResources The renderer resources for this raster
* tile, as created and returned by {@link prepareRasterInMainThread}.
*/
virtual void detachRasterInMainThread(
const Tile& tile,
int32_t overlayTextureCoordinateID,
const CesiumRasterOverlays::RasterOverlayTile& rasterTile,
void* pMainThreadRendererResources) noexcept = 0;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,31 @@
#pragma once
namespace Cesium3DTilesSelection {
class Tile;
/**
* @brief An interface that allows tiles to be excluded from loading and
* rendering when provided in {@link TilesetOptions::excluders}.
*/
class ITileExcluder {
public:
virtual ~ITileExcluder() = default;
/**
* @brief Indicates the start of a new frame, initiated with a call to {@link Tileset::updateView}.
*/
virtual void startNewFrame() noexcept {}
/**
* @brief Determines whether a given tile should be excluded.
*
* @param tile The tile to test
* @return true if this tile and all of its descendants in the bounding volume
* hierarchy should be excluded from loading and rendering.
* @return false if this tile should be included.
*/
virtual bool shouldExclude(const Tile& tile) const noexcept = 0;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,36 @@
#pragma once
#include "Library.h"
#include "SampleHeightResult.h"
#include <CesiumAsync/Future.h>
#include <CesiumGeospatial/Cartographic.h>
#include <vector>
namespace CesiumAsync {
class AsyncSystem;
}
namespace Cesium3DTilesSelection {
/**
* @brief An interface to query heights from a tileset that can do so
* efficiently without necessarily downloading individual tiles.
*/
class CESIUM3DTILESSELECTION_API ITilesetHeightSampler {
public:
/**
* @brief Queries the heights at a list of locations.
*
* @param asyncSystem The async system used to do work in threads.
* @param positions The positions at which to query heights. The height field
* of each {@link CesiumGeospatial::Cartographic} is ignored.
* @return A future that will be resolved when the heights have been queried.
*/
virtual CesiumAsync::Future<SampleHeightResult> sampleHeights(
const CesiumAsync::AsyncSystem& asyncSystem,
std::vector<CesiumGeospatial::Cartographic>&& positions) = 0;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,18 @@
#pragma once
/**
* @brief Classes that implement the 3D Tiles standard
*
* @mermaid-interactive{dependencies/Cesium3DTilesSelection}
*/
namespace Cesium3DTilesSelection {}
#if defined(_WIN32) && defined(CESIUM_SHARED)
#ifdef CESIUM3DTILESSELECTION_BUILDING
#define CESIUM3DTILESSELECTION_API __declspec(dllexport)
#else
#define CESIUM3DTILESSELECTION_API __declspec(dllimport)
#endif
#else
#define CESIUM3DTILESSELECTION_API
#endif

View File

@ -0,0 +1,247 @@
#pragma once
#include "IPrepareRendererResources.h"
#include <CesiumGeometry/Rectangle.h>
#include <CesiumGeospatial/Projection.h>
#include <CesiumRasterOverlays/RasterOverlayTile.h>
#include <CesiumUtility/IntrusivePointer.h>
#include <memory>
namespace Cesium3DTilesSelection {
class Tile;
/**
* @brief The result of applying a {@link CesiumRasterOverlays::RasterOverlayTile} to geometry.
*
* Instances of this class are used by a {@link Tile} in order to map
* imagery data that is given as {@link CesiumRasterOverlays::RasterOverlayTile} instances
* to the 2D region that is covered by the tile geometry.
*/
class RasterMappedTo3DTile final {
public:
/**
* @brief The states indicating whether the raster tile is attached to the
* geometry.
*/
enum class AttachmentState {
/**
* @brief This raster tile is not yet attached to the geometry at all.
*/
Unattached = 0,
/**
* @brief This raster tile is attached to the geometry, but it is a
* temporary, low-res version usable while the full-res version is loading.
*/
TemporarilyAttached = 1,
/**
* @brief This raster tile is attached to the geometry.
*/
Attached = 2
};
/**
* @brief Creates a new instance.
*
* @param pRasterTile The {@link CesiumRasterOverlays::RasterOverlayTile} that is mapped to the
* geometry.
* @param textureCoordinateIndex The index of the texture coordinates to use
* with this mapped raster overlay.
*/
RasterMappedTo3DTile(
const CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlayTile>& pRasterTile,
int32_t textureCoordinateIndex);
/**
* @brief Returns a {@link CesiumRasterOverlays::RasterOverlayTile} that is currently loading.
*
* The caller has to check the exact state of this tile, using
* {@link Tile::getState}.
*
* @return The tile that is loading, or `nullptr`.
*/
CesiumRasterOverlays::RasterOverlayTile* getLoadingTile() noexcept {
return this->_pLoadingTile.get();
}
/** @copydoc getLoadingTile */
const CesiumRasterOverlays::RasterOverlayTile*
getLoadingTile() const noexcept {
return this->_pLoadingTile.get();
}
/**
* @brief Returns the {@link CesiumRasterOverlays::RasterOverlayTile} that represents the imagery
* data that is ready to render.
*
* This will be `nullptr` when the tile data has not yet been loaded.
*
* @return The tile, or `nullptr`.
*/
CesiumRasterOverlays::RasterOverlayTile* getReadyTile() noexcept {
return this->_pReadyTile.get();
}
/** @copydoc getReadyTile */
const CesiumRasterOverlays::RasterOverlayTile* getReadyTile() const noexcept {
return this->_pReadyTile.get();
}
/**
* @brief Returns an identifier for the texture coordinates of this tile.
*
* The texture coordinates for this raster are found in the glTF as an
* attribute named `_CESIUMOVERLAY_n` where `n` is this value.
*
* @return The texture coordinate ID.
*/
int32_t getTextureCoordinateID() const noexcept {
return this->_textureCoordinateID;
}
/**
* @brief Sets the texture coordinate ID.
*
* @see getTextureCoordinateID
*
* @param textureCoordinateID The ID.
*/
void setTextureCoordinateID(int32_t textureCoordinateID) noexcept {
this->_textureCoordinateID = textureCoordinateID;
}
/**
* @brief Returns the translation that converts between the geometry texture
* coordinates and the texture coordinates that should be used to sample this
* raster texture.
*
* `rasterCoordinates = geometryCoordinates * scale + translation`
*
* @returns The translation.
*/
const glm::dvec2& getTranslation() const noexcept {
return this->_translation;
}
/**
* @brief Returns the scaling that converts between the geometry texture
* coordinates and the texture coordinates that should be used to sample this
* raster texture.
*
* @see getTranslation
*
* @returns The scaling.
*/
const glm::dvec2& getScale() const noexcept { return this->_scale; }
/**
* @brief Indicates whether this overlay tile is currently attached to its
* owning geometry tile.
*
* When a raster overlay tile is attached to a geometry tile,
* {@link IPrepareRendererResources::attachRasterInMainThread} is invoked.
* When it is detached,
* {@link IPrepareRendererResources::detachRasterInMainThread} is invoked.
*/
AttachmentState getState() const noexcept { return this->_state; }
/**
* @brief Update this tile during the update of its owner.
*
* This is only supposed to be called by
* `TilesetContentManager::updateDoneState`. It will return whether there is a
* more detailed version of the raster data available.
*
* @param prepareRendererResources The {@link IPrepareRendererResources} used to
* create render resources for raster overlay
* @param tile The owner tile.
* @return The {@link CesiumRasterOverlays::RasterOverlayTile::MoreDetailAvailable} state.
*/
CesiumRasterOverlays::RasterOverlayTile::MoreDetailAvailable
update(IPrepareRendererResources& prepareRendererResources, Tile& tile);
/**
* @copydoc CesiumRasterOverlays::RasterOverlayTile::isMoreDetailAvailable
*/
bool isMoreDetailAvailable() const noexcept;
/**
* @brief Detach the raster from the given tile.
* @param prepareRendererResources The IPrepareRendererResources used to
* detach raster overlay from the tile geometry
* @param tile The owner tile.
*/
void detachFromTile(
IPrepareRendererResources& prepareRendererResources,
Tile& tile) noexcept;
/**
* @brief Does a throttled load of the mapped {@link CesiumRasterOverlays::RasterOverlayTile}.
*
* @return If the mapped tile is already in the process of loading or it has
* already finished loading, this method does nothing and returns true. If too
* many loads are already in progress, this method does nothing and returns
* false. Otherwise, it begins the asynchronous process to load the tile and
* returns true.
*/
bool loadThrottled() noexcept;
/**
* @brief Creates a maping between a {@link CesiumRasterOverlays::RasterOverlay} and a {@link Tile}.
*
* The returned mapping will be to a placeholder {@link CesiumRasterOverlays::RasterOverlayTile} if
* the overlay's tile provider is not yet ready (i.e. it's still a
* placeholder) or if the overlap between the tile and the raster overlay
* cannot yet be determined because the projected rectangle of the tile is not
* yet known.
*
* Returns a pointer to the created `RasterMappedTo3DTile` in the Tile's
* {@link Tile::getMappedRasterTiles} collection. Note that this pointer may
* become invalid as soon as another item is added to or removed from this
* collection.
*
* @param maximumScreenSpaceError The maximum screen space error that is used
* for the current tile
* @param tileProvider The overlay tile provider to map to the tile. This may
* be a placeholder if the tile provider is not yet ready.
* @param placeholder The placeholder tile provider for this overlay. This is
* always a placeholder, even if the tile provider is already ready.
* @param tile The tile to which to map the overlay.
* @param missingProjections The list of projections for which there are not
* yet any texture coordiantes. On return, the given overlay's Projection may
* be added to this collection if the Tile does not yet have texture
* coordinates for the Projection and the Projection is not already in the
* collection.
* @param ellipsoid The {@link CesiumGeospatial::Ellipsoid}.
* @return A pointer the created mapping, which may be to a placeholder, or
* nullptr if no mapping was created at all because the Tile does not overlap
* the raster overlay.
*/
static RasterMappedTo3DTile* mapOverlayToTile(
double maximumScreenSpaceError,
CesiumRasterOverlays::RasterOverlayTileProvider& tileProvider,
CesiumRasterOverlays::RasterOverlayTileProvider& placeholder,
Tile& tile,
std::vector<CesiumGeospatial::Projection>& missingProjections,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
private:
void computeTranslationAndScale(const Tile& tile);
CesiumUtility::IntrusivePointer<CesiumRasterOverlays::RasterOverlayTile>
_pLoadingTile;
CesiumUtility::IntrusivePointer<CesiumRasterOverlays::RasterOverlayTile>
_pReadyTile;
int32_t _textureCoordinateID;
glm::dvec2 _translation;
glm::dvec2 _scale;
AttachmentState _state;
bool _originalFailed;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,217 @@
#pragma once
#include "Library.h"
#include "TilesetExternals.h"
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumRasterOverlays/RasterOverlay.h>
#include <CesiumRasterOverlays/RasterOverlayTileProvider.h>
#include <CesiumUtility/IntrusivePointer.h>
#include <CesiumUtility/ReferenceCounted.h>
#include <CesiumUtility/Tracing.h>
#include <memory>
#include <span>
#include <vector>
namespace Cesium3DTilesSelection {
/**
* @brief A collection of {@link CesiumRasterOverlays::RasterOverlay} instances that are associated
* with a {@link Tileset}.
*
* The raster overlay instances may be added to the raster overlay collection
* of a tileset that is returned with {@link Tileset::getOverlays}. When the
* tileset is loaded, one {@link CesiumRasterOverlays::RasterOverlayTileProvider} will be created
* for each raster overlay that had been added. The raster overlay tile provider
* instances will be passed to the {@link CesiumRasterOverlays::RasterOverlayTile} instances that
* they create when the tiles are updated.
*/
class CESIUM3DTILESSELECTION_API RasterOverlayCollection final {
public:
/**
* @brief Creates a new instance.
*
* @param loadedTiles The list of loaded tiles. The collection does not own
* this list, so the list needs to be kept alive as long as the collection's
* lifetime
* @param externals A collection of loading system to load a raster overlay
* @param ellipsoid The {@link CesiumGeospatial::Ellipsoid}.
*/
RasterOverlayCollection(
Tile::LoadedLinkedList& loadedTiles,
const TilesetExternals& externals,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) noexcept;
/**
* @brief Deleted Copy constructor.
*
* @param rhs The other instance.
*/
RasterOverlayCollection(const RasterOverlayCollection& rhs) = delete;
/**
* @brief Move constructor.
*
* @param rhs The other instance.
*/
RasterOverlayCollection(RasterOverlayCollection&& rhs) noexcept = default;
/**
* @brief Deleted copy assignment.
*
* @param rhs The other instance.
*/
RasterOverlayCollection&
operator=(const RasterOverlayCollection& rhs) = delete;
/**
* @brief Move assignment.
*
* @param rhs The other instance.
*/
RasterOverlayCollection&
operator=(RasterOverlayCollection&& rhs) noexcept = default;
~RasterOverlayCollection() noexcept;
/**
* @brief Adds the given {@link CesiumRasterOverlays::RasterOverlay} to this collection.
*
* @param pOverlay The pointer to the overlay. This may not be `nullptr`.
*/
void add(const CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlay>& pOverlay);
/**
* @brief Remove the given {@link CesiumRasterOverlays::RasterOverlay} from this collection.
*/
void remove(const CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlay>& pOverlay) noexcept;
/**
* @brief Gets the overlays in this collection.
*/
const std::vector<
CesiumUtility::IntrusivePointer<CesiumRasterOverlays::RasterOverlay>>&
getOverlays() const;
/**
* @brief Gets the tile providers in this collection. Each tile provider
* corresponds with the overlay at the same position in the collection
* returned by {@link getOverlays}.
*/
const std::vector<CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlayTileProvider>>&
getTileProviders() const;
/**
* @brief Gets the placeholder tile providers in this collection. Each
* placeholder tile provider corresponds with the overlay at the same position
* in the collection returned by {@link getOverlays}.
*/
const std::vector<CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlayTileProvider>>&
getPlaceholderTileProviders() const;
/**
* @brief Finds the tile provider for a given overlay.
*
* If the specified raster overlay is not part of this collection, this method
* will return nullptr.
*
* If the overlay's real tile provider hasn't finished being
* created yet, a placeholder will be returned. That is, its
* {@link CesiumRasterOverlays::RasterOverlayTileProvider::isPlaceholder} method will return true.
*
* @param overlay The overlay for which to obtain the tile provider.
* @return The tile provider, if any, corresponding to the raster overlay.
*/
CesiumRasterOverlays::RasterOverlayTileProvider* findTileProviderForOverlay(
CesiumRasterOverlays::RasterOverlay& overlay) noexcept;
/**
* @copydoc findTileProviderForOverlay
*/
const CesiumRasterOverlays::RasterOverlayTileProvider*
findTileProviderForOverlay(
const CesiumRasterOverlays::RasterOverlay& overlay) const noexcept;
/**
* @brief Finds the placeholder tile provider for a given overlay.
*
* If the specified raster overlay is not part of this collection, this method
* will return nullptr.
*
* This method will return the placeholder tile provider even if the real one
* has been created. This is useful to create placeholder tiles when the
* rectangle in the overlay's projection is not yet known.
*
* @param overlay The overlay for which to obtain the tile provider.
* @return The placeholder tile provider, if any, corresponding to the raster
* overlay.
*/
CesiumRasterOverlays::RasterOverlayTileProvider*
findPlaceholderTileProviderForOverlay(
CesiumRasterOverlays::RasterOverlay& overlay) noexcept;
/**
* @copydoc findPlaceholderTileProviderForOverlay
*/
const CesiumRasterOverlays::RasterOverlayTileProvider*
findPlaceholderTileProviderForOverlay(
const CesiumRasterOverlays::RasterOverlay& overlay) const noexcept;
/**
* @brief A constant iterator for {@link CesiumRasterOverlays::RasterOverlay} instances.
*/
typedef std::vector<CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlay>>::const_iterator const_iterator;
/**
* @brief Returns an iterator at the beginning of this collection.
*/
const_iterator begin() const noexcept;
/**
* @brief Returns an iterator at the end of this collection.
*/
const_iterator end() const noexcept;
/**
* @brief Gets the number of overlays in the collection.
*/
size_t size() const noexcept;
private:
// We store the list of overlays and tile providers in this separate class
// so that we can separate its lifetime from the lifetime of the
// RasterOverlayCollection. We need to do this because the async operations
// that create tile providers from overlays need to have somewhere to write
// the result. And we can't extend the lifetime of the entire
// RasterOverlayCollection until the async operations complete because the
// RasterOverlayCollection has a pointer to the tile LoadedLinkedList, which
// is owned externally and may become invalid before the async operations
// complete.
struct OverlayList
: public CesiumUtility::ReferenceCountedNonThreadSafe<OverlayList> {
std::vector<
CesiumUtility::IntrusivePointer<CesiumRasterOverlays::RasterOverlay>>
overlays{};
std::vector<CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlayTileProvider>>
tileProviders{};
std::vector<CesiumUtility::IntrusivePointer<
CesiumRasterOverlays::RasterOverlayTileProvider>>
placeholders{};
};
Tile::LoadedLinkedList* _pLoadedTiles;
TilesetExternals _externals;
CesiumGeospatial::Ellipsoid _ellipsoid;
CesiumUtility::IntrusivePointer<OverlayList> _pOverlays;
CESIUM_TRACE_DECLARE_TRACK_SET(_loadingSlots, "Raster Overlay Loading Slot")
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,54 @@
#pragma once
#include "ITileExcluder.h"
#include "Library.h"
#include <CesiumUtility/IntrusivePointer.h>
namespace CesiumRasterOverlays {
class RasterizedPolygonsOverlay;
}
namespace Cesium3DTilesSelection {
/**
* @brief When provided to {@link TilesetOptions::excluders}, uses the polygons
* owned by a {@link CesiumRasterOverlays::RasterizedPolygonsOverlay} to exclude tiles that are
* entirely inside any of the polygon from loading. This is useful when the
* polygons will be used for clipping.
*/
class CESIUM3DTILESSELECTION_API RasterizedPolygonsTileExcluder
: public Cesium3DTilesSelection::ITileExcluder {
public:
/**
* @brief Constructs a new instance.
*
* @param pOverlay The overlay definining the polygons.
*/
RasterizedPolygonsTileExcluder(
const CesiumUtility::IntrusivePointer<
const CesiumRasterOverlays::RasterizedPolygonsOverlay>&
pOverlay) noexcept;
/**
* @brief Determines whether a given tile is entirely inside a polygon and
* therefore should be excluded.
*
* @param tile The tile to check.
* @return true if the tile should be excluded because it is entirely inside a
* polygon.
*/
virtual bool shouldExclude(const Tile& tile) const noexcept override;
/**
* @brief Gets the overlay defining the polygons.
*/
const CesiumRasterOverlays::RasterizedPolygonsOverlay& getOverlay() const;
private:
CesiumUtility::IntrusivePointer<
const CesiumRasterOverlays::RasterizedPolygonsOverlay>
_pOverlay;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,44 @@
#pragma once
#include <CesiumGeospatial/Cartographic.h>
#include <string>
#include <vector>
namespace Cesium3DTilesSelection {
/**
* @brief The result of sampling heights with
* {@link Tileset::sampleHeightMostDetailed}.
*/
struct SampleHeightResult {
/**
* @brief The positions and their sampled heights.
*
* For each resulting position, its longitude and latitude values will match
* values from its input. Its height will either be the height sampled from
* the tileset at that position, or the original input height if the sample
* was unsuccessful. To determine which, look at the value of
* {@link SampleHeightResult::sampleSuccess} at the same index.
*/
std::vector<CesiumGeospatial::Cartographic> positions;
/**
* @brief The success of each sample.
*
* Each entry specifies whether the height for the position at the
* corresponding index was successfully sampled. If true, then
* {@link SampleHeightResult::positions} has a valid height sampled from the
* tileset at this index. If false, the height could not be sampled, leaving
* the height in {@link SampleHeightResult::positions} unchanged from the
* original input height.
*/
std::vector<bool> sampleSuccess;
/**
* @brief Any warnings that occurred while sampling heights.
*/
std::vector<std::string> warnings;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,563 @@
#pragma once
#include "BoundingVolume.h"
#include "Library.h"
#include "RasterMappedTo3DTile.h"
#include "TileContent.h"
#include "TileID.h"
#include "TileRefine.h"
#include "TileSelectionState.h"
#include <CesiumUtility/DoublyLinkedList.h>
#include <glm/common.hpp>
#include <atomic>
#include <limits>
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <vector>
namespace Cesium3DTilesSelection {
class TilesetContentLoader;
/**
* The current state of this tile in the loading process.
*/
enum class TileLoadState {
/**
* @brief This tile is in the process of being unloaded, but could not be
* fully unloaded because an asynchronous process is using its loaded data.
*/
Unloading = -2,
/**
* @brief Something went wrong while loading this tile, but it may be a
* temporary problem.
*/
FailedTemporarily = -1,
/**
* @brief The tile is not yet loaded at all, beyond the metadata in
* tileset.json.
*/
Unloaded = 0,
/**
* @brief The tile content is currently being loaded.
*
* Note that while a tile is in this state, its {@link Tile::getContent},
* and {@link Tile::getState}, methods may be called from the load thread,
* and the state may change due to the internal loading process.
*/
ContentLoading = 1,
/**
* @brief The tile content has finished loading.
*/
ContentLoaded = 2,
/**
* @brief The tile is completely done loading.
*/
Done = 3,
/**
* @brief Something went wrong while loading this tile and it will not be
* retried.
*/
Failed = 4,
};
/**
* @brief A tile in a {@link Tileset}.
*
* The tiles of a tileset form a hierarchy, where each tile may contain
* renderable content, and each tile has an associated bounding volume.
*
* The actual hierarchy is represented with the {@link Tile::getParent}
* and {@link Tile::getChildren} functions.
*
* The renderable content is provided as a {@link TileContent}
* from the {@link Tile::getContent} function.
* The {@link Tile::getGeometricError} function returns the geometric
* error of the representation of the renderable content of a tile.
*
* The {@link BoundingVolume} is given by the {@link Tile::getBoundingVolume}
* function. This bounding volume encloses the renderable content of the
* tile itself, as well as the renderable content of all children, yielding
* a spatially coherent hierarchy of bounding volumes.
*
* The bounding volume of the content of an individual tile is given
* by the {@link Tile::getContentBoundingVolume} function.
*
*/
class CESIUM3DTILESSELECTION_API Tile final {
public:
/**
* @brief Construct a tile with unknown content and a loader that is used to
* load the content of this tile. Tile has Unloaded status when initializing
* with this constructor.
*
* @param pLoader The {@link TilesetContentLoader} that is used to load the tile.
*/
explicit Tile(TilesetContentLoader* pLoader) noexcept;
/**
* @brief Construct a tile with an external content and a loader that is
* associated with this tile. Tile has ContentLoaded status when initializing
* with this constructor.
*
* @param pLoader The {@link TilesetContentLoader} that is assiocated with this tile.
* @param externalContent External content that is associated with this tile.
*/
Tile(
TilesetContentLoader* pLoader,
std::unique_ptr<TileExternalContent>&& externalContent) noexcept;
/**
* @brief Construct a tile with an empty content and a loader that is
* associated with this tile. Tile has ContentLoaded status when initializing
* with this constructor.
*
* @param pLoader The {@link TilesetContentLoader} that is assiocated with this tile.
* @param emptyContent A content tag indicating that the tile has no content.
*/
Tile(TilesetContentLoader* pLoader, TileEmptyContent emptyContent) noexcept;
/**
* @brief Default destructor, which clears all resources associated with this
* tile.
*/
~Tile() noexcept = default;
/**
* @brief Copy constructor.
*
* @param rhs The other instance.
*/
Tile(const Tile& rhs) = delete;
/**
* @brief Move constructor.
*
* @param rhs The other instance.
*/
Tile(Tile&& rhs) noexcept;
/**
* @brief Copy constructor.
*
* @param rhs The other instance.
*/
Tile& operator=(const Tile& rhs) = delete;
/**
* @brief Move assignment operator.
*
* @param rhs The other instance.
*/
Tile& operator=(Tile&& rhs) noexcept;
/**
* @brief Returns the parent of this tile in the tile hierarchy.
*
* This will be the `nullptr` if this is the root tile.
*
* @return The parent.
*/
Tile* getParent() noexcept { return this->_pParent; }
/** @copydoc Tile::getParent() */
const Tile* getParent() const noexcept { return this->_pParent; }
/**
* @brief Returns a *view* on the children of this tile.
*
* The returned span will become invalid when this tile is destroyed.
*
* @return The children of this tile.
*/
std::span<Tile> getChildren() noexcept {
return std::span<Tile>(this->_children);
}
/** @copydoc Tile::getChildren() */
std::span<const Tile> getChildren() const noexcept {
return std::span<const Tile>(this->_children);
}
/**
* @brief Assigns the given child tiles to this tile.
*
* This function is not supposed to be called by clients.
*
* @param children The child tiles.
* @throws `std::runtime_error` if this tile already has children.
*/
void createChildTiles(std::vector<Tile>&& children);
/**
* @brief Returns the {@link BoundingVolume} of this tile.
*
* This is a bounding volume that encloses the content of this tile,
* as well as the content of all child tiles.
*
* @see Tile::getContentBoundingVolume
*
* @return The bounding volume.
*/
const BoundingVolume& getBoundingVolume() const noexcept {
return this->_boundingVolume;
}
/**
* @brief Set the {@link BoundingVolume} of this tile.
*
* This function is not supposed to be called by clients.
*
* @param value The bounding volume.
*/
void setBoundingVolume(const BoundingVolume& value) noexcept {
this->_boundingVolume = value;
}
/**
* @brief Returns the viewer request volume of this tile.
*
* The viewer request volume is an optional {@link BoundingVolume} that
* may be associated with a tile. It allows controlling the rendering
* process of the tile content: If the viewer request volume is present,
* then the content of the tile will only be rendered when the viewer
* (i.e. the camera position) is inside the viewer request volume.
*
* @return The viewer request volume, or an empty optional.
*/
const std::optional<BoundingVolume>& getViewerRequestVolume() const noexcept {
return this->_viewerRequestVolume;
}
/**
* @brief Set the viewer request volume of this tile.
*
* This function is not supposed to be called by clients.
*
* @param value The viewer request volume.
*/
void
setViewerRequestVolume(const std::optional<BoundingVolume>& value) noexcept {
this->_viewerRequestVolume = value;
}
/**
* @brief Returns the geometric error of this tile.
*
* This is the error, in meters, introduced if this tile is rendered and its
* children are not. This is used to compute screen space error, i.e., the
* error measured in pixels.
*
* @return The geometric error of this tile, in meters.
*/
double getGeometricError() const noexcept { return this->_geometricError; }
/**
* @brief Set the geometric error of the contents of this tile.
*
* This function is not supposed to be called by clients.
*
* @param value The geometric error, in meters.
*/
void setGeometricError(double value) noexcept {
this->_geometricError = value;
}
/**
* @brief Gets the tile's geometric error as if by calling
* {@link getGeometricError}, except that if the error is smaller than
* {@link CesiumUtility::Math::Epsilon5} the returned geometric error is instead computed as
* half of the parent tile's (non-zero) geometric error.
*
* This is useful for determining when to refine what would ordinarily be a
* leaf tile, for example to attach more detailed raster overlays to it.
*
* If this tile and all of its ancestors have a geometric error less than
* {@link CesiumUtility::Math::Epsilon5}, returns {@link CesiumUtility::Math::Epsilon5}.
*
* @return The non-zero geometric error.
*/
double getNonZeroGeometricError() const noexcept;
/**
* @brief Returns whether to unconditionally refine this tile.
*
* This is useful in cases such as with external tilesets, where instead of a
* tile having any content, it points to an external tileset's root. So the
* tile always needs to be refined otherwise the external tileset will not be
* displayed.
*
* @return Whether to uncoditionally refine this tile.
*/
bool getUnconditionallyRefine() const noexcept {
return glm::isinf(this->_geometricError);
}
/**
* @brief Marks that this tile should be unconditionally refined.
*
* This function is not supposed to be called by clients.
*/
void setUnconditionallyRefine() noexcept {
this->_geometricError = std::numeric_limits<double>::infinity();
}
/**
* @brief The refinement strategy of this tile.
*
* Returns the {@link TileRefine} value that indicates the refinement strategy
* for this tile. This is `Add` when the content of the
* child tiles is *added* to the content of this tile during refinement, and
* `Replace` when the content of the child tiles *replaces*
* the content of this tile during refinement.
*
* @return The refinement strategy.
*/
TileRefine getRefine() const noexcept { return this->_refine; }
/**
* @brief Set the refinement strategy of this tile.
*
* This function is not supposed to be called by clients.
*
* @param value The refinement strategy.
*/
void setRefine(TileRefine value) noexcept { this->_refine = value; }
/**
* @brief Gets the transformation matrix for this tile.
*
* This matrix does _not_ need to be multiplied with the tile's parent's
* transform as this has already been done.
*
* @return The transform matrix.
*/
const glm::dmat4x4& getTransform() const noexcept { return this->_transform; }
/**
* @brief Set the transformation matrix for this tile.
*
* This function is not supposed to be called by clients.
*
* @param value The transform matrix.
*/
void setTransform(const glm::dmat4x4& value) noexcept {
this->_transform = value;
}
/**
* @brief Returns the {@link TileID} of this tile.
*
* This function is not supposed to be called by clients.
*
* @return The tile ID.
*/
const TileID& getTileID() const noexcept { return this->_id; }
/**
* @brief Set the {@link TileID} of this tile.
*
* This function is not supposed to be called by clients.
*
* @param id The tile ID.
*/
void setTileID(const TileID& id) noexcept { this->_id = id; }
/**
* @brief Returns the {@link BoundingVolume} of the renderable content of this
* tile.
*
* The content bounding volume is a bounding volume that tightly fits only the
* renderable content of the tile. This enables tighter view frustum culling,
* making it possible to exclude from rendering any content not in the view
* frustum.
*
* @see Tile::getBoundingVolume
*/
const std::optional<BoundingVolume>&
getContentBoundingVolume() const noexcept {
return this->_contentBoundingVolume;
}
/**
* @brief Set the {@link BoundingVolume} of the renderable content of this
* tile.
*
* This function is not supposed to be called by clients.
*
* @param value The content bounding volume
*/
void setContentBoundingVolume(
const std::optional<BoundingVolume>& value) noexcept {
this->_contentBoundingVolume = value;
}
/**
* @brief Returns the {@link TileSelectionState} of this tile.
*
* This function is not supposed to be called by clients.
*
* @return The last selection state
*/
TileSelectionState& getLastSelectionState() noexcept {
return this->_lastSelectionState;
}
/** @copydoc Tile::getLastSelectionState() */
const TileSelectionState& getLastSelectionState() const noexcept {
return this->_lastSelectionState;
}
/**
* @brief Set the {@link TileSelectionState} of this tile.
*
* This function is not supposed to be called by clients.
*
* @param newState The new stace
*/
void setLastSelectionState(const TileSelectionState& newState) noexcept {
this->_lastSelectionState = newState;
}
/**
* @brief Determines the number of bytes in this tile's geometry and texture
* data.
*/
int64_t computeByteSize() const noexcept;
/**
* @brief Returns the raster overlay tiles that have been mapped to this tile.
*/
std::vector<RasterMappedTo3DTile>& getMappedRasterTiles() noexcept {
return this->_rasterTiles;
}
/** @copydoc Tile::getMappedRasterTiles() */
const std::vector<RasterMappedTo3DTile>&
getMappedRasterTiles() const noexcept {
return this->_rasterTiles;
}
/**
* @brief Get the content of the tile.
*/
const TileContent& getContent() const noexcept { return _content; }
/** @copydoc Tile::getContent() const */
TileContent& getContent() noexcept { return _content; }
/**
* @brief Determines if this tile is currently renderable.
*/
bool isRenderable() const noexcept;
/**
* @brief Determines if this tile has mesh content.
*/
bool isRenderContent() const noexcept;
/**
* @brief Determines if this tile has external tileset content.
*/
bool isExternalContent() const noexcept;
/**
* @brief Determines if this tile has empty content.
*/
bool isEmptyContent() const noexcept;
/**
* @brief get the loader that is used to load the tile content.
*/
TilesetContentLoader* getLoader() const noexcept;
/**
* @brief Returns the {@link TileLoadState} of this tile.
*/
TileLoadState getState() const noexcept;
private:
struct TileConstructorImpl {};
template <
typename... TileContentArgs,
typename TileContentEnable = std::enable_if_t<
std::is_constructible_v<TileContent, TileContentArgs&&...>,
int>>
Tile(
TileConstructorImpl tag,
TileLoadState loadState,
TilesetContentLoader* pLoader,
TileContentArgs&&... args);
void setParent(Tile* pParent) noexcept;
void setState(TileLoadState state) noexcept;
/**
* @brief Gets a flag indicating whether this tile might have latent children.
* Latent children don't exist in the `_children` property, but can be created
* by the {@link TilesetContentLoader}.
*
* When true, this tile might have children that can be created by the
* TilesetContentLoader but aren't yet reflected in the `_children` property.
* For example, in implicit tiling, we save memory by only creating explicit
* Tile instances from implicit availability as those instances are needed.
* When this flag is true, the creation of those explicit instances hasn't
* happened yet for this tile.
*
* If this flag is false, the children have already been created, if they
* exist. The tile may still have no children because it is a leaf node.
*/
bool getMightHaveLatentChildren() const noexcept;
void setMightHaveLatentChildren(bool mightHaveLatentChildren) noexcept;
// Position in bounding-volume hierarchy.
Tile* _pParent;
std::vector<Tile> _children;
// Properties from tileset.json.
// These are immutable after the tile leaves TileState::Unloaded.
TileID _id;
BoundingVolume _boundingVolume;
std::optional<BoundingVolume> _viewerRequestVolume;
std::optional<BoundingVolume> _contentBoundingVolume;
double _geometricError;
TileRefine _refine;
glm::dmat4x4 _transform;
// Selection state
TileSelectionState _lastSelectionState;
// tile content
CesiumUtility::DoublyLinkedListPointers<Tile> _loadedTilesLinks;
TileContent _content;
TilesetContentLoader* _pLoader;
TileLoadState _loadState;
bool _mightHaveLatentChildren;
// mapped raster overlay
std::vector<RasterMappedTo3DTile> _rasterTiles;
friend class TilesetContentManager;
friend class MockTilesetContentManagerTestFixture;
public:
/**
* @brief A {@link CesiumUtility::DoublyLinkedList} for tile objects.
*/
typedef CesiumUtility::DoublyLinkedList<Tile, &Tile::_loadedTilesLinks>
LoadedLinkedList;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,306 @@
#pragma once
#include "Library.h"
#include "TilesetMetadata.h"
#include <CesiumGeospatial/Projection.h>
#include <CesiumGltf/Model.h>
#include <CesiumRasterOverlays/RasterOverlayDetails.h>
#include <CesiumUtility/CreditSystem.h>
#include <memory>
#include <variant>
#include <vector>
namespace Cesium3DTilesSelection {
/**
* @brief A content tag that indicates the {@link TilesetContentLoader} does not
* know if a tile's content will point to a mesh content or an external
* tileset. The content of the tile is only known when the loader loads the tile
* to inspect the content.
*/
struct CESIUM3DTILESSELECTION_API TileUnknownContent {};
/**
* @brief A content tag that indicates a tile has no content.
*
* There are two possible ways to handle a tile with no content:
*
* 1. Treat it as a placeholder used for more efficient culling, but
* never render it. Refining to this tile is equivalent to refining
* to its children.
* 2. Treat it as an indication that nothing need be rendered in this
* area at this level-of-detail. In other words, "render" it as a
* hole. To have this behavior, the tile should _not_ have content at
* all.
*
* We distinguish whether the tileset creator wanted (1) or (2) by
* comparing this tile's geometricError to the geometricError of its
* parent tile. If this tile's error is greater than or equal to its
* parent, treat it as (1). If it's less, treat it as (2).
*
* For a tile with no parent there's no difference between the
* behaviors.
*/
struct CESIUM3DTILESSELECTION_API TileEmptyContent {};
/**
* @brief A content tag that indicates a tile content points to an
* external tileset. When this tile is loaded, all the tiles in the
* external tileset will become children of this external content tile
*/
struct CESIUM3DTILESSELECTION_API TileExternalContent {
/**
* @brief The metadata associated with this tileset.
*/
TilesetMetadata metadata;
};
/**
* @brief A content tag that indicates a tile has a glTF model content and
* render resources for the model
*/
class CESIUM3DTILESSELECTION_API TileRenderContent {
public:
/**
* @brief Construct the content with a glTF model
*
* @param model A glTF model that will be owned by this content
*/
TileRenderContent(CesiumGltf::Model&& model);
/**
* @brief Retrieve a glTF model that is owned by this content
*
* @return A glTF model that is owned by this content
*/
const CesiumGltf::Model& getModel() const noexcept;
/**
* @brief Retrieve a glTF model that is owned by this content
*
* @return A glTF model that is owned by this content
*/
CesiumGltf::Model& getModel() noexcept;
/**
* @brief Set the glTF model for this content
*
* @param model A glTF model that will be owned by this content
*/
void setModel(const CesiumGltf::Model& model);
/**
* @brief Set the glTF model for this content
*
* @param model A glTF model that will be owned by this content
*/
void setModel(CesiumGltf::Model&& model);
/**
* @brief Get the {@link CesiumRasterOverlays::RasterOverlayDetails} which is the result of generating raster overlay UVs for the glTF model
*
* @return The {@link CesiumRasterOverlays::RasterOverlayDetails} that is owned by this content
*/
const CesiumRasterOverlays::RasterOverlayDetails&
getRasterOverlayDetails() const noexcept;
/**
* @brief Get the {@link CesiumRasterOverlays::RasterOverlayDetails} which is the result of generating raster overlay UVs for the glTF model
*
* @return The {@link CesiumRasterOverlays::RasterOverlayDetails} that is owned by this content
*/
CesiumRasterOverlays::RasterOverlayDetails&
getRasterOverlayDetails() noexcept;
/**
* @brief Set the {@link CesiumRasterOverlays::RasterOverlayDetails} which is the result of generating raster overlay UVs for the glTF model
*
* @param rasterOverlayDetails The {@link CesiumRasterOverlays::RasterOverlayDetails} that will be owned by this content
*/
void setRasterOverlayDetails(
const CesiumRasterOverlays::RasterOverlayDetails& rasterOverlayDetails);
/**
* @brief Set the {@link CesiumRasterOverlays::RasterOverlayDetails} which is the result of generating raster overlay UVs for the glTF model
*
* @param rasterOverlayDetails The {@link CesiumRasterOverlays::RasterOverlayDetails} that will be owned by this content
*/
void setRasterOverlayDetails(
CesiumRasterOverlays::RasterOverlayDetails&& rasterOverlayDetails);
/**
* @brief Get the list of \ref CesiumUtility::Credit "Credit" of the content
*
* @return The list of \ref CesiumUtility::Credit "Credit" of the content
*/
const std::vector<CesiumUtility::Credit>& getCredits() const noexcept;
/**
* @brief Get the list of \ref CesiumUtility::Credit "Credit" of the content
*
* @return The list of \ref CesiumUtility::Credit "Credit" of the content
*/
std::vector<CesiumUtility::Credit>& getCredits() noexcept;
/**
* @brief Set the list of \ref CesiumUtility::Credit "Credit" for the content
*
* @param credits The list of \ref CesiumUtility::Credit "Credit" to be owned
* by the content
*/
void setCredits(std::vector<CesiumUtility::Credit>&& credits);
/**
* @brief Set the list of \ref CesiumUtility::Credit "Credit" for the content
*
* @param credits The list of \ref CesiumUtility::Credit "Credit" to be owned
* by the content
*/
void setCredits(const std::vector<CesiumUtility::Credit>& credits);
/**
* @brief Get the render resources created for the glTF model of the content
*
* @return The render resources that is created for the glTF model
*/
void* getRenderResources() const noexcept;
/**
* @brief Set the render resources created for the glTF model of the content
*
* @param pRenderResources The render resources that is created for the glTF
* model
*/
void setRenderResources(void* pRenderResources) noexcept;
/**
* @brief Get the fade percentage that this tile during an LOD transition.
*
* This will be used when {@link TilesetOptions::enableLodTransitionPeriod}
* is true. Tile fades can be used to make LOD transitions appear less abrupt
* and jarring. It is up to client implementations how to render the fade
* percentage, but dithered fading is recommended.
*
* @return The fade percentage.
*/
float getLodTransitionFadePercentage() const noexcept;
/**
* @brief Set the fade percentage of this tile during an LOD transition with.
* Not to be used by clients.
*
* @param percentage The new fade percentage.
*/
void setLodTransitionFadePercentage(float percentage) noexcept;
private:
CesiumGltf::Model _model;
void* _pRenderResources;
CesiumRasterOverlays::RasterOverlayDetails _rasterOverlayDetails;
std::vector<CesiumUtility::Credit> _credits;
float _lodTransitionFadePercentage;
};
/**
* @brief A tile content container that can store and query the content type
* that is currently being owned by the tile
*/
class CESIUM3DTILESSELECTION_API TileContent {
using TileContentKindImpl = std::variant<
TileUnknownContent,
TileEmptyContent,
std::unique_ptr<TileExternalContent>,
std::unique_ptr<TileRenderContent>>;
public:
/**
* @brief Construct an unknown content for a tile. This constructor
* is useful when the tile content is known after its content is downloaded by
* {@link TilesetContentLoader}
*/
TileContent();
/**
* @brief Construct an empty content for a tile
*/
TileContent(TileEmptyContent content);
/**
* @brief Construct an external content for a tile whose content
* points to an external tileset
*/
TileContent(std::unique_ptr<TileExternalContent>&& content);
/**
* @brief Set an unknown content tag for a tile. This constructor
* is useful when the tile content is known after its content is downloaded by
* {@link TilesetContentLoader}
*/
void setContentKind(TileUnknownContent content);
/**
* @brief Construct an empty content tag for a tile
*/
void setContentKind(TileEmptyContent content);
/**
* @brief Set an external content for a tile whose content
* points to an external tileset
*/
void setContentKind(std::unique_ptr<TileExternalContent>&& content);
/**
* @brief Set a glTF model content for a tile
*/
void setContentKind(std::unique_ptr<TileRenderContent>&& content);
/**
* @brief Query if a tile has an unknown content
*/
bool isUnknownContent() const noexcept;
/**
* @brief Query if a tile has an empty content
*/
bool isEmptyContent() const noexcept;
/**
* @brief Query if a tile has an external content which points to
* an external tileset
*/
bool isExternalContent() const noexcept;
/**
* @brief Query if a tile has an glTF model content
*/
bool isRenderContent() const noexcept;
/**
* @brief Get the {@link TileRenderContent} which stores the glTF model
* and render resources of the tile
*/
const TileRenderContent* getRenderContent() const noexcept;
/**
* @brief Get the {@link TileRenderContent} which stores the glTF model
* and render resources of the tile
*/
TileRenderContent* getRenderContent() noexcept;
/**
* @brief Get the {@link TileExternalContent} which stores the details of
* the external tileset.
*/
const TileExternalContent* getExternalContent() const noexcept;
/**
* @brief Get the {@link TileExternalContent} which stores the details of
* the external tileset.
*/
TileExternalContent* getExternalContent() noexcept;
private:
TileContentKindImpl _contentKind;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,61 @@
#pragma once
#include "Library.h"
#include <CesiumGeometry/OctreeTileID.h>
#include <CesiumGeometry/QuadtreeTileID.h>
#include <string>
#include <variant>
namespace Cesium3DTilesSelection {
/**
* @brief An identifier for a {@link Tile} inside the tile hierarchy.
*
* This ID is stored in the tile as the {@link Tile::getTileID}.
* It is assigned to the tile at construction time, and may be
* used to identify and access the children of a given tile.
*
* Depending on the exact type of the tile and its contents, this
* identifier may have different forms:
*
* * A `std::string`: This is an explicitly-described tile and
* the ID is the URL of the tile's content.
* * A {@link CesiumGeometry::QuadtreeTileID}: This is an implicit
* tile in the quadtree. The URL of the tile's content is formed
* by instantiating the context's template URL with this ID.
* * A {@link CesiumGeometry::OctreeTileID}: This is an implicit
* tile in the octree. The URL of the tile's content is formed
* by instantiating the context's template URL with this ID.
* * A {@link CesiumGeometry::UpsampledQuadtreeNode}: This tile doesn't
* have any content, but content for it can be created by subdividing
* the parent tile's content.
*/
typedef std::variant<
std::string,
CesiumGeometry::QuadtreeTileID,
CesiumGeometry::OctreeTileID,
CesiumGeometry::UpsampledQuadtreeNode>
TileID;
/**
* @brief Utility functions related to {@link TileID} objects.
*/
struct CESIUM3DTILESSELECTION_API TileIdUtilities {
/**
* @brief Creates an unspecified string representation of the given {@link
* TileID}.
*
* The returned string will contain information about the given tile ID,
* depending on its type. The exact format and contents of this string
* is not specified. This is mainly intended for printing informative
* log messages.
*
* @param tileId The tile ID
* @return The string
*/
static std::string createTileIdString(const TileID& tileId);
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,162 @@
#pragma once
#include "BoundingVolume.h"
#include "TileContent.h"
#include <CesiumAsync/IAssetRequest.h>
#include <CesiumGeometry/Axis.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/Model.h>
#include <CesiumRasterOverlays/RasterOverlayDetails.h>
#include <functional>
#include <memory>
#include <optional>
#include <variant>
namespace Cesium3DTilesSelection {
class Tile;
/**
* @brief Store the content of the tile after finishing
* loading tile using {@link TilesetContentLoader::loadTileContent}:
*
* 1. Returning {@link TileUnknownContent} means that the loader doesn't know
* the content of the tile. This content type is useful when loader fails to
* load the tile content; or a background task is running to determine the tile
* content and the loader wants the client to retry later at some point in the
* future
*
* 2. Returning {@link TileEmptyContent} means that this tile has no content and mostly used
* for efficient culling during the traversal process
*
* 3. Returning {@link TileExternalContent} means that this tile points to an external tileset
*
* 4. Returning {@link CesiumGltf::Model} means that this tile has glTF model
*/
using TileContentKind = std::variant<
TileUnknownContent,
TileEmptyContent,
TileExternalContent,
CesiumGltf::Model>;
/**
* @brief Indicate the status of {@link Cesium3DTilesSelection::TilesetContentLoader::loadTileContent} and
* {@link Cesium3DTilesSelection::TilesetContentLoader::createTileChildren} operations
*/
enum class TileLoadResultState {
/**
* @brief The operation is successful and all the fields in {@link TileLoadResult}
* or {@link TileChildrenResult} are applied to the tile
*/
Success,
/**
* @brief The operation is failed and __none__ of the fields in {@link TileLoadResult}
* or {@link TileChildrenResult} are applied to the tile
*/
Failed,
/**
* @brief The operation requires the client to retry later due to some
* background work happenning and
* __none__ of the fields in {@link TileLoadResult} or {@link TileChildrenResult} are applied to the tile
*/
RetryLater
};
/**
* @brief Store the result of loading a tile content after
* invoking {@link TilesetContentLoader::loadTileContent}
*/
struct CESIUM3DTILESSELECTION_API TileLoadResult {
/**
* @brief The content type of the tile.
*/
TileContentKind contentKind;
/**
* @brief The up axis of glTF content.
*/
CesiumGeometry::Axis glTFUpAxis;
/**
* @brief A tile can potentially store a more fit bounding volume along with
* its content. If this field is set, the tile's bounding volume will be
* updated after the loading is finished.
*/
std::optional<BoundingVolume> updatedBoundingVolume;
/**
* @brief A tile can potentially store a more fit content bounding volume
* along with its content. If this field is set, the tile's content bounding
* volume will be updated after the loading is finished.
*/
std::optional<BoundingVolume> updatedContentBoundingVolume;
/**
* @brief Holds details of the {@link TileRenderContent} that are useful
* for raster overlays.
*/
std::optional<CesiumRasterOverlays::RasterOverlayDetails>
rasterOverlayDetails;
/**
* @brief The asset accessor that was used to retrieve this tile, and that
* should be used to retrieve further resources referenced by the tile.
*/
std::shared_ptr<CesiumAsync::IAssetAccessor> pAssetAccessor;
/**
* @brief The request that is created to download the tile content.
*/
std::shared_ptr<CesiumAsync::IAssetRequest> pCompletedRequest;
/**
* @brief A callback that is invoked in the main thread immediately when the
* loading is finished. This callback is useful when the content request has
* other fields like geometric error,
* children (in the case of {@link TileExternalContent}), etc, to override the existing fields.
*/
std::function<void(Tile&)> tileInitializer;
/**
* @brief The result of loading a tile. Note that if the state is Failed or
* RetryLater, __none__ of the fields above (including {@link TileLoadResult::tileInitializer}) will be
* applied to a tile when the loading is finished
*/
TileLoadResultState state;
/**
* @brief The ellipsoid that this tile uses.
*
* This value is only guaranteed to be accurate when {@link TileLoadResult::state} is equal to {@link TileLoadResultState::Success}.
*/
CesiumGeospatial::Ellipsoid ellipsoid =
CesiumGeospatial::Ellipsoid::UNIT_SPHERE;
/**
* @brief Create a result with Failed state
*
* @param pAssetAccessor The \ref CesiumAsync::IAssetAccessor "IAssetAccessor"
* used to load tiles.
* @param pCompletedRequest The failed request
*/
static TileLoadResult createFailedResult(
std::shared_ptr<CesiumAsync::IAssetAccessor> pAssetAccessor,
std::shared_ptr<CesiumAsync::IAssetRequest> pCompletedRequest);
/**
* @brief Create a result with RetryLater state
*
* @param pAssetAccessor The \ref CesiumAsync::IAssetAccessor "IAssetAccessor"
* used to load tiles.
* @param pCompletedRequest The failed request
*/
static TileLoadResult createRetryLaterResult(
std::shared_ptr<CesiumAsync::IAssetAccessor> pAssetAccessor,
std::shared_ptr<CesiumAsync::IAssetRequest> pCompletedRequest);
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,147 @@
#pragma once
#include "Library.h"
#include "Tile.h"
#include <cstdint>
#include <unordered_map>
#include <vector>
namespace Cesium3DTilesSelection {
/**
* @brief The occlusion state of a tile as reported by the renderer proxy.
*/
enum class CESIUM3DTILESSELECTION_API TileOcclusionState {
/**
* @brief The renderer does not yet know if the tile's bounding volume is
* occluded or not.
*
* This can be due to the typical occlusion delay caused by buffered
* rendering or otherwise be due to postponed occlusion queries. We can
* choose to wait for the occlusion information to become available before
* commiting to load the tile. This might prevent unneeded tile loads at the
* cost of a small delay.
*/
OcclusionUnavailable,
/**
* @brief The tile's bounding volume is known by the renderer to be visible.
*/
NotOccluded,
/**
* @brief The tile's bounding volume is known by the renderer to be occluded.
*/
Occluded
};
/**
* @brief An interface for client renderers to use to represent tile bounding
* volumes that should be occlusion tested.
*/
class CESIUM3DTILESSELECTION_API TileOcclusionRendererProxy {
public:
/**
* @brief Get the occlusion state for this tile. If this is
* OcclusionUnavailable, the traversal may decide to wait for the occlusion
* result to become available in future frames.
*
* Client implementation note: Do not return OcclusionUnavailable if the
* occlusion for this tile will _never_ become available, otherwise the tile
* may not refine while waiting for occlusion. In such a case return
* NotOccluded so the traversal can assume it is _known_ to be visible.
*
* @return The occlusion state of this tile.
*/
virtual TileOcclusionState getOcclusionState() const = 0;
protected:
friend class TileOcclusionRendererProxyPool;
/**
* @brief Reset this proxy to target a new tile. If nullptr, this proxy is
* back in the pool and will not be used for further occlusion until reset
* is called again with an actual tile.
*
* @param pTile The tile that this proxy represents or nullptr if the proxy
* is back in the pool.
*/
virtual void reset(const Tile* pTile) = 0;
private:
bool _usedLastFrame = false;
TileOcclusionRendererProxy* _pNext = nullptr;
};
/**
* @brief A pool of {@link TileOcclusionRendererProxy} objects. Allows quick
* remapping of tiles to occlusion renderer proxies so new proxies do not have
* to be created for each new tile requesting occlusion results.
*/
class CESIUM3DTILESSELECTION_API TileOcclusionRendererProxyPool {
public:
/**
* @brief Constructs a new instance.
*
* @param maximumPoolSize The maximum number of
* {@link TileOcclusionRendererProxy} instances that may exist in this pool.
*/
TileOcclusionRendererProxyPool(int32_t maximumPoolSize);
/**
* @brief Destroys this pool.
*/
virtual ~TileOcclusionRendererProxyPool();
/**
* @brief Destroy the pool.
*/
void destroyPool();
/**
* @brief Get the {@link TileOcclusionRendererProxy} mapped to the tile.
* Attempts to create a new mapping if one does not exist already by
* assigning a proxy from the free list.
*
* @param tile The tile.
* @param currentFrame The current frame number.
* @return The occlusion proxy mapped to this tile, or nullptr if one can't
* be made.
*/
const TileOcclusionRendererProxy*
fetchOcclusionProxyForTile(const Tile& tile, int32_t currentFrame);
/**
* @brief Prunes the occlusion proxy mappings and removes any mappings that
* were unused the last frame. Any mapping corresponding to a tile that was
* not visited will have been unused. Occlusion proxies from removed mappings
* will be returned to the free list.
*/
void pruneOcclusionProxyMappings();
protected:
/**
* @brief Create a {@link TileOcclusionRendererProxy}.
*
* @return A new occlusion proxy.
*/
virtual TileOcclusionRendererProxy* createProxy() = 0;
/**
* @brief Destroy a {@link TileOcclusionRendererProxy} that is done being used.
*
* @param pProxy The proxy to be destroyed.
*/
virtual void destroyProxy(TileOcclusionRendererProxy* pProxy) = 0;
private:
// Singly linked list representing the free proxies in the pool
TileOcclusionRendererProxy* _pFreeProxiesHead;
int32_t _currentSize;
int32_t _maxSize;
// The currently used proxies in the pool
std::unordered_map<const Tile*, TileOcclusionRendererProxy*>
_tileToOcclusionProxyMappings;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,23 @@
#pragma once
namespace Cesium3DTilesSelection {
/**
* @brief Refinement strategies for a {@link Cesium3DTilesSelection::Tile}.
*/
enum class TileRefine {
/**
* @brief The content of the child tiles will be added to the content of the
* parent tile.
*/
Add = 0,
/**
* @brief The content of the child tiles will replace the content of the
* parent tile.
*/
Replace = 1
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,168 @@
#pragma once
#include "Library.h"
#include <cstdint>
namespace Cesium3DTilesSelection {
/**
* @brief A description of the state of a {@link Tile} during the rendering
* process
*
* Instances of this class combine a frame number and a
* {@link TileSelectionState::Result} that describes the actual state of the
* tile.
* Instances of this class are stored in a {@link Tile}, and are used to track
* the state of the tile during the rendering process. The {@link Tileset}
* updates this state while traversing the tile hierarchy, tracking whether a
* tile was rendered, culled, or refined in the last frame.
*/
class TileSelectionState final {
public:
/**
* @brief Enumeration of possible results of a {@link TileSelectionState}
*/
enum class CESIUM3DTILESSELECTION_API Result {
/**
* @brief There was no selection result.
*
* This may be the case when the tile wasn't visited last frame.
*/
None = 0,
/**
* @brief This tile was deemed not visible and culled.
*/
Culled = 1,
/**
* @brief The tile was selected for rendering.
*/
Rendered = 2,
/**
* @brief This tile did not meet the required screen-space error and was
* refined.
*/
Refined = 3,
/**
* @brief This tile was rendered but then removed from the render list
*
* This tile was originally rendered, but it got kicked out of the render
* list in favor of an ancestor because it is not yet renderable.
*/
RenderedAndKicked = 4,
/**
* @brief This tile was refined but then removed from the render list
*
* This tile was originally refined, but its rendered descendants got kicked
* out of the render list in favor of an ancestor because it is not yet
* renderable.
*/
RefinedAndKicked = 5
};
/**
* @brief Initializes a new instance with
* {@link TileSelectionState::Result::None}
*/
constexpr TileSelectionState() noexcept
: _frameNumber(0), _result(Result::None) {}
/**
* @brief Initializes a new instance with a given
* {@link TileSelectionState::Result}.
*
* @param frameNumber The frame number in which the selection took place.
* @param result The result of the selection.
*/
constexpr TileSelectionState(int32_t frameNumber, Result result) noexcept
: _frameNumber(frameNumber), _result(result) {}
/**
* @brief Gets the frame number in which selection took place.
*/
constexpr int32_t getFrameNumber() const noexcept {
return this->_frameNumber;
}
/**
* @brief Gets the result of selection.
*
* The given frame number must match the frame number in which selection last
* took place. Otherwise, {@link TileSelectionState::Result::None} is
* returned.
*
* @param frameNumber The previous frame number.
* @return The {@link TileSelectionState::Result}
*/
constexpr Result getResult(int32_t frameNumber) const noexcept {
if (this->_frameNumber != frameNumber) {
return Result::None;
}
return this->_result;
}
/**
* @brief Determines if this tile or its descendents were kicked from the
* render list.
*
* In other words, if its last selection result was
* {@link TileSelectionState::Result::RenderedAndKicked} or
* {@link TileSelectionState::Result::RefinedAndKicked}.
*
* @param frameNumber The previous frame number.
* @return `true` if the tile was kicked, and `false` otherwise
*/
constexpr bool wasKicked(int32_t frameNumber) const noexcept {
const Result result = this->getResult(frameNumber);
return result == Result::RenderedAndKicked ||
result == Result::RefinedAndKicked;
}
/**
* @brief Gets the original selection result prior to being kicked.
*
* If the tile wasn't kicked, the original value is returned.
*
* @param frameNumber The previous frame number.
* @return The {@link TileSelectionState::Result} prior to being kicked.
*/
constexpr Result getOriginalResult(int32_t frameNumber) const noexcept {
const Result result = this->getResult(frameNumber);
switch (result) {
case Result::RefinedAndKicked:
return Result::Refined;
case Result::RenderedAndKicked:
return Result::Rendered;
default:
return result;
}
}
/**
* @brief Marks this tile as "kicked".
*/
constexpr void kick() noexcept {
switch (this->_result) {
case Result::Rendered:
this->_result = Result::RenderedAndKicked;
break;
case Result::Refined:
this->_result = Result::RefinedAndKicked;
break;
default:
break;
}
}
private:
int32_t _frameNumber;
Result _result;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,572 @@
#pragma once
#include "Library.h"
#include "RasterOverlayCollection.h"
#include "SampleHeightResult.h"
#include "Tile.h"
#include "TilesetContentLoader.h"
#include "TilesetExternals.h"
#include "TilesetLoadFailureDetails.h"
#include "TilesetOptions.h"
#include "ViewState.h"
#include "ViewUpdateResult.h"
#include <CesiumAsync/AsyncSystem.h>
#include <CesiumUtility/IntrusivePointer.h>
#include <rapidjson/fwd.h>
#include <list>
#include <memory>
#include <optional>
#include <string>
#include <vector>
namespace Cesium3DTilesSelection {
class TilesetContentManager;
class TilesetMetadata;
class TilesetHeightQuery;
struct TilesetHeightRequest;
class TilesetSharedAssetSystem;
/**
* @brief A <a
* href="https://github.com/CesiumGS/3d-tiles/tree/master/specification">3D
* Tiles tileset</a>, used for streaming massive heterogeneous 3D geospatial
* datasets.
*/
class CESIUM3DTILESSELECTION_API Tileset final {
public:
/**
* @brief Constructs a new instance with a given custom tileset loader.
* @param externals The external interfaces to use.
* @param pCustomLoader The custom loader used to load the tileset and tile
* content.
* @param pRootTile The root tile that is associated with the custom loader
* @param options Additional options for the tileset.
*/
Tileset(
const TilesetExternals& externals,
std::unique_ptr<TilesetContentLoader>&& pCustomLoader,
std::unique_ptr<Tile>&& pRootTile,
const TilesetOptions& options = TilesetOptions());
/**
* @brief Constructs a new instance with a given `tileset.json` URL.
* @param externals The external interfaces to use.
* @param url The URL of the `tileset.json`.
* @param options Additional options for the tileset.
*/
Tileset(
const TilesetExternals& externals,
const std::string& url,
const TilesetOptions& options = TilesetOptions());
/**
* @brief Constructs a new instance with the given asset ID on <a
* href="https://cesium.com/ion/">Cesium ion</a>.
* @param externals The external interfaces to use.
* @param ionAssetID The ID of the Cesium ion asset to use.
* @param ionAccessToken The Cesium ion access token authorizing access to the
* asset.
* @param options Additional options for the tileset.
* @param ionAssetEndpointUrl The URL of the ion asset endpoint. Defaults
* to Cesium ion but a custom endpoint can be specified.
*/
Tileset(
const TilesetExternals& externals,
int64_t ionAssetID,
const std::string& ionAccessToken,
const TilesetOptions& options = TilesetOptions(),
const std::string& ionAssetEndpointUrl = "https://api.cesium.com/");
/**
* @brief Destroys this tileset.
*
* Destroying the tileset will immediately (before the destructor returns)
* unload as much tile content as possible. However, tiles that are currently
* in the process of being loaded cannot be unloaded immediately. These tiles
* will be unloaded asynchronously some time after this destructor returns. To
* be notified of completion of the async portion of the tileset destruction,
* subscribe to {@link getAsyncDestructionCompleteEvent}.
*/
~Tileset() noexcept;
/**
* @brief A future that resolves when this Tileset has been destroyed (i.e.
* its destructor has been called) and all async operations that it was
* executing have completed.
*/
CesiumAsync::SharedFuture<void>& getAsyncDestructionCompleteEvent();
/**
* @brief A future that resolves when the details of the root tile of this
* tileset are available. The root tile's content (e.g., 3D model), however,
* will not necessarily be loaded yet.
*/
CesiumAsync::SharedFuture<void>& getRootTileAvailableEvent();
/**
* @brief Get tileset credits.
*/
const std::vector<CesiumUtility::Credit>& getTilesetCredits() const noexcept;
/**
* @brief Sets whether or not the tileset's credits should be shown on screen.
* @param showCreditsOnScreen Whether the credits should be shown on screen.
*/
void setShowCreditsOnScreen(bool showCreditsOnScreen) noexcept;
/**
* @brief Gets the {@link TilesetExternals} that summarize the external
* interfaces used by this tileset.
*/
TilesetExternals& getExternals() noexcept { return this->_externals; }
/**
* @brief Gets the {@link TilesetExternals} that summarize the external
* interfaces used by this tileset.
*/
const TilesetExternals& getExternals() const noexcept {
return this->_externals;
}
/**
* @brief Returns the {@link CesiumAsync::AsyncSystem} that is used for
* dispatching asynchronous tasks.
*/
CesiumAsync::AsyncSystem& getAsyncSystem() noexcept {
return this->_asyncSystem;
}
/** @copydoc Tileset::getAsyncSystem() */
const CesiumAsync::AsyncSystem& getAsyncSystem() const noexcept {
return this->_asyncSystem;
}
/** @copydoc Tileset::getOptions() */
const TilesetOptions& getOptions() const noexcept { return this->_options; }
/**
* @brief Gets the {@link TilesetOptions} of this tileset.
*/
TilesetOptions& getOptions() noexcept { return this->_options; }
/**
* @brief Gets the {@link CesiumGeospatial::Ellipsoid} used by this tileset.
*/
const CesiumGeospatial::Ellipsoid& getEllipsoid() const {
return this->_options.ellipsoid;
}
/** @copydoc Tileset::getEllipsoid */
CesiumGeospatial::Ellipsoid& getEllipsoid() noexcept {
return this->_options.ellipsoid;
}
/**
* @brief Gets the root tile of this tileset.
*
* This may be `nullptr` if there is currently no root tile.
*/
Tile* getRootTile() noexcept;
/** @copydoc Tileset::getRootTile() */
const Tile* getRootTile() const noexcept;
/**
* @brief Returns the {@link RasterOverlayCollection} of this tileset.
*/
RasterOverlayCollection& getOverlays() noexcept;
/** @copydoc Tileset::getOverlays() */
const RasterOverlayCollection& getOverlays() const noexcept;
/**
* @brief Returns the {@link TilesetSharedAssetSystem} of this tileset.
*/
TilesetSharedAssetSystem& getSharedAssetSystem() noexcept;
/** @copydoc Tileset::getSharedAssetSystem() */
const TilesetSharedAssetSystem& getSharedAssetSystem() const noexcept;
/**
* @brief Updates this view but waits for all tiles that meet sse to finish
* loading and ready to be rendered before returning the function. This method
* is significantly slower than {@link Tileset::updateView} and should only be
* used for capturing movie or non-realtime situation.
* @param frustums The {@link ViewState}s that the view should be updated for
* @returns The set of tiles to render in the updated view. This value is only
* valid until the next call to `updateView` or until the tileset is
* destroyed, whichever comes first.
*/
const ViewUpdateResult&
updateViewOffline(const std::vector<ViewState>& frustums);
/**
* @brief Updates this view, returning the set of tiles to render in this
* view.
* @param frustums The {@link ViewState}s that the view should be updated for
* @param deltaTime The amount of time that has passed since the last call to
* updateView, in seconds.
* @returns The set of tiles to render in the updated view. This value is only
* valid until the next call to `updateView` or until the tileset is
* destroyed, whichever comes first.
*/
const ViewUpdateResult&
updateView(const std::vector<ViewState>& frustums, float deltaTime = 0.0f);
/**
* @brief Gets the total number of tiles that are currently loaded.
*/
int32_t getNumberOfTilesLoaded() const;
/**
* @brief Estimate the percentage of the tiles for the current view that have
* been loaded.
*/
float computeLoadProgress() noexcept;
/**
* @brief Invokes a function for each tile that is currently loaded.
*
* @param callback The function to invoke.
*/
void forEachLoadedTile(const std::function<void(Tile& tile)>& callback);
/**
* @brief Invokes a function for each tile that is currently loaded.
*
* @param callback The function to invoke.
*/
void forEachLoadedTile(
const std::function<void(const Tile& tile)>& callback) const;
/**
* @brief Gets the total number of bytes of tile and raster overlay data that
* are currently loaded.
*/
int64_t getTotalDataBytes() const noexcept;
/**
* @brief Gets the {@link TilesetMetadata} associated with the main or
* external tileset.json that contains a given tile. If the metadata is not
* yet loaded, this method returns nullptr.
*
* If this tileset's root tile is not yet available, this method returns
* nullptr.
*
* If the tileset has a {@link TilesetMetadata::schemaUri}, it will not
* necessarily have been loaded yet.
*
* If the provided tile is not the root tile of a tileset.json, this method
* walks up the {@link Tile::getParent} chain until it finds the closest
* root and then returns the metadata associated with the corresponding
* tileset.json.
*
* Consider calling {@link loadMetadata} instead, which will return a future
* that only resolves after the root tile is loaded and the `schemaUri`, if
* any, has been resolved.
*
* @param pTile The tile. If this parameter is nullptr, the metadata for the
* main tileset.json is returned.
* @return The found metadata, or nullptr if the root tile is not yet loaded.
*/
const TilesetMetadata* getMetadata(const Tile* pTile = nullptr) const;
/**
* @brief Asynchronously loads the metadata associated with the main
* tileset.json.
*
* Before the returned future resolves, the root tile of this tileset will be
* loaded and the {@link TilesetMetadata::schemaUri} will be loaded if one
* has been specified.
*
* If the tileset or `schemaUri` fail to load, the returned future will
* reject.
*
* @return A shared future that resolves to the loaded metadata. Once this
* future resolves, {@link getMetadata} can be used to synchronously obtain
* the same metadata instance.
*/
CesiumAsync::Future<const TilesetMetadata*> loadMetadata();
/**
* @brief Initiates an asynchronous query for the height of this tileset at a
* list of cartographic positions (longitude and latitude). The most detailed
* available tiles are used to determine each height.
*
* The height of the input positions is ignored. The output height is
* expressed in meters above the ellipsoid (usually WGS84), which should not
* be confused with a height above mean sea level.
*
* Note that {@link Tileset::updateView} must be called periodically, or else
* the returned `Future` will never resolve. If you are not using this tileset
* for visualization, you can call `updateView` with an empty list of
* frustums.
*
* @param positions The positions for which to sample heights.
* @return A future that asynchronously resolves to the result of the height
* query.
*/
CesiumAsync::Future<SampleHeightResult> sampleHeightMostDetailed(
const std::vector<CesiumGeospatial::Cartographic>& positions);
private:
/**
* @brief The result of traversing one branch of the tile hierarchy.
*
* Instances of this structure are created by the `_visit...` functions,
* and summarize the information that was gathered during the traversal
* of the respective branch, so that this information can be used by
* the parent to decide on the further traversal process.
*/
struct TraversalDetails {
/**
* @brief Whether all selected tiles in this tile's subtree are renderable.
*
* This is `true` if all selected (i.e. not culled or refined) tiles in this
* tile's subtree are renderable. If the subtree is renderable, we'll render
* it; no drama.
*/
bool allAreRenderable = true;
/**
* @brief Whether any tile in this tile's subtree was rendered in the last
* frame.
*
* This is `true` if any tiles in this tile's subtree were rendered last
* frame. If any were, we must render the subtree rather than this tile,
* because rendering this tile would cause detail to vanish that was visible
* last frame, and that's no good.
*/
bool anyWereRenderedLastFrame = false;
/**
* @brief The number of selected tiles in this tile's subtree that are not
* yet renderable.
*
* Counts the number of selected tiles in this tile's subtree that are
* not yet ready to be rendered because they need more loading. Note that
* this value will _not_ necessarily be zero when
* `allAreRenderable` is `true`, for subtle reasons.
* When `allAreRenderable` and `anyWereRenderedLastFrame` are both `false`,
* we will render this tile instead of any tiles in its subtree and the
* `allAreRenderable` value for this tile will reflect only whether _this_
* tile is renderable. The `notYetRenderableCount` value, however, will
* still reflect the total number of tiles that we are waiting on, including
* the ones that we're not rendering. `notYetRenderableCount` is only reset
* when a subtree is removed from the render queue because the
* `notYetRenderableCount` exceeds the
* {@link TilesetOptions::loadingDescendantLimit}.
*/
uint32_t notYetRenderableCount = 0;
};
/**
* @brief Input information that is constant throughout the traversal.
*
* An instance of this structure is created upon entry of the top-level
* `_visitTile` function, for the traversal for a certain frame, and
* passed on through the traversal.
*/
struct FrameState {
const std::vector<ViewState>& frustums;
std::vector<double> fogDensities;
int32_t lastFrameNumber;
int32_t currentFrameNumber;
};
TraversalDetails _renderLeaf(
const FrameState& frameState,
Tile& tile,
double tilePriority,
ViewUpdateResult& result);
TraversalDetails _renderInnerTile(
const FrameState& frameState,
Tile& tile,
ViewUpdateResult& result);
bool _kickDescendantsAndRenderTile(
const FrameState& frameState,
Tile& tile,
ViewUpdateResult& result,
TraversalDetails& traversalDetails,
size_t firstRenderedDescendantIndex,
size_t workerThreadLoadQueueIndex,
size_t mainThreadLoadQueueIndex,
bool queuedForLoad,
double tilePriority);
TileOcclusionState
_checkOcclusion(const Tile& tile, const FrameState& frameState);
TraversalDetails _visitTile(
const FrameState& frameState,
uint32_t depth,
bool meetsSse,
bool ancestorMeetsSse,
Tile& tile,
double tilePriority,
ViewUpdateResult& result);
struct CullResult {
// whether we should visit this tile
bool shouldVisit = true;
// whether this tile was culled (Note: we might still want to visit it)
bool culled = false;
};
// TODO: abstract these into a composable culling interface.
void _frustumCull(
const Tile& tile,
const FrameState& frameState,
bool cullWithChildrenBounds,
CullResult& cullResult);
void _fogCull(
const FrameState& frameState,
const std::vector<double>& distances,
CullResult& cullResult);
bool _meetsSse(
const std::vector<ViewState>& frustums,
const Tile& tile,
const std::vector<double>& distances,
bool culled) const noexcept;
TraversalDetails _visitTileIfNeeded(
const FrameState& frameState,
uint32_t depth,
bool ancestorMeetsSse,
Tile& tile,
ViewUpdateResult& result);
TraversalDetails _visitVisibleChildrenNearToFar(
const FrameState& frameState,
uint32_t depth,
bool ancestorMeetsSse,
Tile& tile,
ViewUpdateResult& result);
/**
* @brief When called on an additive-refined tile, queues it for load and adds
* it to the render list.
*
* For replacement-refined tiles, this method does nothing and returns false.
*
* @param tile The tile to potentially load and render.
* @param result The current view update result.
* @param tilePriority The load priority of this tile.
* priority.
* @param queuedForLoad True if this tile has already been queued for loading.
* @return true The additive-refined tile was queued for load and added to the
* render list.
* @return false The non-additive-refined tile was ignored.
*/
bool _loadAndRenderAdditiveRefinedTile(
Tile& tile,
ViewUpdateResult& result,
double tilePriority,
bool queuedForLoad);
void _processWorkerThreadLoadQueue();
void _processMainThreadLoadQueue();
void _unloadCachedTiles(double timeBudget) noexcept;
void _markTileVisited(Tile& tile) noexcept;
void _updateLodTransitions(
const FrameState& frameState,
float deltaTime,
ViewUpdateResult& result) const noexcept;
TilesetExternals _externals;
CesiumAsync::AsyncSystem _asyncSystem;
TilesetOptions _options;
int32_t _previousFrameNumber;
ViewUpdateResult _updateResult;
enum class TileLoadPriorityGroup {
/**
* @brief Low priority tiles that aren't needed right now, but
* are being preloaded for the future.
*/
Preload = 0,
/**
* @brief Medium priority tiles that are needed to render the current view
* the appropriate level-of-detail.
*/
Normal = 1,
/**
* @brief High priority tiles that are causing extra detail to be rendered
* in the scene, potentially creating a performance problem and aliasing
* artifacts.
*/
Urgent = 2
};
struct TileLoadTask {
/**
* @brief The tile to be loaded.
*/
Tile* pTile;
/**
* @brief The priority group (low / medium / high) in which to load this
* tile.
*
* All tiles in a higher priority group are given a chance to load before
* any tiles in a lower priority group.
*/
TileLoadPriorityGroup group;
/**
* @brief The priority of this tile within its priority group.
*
* Tiles with a _lower_ value for this property load sooner!
*/
double priority;
bool operator<(const TileLoadTask& rhs) const noexcept {
if (this->group == rhs.group)
return this->priority < rhs.priority;
else
return this->group > rhs.group;
}
};
std::vector<TileLoadTask> _mainThreadLoadQueue;
std::vector<TileLoadTask> _workerThreadLoadQueue;
std::vector<Tile*> _heightQueryLoadQueue;
Tile::LoadedLinkedList _loadedTiles;
// Holds computed distances, to avoid allocating them on the heap during tile
// selection.
std::vector<double> _distances;
// Holds the occlusion proxies of the children of a tile. Store them in this
// scratch variable so that it can allocate only when growing bigger.
std::vector<const TileOcclusionRendererProxy*> _childOcclusionProxies;
CesiumUtility::IntrusivePointer<TilesetContentManager>
_pTilesetContentManager;
std::list<TilesetHeightRequest> _heightRequests;
void addTileToLoadQueue(
Tile& tile,
TileLoadPriorityGroup priorityGroup,
double priority);
static TraversalDetails createTraversalDetailsForSingleTile(
const FrameState& frameState,
const Tile& tile,
const TileSelectionState& lastFrameSelectionState);
Tileset(const Tileset& rhs) = delete;
Tileset& operator=(const Tileset& rhs) = delete;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,172 @@
#pragma once
#include "BoundingVolume.h"
#include "Library.h"
#include "TileContent.h"
#include "TileLoadResult.h"
#include "TilesetOptions.h"
#include <Cesium3DTilesSelection/SampleHeightResult.h>
#include <CesiumAsync/AsyncSystem.h>
#include <CesiumAsync/Future.h>
#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeometry/Axis.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/Model.h>
#include <CesiumRasterOverlays/RasterOverlayDetails.h>
#include <spdlog/logger.h>
#include <functional>
#include <memory>
#include <optional>
#include <vector>
namespace Cesium3DTilesSelection {
class Tile;
class ITilesetHeightSampler;
/**
* @brief Store the parameters that are needed to load a tile
*/
struct CESIUM3DTILESSELECTION_API TileLoadInput {
/**
* @brief Creates a new instance
*
* @param tile The {@link Tile} that the content belongs to.
* @param contentOptions The content options the {@link TilesetContentLoader} will use to process the content of the tile.
* @param asyncSystem The async system to use for tile content loading.
* @param pAssetAccessor The asset accessor to make further requests with.
* @param pLogger The logger that will be used
* @param requestHeaders The request headers that will be attached to the
* request.
* @param ellipsoid The {@link CesiumGeospatial::Ellipsoid}.
*/
TileLoadInput(
const Tile& tile,
const TilesetContentOptions& contentOptions,
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor,
const std::shared_ptr<spdlog::logger>& pLogger,
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
/**
* @brief The tile that the {@link TilesetContentLoader} will request the server for the content.
*/
const Tile& tile;
/**
* @brief The content options the {@link TilesetContentLoader} will use to process the content of the tile.
*/
const TilesetContentOptions& contentOptions;
/**
* @brief The async system to run the loading in worker thread or main thread.
*/
const CesiumAsync::AsyncSystem& asyncSystem;
/**
* @brief The asset accessor to make requests for the tile content over the
* wire.
*/
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor;
/**
* @brief The logger that receives details of loading errors and warnings.
*/
const std::shared_ptr<spdlog::logger>& pLogger;
/**
* @brief The request headers that will be attached to the request.
*/
const std::vector<CesiumAsync::IAssetAccessor::THeader>& requestHeaders;
/**
* @brief The ellipsoid that this tileset uses.
*/
const CesiumGeospatial::Ellipsoid& ellipsoid;
};
/**
* @brief Store the result of creating tile's children after
* invoking {@link TilesetContentLoader::createTileChildren}
*/
struct CESIUM3DTILESSELECTION_API TileChildrenResult {
/**
* @brief The children of this tile.
*/
std::vector<Tile> children;
/**
* @brief The result of creating children for
* this tile. Note that: when receiving RetryLater status, client
* needs to load this tile's content first or its parent's content. The reason
* is that some tileset formats store the tile's children along with its
* content or store a whole subtree for every n-th level tile (e.g Quantized
* Mesh format). So unless the tile's content or the root tile of the subtree
* the tile is in is loaded, the loader won't know how to create the tile's
* children.
*/
TileLoadResultState state;
};
/**
* @brief The loader interface to load the tile content
*/
class CESIUM3DTILESSELECTION_API TilesetContentLoader {
public:
/**
* @brief Default virtual destructor
*/
virtual ~TilesetContentLoader() = default;
/**
* @brief Load the tile content.
*
* @param input The {@link TileLoadInput} that has the tile info and loading systems to load this tile's content
* @return The future of {@link TileLoadResult} that stores the tile's content
*/
virtual CesiumAsync::Future<TileLoadResult>
loadTileContent(const TileLoadInput& input) = 0;
/**
* @brief Create the tile's children.
*
* Note that: when receiving RetryLater status, client
* needs to load this tile's content first or its parent's content. The reason
* is that some tileset formats store the tile's children along with its
* content or store a whole subtree for every n-th level tile (e.g Quantized
* Mesh format). So unless the tile's content or the root tile of the subtree
* the tile is in is loaded, the loader won't know how to create the tile's
* children.
*
* @param tile The tile to create children for.
* @param ellipsoid The {@link CesiumGeospatial::Ellipsoid}.
* @return The {@link TileChildrenResult} that stores the tile's children
*/
virtual TileChildrenResult createTileChildren(
const Tile& tile,
const CesiumGeospatial::Ellipsoid& ellipsoid
CESIUM_DEFAULT_ELLIPSOID) = 0;
/**
* @brief Gets an interface that can be used to efficiently query heights from
* this tileset.
*
* Some loaders may be able to query heights very efficiently by using a web
* service or by using an analytical model, e.g., when the "terrain" is a
* simple ellipsoid.
*
* For loaders that have no particular way to query heights, this method will
* return `nullptr`, signaling that heights should be computed by downloading
* and sampling individual tiles.
*
* @return The interface that can be used to efficiently query heights from
* this loader, or `nullptr` if this loader has no particular way to do that.
* The returned instance must have a lifetime that is at least as long as the
* loader itself.
*/
virtual ITilesetHeightSampler* getHeightSampler() { return nullptr; }
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,82 @@
#pragma once
#include "Library.h"
#include "TileOcclusionRendererProxy.h"
#include "TilesetSharedAssetSystem.h"
#include "spdlog-cesium.h"
#include <CesiumAsync/AsyncSystem.h>
#include <memory>
namespace CesiumAsync {
class IAssetAccessor;
class ITaskProcessor;
} // namespace CesiumAsync
namespace CesiumUtility {
class CreditSystem;
}
namespace Cesium3DTilesSelection {
class IPrepareRendererResources;
/**
* @brief External interfaces used by a {@link Tileset}.
*
* Not supposed to be used by clients.
*/
class CESIUM3DTILESSELECTION_API TilesetExternals final {
public:
/**
* @brief An external {@link CesiumAsync::IAssetAccessor}.
*/
std::shared_ptr<CesiumAsync::IAssetAccessor> pAssetAccessor;
/**
* @brief An external {@link IPrepareRendererResources}.
*/
std::shared_ptr<IPrepareRendererResources> pPrepareRendererResources;
/**
* @brief The async system to use to do work in threads.
*
* The tileset will automatically call
* {@link CesiumAsync::AsyncSystem::dispatchMainThreadTasks} from
* {@link Tileset::updateView}.
*/
CesiumAsync::AsyncSystem asyncSystem;
/**
* @brief An external {@link CesiumUtility::CreditSystem} that can be used to manage credit
* strings and track which which credits to show and remove from the screen
* each frame.
*/
std::shared_ptr<CesiumUtility::CreditSystem> pCreditSystem;
/**
* @brief A spdlog logger that will receive log messages.
*
* If not specified, defaults to `spdlog::default_logger()`.
*/
std::shared_ptr<spdlog::logger> pLogger = spdlog::default_logger();
/**
* @brief A pool of renderer proxies to determine the occlusion state of
* tile bounding volumes.
*
* If not specified, the traversal will not attempt to leverage occlusion
* information.
*/
std::shared_ptr<TileOcclusionRendererProxyPool> pTileOcclusionProxyPool =
nullptr;
/**
* @brief The shared asset system used to facilitate sharing of common assets,
* such as images, between and within tilesets.
*/
CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem> pSharedAssetSystem =
TilesetSharedAssetSystem::getDefault();
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,60 @@
#pragma once
#include <memory>
#include <string>
namespace CesiumAsync {
class IAssetRequest;
}
namespace Cesium3DTilesSelection {
class Tileset;
/**
* @brief The type of load that failed in `TilesetLoadFailureDetails`.
*/
enum class TilesetLoadType {
/**
* @brief An unknown load error.
*/
Unknown,
/**
* @brief A Cesium ion asset endpoint.
*/
CesiumIon,
/**
* @brief The root tileset.json.
*/
TilesetJson
};
/**
* Information on a tileset that failed to load.
*/
class TilesetLoadFailureDetails {
public:
/**
* @brief The tileset that encountered the load failure.
*/
const Tileset* pTileset = nullptr;
/**
* @brief The type of request that failed to load.
*/
TilesetLoadType type = TilesetLoadType::Unknown;
/**
* The status code of the HTTP response.
*/
uint16_t statusCode{200};
/**
* @brief A human-readable explanation of what failed.
*/
std::string message = "";
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,77 @@
#pragma once
#include "Library.h"
#include <Cesium3DTiles/GroupMetadata.h>
#include <Cesium3DTiles/Schema.h>
#include <CesiumAsync/SharedFuture.h>
#include <optional>
#include <string>
#include <vector>
namespace CesiumAsync {
class AsyncSystem;
class IAssetAccessor;
} // namespace CesiumAsync
namespace Cesium3DTilesSelection {
/**
* @brief Holds the metadata associated with a {@link Tileset} or an external
* tileset.
*/
class CESIUM3DTILESSELECTION_API TilesetMetadata {
public:
~TilesetMetadata() noexcept;
/**
* @brief An object defining the structure of metadata classes and enums. When
* this is defined, then `schemaUri` shall be undefined.
*/
std::optional<Cesium3DTiles::Schema> schema;
/**
* @brief The URI (or IRI) of the external schema file. When this is defined,
* then `schema` shall be undefined.
*/
std::optional<std::string> schemaUri;
/**
* @brief An array of groups that tile content may belong to. Each element of
* this array is a metadata entity that describes the group. The tile content
* `group` property is an index into this array.
*/
std::vector<Cesium3DTiles::GroupMetadata> groups;
/**
* @brief A metadata entity that is associated with this tileset.
*/
std::optional<Cesium3DTiles::MetadataEntity> metadata;
/**
* @brief Asynchronously loads the {@link schema} from the {@link schemaUri}.
* If the {@link schemaUri} does not contain a value, this method does
* nothing and returns an already-resolved future.
*
* Calling this method multiple times will return the same shared future each
* time, unless the {@link schemaUri} is changed. In that case, when this
* method is called, the previous load is canceled and the new one begins.
*
* @param asyncSystem The async system used to do work in threads.
* @param pAssetAccessor The asset accessor used to request the schema from
* the schemaUri.
* @return A future that resolves when the schema has been loaded from the
* schemaUri.
*/
CesiumAsync::SharedFuture<void>& loadSchemaUri(
const CesiumAsync::AsyncSystem& asyncSystem,
const std::shared_ptr<CesiumAsync::IAssetAccessor>& pAssetAccessor);
private:
std::optional<CesiumAsync::SharedFuture<void>> _loadingFuture;
std::optional<std::string> _loadingSchemaUri;
std::shared_ptr<bool> _pLoadingCanceled;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,333 @@
#pragma once
#include "Library.h"
#include <CesiumGeospatial/Ellipsoid.h>
#include <CesiumGltf/Ktx2TranscodeTargets.h>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <vector>
namespace Cesium3DTilesSelection {
class ITileExcluder;
class TilesetLoadFailureDetails;
/**
* @brief Options for configuring the parsing of a {@link Tileset}'s content
* and construction of Gltf models.
*/
struct CESIUM3DTILESSELECTION_API TilesetContentOptions {
/**
* @brief Whether to include a water mask within the Gltf extras.
*
* Currently only applicable for quantized-mesh tilesets that support the
* water mask extension.
*/
bool enableWaterMask = false;
/**
* @brief Whether to generate smooth normals when normals are missing in the
* original Gltf.
*
* According to the Gltf spec: "When normals are not specified, client
* implementations should calculate flat normals." However, calculating flat
* normals requires duplicating vertices. This option allows the gltfs to be
* sent with explicit smooth normals when the original gltf was missing
* normals.
*/
bool generateMissingNormalsSmooth = false;
/**
* @brief For each possible input transmission format, this struct names
* the ideal target gpu-compressed pixel format to transcode to.
*/
CesiumGltf::Ktx2TranscodeTargets ktx2TranscodeTargets;
/**
* @brief Whether or not to transform texture coordinates during load when
* textures have the `KHR_texture_transform` extension. Set this to false if
* texture coordinates will be transformed another way, such as in a vertex
* shader.
*/
bool applyTextureTransform = true;
};
/**
* @brief Defines the fog density at a certain height.
*
* @see TilesetOptions::fogDensityTable
*/
struct CESIUM3DTILESSELECTION_API FogDensityAtHeight {
/** @brief The height. */
double cameraHeight;
/** @brief The fog density. */
double fogDensity;
};
/**
* @brief Additional options for configuring a {@link Tileset}.
*/
struct CESIUM3DTILESSELECTION_API TilesetOptions {
/**
* @brief A credit text for this tileset, if needed.
*/
std::optional<std::string> credit;
/**
* @brief Whether or not to display tileset's credits on the screen.
*/
bool showCreditsOnScreen = false;
/**
* @brief The maximum number of pixels of error when rendering this tileset.
* This is used to select an appropriate level-of-detail.
*
* When a tileset uses the older layer.json / quantized-mesh format rather
* than 3D Tiles, this value is effectively divided by 8.0. So the default
* value of 16.0 corresponds to the standard value for quantized-mesh terrain
* of 2.0.
*/
double maximumScreenSpaceError = 16.0;
/**
* @brief The maximum number of tiles that may simultaneously be in the
* process of loading.
*/
uint32_t maximumSimultaneousTileLoads = 20;
/**
* @brief The maximum number of subtrees that may simultaneously be in the
* process of loading.
*/
uint32_t maximumSimultaneousSubtreeLoads = 20;
/**
* @brief Indicates whether the ancestors of rendered tiles should be
* preloaded. Setting this to true optimizes the zoom-out experience and
* provides more detail in newly-exposed areas when panning. The down side is
* that it requires loading more tiles.
*/
bool preloadAncestors = true;
/**
* @brief Indicates whether the siblings of rendered tiles should be
* preloaded. Setting this to true causes tiles with the same parent as a
* rendered tile to be loaded, even if they are culled. Setting this to true
* may provide a better panning experience at the cost of loading more tiles.
*/
bool preloadSiblings = true;
/**
* @brief The number of loading descendant tiles that is considered "too
* many". If a tile has too many loading descendants, that tile will be loaded
* and rendered before any of its descendants are loaded and rendered. This
* means more feedback for the user that something is happening at the cost of
* a longer overall load time. Setting this to 0 will cause each tile level to
* be loaded successively, significantly increasing load time. Setting it to a
* large number (e.g. 1000) will minimize the number of tiles that are loaded
* but tend to make detail appear all at once after a long wait.
*/
uint32_t loadingDescendantLimit = 20;
/**
* @brief Never render a tileset with missing tiles.
*
* When true, the tileset will guarantee that the tileset will never be
* rendered with holes in place of tiles that are not yet loaded. It does this
* by refusing to refine a parent tile until all of its child tiles are ready
* to render. Thus, when the camera moves, we will always have something -
* even if it's low resolution - to render any part of the tileset that
* becomes visible. When false, overall loading will be faster, but
* newly-visible parts of the tileset may initially be blank.
*/
bool forbidHoles = false;
/**
* @brief Enable culling of tiles against the frustum.
*/
bool enableFrustumCulling = true;
/**
* @brief Enable culling of occluded tiles, as reported by the renderer.
*/
bool enableOcclusionCulling = true;
/**
* @brief Wait to refine until the occlusion state of a tile is known.
*
* Only applicable when enableOcclusionInfo is true. Enabling this option may
* cause a small delay between when a tile is needed according to the SSE and
* when the tile load is kicked off. On the other hand, this delay could
* allow the occlusion system to avoid loading a tile entirely if it is
* found to be unnecessary a few frames later.
*/
bool delayRefinementForOcclusion = true;
/**
* @brief Enable culling of tiles that cannot be seen through atmospheric fog.
*/
bool enableFogCulling = true;
/**
* @brief Whether culled tiles should be refined until they meet
* culledScreenSpaceError.
*
* When true, any culled tile from a disabled culling stage will be refined
* until it meets the specified culledScreenSpaceError. Otherwise, its
* screen-space error check will be disabled altogether and it will not bother
* to refine any futher.
*/
bool enforceCulledScreenSpaceError = true;
/**
* @brief The screen-space error to refine until for culled tiles from
* disabled culling stages.
*
* When enforceCulledScreenSpaceError is true, culled tiles from disabled
* culling stages will be refined until they meet this screen-space error
* value.
*/
double culledScreenSpaceError = 64.0;
/**
* @brief The maximum number of bytes that may be cached.
*
* Note that this value, even if 0, will never
* cause tiles that are needed for rendering to be unloaded. However, if the
* total number of loaded bytes is greater than this value, tiles will be
* unloaded until the total is under this number or until only required tiles
* remain, whichever comes first.
*/
int64_t maximumCachedBytes = 512 * 1024 * 1024;
/**
* @brief A table that maps the camera height above the ellipsoid to a fog
* density. Tiles that are in full fog are culled. The density of the fog
* increases as this number approaches 1.0 and becomes less dense as it
* approaches zero. The more dense the fog is, the more aggressively the tiles
* are culled. For example, if the camera is a height of 1000.0m above the
* ellipsoid, increasing the value to 3.0e-3 will cause many tiles close to
* the viewer be culled. Decreasing the value will push the fog further from
* the viewer, but decrease performance as more of the tiles are rendered.
* Tiles are culled when `1.0 - glm::exp(-(distance * distance * fogDensity *
* fogDensity))` is >= 1.0.
*/
std::vector<FogDensityAtHeight> fogDensityTable = {
{359.393, 2.0e-5}, {800.749, 2.0e-4}, {1275.6501, 1.0e-4},
{2151.1192, 7.0e-5}, {3141.7763, 5.0e-5}, {4777.5198, 4.0e-5},
{6281.2493, 3.0e-5}, {12364.307, 1.9e-5}, {15900.765, 1.0e-5},
{49889.0549, 8.5e-6}, {78026.8259, 6.2e-6}, {99260.7344, 5.8e-6},
{120036.3873, 5.3e-6}, {151011.0158, 5.2e-6}, {156091.1953, 5.1e-6},
{203849.3112, 4.2e-6}, {274866.9803, 4.0e-6}, {319916.3149, 3.4e-6},
{493552.0528, 2.6e-6}, {628733.5874, 2.2e-6}, {1000000.0, 0.0}};
/**
* @brief Whether to render tiles directly under the camera, even if they're
* not in the view frustum.
*
* This is useful for detecting the camera's collision with terrain and other
* models. NOTE: This option currently only works with tiles that use a
* `region` as their bounding volume. It is ignored for other bounding volume
* types.
*/
bool renderTilesUnderCamera = true;
/**
* @brief A list of interfaces that are given an opportunity to exclude tiles
* from loading and rendering. If any of the excluders indicate that a tile
* should not be loaded, it will not be loaded.
*/
std::vector<std::shared_ptr<ITileExcluder>> excluders;
/**
* @brief A callback function that is invoked when a tileset resource fails to
* load.
*
* Tileset resources include a Cesium ion asset endpoint, a tileset's root
* tileset.json or layer.json, an individual tile's content, or an implicit
* tiling subtree.
*/
std::function<void(const TilesetLoadFailureDetails&)> loadErrorCallback;
/**
* @brief Whether to keep tiles loaded during a transition period when
* switching to a different LOD tile.
*
* For each tile, {@link TileRenderContent::getLodTransitionFadePercentage} will
* indicate to the client how faded to render the tile throughout the
* transition. Tile fades can be used to mask LOD transitions and make them
* appear less abrupt and jarring.
*/
bool enableLodTransitionPeriod = false;
/**
* @brief How long it should take to transition between tiles of different
* LODs, in seconds.
*
* When a tile refines or unrefines to a higher or lower LOD tile, a fade
* can optionally be applied to smooth the transition. This value determines
* how many seconds the whole transition should take. Note that the old tile
* doesn't start fading out until the new tile fully fades in.
*/
float lodTransitionLength = 1.0f;
/**
* @brief Whether to kick descendants while a tile is still fading in.
*
* This does not delay loading of descendants, but it keeps them off the
* render list while the tile is fading in. If this is false, the tile
* currently fading in will pop in to full opacity if descendants are
* rendered (this counteracts the benefits of LOD transition blending).
*
*/
bool kickDescendantsWhileFadingIn = true;
/**
* @brief A soft limit on how long (in milliseconds) to spend on the
* main-thread part of tile loading each frame (each call to
* Tileset::updateView). A value of 0.0 indicates that all pending
* main-thread loads should be completed each tick.
*
* Setting this to too low of a value will impede overall tile load progress,
* creating a discernable load latency.
*/
double mainThreadLoadingTimeLimit = 0.0;
/**
* @brief A soft limit on how long (in milliseconds) to spend unloading
* cached tiles each frame (each call to Tileset::updateView). A value of 0.0
* indicates that the tile cache should not throttle unloading tiles.
*/
double tileCacheUnloadTimeLimit = 0.0;
/**
* @brief Options for configuring the parsing of a {@link Tileset}'s content
* and construction of Gltf models.
*/
TilesetContentOptions contentOptions;
/**
* @brief Arbitrary data that will be passed to {@link IPrepareRendererResources::prepareInLoadThread}.
*
* This object is copied and given to tile preparation threads,
* so it must be inexpensive to copy.
*/
std::any rendererOptions;
/**
* @brief The ellipsoid to use for this tileset.
* This value shouldn't be changed after the tileset is constructed. If you
* need to change a tileset's ellipsoid, please recreate the tileset.
*
* If no ellipsoid is set, Ellipsoid::WGS84 will be used by default.
*/
CesiumGeospatial::Ellipsoid ellipsoid = CesiumGeospatial::Ellipsoid::WGS84;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,22 @@
#pragma once
#include <CesiumGltfReader/GltfSharedAssetSystem.h>
namespace Cesium3DTilesSelection {
/**
* @brief Contains assets that are potentially shared across multiple Tilesets.
*/
class TilesetSharedAssetSystem
: public CesiumGltfReader::GltfSharedAssetSystem {
public:
/**
* @brief Obtains an `IntrusivePointer` to the `TilesetSharedAssetSystem`
* singleton.
*/
static CesiumUtility::IntrusivePointer<TilesetSharedAssetSystem> getDefault();
virtual ~TilesetSharedAssetSystem() = default;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,182 @@
#pragma once
#include "BoundingVolume.h"
#include "Library.h"
#include <CesiumGeometry/CullingVolume.h>
#include <CesiumGeometry/Plane.h>
#include <CesiumGeospatial/Cartographic.h>
#include <CesiumGeospatial/Ellipsoid.h>
#include <glm/mat3x3.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <vector>
namespace Cesium3DTilesSelection {
/**
* @brief The state of the view that is used during the traversal of a tileset.
*
* An instance of a view state can be created with the {@link create} function.
*/
class CESIUM3DTILESSELECTION_API ViewState final {
// TODO: Add support for orthographic and off-center perspective frustums
public:
/**
* @brief Creates a new instance of a view state.
*
* @param position The position of the eye point of the camera.
* @param direction The view direction vector of the camera.
* @param up The up vector of the camera.
* @param viewportSize The size of the viewport, in pixels.
* @param horizontalFieldOfView The horizontal field-of-view (opening)
* angle of the camera, in radians.
* @param verticalFieldOfView The vertical field-of-view (opening)
* angle of the camera, in radians.
* @param ellipsoid The ellipsoid that will be used to compute the
* {@link ViewState#getPositionCartographic cartographic position}
* from the cartesian position.
* Default value: {@link CesiumGeospatial::Ellipsoid::WGS84}.
*/
static ViewState create(
const glm::dvec3& position,
const glm::dvec3& direction,
const glm::dvec3& up,
const glm::dvec2& viewportSize,
double horizontalFieldOfView,
double verticalFieldOfView,
const CesiumGeospatial::Ellipsoid& ellipsoid CESIUM_DEFAULT_ELLIPSOID);
/**
* @brief Gets the position of the camera in Earth-centered, Earth-fixed
* coordinates.
*/
const glm::dvec3& getPosition() const noexcept { return this->_position; }
/**
* @brief Gets the look direction of the camera in Earth-centered, Earth-fixed
* coordinates.
*/
const glm::dvec3& getDirection() const noexcept { return this->_direction; }
/**
* @brief Gets the up direction of the camera in Earth-centered, Earth-fixed
* coordinates.
*/
const glm::dvec3& getUp() const noexcept { return this->_up; }
/**
* @brief Gets the position of the camera as a longitude / latitude / height.
*
* The result may be `std::nullopt` if the Cartesian position is
* very near the center of the Ellipsoid.
*/
const std::optional<CesiumGeospatial::Cartographic>&
getPositionCartographic() const noexcept {
return this->_positionCartographic;
}
/**
* @brief Gets the size of the viewport in pixels.
*/
const glm::dvec2& getViewportSize() const noexcept {
return this->_viewportSize;
}
/**
* @brief Gets the horizontal field-of-view angle in radians.
*/
double getHorizontalFieldOfView() const noexcept {
return this->_horizontalFieldOfView;
}
/**
* @brief Gets the vertical field-of-view angle in radians.
*/
double getVerticalFieldOfView() const noexcept {
return this->_verticalFieldOfView;
}
/**
* @brief Returns whether the given {@link BoundingVolume} is visible for this
* camera
*
* Returns whether the given bounding volume is visible for this camera,
* meaning that the given volume is at least partially contained in
* the frustum of this camera.
*
* @return Whether the bounding volume is visible
*/
bool
isBoundingVolumeVisible(const BoundingVolume& boundingVolume) const noexcept;
/**
* @brief Computes the squared distance to the given {@link BoundingVolume}.
*
* Computes the squared euclidean distance from the position of this camera
* to the closest point of the given bounding volume.
*
* @param boundingVolume The bounding volume
* @returns The squared distance
*/
double computeDistanceSquaredToBoundingVolume(
const BoundingVolume& boundingVolume) const noexcept;
/**
* @brief Computes the screen space error from a given geometric error
*
* Computes the screen space error (SSE) that results from the given
* geometric error, when it is viewed with this camera from the given
* distance.
*
* The given distance will be clamped to a small positive value if
* it is negative or too close to zero.
*
* @param geometricError The geometric error
* @param distance The viewing distance
* @return The screen space error
*/
double computeScreenSpaceError(double geometricError, double distance)
const noexcept;
private:
/**
* @brief Creates a new instance.
*
* @param position The position of the eye point of the camera.
* @param direction The view direction vector of the camera.
* @param up The up vector of the camera.
* @param viewportSize The size of the viewport, in pixels.
* @param horizontalFieldOfView The horizontal field-of-view (opening)
* angle of the camera, in radians.
* @param verticalFieldOfView The vertical field-of-view (opening)
* angle of the camera, in radians.
*/
ViewState(
const glm::dvec3& position,
const glm::dvec3& direction,
const glm::dvec3& up,
const glm::dvec2& viewportSize,
double horizontalFieldOfView,
double verticalFieldOfView,
const std::optional<CesiumGeospatial::Cartographic>& positionCartographic,
const CesiumGeospatial::Ellipsoid& ellipsoid);
const glm::dvec3 _position;
const glm::dvec3 _direction;
const glm::dvec3 _up;
const glm::dvec2 _viewportSize;
const double _horizontalFieldOfView;
const double _verticalFieldOfView;
const CesiumGeospatial::Ellipsoid _ellipsoid;
const double _sseDenominator;
const std::optional<CesiumGeospatial::Cartographic> _positionCartographic;
const CullingVolume _cullingVolume;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,91 @@
#pragma once
#include "Library.h"
#include <cstdint>
#include <unordered_set>
#include <vector>
namespace Cesium3DTilesSelection {
class Tile;
/**
* @brief Reports the results of {@link Tileset::updateView}.
*
* Users of a {@link Tileset} will call {@link Tileset::updateView} and receive
* this structure so that they can update the state of their rendering system
* accordingly. The tileset will internally keep track the current state of the
* tiles as their {@link Tile::getLastSelectionState} throughout the rendering
* process, and use this structure to provide information about the state
* changes of tiles to clients.
*/
class CESIUM3DTILESSELECTION_API ViewUpdateResult final {
public:
/**
* @brief The tiles that were selected by the tileset traversal this frame.
* These tiles should be rendered by the client.
*
* Tiles in this list may be fading in if
* {@link TilesetOptions::enableLodTransitionPeriod} is true.
*/
std::vector<Tile*> tilesToRenderThisFrame;
/**
* @brief Tiles on this list are no longer selected for rendering.
*
* If {@link TilesetOptions::enableLodTransitionPeriod} is true they may be
* fading out. If a tile's {TileRenderContent::lodTransitionPercentage} is 0
* or lod transitions are disabled, the tile should be hidden right away.
*/
std::unordered_set<Tile*> tilesFadingOut;
/**
* @brief The number of tiles in the worker thread load queue.
*/
int32_t workerThreadTileLoadQueueLength = 0;
/**
* @brief The number of tiles in the main thread load queue.
*/
int32_t mainThreadTileLoadQueueLength = 0;
/**
* @brief The number of tiles visited during tileset traversal this frame.
*/
uint32_t tilesVisited = 0;
/**
* @brief The number of culled tiles visited during tileset traversal this
* frame.
*/
uint32_t culledTilesVisited = 0;
/**
* @brief The number of tiles that were skipped because they were culled
* during tileset traversal this frame.
*/
uint32_t tilesCulled = 0;
/**
* @brief The number of tiles occluded this frame.
*/
uint32_t tilesOccluded = 0;
/**
* @brief The number of tiles still waiting to obtain a \ref
* TileOcclusionState this frame.
*/
uint32_t tilesWaitingForOcclusionResults = 0;
/**
* @brief The number of tiles kicked from the render list this frame.
*/
uint32_t tilesKicked = 0;
/**
* @brief The maximum depth of the tile tree visited this frame.
*/
uint32_t maxDepthVisited = 0;
/**
* @brief The frame number. This is incremented every time \ref
* Tileset::updateView is called.
*/
int32_t frameNumber = 0;
};
} // namespace Cesium3DTilesSelection

View File

@ -0,0 +1,13 @@
#pragma once
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#include <spdlog/spdlog.h>
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif

View File

@ -0,0 +1,18 @@
#pragma once
/**
* @brief Classes for writing [3D Tiles](https://github.com/CesiumGS/3d-tiles).
*
* @mermaid-interactive{dependencies/Cesium3DTilesWriter}
*/
namespace Cesium3DTilesWriter {}
#if defined(_WIN32) && defined(CESIUM_SHARED)
#ifdef CESIUM3DTILESWRITER_BUILDING
#define CESIUM3DTILESWRITER_API __declspec(dllexport)
#else
#define CESIUM3DTILESWRITER_API __declspec(dllimport)
#endif
#else
#define CESIUM3DTILESWRITER_API
#endif

View File

@ -0,0 +1,81 @@
#pragma once
#include "Cesium3DTilesWriter/Library.h"
#include <CesiumJsonWriter/ExtensionWriterContext.h>
// forward declarations
namespace Cesium3DTiles {
struct Schema;
}
namespace Cesium3DTilesWriter {
/**
* @brief The result of writing a schema with
* {@link SchemaWriter::writeSchema}.
*/
struct CESIUM3DTILESWRITER_API SchemaWriterResult {
/**
* @brief The final generated std::vector<std::byte> of the schema JSON.
*/
std::vector<std::byte> schemaBytes;
/**
* @brief Errors, if any, that occurred during the write process.
*/
std::vector<std::string> errors;
/**
* @brief Warnings, if any, that occurred during the write process.
*/
std::vector<std::string> warnings;
};
/**
* @brief Options for how to write a schema.
*/
struct CESIUM3DTILESWRITER_API SchemaWriterOptions {
/**
* @brief If the schema JSON should be pretty printed.
*/
bool prettyPrint = false;
};
/**
* @brief Writes schemas.
*/
class CESIUM3DTILESWRITER_API SchemaWriter {
public:
/**
* @brief Constructs a new instance.
*/
SchemaWriter();
/**
* @brief Gets the context used to control how schema extensions are written.
*/
CesiumJsonWriter::ExtensionWriterContext& getExtensions();
/**
* @brief Gets the context used to control how schema extensions are written.
*/
const CesiumJsonWriter::ExtensionWriterContext& getExtensions() const;
/**
* @brief Serializes the provided schema object into a byte vector using the
* provided flags to convert.
*
* @param schema The schema.
* @param options Options for how to write the schema.
* @return The result of writing the schema.
*/
SchemaWriterResult writeSchema(
const Cesium3DTiles::Schema& schema,
const SchemaWriterOptions& options = SchemaWriterOptions()) const;
private:
CesiumJsonWriter::ExtensionWriterContext _context;
};
} // namespace Cesium3DTilesWriter

Some files were not shown because too many files have changed in this diff Show More