Cesium for Unreal and Foliage

I am developing a program which uses Cesium for Unreal. While it works great as is, it would be nice to be able to also have foliage just to make it look a bit more real.
I have seen the tutorials here on adding foliage to cesium landscapes. The project is not using using sub levels and the other tutorials are out dated as in the code examples are using an older cesium api and are for either UE 4 or apparently a beta of UE5.

I wrestled with trying to update the tutorial code, but not knowing the cesium API and how it is supposed to work it is rather difficult to fix.

I did manage to find a later project from the same person who made that tutorial for UE5. However, it too is on an older api and has the same issues I have run into trying to update the original tutorial.

It does, however, use GeoJSONs to do its work, which seems to me to be a bit better than the, admittedly clever, “view the scene and determine where grass and trees should go from the color”.

The first level of problems come from obvious moving and/or renaming of some functions.

The first issue is the inability of the plugin (generic foliage) to find HierarchicalInstancedStaticMeshComponent.h

This one is simple to fix, you now need to explicitly include:
#include “Components/HierarchicalInstancedStaticMeshComponent.h”

The next is a complaint about isPointInsideMesh() wanting an actual enum rather than a byte. ALso easy to fix. Change the type of outcome (the offending parameter) to not be TEnumAsByte<> but rather just the pins enum.

Next will be several complaints about unexpected calls but this is really due to an unidentified identifier for FRHIGPUTextureReadback
Again, you now need to add : #include “RHIGPUReadback.h”

At last we come to the parts I have yet to solve and these are the cesium parts.
There are several calls to functions that apparently used to exist in the GeoReference object but have been removed or just moved. Maybe renamed and I couldn’t find it.

Each of these are being called off of a GeoReference->functionnamehere()

I did find similarly named functions in, I believe the name was GeoTransforms.h
However, those expect an origin as well. Something I think was being provided for “free” as a GeoReference object.

Maybe someone can provide some guidance on where to go for these three functions.
Any help is, of course, appreciated.

I’ll come back here and edit/add if I find anything independently.

Thank you.

Edit: One more function I found that is no longer part of GeoReference


Some progress, but no idea if I’m going the right way.
Digging into the cesium plugin github…
I found that you can get GeoTransforms from a GeoReference.
However, the foliage plugin code works with FVectors and now the transforms all want dvec3s
You have to convert it yourself.

Which I have.

So, you can call the transform functions from the geotransforms fetched from GeoReference. Its a bid wordy, but straightforward.


FVector ACesiumClusterFoliageActor::GeographicToEngineLocation(const FVector& GeographicLocation)
glm::dvec3 dvecLocation(GeographicLocation.X, GeographicLocation.Y, GeographicLocation.Z);
glm::dvec3 dvecOrigin(GeoReference->GetOriginEarthCenteredEarthFixed().X, GeoReference->GetOriginEarthCenteredEarthFixed().Y, GeoReference->GetOriginEarthCenteredEarthFixed().Z);

GeoTransforms gTrans=GeoReference->GetGeoTransforms();
glm::dvec3 dvecTrans=gTrans.TransformLongitudeLatitudeHeightToUnreal(dvecOrigin,dvecLocation);

return FVector(dvecTrans.x, dvecTrans.y, dvecTrans.z);


However, when it comes to ComputeEastSouthUpToUnreal() there is a new problem. This now returns something called a dmat4. The function that is using ComputeEastSouthUpToUnreal() is expecting another FVector. I have no idea how to transform dmat4 to an FVector right now.

This plugin code isn’t mine. So just changing the function return to a dmat4 will probably just cascade to more issues.

Edit: the functions using ComputeEastSouthUpToUnreal() are only wanting the Up vector. Doing so by calling ToQuat().GetUpVector(). I have no idea what the old ComputeEastSouthUpToUnreal() returned that had a member ToQuat() in it.

Digging in the history of GeoReference I find that it used to return an FMatrix. I am now truly stuck because I have no idea what values from dmat4 go into what places in FMatrix to do a conversion.

Can you please link to the specific code that you’re having trouble adapting? In general, you shouldn’t need to use GeoTransforms. The necessary methods are available directly on CesiumGeoreference (or on UCesiumWgs84Ellipsoid in some cases), though some of their names have changed over time. VecMath.h can help you convert between glm types (like dmat4 and dvec3) and Unreal types (like FMatrix and FVector).

I admit I’m not able to follow the post 100%, but I wanted to mention that there is an example of glm::dmat4 (4x4 matrix of doubles) to FMatrix in this file:

Hey, thanks.
The code isn’t mine but it resides here at GitHub


It is from the same guy who did the procedural foliage tutorial here on Cesium, but that was for older UE and an older Cesium API. This one takes a different approach using a GeoJSON.

I’ll look into this VecMath.h you mention.
Thank you.

Yes, sorry. It became a stream of consciousness unfortunately as I worked on this throughout the day.

Thank you for the example. I’ll give it a peek when I get back to working on the problem.

Well. I am not able to find VecMath.h
The transforms calls are definitely not in CesiumGeoreference as this is what lead me to post this question. The compiler claims the transform functions are not members of CesiumGeoreference.

As this isn’t my code and I was trying to learn how it worked, it is extremely hard to “fix” (not your fault). So it is nearly impossible for me to try to describe the intent of the original author.

Alright. For anyone else tracking this:

TransformLongitudeLatitudeHeightToUnreal() has been renamed to:


The rest are also similarly renamed.

Thank you all for the suggestions and pointers.