Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

### ? - ?

##### Additions :tada:

- Added `CesiumVectorTilesRasterOverlay` supporting vector data loaded from 3D Tiles tilesets.
- Added support for displaying points in `CesiumGeoJsonDocumentRasterOverlay` and `CesiumVectorTilesRasterOverlay`.

##### Fixes :wrench:

- Added missing includes that introduced compilation failures when building the plugin from source against UE 5.7's bundled clang 20.1.8 toolchain (introduced in v2.25.0 by #1685; binary plugin users were unaffected).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "CesiumGeometry/QuadtreeTilingScheme.h"
#include "CesiumGeospatial/GlobeRectangle.h"
#include "CesiumGeospatial/Projection.h"
#include "CesiumRasterOverlays/GeoJsonDocumentRasterOverlay.h"
#include "CesiumVectorData/VectorStyle.h"
#include "CesiumVectorOverlays/GeoJsonDocumentRasterOverlay.h"

#include "CesiumRuntime.h"

Expand Down Expand Up @@ -52,7 +52,7 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay(
return nullptr;
}

CesiumRasterOverlays::GeoJsonDocumentRasterOverlayOptions vectorOptions{
CesiumVectorOverlays::GeoJsonDocumentRasterOverlayOptions vectorOptions{
this->DefaultStyle.toNative(),
options.ellipsoid,
this->MipLevels};
Expand All @@ -63,7 +63,7 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay(
this->CesiumIonServer = UCesiumIonServer::GetServerForNewObjects();
}

return std::make_unique<CesiumRasterOverlays::GeoJsonDocumentRasterOverlay>(
return std::make_unique<CesiumVectorOverlays::GeoJsonDocumentRasterOverlay>(
TCHAR_TO_UTF8(*this->MaterialLayerKey),
wrapLoaderFuture(
this,
Expand All @@ -85,7 +85,7 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay(
headers.push_back({TCHAR_TO_UTF8(*k), TCHAR_TO_UTF8(*v)});
}

return std::make_unique<CesiumRasterOverlays::GeoJsonDocumentRasterOverlay>(
return std::make_unique<CesiumVectorOverlays::GeoJsonDocumentRasterOverlay>(
TCHAR_TO_UTF8(*this->MaterialLayerKey),
wrapLoaderFuture(
this,
Expand All @@ -102,7 +102,7 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay(
this->OnDocumentLoaded.Execute(this->GeoJsonDocument);
}

return std::make_unique<CesiumRasterOverlays::GeoJsonDocumentRasterOverlay>(
return std::make_unique<CesiumVectorOverlays::GeoJsonDocumentRasterOverlay>(
getAsyncSystem(),
TCHAR_TO_UTF8(*this->MaterialLayerKey),
this->GeoJsonDocument.GetDocument(),
Expand Down
79 changes: 61 additions & 18 deletions Source/CesiumRuntime/Private/CesiumVectorStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ lineStyleToNative(const FCesiumVectorLineStyle& InLineStyle) {
InLineStyle.Width,
(CesiumVectorData::LineWidthMode)InLineStyle.WidthMode};
}

CesiumVectorData::ColorStyle
fillStyleToNative(const FCesiumVectorPolygonFillStyle& fillStyle) {
return CesiumVectorData::ColorStyle{
CesiumUtility::Color{
fillStyle.Color.R,
fillStyle.Color.G,
fillStyle.Color.B,
fillStyle.Color.A},
(CesiumVectorData::ColorMode)fillStyle.ColorMode};
}
} // namespace

CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const {
Expand All @@ -32,32 +43,34 @@ CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const {
(uint8)CesiumVectorData::LineWidthMode::Pixels ==
(uint8)ECesiumVectorLineWidthMode::Pixels);

std::optional<CesiumVectorData::ColorStyle> fillStyle;
if (this->PolygonStyle.Fill) {
fillStyle = CesiumVectorData::ColorStyle{
CesiumUtility::Color{
this->PolygonStyle.FillStyle.Color.R,
this->PolygonStyle.FillStyle.Color.G,
this->PolygonStyle.FillStyle.Color.B,
this->PolygonStyle.FillStyle.Color.A},
(CesiumVectorData::ColorMode)this->PolygonStyle.FillStyle.ColorMode};
}

return CesiumVectorData::VectorStyle{
lineStyleToNative(this->LineStyle),
CesiumVectorData::PolygonStyle{
fillStyle,
this->PolygonStyle.Fill
? std::optional<CesiumVectorData::ColorStyle>(
fillStyleToNative(this->PolygonStyle.FillStyle))
: std::nullopt,
this->PolygonStyle.Outline
? std::optional<CesiumVectorData::LineStyle>(
lineStyleToNative(this->PolygonStyle.OutlineStyle))
: std::nullopt},
CesiumVectorData::PointStyle{
this->PointStyle.Radius,
this->PointStyle.Fill
? std::optional<CesiumVectorData::ColorStyle>(
fillStyleToNative(this->PointStyle.FillStyle))
: std::nullopt,
this->PointStyle.Outline
? std::optional<CesiumVectorData::LineStyle>(
lineStyleToNative(this->PointStyle.OutlineStyle))
: std::nullopt}};
}

FCesiumVectorStyle
FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) {
FCesiumVectorLineStyle OutlineStyle;
FCesiumVectorLineStyle PolygonOutlineStyle;
if (style.polygon.outline) {
OutlineStyle = FCesiumVectorLineStyle{
PolygonOutlineStyle = FCesiumVectorLineStyle{
FColor(
(uint8)style.polygon.outline->color.r,
(uint8)style.polygon.outline->color.g,
Expand All @@ -68,9 +81,9 @@ FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) {
(ECesiumVectorLineWidthMode)style.polygon.outline->widthMode};
}

FCesiumVectorPolygonFillStyle FillStyle;
FCesiumVectorPolygonFillStyle PolygonFillStyle;
if (style.polygon.fill) {
FillStyle = FCesiumVectorPolygonFillStyle{
PolygonFillStyle = FCesiumVectorPolygonFillStyle{
FColor(
(uint8)style.polygon.fill->color.r,
(uint8)style.polygon.fill->color.g,
Expand All @@ -79,6 +92,30 @@ FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) {
(ECesiumVectorColorMode)style.polygon.fill->colorMode};
}

FCesiumVectorLineStyle PointOutlineStyle;
if (style.point.outline) {
PolygonOutlineStyle = FCesiumVectorLineStyle{
FColor(
(uint8)style.point.outline->color.r,
(uint8)style.point.outline->color.g,
(uint8)style.point.outline->color.b,
(uint8)style.point.outline->color.a),
Comment thread
azrogers marked this conversation as resolved.
Outdated
(ECesiumVectorColorMode)style.point.outline->colorMode,
style.point.outline->width,
(ECesiumVectorLineWidthMode)style.point.outline->widthMode};
}

FCesiumVectorPolygonFillStyle PointFillStyle;
if (style.point.fill) {
PolygonFillStyle = FCesiumVectorPolygonFillStyle{
FColor(
(uint8)style.point.fill->color.r,
(uint8)style.point.fill->color.g,
(uint8)style.point.fill->color.b,
(uint8)style.point.fill->color.a),
(ECesiumVectorColorMode)style.point.fill->colorMode};
}

return FCesiumVectorStyle{
FCesiumVectorLineStyle{
FColor(
Expand All @@ -91,7 +128,13 @@ FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) {
(ECesiumVectorLineWidthMode)style.line.widthMode},
FCesiumVectorPolygonStyle{
style.polygon.fill.has_value(),
FillStyle,
PolygonFillStyle,
style.polygon.outline.has_value(),
OutlineStyle}};
PolygonOutlineStyle},
FCesiumVectorPointStyle{
(float)style.point.radius,
style.point.fill.has_value(),
PointFillStyle,
style.point.outline.has_value(),
PointOutlineStyle}};
}
50 changes: 50 additions & 0 deletions Source/CesiumRuntime/Private/CesiumVectorTilesRasterOverlay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2020-2024 CesiumGS, Inc. and Contributors

#include "CesiumVectorTilesRasterOverlay.h"

#include <CesiumAsync/IAssetAccessor.h>
#include <CesiumGeometry/QuadtreeTilingScheme.h>
#include <CesiumGeospatial/GlobeRectangle.h>
#include <CesiumGeospatial/Projection.h>
#include <CesiumVectorData/VectorStyle.h>
#include <CesiumVectorOverlays/VectorTilesRasterOverlay.h>

#include "CesiumCustomVersion.h"
#include "CesiumRuntime.h"

#include <vector>

std::unique_ptr<CesiumRasterOverlays::RasterOverlay>
UCesiumVectorTilesRasterOverlay::CreateOverlay(
const CesiumRasterOverlays::RasterOverlayOptions& options) {
std::vector<CesiumAsync::IAssetAccessor::THeader> headers;
headers.reserve(this->RequestHeaders.Num());

for (auto& [k, v] : this->RequestHeaders) {
headers.push_back({TCHAR_TO_UTF8(*k), TCHAR_TO_UTF8(*v)});
}

CesiumVectorOverlays::VectorTilesRasterOverlayOptions vectorOptions{
this->DefaultStyle.toNative(),
headers};

if (this->Source == ECesiumVectorTilesRasterOverlaySource::FromCesiumIon) {
if (!IsValid(this->CesiumIonServer)) {
this->CesiumIonServer = UCesiumIonServer::GetServerForNewObjects();
}

return std::make_unique<CesiumVectorOverlays::VectorTilesRasterOverlay>(
TCHAR_TO_UTF8(*this->MaterialLayerKey),
this->IonAssetID,
TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken),
std::string(TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)) + "/",
vectorOptions,
options);
}

return std::make_unique<CesiumVectorOverlays::VectorTilesRasterOverlay>(
TCHAR_TO_UTF8(*this->MaterialLayerKey),
TCHAR_TO_UTF8(*this->Url),
vectorOptions,
options);
Comment thread
azrogers marked this conversation as resolved.
}
49 changes: 49 additions & 0 deletions Source/CesiumRuntime/Public/CesiumVectorStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,49 @@ struct FCesiumVectorPolygonStyle {
FCesiumVectorLineStyle OutlineStyle;
};

USTRUCT(BlueprintType)
struct FCesiumVectorPointStyle {
GENERATED_BODY()

/**
* The radius of the point.
Comment thread
azrogers marked this conversation as resolved.
Outdated
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
float Radius = 1.0f;

/**
* Whether the point should be filled.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
bool Fill = true;

/**
* If `Fill` is true, this style will be used when filling the point.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (EditCondition = "Fill"))
FCesiumVectorPolygonFillStyle FillStyle;

/**
* Whether the point should be outlined.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
bool Outline = false;

/**
* If `Outline` is true, this style will be used when outlining the point.
*/
UPROPERTY(
EditAnywhere,
BlueprintReadWrite,
Category = "Cesium",
meta = (EditCondition = "Outline"))
FCesiumVectorLineStyle OutlineStyle;
};

/**
* Style information to use when drawing vector data.
*/
Expand All @@ -154,6 +197,12 @@ struct FCesiumVectorStyle {
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
FCesiumVectorPolygonStyle PolygonStyle;

/**
* Styles to use when drawing points.
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
FCesiumVectorPointStyle PointStyle;

/**
* Converts this Unreal representation into the Cesium Native equivalent.
*/
Expand Down
Loading
Loading