Fix Road tag and add some sidewalk to semantic segmentation

This commit is contained in:
bernatx 2020-02-05 10:48:11 +01:00 committed by Marc Garcia Puig
parent a521eef213
commit 878e8123da
3 changed files with 38 additions and 6 deletions

View File

@ -21,9 +21,13 @@ UMoveAssetsCommandlet::UMoveAssetsCommandlet()
// and for specifying the path to these meshes when spawning them in a world.
namespace SSTags {
// Carla Semantic Segmentation Folder Tags
static const FString ROAD = TEXT("Roads");
static const FString ROAD = TEXT("Road");
static const FString ROADLINES = TEXT("RoadLines");
static const FString TERRAIN = TEXT("Terrain");
static const FString GRASS = TEXT("Terrain");
static const FString SIDEWALK = TEXT("SideWalk");
static const FString CURB = TEXT("SideWalk");
static const FString GUTTER = TEXT("SideWalk");
// RoadRunner Tags
//
@ -34,7 +38,11 @@ namespace SSTags {
// meshSubType is a denomination of the tag (e.g. "Road", "Gutter", "Ground")
static const FString R_ROAD = TEXT("Road_Road");
static const FString R_TERRAIN = TEXT("Terrain");
static const FString R_GRASS = TEXT("Road_Grass");
static const FString R_MARKING = TEXT("Road_Marking");
static const FString R_SIDEWALK = TEXT("Road_Sidewalk");
static const FString R_CURB = TEXT("Road_Curb");
static const FString R_GUTTER = TEXT("Road_Gutter");
}
FMovePackageParams UMoveAssetsCommandlet::ParseParams(const FString &InParams) const
@ -112,7 +120,7 @@ void UMoveAssetsCommandlet::MoveAssetsFromMapForSemanticSegmentation(
AssetsObjectLibrary->GetAssetDataList(MapContents);
AssetsObjectLibrary->ClearLoaded();
TArray<FString> DestinationPaths = {SSTags::ROAD, SSTags::ROADLINES, SSTags::TERRAIN};
TArray<FString> DestinationPaths = {SSTags::ROAD, SSTags::ROADLINES, SSTags::TERRAIN, SSTags::GRASS, SSTags::SIDEWALK, SSTags::CURB, SSTags::GUTTER};
// Init Map with keys
TMap<FString, TArray<UObject *>> AssetDataMap;
@ -154,6 +162,18 @@ void UMoveAssetsCommandlet::MoveAssetsFromMapForSemanticSegmentation(
{
AssetDataMap[SSTags::TERRAIN].Add(MeshAsset);
}
else if (AssetName.Contains(SSTags::R_SIDEWALK))
{
AssetDataMap[SSTags::SIDEWALK].Add(MeshAsset);
}
else if (AssetName.Contains(SSTags::R_CURB))
{
AssetDataMap[SSTags::CURB].Add(MeshAsset);
}
else if (AssetName.Contains(SSTags::R_GUTTER))
{
AssetDataMap[SSTags::GUTTER].Add(MeshAsset);
}
}
}

View File

@ -24,17 +24,20 @@ UPrepareAssetsForCookingCommandlet::UPrepareAssetsForCookingCommandlet()
// Get Carla Default materials, these will be used for maps that need to use
// Carla materials
static ConstructorHelpers::FObjectFinder<UMaterial> MarkingNode(TEXT(
"Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_W.M_MarkingLane_W'"));
"Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_Y.M_MarkingLane_Y'"));
static ConstructorHelpers::FObjectFinder<UMaterial> RoadNode(TEXT(
"Material'/Game/Carla/Static/GenericMaterials/Masters/LowComplexity/M_Road1.M_Road1'"));
static ConstructorHelpers::FObjectFinder<UMaterial> RoadNodeAux(TEXT(
"Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_Y.M_MarkingLane_Y'"));
"Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_W.M_MarkingLane_W'"));
static ConstructorHelpers::FObjectFinder<UMaterial> TerrainNodeMaterial(TEXT(
"Material'/Game/Carla/Static/GenericMaterials/Grass/M_Grass01.M_Grass01'"));
static ConstructorHelpers::FObjectFinder<UMaterial> SidewalkNode(TEXT(
"Material'/Game/Carla/Static/GenericMaterials/CheapMaterials/M_SideWalkCheap01'"));
MarkingNodeMaterial = (UMaterial *) MarkingNode.Object;
RoadNodeMaterial = (UMaterial *) RoadNode.Object;
MarkingNodeMaterialAux = (UMaterial *) RoadNodeAux.Object;
SidewalkNodeMaterial = (UMaterial *) SidewalkNode.Object;
#endif
}
#if WITH_EDITORONLY_DATA
@ -126,7 +129,7 @@ TArray<AStaticMeshActor *> UPrepareAssetsForCookingCommandlet::SpawnMeshesToWorl
MeshAsset->MarkPackageDirty();
}
// rotate all meshes 180 degrees to fit with OpenDRIVE info
// rotate all meshes 180 degrees to fit with OpenDRIVE info
// (seems that new version of RoadRunner is doing this)
// MeshActor->SetActorRotation(FRotator(0.0f, 180.0f, 0.0f));
@ -149,6 +152,10 @@ TArray<AStaticMeshActor *> UPrepareAssetsForCookingCommandlet::SpawnMeshesToWorl
{
MeshActor->GetStaticMeshComponent()->SetMaterial(0, TerrainNodeMaterial);
}
else if (AssetName.Contains(SSTags::R_SIDEWALK))
{
MeshActor->GetStaticMeshComponent()->SetMaterial(0, SidewalkNodeMaterial);
}
}
}
}
@ -374,9 +381,10 @@ void UPrepareAssetsForCookingCommandlet::PrepareMapsForCooking(
FString RoadsPath = BasePath + SSTags::ROAD + MapPath;
FString RoadLinesPath = BasePath + SSTags::ROADLINES + MapPath;
FString TerrainPath = BasePath + SSTags::TERRAIN + MapPath;
FString SidewalkPath = BasePath + SSTags::SIDEWALK + MapPath;
// Spawn assets located in semantic segmentation fodlers
TArray<FString> DataPath = {DefaultPath, RoadsPath, RoadLinesPath, TerrainPath};
TArray<FString> DataPath = {DefaultPath, RoadsPath, RoadLinesPath, TerrainPath, SidewalkPath};
TArray<AStaticMeshActor *> SpawnedActors = SpawnMeshesToWorld(DataPath, Map.bUseCarlaMapMaterials);

View File

@ -160,6 +160,10 @@ private:
UPROPERTY()
UMaterial *TerrainNodeMaterial;
/// Workaround material for the SidewalkNodes
UPROPERTY()
UMaterial *SidewalkNodeMaterial;
/// Saves @a Package in .umap format in path @a PackagePath inside Unreal
/// Content folder
bool SavePackage(const FString &PackagePath, UPackage *Package) const;