-
Notifications
You must be signed in to change notification settings - Fork 321
Add iTwin support to Cesium for Unreal #1665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
azrogers
wants to merge
19
commits into
main
Choose a base branch
from
itwin-client
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0d9cfe2
iTwin CCC loader support in Unreal
azrogers e5a385a
Add mesh export service loader
azrogers 6536153
Add iTwin Reality Data loader
azrogers 15c5370
iTwin blueprint API
azrogers 111480f
Add raster overlay.
azrogers 4d3a810
Update cesium-native
azrogers 158c84c
Fix missing include
azrogers c4f213e
Remove ITwinResource stuff
azrogers 570f08f
Merge branch 'main' of github.com:CesiumGS/cesium-unreal into itwin-c…
azrogers 14b1bb0
Fix build with latest native
azrogers 5911836
Implement token refresh
azrogers 5ece3c0
More implementation, use feature-overlay branch of native
azrogers a154519
IModel blueprint
azrogers dd8adc2
Main iTwin APIs in Cesium for Unreal
azrogers e33520d
Update cesium-native
azrogers b0538bf
Merge from main
azrogers 2a9c2c3
Fix crashes
azrogers 3f27453
Merge branch 'main' of github.com:CesiumGS/cesium-unreal into itwin-c…
azrogers 9dbfe6c
Merge branch 'main' into itwin-client
j9liu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,7 +4,11 @@ | |||||
#include "Async/Async.h" | ||||||
#include "Camera/CameraTypes.h" | ||||||
#include "Camera/PlayerCameraManager.h" | ||||||
#include "Cesium3DTilesSelection/CesiumIonTilesetContentLoaderFactory.h" | ||||||
#include "Cesium3DTilesSelection/EllipsoidTilesetLoader.h" | ||||||
#include "Cesium3DTilesSelection/IModelMeshExportContentLoaderFactory.h" | ||||||
#include "Cesium3DTilesSelection/ITwinCesiumCuratedContentLoaderFactory.h" | ||||||
#include "Cesium3DTilesSelection/ITwinRealityDataContentLoaderFactory.h" | ||||||
#include "Cesium3DTilesSelection/Tile.h" | ||||||
#include "Cesium3DTilesSelection/TilesetLoadFailureDetails.h" | ||||||
#include "Cesium3DTilesSelection/TilesetOptions.h" | ||||||
Comment on lines
+7
to
14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make these angle brackets? I see that other files in this PR are using angle brackets anyway. |
||||||
|
@@ -436,6 +440,54 @@ void ACesium3DTileset::SetIonAccessToken(const FString& InAccessToken) { | |||||
} | ||||||
} | ||||||
|
||||||
void ACesium3DTileset::SetITwinCesiumContentID(int64 InContentID) { | ||||||
if (InContentID >= 0 && InContentID != this->ITwinCesiumContentID) { | ||||||
if (this->TilesetSource == ETilesetSource::FromITwinCesiumCuratedContent) { | ||||||
this->DestroyTileset(); | ||||||
} | ||||||
this->ITwinCesiumContentID = InContentID; | ||||||
} | ||||||
} | ||||||
|
||||||
void ACesium3DTileset::SetIModelID(const FString& InModelID) { | ||||||
if (InModelID != this->IModelID) { | ||||||
if (this->TilesetSource == ETilesetSource::FromIModelMeshExportService) { | ||||||
this->DestroyTileset(); | ||||||
} | ||||||
this->IModelID = InModelID; | ||||||
} | ||||||
} | ||||||
|
||||||
void ACesium3DTileset::SetRealityDataID(const FString& InRealityDataID) { | ||||||
if (InRealityDataID != this->RealityDataID) { | ||||||
if (this->TilesetSource == ETilesetSource::FromITwinRealityData) { | ||||||
this->DestroyTileset(); | ||||||
} | ||||||
this->RealityDataID = InRealityDataID; | ||||||
} | ||||||
} | ||||||
|
||||||
void ACesium3DTileset::SetITwinID(const FString& InITwinID) { | ||||||
if (InITwinID != this->ITwinID) { | ||||||
if (this->TilesetSource == ETilesetSource::FromITwinRealityData) { | ||||||
this->DestroyTileset(); | ||||||
} | ||||||
this->ITwinID = InITwinID; | ||||||
} | ||||||
} | ||||||
|
||||||
void ACesium3DTileset::SetITwinConnection( | ||||||
UCesiumITwinConnection* InConnection) { | ||||||
if (this->ITwinConnection != InConnection) { | ||||||
if (this->TilesetSource == ETilesetSource::FromITwinCesiumCuratedContent || | ||||||
this->TilesetSource == ETilesetSource::FromIModelMeshExportService || | ||||||
this->TilesetSource == ETilesetSource::FromITwinRealityData) { | ||||||
this->DestroyTileset(); | ||||||
} | ||||||
this->ITwinConnection = InConnection; | ||||||
} | ||||||
} | ||||||
|
||||||
void ACesium3DTileset::SetCesiumIonServer(UCesiumIonServer* Server) { | ||||||
if (this->CesiumIonServer != Server) { | ||||||
if (this->TilesetSource == ETilesetSource::FromCesiumIon) { | ||||||
|
@@ -1110,28 +1162,137 @@ void ACesium3DTileset::LoadTileset() { | |||||
Log, | ||||||
TEXT("Loading tileset for asset ID %d"), | ||||||
this->IonAssetID); | ||||||
FString token = this->IonAccessToken.IsEmpty() | ||||||
? this->CesiumIonServer->DefaultIonAccessToken | ||||||
: this->IonAccessToken; | ||||||
{ | ||||||
FString token = this->IonAccessToken.IsEmpty() | ||||||
? this->CesiumIonServer->DefaultIonAccessToken | ||||||
: this->IonAccessToken; | ||||||
|
||||||
#if WITH_EDITOR | ||||||
this->CesiumIonServer->ResolveApiUrl(); | ||||||
this->CesiumIonServer->ResolveApiUrl(); | ||||||
#endif | ||||||
|
||||||
std::string ionAssetEndpointUrl = | ||||||
TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl); | ||||||
std::string ionAssetEndpointUrl = | ||||||
TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl); | ||||||
|
||||||
if (!ionAssetEndpointUrl.empty()) { | ||||||
// Make sure the URL ends with a slash | ||||||
if (!ionAssetEndpointUrl.empty() && *ionAssetEndpointUrl.rbegin() != '/') | ||||||
ionAssetEndpointUrl += '/'; | ||||||
if (!ionAssetEndpointUrl.empty()) { | ||||||
// Make sure the URL ends with a slash | ||||||
if (!ionAssetEndpointUrl.empty() && | ||||||
*ionAssetEndpointUrl.rbegin() != '/') | ||||||
ionAssetEndpointUrl += '/'; | ||||||
|
||||||
this->_pTileset = MakeUnique<Cesium3DTilesSelection::Tileset>( | ||||||
externals, | ||||||
static_cast<uint32_t>(this->IonAssetID), | ||||||
TCHAR_TO_UTF8(*token), | ||||||
options, | ||||||
ionAssetEndpointUrl); | ||||||
} | ||||||
} | ||||||
break; | ||||||
case ETilesetSource::FromITwinCesiumCuratedContent: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Loading tileset for asset ID %d"), | ||||||
this->ITwinCesiumContentID); | ||||||
|
||||||
{ | ||||||
const std::string token = IsValid(this->ITwinConnection) | ||||||
? this->ITwinConnection->GetConnection() | ||||||
->getAuthenticationToken() | ||||||
.getToken() | ||||||
: ""; | ||||||
this->_pTileset = MakeUnique<Cesium3DTilesSelection::Tileset>( | ||||||
externals, | ||||||
Cesium3DTilesSelection::ITwinCesiumCuratedContentLoaderFactory( | ||||||
static_cast<uint32_t>(this->ITwinCesiumContentID), | ||||||
token), | ||||||
options); | ||||||
} | ||||||
break; | ||||||
case ETilesetSource::FromIModelMeshExportService: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Loading mesh export for iModel ID %s"), | ||||||
*this->IModelID); | ||||||
|
||||||
{ | ||||||
const std::string token = IsValid(this->ITwinConnection) | ||||||
? this->ITwinConnection->GetConnection() | ||||||
->getAuthenticationToken() | ||||||
.getToken() | ||||||
: ""; | ||||||
this->_pTileset = MakeUnique<Cesium3DTilesSelection::Tileset>( | ||||||
externals, | ||||||
static_cast<uint32_t>(this->IonAssetID), | ||||||
TCHAR_TO_UTF8(*token), | ||||||
options, | ||||||
ionAssetEndpointUrl); | ||||||
Cesium3DTilesSelection::IModelMeshExportContentLoaderFactory( | ||||||
TCHAR_TO_UTF8(*this->IModelID), | ||||||
std::nullopt, | ||||||
token), | ||||||
options); | ||||||
} | ||||||
break; | ||||||
case ETilesetSource::FromITwinRealityData: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Loading reality data ID %s"), | ||||||
*this->RealityDataID); | ||||||
|
||||||
{ | ||||||
const std::string token = IsValid(this->ITwinConnection) | ||||||
? this->ITwinConnection->GetConnection() | ||||||
->getAuthenticationToken() | ||||||
.getToken() | ||||||
: ""; | ||||||
|
||||||
this->_pTileset = MakeUnique<Cesium3DTilesSelection::Tileset>( | ||||||
externals, | ||||||
Cesium3DTilesSelection::ITwinRealityDataContentLoaderFactory( | ||||||
TCHAR_TO_UTF8(*this->RealityDataID), | ||||||
this->ITwinID.IsEmpty() ? std::nullopt | ||||||
: std::make_optional<std::string>( | ||||||
TCHAR_TO_UTF8(*this->ITwinID)), | ||||||
token, | ||||||
[asyncSystem, | ||||||
pConnectionObject = this->ITwinConnection](const std::string&) { | ||||||
if (!IsValid(pConnectionObject) || | ||||||
!pConnectionObject->GetConnection().IsValid()) { | ||||||
return asyncSystem.createResolvedFuture< | ||||||
CesiumUtility:: | ||||||
Result<std::string>>(CesiumUtility::ErrorList::error( | ||||||
"iTwin connection property on tileset is not valid.")); | ||||||
} | ||||||
|
||||||
const TSharedPtr<CesiumITwinClient::Connection> pConnection = | ||||||
pConnectionObject->GetConnection(); | ||||||
if (!pConnection->getRefreshToken()) { | ||||||
return asyncSystem.createResolvedFuture< | ||||||
CesiumUtility:: | ||||||
Result<std::string>>(CesiumUtility::ErrorList::error( | ||||||
"Access token for reality data is expired, no refresh token available.")); | ||||||
} | ||||||
|
||||||
return pConnection->me().thenImmediately( | ||||||
[pConnection]( | ||||||
CesiumUtility::Result<CesiumITwinClient::UserProfile>&& | ||||||
result) -> CesiumUtility::Result<std::string> { | ||||||
if (!result.value) { | ||||||
return CesiumUtility::Result<std::string>( | ||||||
result.errors); | ||||||
} | ||||||
|
||||||
if (!pConnection->getAuthenticationToken().isValid()) { | ||||||
return CesiumUtility::Result< | ||||||
std::string>(CesiumUtility::ErrorList::error( | ||||||
"Tried to refresh access token for reality data, but was not able to obtain valid token.")); | ||||||
} | ||||||
|
||||||
return CesiumUtility::Result<std::string>( | ||||||
pConnection->getAuthenticationToken().getToken()); | ||||||
}); | ||||||
}), | ||||||
options); | ||||||
} | ||||||
break; | ||||||
} | ||||||
|
@@ -1183,6 +1344,27 @@ void ACesium3DTileset::LoadTileset() { | |||||
TEXT("Loading tileset for asset ID %d done"), | ||||||
this->IonAssetID); | ||||||
break; | ||||||
case ETilesetSource::FromITwinCesiumCuratedContent: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Loading tileset for asset ID %d done"), | ||||||
this->ITwinCesiumContentID); | ||||||
break; | ||||||
case ETilesetSource::FromIModelMeshExportService: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Loading mesh export for iModel ID %s done"), | ||||||
*this->IModelID); | ||||||
break; | ||||||
case ETilesetSource::FromITwinRealityData: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Loading reality data ID %s done"), | ||||||
*this->RealityDataID); | ||||||
break; | ||||||
} | ||||||
|
||||||
switch (ApplyDpiScaling) { | ||||||
|
@@ -1224,6 +1406,27 @@ void ACesium3DTileset::DestroyTileset() { | |||||
TEXT("Destroying tileset for asset ID %d"), | ||||||
this->IonAssetID); | ||||||
break; | ||||||
case ETilesetSource::FromITwinCesiumCuratedContent: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Verbose, | ||||||
TEXT("Destroying tileset for asset ID %d"), | ||||||
this->ITwinCesiumContentID); | ||||||
break; | ||||||
case ETilesetSource::FromIModelMeshExportService: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Destroying tileset for iModel ID %s"), | ||||||
*this->IModelID); | ||||||
break; | ||||||
case ETilesetSource::FromITwinRealityData: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Destroying tileset for reality data ID %s done"), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
*this->RealityDataID); | ||||||
break; | ||||||
} | ||||||
|
||||||
// The way CesiumRasterOverlay::add is currently implemented, destroying the | ||||||
|
@@ -1282,6 +1485,27 @@ void ACesium3DTileset::DestroyTileset() { | |||||
TEXT("Destroying tileset for asset ID %d done"), | ||||||
this->IonAssetID); | ||||||
break; | ||||||
case ETilesetSource::FromITwinCesiumCuratedContent: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Verbose, | ||||||
TEXT("Destroying tileset for asset ID %d done"), | ||||||
this->ITwinCesiumContentID); | ||||||
break; | ||||||
case ETilesetSource::FromIModelMeshExportService: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Destroying tileset for iModel ID %s done"), | ||||||
*this->IModelID); | ||||||
break; | ||||||
case ETilesetSource::FromITwinRealityData: | ||||||
UE_LOG( | ||||||
LogCesium, | ||||||
Log, | ||||||
TEXT("Destroying tileset for reality data ID %s done"), | ||||||
*this->RealityDataID); | ||||||
break; | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -2178,6 +2402,12 @@ void ACesium3DTileset::PostEditChangeProperty( | |||||
PropName == GET_MEMBER_NAME_CHECKED(ACesium3DTileset, Url) || | ||||||
PropName == GET_MEMBER_NAME_CHECKED(ACesium3DTileset, IonAssetID) || | ||||||
PropName == GET_MEMBER_NAME_CHECKED(ACesium3DTileset, IonAccessToken) || | ||||||
PropName == | ||||||
GET_MEMBER_NAME_CHECKED(ACesium3DTileset, ITwinCesiumContentID) || | ||||||
PropName == GET_MEMBER_NAME_CHECKED(ACesium3DTileset, IModelID) || | ||||||
PropName == GET_MEMBER_NAME_CHECKED(ACesium3DTileset, RealityDataID) || | ||||||
PropName == GET_MEMBER_NAME_CHECKED(ACesium3DTileset, ITwinID) || | ||||||
PropName == GET_MEMBER_NAME_CHECKED(ACesium3DTileset, ITwinConnection) || | ||||||
PropName == | ||||||
GET_MEMBER_NAME_CHECKED(ACesium3DTileset, CreatePhysicsMeshes) || | ||||||
PropName == | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to update
CHANGES.md
!