Road map of the level. More...
#include <RoadMap.h>
Public Member Functions | |
FRoadMapPixelData | GetDataAt (uint32 PixelX, uint32 PixelY) const |
Retrieve the data stored at a given pixel. More... | |
FRoadMapPixelData | GetDataAt (const FVector &WorldLocation) const |
Clamps value if lies outside map limits. More... | |
uint32 | GetHeight () const |
uint32 | GetWidth () const |
FVector | GetWorldLocation (uint32 PixelX, uint32 PixelY) const |
Return the world location of a given pixel. More... | |
FRoadMapIntersectionResult | Intersect (const FTransform &BoxTransform, const FVector &BoxExtent, float ChecksPerCentimeter) const |
Intersect actor bounds with map. More... | |
void | Reset (uint32 Width, uint32 Height, float PixelsPerCentimeter, const FTransform &WorldToMap, const FVector &MapOffset) |
Resets current map an initializes an empty map of the given size. More... | |
bool | SaveAsPNG (const FString &Folder, const FString &MapName) const |
Save the current map as PNG with the pixel data encoded as color. More... | |
void | SetPixelAt (uint32 PixelX, uint32 PixelY, ECityMapMeshTag Tag, const FTransform &Transform, bool bInvertDirection=false) |
URoadMap (const FObjectInitializer &ObjectInitializer) | |
Creates a valid empty map (every point is off-road). More... | |
Private Member Functions | |
int32 | GetIndex (uint32 PixelX, uint32 PixelY) const |
bool | IsValid () const |
Private Attributes | |
uint32 | Height |
Height of the map in pixels. More... | |
FVector | MapOffset |
Offset of the map in map coordinates. More... | |
float | PixelsPerCentimeter |
Number of pixels per centimeter. More... | |
TArray< uint16 > | RoadMapData |
uint32 | Width |
Width of the map in pixels. More... | |
FTransform | WorldToMap |
World-to-map transform. More... | |
Road map of the level.
Contains information in 2D of which areas are road and lane directions.
URoadMap::URoadMap | ( | const FObjectInitializer & | ObjectInitializer | ) |
Creates a valid empty map (every point is off-road).
Definition at line 71 of file RoadMap.cpp.
References RoadMapData, and FRoadMapPixelData::Value.
|
inline |
Retrieve the data stored at a given pixel.
Definition at line 128 of file RoadMap.h.
References GetIndex(), Intersect(), IsValid(), RoadMapData, and SaveAsPNG().
Referenced by GetDataAt(), Intersect(), and SaveAsPNG().
FRoadMapPixelData URoadMap::GetDataAt | ( | const FVector & | WorldLocation | ) | const |
Clamps value if lies outside map limits.
Definition at line 210 of file RoadMap.cpp.
References ClampFloatToUInt(), GetDataAt(), Height, IsValid(), MapOffset, PixelsPerCentimeter, Width, and WorldToMap.
|
inline |
Definition at line 119 of file RoadMap.h.
References GetWorldLocation(), and Height.
Referenced by SaveAsPNG().
|
inlineprivate |
Definition at line 161 of file RoadMap.h.
Referenced by GetDataAt(), and SetPixelAt().
|
inline |
Definition at line 114 of file RoadMap.h.
References Width.
Referenced by SaveAsPNG().
FVector URoadMap::GetWorldLocation | ( | uint32 | PixelX, |
uint32 | PixelY | ||
) | const |
Return the world location of a given pixel.
Definition at line 201 of file RoadMap.cpp.
References MapOffset, PixelsPerCentimeter, and WorldToMap.
Referenced by GetHeight(), and SaveAsPNG().
FRoadMapIntersectionResult URoadMap::Intersect | ( | const FTransform & | BoxTransform, |
const FVector & | BoxExtent, | ||
float | ChecksPerCentimeter | ||
) | const |
Intersect actor bounds with map.
Bounds box is projected to the map and checked against it for possible intersections with off-road areas and opposite lanes.
Definition at line 219 of file RoadMap.cpp.
References GetDataAt(), FRoadMapIntersectionResult::OffRoad, and FRoadMapIntersectionResult::OppositeLane.
Referenced by GetDataAt().
|
inlineprivate |
Definition at line 166 of file RoadMap.h.
References RoadMapData, and Width.
Referenced by GetDataAt(), and SaveAsPNG().
void URoadMap::Reset | ( | uint32 | Width, |
uint32 | Height, | ||
float | PixelsPerCentimeter, | ||
const FTransform & | WorldToMap, | ||
const FVector & | MapOffset | ||
) |
Resets current map an initializes an empty map of the given size.
Definition at line 83 of file RoadMap.cpp.
References Height, MapOffset, PixelsPerCentimeter, RoadMapData, Width, and WorldToMap.
Referenced by ACityMapGenerator::GenerateRoadMap().
bool URoadMap::SaveAsPNG | ( | const FString & | Folder, |
const FString & | MapName | ||
) | const |
Save the current map as PNG with the pixel data encoded as color.
Definition at line 251 of file RoadMap.cpp.
References GetDataAt(), GetHeight(), GetWidth(), GetWorldLocation(), Height, IsValid(), MapOffset, PixelsPerCentimeter, RoadMapData, FPixelReader::SavePixelsToDisk(), Width, and WorldToMap.
Referenced by ACityMapGenerator::GenerateRoadMap(), and GetDataAt().
void URoadMap::SetPixelAt | ( | uint32 | PixelX, |
uint32 | PixelY, | ||
ECityMapMeshTag | Tag, | ||
const FTransform & | Transform, | ||
bool | bInvertDirection = false |
||
) |
Definition at line 98 of file RoadMap.cpp.
References FRoadMapPixelData::Encode(), GetIndex(), and RoadMapData.
Referenced by ACityMapGenerator::GenerateRoadMap().
|
private |
Height of the map in pixels.
Definition at line 189 of file RoadMap.h.
Referenced by GetDataAt(), GetHeight(), Reset(), and SaveAsPNG().
|
private |
Offset of the map in map coordinates.
Definition at line 177 of file RoadMap.h.
Referenced by GetDataAt(), GetWorldLocation(), Reset(), and SaveAsPNG().
|
private |
Number of pixels per centimeter.
Definition at line 181 of file RoadMap.h.
Referenced by GetDataAt(), GetWorldLocation(), Reset(), and SaveAsPNG().
|
private |
Definition at line 192 of file RoadMap.h.
Referenced by GetDataAt(), IsValid(), Reset(), SaveAsPNG(), SetPixelAt(), and URoadMap().
|
private |
Width of the map in pixels.
Definition at line 185 of file RoadMap.h.
Referenced by GetDataAt(), GetWidth(), IsValid(), Reset(), and SaveAsPNG().
|
private |
World-to-map transform.
Definition at line 173 of file RoadMap.h.
Referenced by GetDataAt(), GetWorldLocation(), Reset(), and SaveAsPNG().