Skip to content
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

Add functions to get the approximate location of a tileset during runtime #1458

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
37 changes: 37 additions & 0 deletions Source/CesiumRuntime/Private/Cesium3DTileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,43 @@ void ACesium3DTileset::InvalidateResolvedGeoreference() {
this->ResolvedGeoreference = nullptr;
}

FVector ACesium3DTileset::GetApproximateTilesetLocationUnreal(bool& rootTileAvailable) {
ACesiumGeoreference* pGeoreference = this->ResolveGeoreference();
bool tempBool = false;

FVector approximateRootTileLocationECEF = this->GetApproximateTilesetLocationECEF(tempBool);
FVector approximateRootTileLocationUnreal = pGeoreference->TransformEarthCenteredEarthFixedPositionToUnreal(approximateRootTileLocationECEF);

rootTileAvailable = tempBool;
return approximateRootTileLocationUnreal;
}


FVector ACesium3DTileset::GetApproximateTilesetLocationECEF(bool& rootTileAvailable) {
const Cesium3DTilesSelection::Tile* pRootTile =
this->_pTileset->getRootTile();
if (!pRootTile) {
UE_LOG(
LogCesium,
Warning,
TEXT("Root tile not (yet) available for actor %s"),
*this->GetName());

rootTileAvailable = false;

return FVector::ZeroVector;
}

glm::dmat4x4 rootTileTransform = pRootTile->getTransform();
glm::dvec3 translation(rootTileTransform[3][0], rootTileTransform[3][1], rootTileTransform[3][2]);

FVector approximateRootTileLocationECEF = VecMath::createVector(translation);

rootTileAvailable = true;

return approximateRootTileLocationECEF;
}

TSoftObjectPtr<ACesiumCreditSystem> ACesium3DTileset::GetCreditSystem() const {
return this->CreditSystem;
}
Expand Down
20 changes: 20 additions & 0 deletions Source/CesiumRuntime/Public/Cesium3DTileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ class CESIUMRUNTIME_API ACesium3DTileset : public AActor {
UFUNCTION(BlueprintCallable, Category = "Cesium")
void InvalidateResolvedGeoreference();

/**
* Returns the approximate Unreal Location of this tileset or a zero-Vector if
* the root tile is not available yet
*/
UFUNCTION(
BlueprintCallable,
Category = "Cesium",
meta = (ReturnDisplayName = "approximate Unreal Location"))
FVector GetApproximateTilesetLocationUnreal(bool& rootTileAvailable);

/**
* Returns the approximate ECEF Location of this tileset or a zero-Vector if
* the root tile is not available yet
*/
UFUNCTION(
BlueprintCallable,
Category = "Cesium",
meta = (ReturnDisplayName = "approximate ECEF Location"))
FVector GetApproximateTilesetLocationECEF(bool& rootTileAvailable);

private:
/**
* The actor managing this tileset's content attributions.
Expand Down