BP_Coala
Description:
The main Blueprint (BP) of Coala. This BP handles the loading and deleting of all Coala areas. It is the heart of Coala.
Variables:
Default:
AsyncLoading : bool to use AsyncLoading (please note : you have to use combined cells for async loading)
Request Coala Area: event that is triggered by the COALA plugin
Area Loaded: event that is triggered by the COALA plugin
Map Loaded: event that is triggered by the COALA plugin
Gps Position Changed: event that is triggered by the COALA plugin
Request Weather Update: event that is triggered by the COALA plugin
Weather Data Received: event that is triggered by the COALA plugin
Request Custom POIUpdate: event that is triggered by the COALA plugin
Setup:
LoadByBeginPlay:
Demo Mode:
Asset Path:
CoalaScale:
UseDayNightSystem:
CoalaZoom:
CoalaProjectApiKey:
AreaLoadBuffer:
Dev:
RenderAreaDimensions
PlayerEditorStartLon
PlayerEditorStartLat
Buildings:
DefaultBuildingLevel
CombineMeshes
ClampBuildingLevel
Height Per Level
CreateBuildingMeshes
limitMaxBuildingLavelTo
Material:
MaterialAreaDimension
MaterialWater
MaterialBuildingFloor
MaterialBuildingWall
MaterialBuildingRoof
Material Building Foundation
Render:
Render Water
Render Buildings
Render Cells
Render POIs
Render Custom POIs
Render Streets
Pois:
Pois
Custom Poi Configuration
Basic:
Async Loading
Get Weather Updates
Get Weather Delay
Streets:
StreetsDefaultRenderConfig
StreetsConfig
Cell:
Combine Cells
Cell Default Render Config
Render Config Cell
Elevation Scale
Coala Decoration:
Area Decoration Configuration
Coala Meshes:
Water Z offset
Street Z offset
Cell Z offset
Coala Area Controller:
Player Current Lat
Player Current Lon
Event Map Loaded Logic:
Map First Time Loaded
Count Areas to Create Till Map Loaded
Intern:
Current Weather
Buffered Requests
In Mesh Generation
Running Threads
Current Weather as Type
Switch to Async
Is Debug
Coala Water:
Outline Width
Outline Material
Crime:
Crime Render Config: Configure which crimes should be rendered and how as well as the display of a crime heatmap and its specifications
Transportation:
Transportation Render Config: Configure which transportation data should be rendered, set the blueprints for stops and vehicles as well as the perimeter in which transportation data should be displayed
Functions:
ConstructionScript (default):
The ConstructionScript handles the scaling of all Coala actors. Here, the CoalaScaling is getting set. Find out more under the function "ScaleCoalaActors".
CreateArea
Input:
area:coalaArea
material:Material
Output:
CoalaMeshActor
CreateWater
Creation of water meshes.
Input :
area:coalaArea
material:Material
outlineWidth:Float
outlineMaterial:Material
Output:
--
CreateBuldings
Creation of building meshes.
Input :
area:coalaArea
Combine:Boolean
createMeshes:Intenger
materialFloor:Material
materialWall:Material
materialRoof:Material
generateUVs:Boolean
heightPerLevel:float
outgenerateCollisionslineWidth:Boolean
Output:
--
CreateCell
Creation of cell meshes.
Input :
area:coalaArea
renderConfig:CoalaCellRenderConfig
mergeCells:Boolean
Output:
--
CreatePois
Creation of POIs.
Input :
area:coalaArea
poiConfiguration:Map[string:actor]
Output:
--
CreateStreets
Creation of street meshes.
Input :
area:coalaArea
renderConfig:coalaStreetConfig
Output :
--
CreateCrimes
Creation of objects that represent the crime data. Important: If you have an area load buffer of 1 or more in a location with an extreme amount of crime data, the loading of the initial areas might cause an Infinite Loop Exception by Unreal because the standard maximum loop count of 1000.000 is exceeded. If this problem occurs, you can prevent it by increasing the Maximum Loop Counter in the Project Settings (recommended: 100.000.000).
Input : Area:CoalaArea CrimeRenderConfig:CoalaCrimeRenderConfigOutput : --
CreateCrime
This function is called for each crime data set from the area request.
It includes a merge logic that merges crime pins with the same or close location and same crime type combination into one pin to improve performance. This does not change the weight distribution on the heatmap as the weight data of the merged crimes is added together. The tolerance can be changed in the variable "CrimeMergeTolerance" (Default: 10).
If "Filter Crimes" returns that the crime data should not be merged, the crime data is compared to the settings in the Crime Render Config. If, according to the config, this crime fits the parameters to be rendered, the blueprint specified in the config (either the Default Crime Pin Blueprint or the one set in Crime Types To Display) is spawned at the world position corresponding to its location in the real world. If you want to influence the conditions in which the crime pin blueprint is spawned, you can do so here.
After spawning the crime pin, the object and corresponding data are saved into "Rendered Crime Info Per Area". This is mainly used for the "Filter Crimes" - function as well as the heatmap generation.
Since you have the option in the Crime Render Config to highlight specific crime type combinations, after saving the crime info it is checked if this particular crime pin shall be highlighted according to the config settings. If this is true, the highlighter blueprint specified in the config will be spawned. If you want to alter the conditions in which a crime pin is highlighted or how, you can do so here.
Input :
Area: CoalaArea
CrimeRenderConfig: CoalaCrimeRenderConfig
Crime: Coala Crime
Output :
IsBeingRendered: Bool
SpawnNewHeatMapToken
Spawning of tokens for heatmap.
This function spawns the right token for the HeatMapType specified in the Crime Render Config. As HeatMapType Flat is meant for Hexagon meshes or similar, this function also calculates which tokens need to have an offset by half a cell width. This function is used multiple times in the AddHeatMapForCrimesMacro.
Input :
CellCenterToken:Vector3
YIndex:Float
Displacement:Float
Area:CoalaArea
HeatMapParent:CoalaActor
TerrainPos:Vector3
Output :
Token:BPHeatMapToken
CreateCoalaMeshes
Creation of all meshes for Coala.
Input :
InCoalaArea:coalaArea
Output :
Success:Boolean
Area:coalaArea
ScaleCoalaActors
Scales Coala actors.
Input :
--
Output :
--
Macros:
AddHeatMapForCrimesMacro:
Creation of crime heatmap (One Heatmap Token per cell).
First, parent objects are created and it is checked if a heatmap shall be generated according to the Crime Render Config. If you want to edit the conditions in which a heatmap shall be generated at all, you can intersect here.
Next, we are looping through all crime info that has been saved in "Rendered Crime Info Per Area".
For each Crime Info, it is checked if the rendered crime is an area crime (meaning we do not know the exact location but how high the crime count per 100.000 inhabitants is for this area and this particular crime type combination). Area Crimes are handled a bit different (See below). If this crime info is not an an area crime, it is searched for the particular cell the crime's location is in.
If this crime info happens to be an area crime, the weight needs to be added onto all tokens in the area. For this to happen, a raycast is used for each cell inthe area to see if there are already tokens spawned from previously loaded areas at the location of this cell. If the raycast hits a token, the weight saved in the crime info will be added directly onto the token. If no token exists already for this cell, the cell index and weight are saved into WeightPerCellIndex for later use (see below).
If this crime is not an area crime and this cell is the one the crime is positioned in, the calculation for how much weight should be added onto the (not yet existing) token for this cell index. This is done by going through all cell indeces around the cell this crime is positioned in (going x cells into each cardinal direction where x is Influence and can be set in the Crime Render Config). For each of those cell indeces, the weight is calculated according to how far the cell is away from the actual crime location. If the index is within the area borders, this is then saved in WeightPerCellIndex for later use (see below).
If the index however is outside the area borders (IsBorderIndex == true), it is checked per raycast if a token for this index already exists from a preloaded area. if it does, the previously calculated weight is added upon the token.
If there is no preexisting token, a new one is spawned and the weight is added upon it. These tokens are set invisible to visually maintain clean area borders in the heatmap. They will be only set visible as soon as an area loads underneath them.
After all Crime Info has been looped through and its weight has been saved in WeightPerCellIndex accordingly, we are looping through all area cells to add the respective weight onto already existing tokens (check per raycast again) or spawn a new one and add the weight onto it then.
After all the tokens have been spawned, all tokens that were spawned or altered during this runthrough have UpdateAfterInitComplete (see BP_HeatMapToken for more info) called on them.
Input :
InCoalaArea:coalaArea
Output :
----
LoopWithDelay:
A loop with a pause function.
Input :
Exec:Exec
Array:Wildcard
DelayIn:Exec
Output :
loopBody:Exec
ArrayElem:Wildcard
Index:Integer
completed:Exec
DelayOut:Exec
Async :
There is an alternative function for each mesh rendering method.
The async Nodes will start a thread, that does all the needed calculations in the background. The BP can ask the thread if it is done, get the results from it and is able to reset its functionality.
To use these you have to set "AsyncLoading" to true in your created Child of BP_Coala.
LoadCoalaAreaFromResponseAsync:
Input :
Exec:Exec
string:JsonRaw
int:DefaultBuildingLevel
bool:ClampToDefaultBuildingLevel
int:LimitMaxBuildingLevelTo
Output :
Exec:Exec
Startet thread BP needs to use:
AsyncLoadingDone:
to check if thread is done parsing
Output:
bool:ReturnValue
GetAsyncJsonResult:
Returns the parsed JSON.
Output:
UCoalaArea:ReturnValue
ResetJsonThread:
Resets the thread that parsed the JSON and allows a new Task.
Input :
Exec:Exec
Output :
Exec:Exec
CreateCellsAsync:
Input :
Exec:Exec
Actor:SpawnActor
Array<CoalaCell>:Cells
CoalaRenderConfig:DefaultRenderConfig
Array<CoalaRenderConfig>:RenderConfig
Output :
Exec:Exec
AsyncCellMeshDone:
A check to see if the Mesh generation is done.
Input :
Exec:Exec
Output :
Exec:Exec
bool:ReturnValue
GetCellMeshResult
Allows to get the result
Input :
Exec:Exec
Output :
Exec:Exec
CoalaMeshActor:ReturnValue
ResetCellMeshThread:
Resets the thread that did the calculations for the cells and allows a new Task.
Input :
Exec:Exec
Output :
Exec:Exec
CreateWaterAsync
Input :
Actor:SpawnActor
area:coalaArea
material:Material
outlineWidth:Float
outlineMaterial:Material
bool:GenerateWater
Output :
Exec:Exec
AsyncWaterMeshDone:
A check to see if the Mesh generation is done.
Input :
Exec:Exec
Output :
Exec:Exec
bool:ReturnValue
GetWaterMeshResult
Allows to get the result
Input :
Exec:Exec
Output :
Exec:Exec
CoalaMeshActor:ReturnValue
ResetWaterMeshThread:
Resets the thread that did the calculations for the water and allows a new Task.
Input :
Exec:Exec
Output :
Exec:Exec
CreateBuildingsAsync:
Input :
area:coalaArea
Combine:Boolean
createMeshes:Intenger
materialFloor:Material
materialWall:Material
materialRoof:Material
generateUVs:Boolean
heightPerLevel:float
outgenerateCollisionslineWidth:Boolean
AsyncBuildingsMeshDone:
A check to see if the Mesh generation is done.
Input :
Exec:Exec
Output :
Exec:Exec
bool:ReturnValue
GetBuildingsMeshResult
Allows to get the result
Input :
Exec:Exec
Output :
Exec:Exec
CoalaMeshActor:ReturnValue
ResetBuildingsMeshThread:
Resets the thread that did the calculations for the buildings and allows a new Task.
Input :
Exec:Exec
Output :
Exec:Exec
CreateStreetsAsync:
Input :
area:coalaArea
renderConfig:coalaStreetConfig
AsyncStreetsMeshDone:
A check to see if the Mesh generation is done.
Input :
Exec:Exec
Output :
Exec:Exec
bool:ReturnValue
GetStreetsMeshResult
Allows to get the result
Input :
Exec:Exec
Output :
Exec:Exec
CoalaMeshActor:ReturnValue
ResetStreetsMeshThread:
Resets the thread that did the calculations for the streets and allows a new Task.
Input :
Exec:Exec
Output :
Exec:Exec
Events:
BeginPlay (default):
Loads the Coala areas on startup of the level.
EndPlay (default):
Cleanup Coala.
CreateCoalaMesheSuccess:
All Coala meshes were created.
CreateCoalaMeshesFail:
There was a problem creating Coala meshes.
OnGpsPositionChanged:
Reaction on the bound unreal implementation of OnLocationChanged.
OnRequestCoalaArea:
The internal event to start a new request.
OnCoalaRequestError:
Reaction to an error on RequestCoalaArea
OnCoalaRequestSuccess:
Handling of the result of RequestCoalaArea.
EventAreaLoaded:
Is called after a new area is loaded. Updates the Z positions of all objects in the transportation layer.
RenderTransportationData:
This is called once when new transportation data arrives at the client. Invalid routes and respective stop objects are cleaned up while newly added ones are spawned. Any new vehicles or stops are initiated.
RequestTransportationData and OnTransportationRequestSuccess/OnTransportationRequestError:
Is called once on BeginPlay and in RequestUpdatedTransportationData. Sends a request to the Coala server for transportation data in a perimeter around the player location (perimeter can be configured in TransportationRenderConfig). The server response is then either rendered as into objects on success or an error message is displayed.
UpdateTransportationLayer:
Is called every Tick. This updates the vehicles positions in realtime so all vehicles that should be around your location right now are displayed properly. Trips that are invalid because the vehicle reached it's end stop the last frame are cleaned up. Newly spawned vehicles are initiated.
RequestUpdatedTransportationData:
Is called every time the GPS position of the player is updated. Checks if the player has left the old transportation data perimeter and requests new data if that is the case.
Event Dispatchers:
RequestCoalaArea:
Graph internal event that starts the server call to get an area.
AreaLoaded:
A call that enables you to react to a loaded area (also gives you the area that was loaded).
MapLoaded:
A call that enables you to react to a loaded map (when all areas are done)