Cpp Project - jgoffeney/Cesium4Unreal Wiki

Back

Accessing Cesium in Visual Studio

// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class CesiumTest : ModuleRules
{
	public CesiumTest(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
	
		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "CesiumRuntime" });

		PrivateDependencyModuleNames.AddRange(new string[] {  });

		CppStandard = CppStandardVersion.Cpp17;

		// Uncomment if you are using Slate UI
		// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });

		// Uncomment if you are using online features
		// PrivateDependencyModuleNames.Add("OnlineSubsystem");

		// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
	}
}

Loading Tileset

To load the tileset at runtime create an Actor subclass and then add the loading code to the BeginPlay() function.

// Called when the game starts or when spawned
void ATileLoader::BeginPlay()
{
	ACesium3DTileset* tileSet =
		Cast<ACesium3DTileset>(UGameplayStatics::BeginDeferredActorSpawnFromClass(
			GetWorld(),
			ACesium3DTileset::StaticClass(),
			FTransform()));

	if (tileSet) {
		tileSet->SetTilesetSource(ETilesetSource::FromUrl);
		tileSet->SetUrl("file:///K:/Data/3dTiles/3dtiles/tileset.json");
	}
	
	Super::BeginPlay();
	
}

Getting a Georeference and Converting a Point to Unreal Coords

// Cesium Includes
#include "CesiumGeoreference.h"

ACesiumGeoreference * geoReference = ACesiumGeoreference::GetDefaultGeoreference(this);

glm::dvec3 UECoords = geoReference->TransformLongitudeLatitudeHeightToUnreal(glm::dvec3(latCoord, longCoord, elevation));

Updating Time Zone