Skip to content

Commit

Permalink
Refactor away some duplicate code when creating locations
Browse files Browse the repository at this point in the history
  • Loading branch information
csciguy8 committed Oct 4, 2023
1 parent 2bf0b3b commit b6df20e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 28 deletions.
58 changes: 30 additions & 28 deletions Source/CesiumRuntime/Private/Tests/CesiumSceneGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ FString SceneGenerationContext::testIonToken(
FString SceneGenerationContext::testGoogleUrl(
"https://tile.googleapis.com/v1/3dtiles/root.json?key=AIzaSyCnRPXWDIj1LuX6OWIweIqZFHHoXVgdYss");

void SceneGenerationContext::setCommonProperties(
const FVector& origin,
const FVector& position,
const FRotator& rotation,
float fieldOfView) {
startPosition = position;
startRotation = rotation;
startFieldOfView = fieldOfView;

georeference->SetOriginLongitudeLatitudeHeight(origin);

pawn->SetActorLocation(startPosition);
pawn->SetActorRotation(startRotation);
}

void SceneGenerationContext::refreshTilesets() {
std::vector<ACesium3DTileset*>::iterator it;
for (it = tilesets.begin(); it != tilesets.end(); ++it)
Expand Down Expand Up @@ -122,16 +137,12 @@ void createCommonWorldObjects(SceneGenerationContext& context) {
}

void setupForGoogleplex(SceneGenerationContext& context) {
FVector targetOrigin(-122.083969, 37.424492, 142.859116);

context.startPosition = FVector(0, 0, 0);
context.startRotation = FRotator(-25, 95, 0);
context.startFieldOfView = 90.0f;

context.georeference->SetOriginLongitudeLatitudeHeight(targetOrigin);

context.pawn->SetActorLocation(context.startPosition);
context.pawn->SetActorRotation(context.startRotation);
context.setCommonProperties(
FVector(-122.083969, 37.424492, 142.859116),
FVector(0, 0, 0),
FRotator(-25, 95, 0),
90.0f);

ACesium3DTileset* tileset = context.world->SpawnActor<ACesium3DTileset>();
tileset->SetUrl(SceneGenerationContext::testGoogleUrl);
Expand All @@ -142,16 +153,12 @@ void setupForGoogleplex(SceneGenerationContext& context) {
}

void setupForDenver(SceneGenerationContext& context) {
FVector targetOrigin(-104.988892, 39.743462, 1798.679443);

context.startPosition = FVector(0, 0, 0);
context.startRotation = FRotator(-5.2, -149.4, 0);
context.startFieldOfView = 90.0f;

context.georeference->SetOriginLongitudeLatitudeHeight(targetOrigin);

context.pawn->SetActorLocation(context.startPosition);
context.pawn->SetActorRotation(context.startRotation);
context.setCommonProperties(
FVector(-104.988892, 39.743462, 1798.679443),
FVector(0, 0, 0),
FRotator(-5.2, -149.4, 0),
90.0f);

// Add Cesium World Terrain
ACesium3DTileset* worldTerrainTileset =
Expand Down Expand Up @@ -186,18 +193,13 @@ void setupForDenver(SceneGenerationContext& context) {
}

void setupForMontrealPointCloud(SceneGenerationContext& context) {
FVector targetOrigin(-73.616526, 45.57335, 95.048859);

context.startPosition = FVector(0, 0, 0);
context.startRotation = FRotator(-90.0, 0.0, 0.0);
context.startFieldOfView = 90.0f;

context.georeference->SetOriginLongitudeLatitudeHeight(targetOrigin);

context.pawn->SetActorLocation(context.startPosition);
context.pawn->SetActorRotation(context.startRotation);
context.setCommonProperties(
FVector(-73.616526, 45.57335, 95.048859),
FVector(0, 0, 0),
FRotator(-90.0, 0.0, 0.0),
90.0f);

// Montreal Point Cloud
ACesium3DTileset* montrealTileset =
context.world->SpawnActor<ACesium3DTileset>();
montrealTileset->SetTilesetSource(ETilesetSource::FromCesiumIon);
Expand Down
6 changes: 6 additions & 0 deletions Source/CesiumRuntime/Private/Tests/CesiumSceneGeneration.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ struct SceneGenerationContext {
FRotator startRotation;
float startFieldOfView;

void setCommonProperties(
const FVector& origin,
const FVector& position,
const FRotator& rotation,
float fieldOfView);

void refreshTilesets();
void setSuspendUpdate(bool suspend);
bool areTilesetsDoneLoading();
Expand Down

0 comments on commit b6df20e

Please sign in to comment.