Hi,
I’m trying to theme 3D Tile Sets at runtime by adding colored polygons.
Short questions:
- Does anyone know how to dynamically set a Material Instance (MI) layer name at run time?
- Does anyone know how to dynamically set Material Layer Blend (MLB) parameters at run time? (I can create a Material Instance Dynamic (MID) - but are the parameters on the MLB accessible via the MID?)
- Can I use Actor->AddComponent to add a CesiumPolygonRasterOverlay(CPRO) at run time?
I’m trying to do all this in Blueprints - but if I need to switch to C++, I can do that.
Background:
There may well be a better way of achieving my goal - any suggestions most gratefully received!
I’m trying to add colored polygons at run time. Here’s my approach as pseudo code
UPDATE
I misunderstood how the layers work in the Material Instance. I’ll be working on a fixed palette (set in editor at the design time) for now and it will change some aspects of my approach. However, I still think I need to be able to set MLB parameters at run time for my original goal of allowing users to choose any color they want at runtime (e.g. using a color wheel).
For Each Polygon (e.g. West District tinted yellow):
- Create a material instance (MI)
- Create a material layer blend (MLB) - controls color (e.g. yellow) and opacity (e.g. 1)
- Replace the clipping layer (top layer) of the MI with the MLB and set its name (e.g. West_District)
- Create the Cesium Cartographic Polygon (CPoly)
- For the world terrain (CTS_Terrain) and/or the world buildings (CTS_Buildings)
- Add a CesiumPolygonRasterOverlay (CPRO) component to the CTS
- Add the CPoly to the Polygons array of the CPRO
- Uncheck Exclude TIles Inside of the CPRO
- Set the Material Layer Key to the MLB top layer name (e.g. West_District)
So, I’m hoping to end up with an overlay for each separate polygon from the input file. That’s because I believe each raster overlay is limited to one material. I know it’s possible to achieve the effect I want by creating a GeoTIFF - but I don’t want to have to generate those each time a user draws on a map.
I can successfully create and add the CPoly’s.
However, I’m having trouble with the following:
- setting the MLB parameters (color and opacity)
- renaming the top layer of the MI to give it a unique “Material Layer Key” that the CPRO can reference
- adding the CPRO using AddComponent (this may, or may not be working - I can’t tell!)
Here are my blueprints:
Calling code (read from JSON and successfully parsing):
Creating a Material Instance (the thing I need MOST help with):
Creating (spawning) a Cesium Cartographic Polygon (works as expected - included for completeness)
Adding a Cesium Polygon Raster Overlay component to a Cesium 3D Tileset (this may or may not be working - not sure!)