deleting useless files

This commit is contained in:
Manish 2019-07-05 11:58:49 +02:00 committed by Néstor Subirón
parent 9f1ebea9a8
commit 6f22259c29
8 changed files with 0 additions and 1299 deletions

View File

@ -1,140 +0,0 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "FBXExporterPreparatorCommandlet.h"
#include "Engine/StaticMeshActor.h"
#include "GameFramework/WorldSettings.h"
#include "Misc/PackageName.h"
#include "UObject/MetaData.h"
#include "UObject/Package.h"
UFBXExporterPreparatorCommandlet::UFBXExporterPreparatorCommandlet()
{
IsClient = false;
IsEditor = true;
IsServer = false;
LogToConsole = true;
}
#if WITH_EDITORONLY_DATA
bool UFBXExporterPreparatorCommandlet::ParseParams(const FString &InParams)
{
Params = InParams;
ParseCommandLine(*Params, Tokens, Switches);
return true;
}
void UFBXExporterPreparatorCommandlet::LoadWorld(FAssetData &AssetData)
{
FString SeedMap;
FParse::Value(*Params, TEXT("SourceMap="), SeedMap);
MapObjectLibrary = UObjectLibrary::CreateLibrary(UWorld::StaticClass(), false, GIsEditor);
MapObjectLibrary->AddToRoot();
MapObjectLibrary->LoadAssetDataFromPath(*SeedMap);
MapObjectLibrary->LoadAssetsFromAssetData();
MapObjectLibrary->GetAssetDataList(AssetDatas);
if (AssetDatas.Num() > 0)
{
AssetData = AssetDatas.Pop();
}
}
void UFBXExporterPreparatorCommandlet::AddMeshesToWorld()
{
TArray<FString> CmdLineDirEntries;
const FString CookDirPrefix = TEXT("MESHESDIR=");
for (int32 SwitchIdx = 0; SwitchIdx < Switches.Num(); SwitchIdx++)
{
const FString &Switch = Switches[SwitchIdx];
if (Switch.StartsWith(CookDirPrefix))
{
FString DirToCook = Switch.Right(Switch.Len() - 10);
// Allow support for -COOKDIR=Dir1+Dir2+Dir3 as well as -COOKDIR=Dir1
// -COOKDIR=Dir2
for (int32 PlusIdx = DirToCook.Find(TEXT("+"));
PlusIdx != INDEX_NONE;
PlusIdx = DirToCook.Find(TEXT("+")))
{
FString DirName = DirToCook.Left(PlusIdx);
// The dir may be contained within quotes
DirName = DirName.TrimQuotes();
FPaths::NormalizeDirectoryName(DirName);
CmdLineDirEntries.Add(DirName);
DirToCook = DirToCook.Right(DirToCook.Len() - (PlusIdx + 1));
DirToCook = DirToCook.TrimQuotes();
}
}
}
AssetsObjectLibrary = UObjectLibrary::CreateLibrary(UStaticMesh::StaticClass(), false, GIsEditor);
AssetsObjectLibrary->AddToRoot();
AssetsObjectLibrary->LoadAssetDataFromPaths(CmdLineDirEntries);
AssetsObjectLibrary->LoadAssetsFromAssetData();
const FTransform zeroTransform = FTransform();
FVector initialVector = FVector(0, 0, 0);
FRotator initialRotator = FRotator(0, 180, 0);
FActorSpawnParameters SpawnInfo;
MapContents.Empty();
AssetsObjectLibrary->GetAssetDataList(MapContents);
UStaticMesh *MeshAsset;
AStaticMeshActor *MeshActor;
for (auto MapAsset : MapContents)
{
MeshAsset = CastChecked<UStaticMesh>(MapAsset.GetAsset());
MeshActor = World->SpawnActor<AStaticMeshActor>(AStaticMeshActor::StaticClass(),
initialVector,
initialRotator);
MeshActor->GetStaticMeshComponent()->SetStaticMesh(CastChecked<UStaticMesh>(MeshAsset));
}
World->MarkPackageDirty();
}
bool UFBXExporterPreparatorCommandlet::SaveWorld(FAssetData &AssetData)
{
FString DestPath, WorldName, PackageName;
FParse::Value(*Params, TEXT("DestMapPath="), DestPath);
FParse::Value(*Params, TEXT("DestMapName="), WorldName);
PackageName = DestPath + "/" + WorldName;
UPackage *Package = AssetData.GetPackage();
Package->SetFolderName(*DestPath);
Package->FullyLoad();
Package->MarkPackageDirty();
FAssetRegistryModule::AssetCreated(World);
// Notify the system about the map's name change
World->Rename(*WorldName, World->GetOuter());
FAssetRegistryModule::AssetRenamed(World, *PackageName);
World->MarkPackageDirty();
World->GetOuter()->MarkPackageDirty();
// Saving the package
FString PackageFileName = FPackageName::LongPackageNameToFilename(PackageName,
FPackageName::GetMapPackageExtension());
return UPackage::SavePackage(Package, World, EObjectFlags::RF_Public | EObjectFlags::RF_Standalone,
*PackageFileName, GError, nullptr, true, true, SAVE_NoError);
}
int32 UFBXExporterPreparatorCommandlet::Main(const FString &ParamsIn)
{
ParseParams(ParamsIn);
FAssetData AssetData;
LoadWorld(AssetData);
World = CastChecked<UWorld>(AssetData.GetAsset());
AddMeshesToWorld();
SaveWorld(AssetData);
return 0;
}
#endif

View File

@ -1,98 +0,0 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Commandlets/Commandlet.h"
#include "CoreMinimal.h"
#include "Engine/ObjectLibrary.h"
#include "Engine/World.h"
#if WITH_EDITORONLY_DATA
#include <AssetRegistry/Public/AssetRegistryModule.h>
#include <Developer/AssetTools/Public/IAssetTools.h>
#include <Developer/AssetTools/Public/AssetToolsModule.h>
#endif // WITH_EDITORONLY_DATA
#include "FBXExporterPreparatorCommandlet.generated.h"
UCLASS()
class UFBXExporterPreparatorCommandlet
: public UCommandlet
{
GENERATED_BODY()
public:
/// Default constructor.
UFBXExporterPreparatorCommandlet();
#if WITH_EDITORONLY_DATA
/// Parses the command line parameters
/// @param InParams - The parameters to parse
bool ParseParams(const FString &InParams);
/// Move meshes from one folder to another. It only works with StaticMeshes
/// @param SrcPath - Source folder from which the StaticMeshes will be obtained
/// @param DestPath - Posible folder in which the Meshes will be ordered
/// following
/// the semantic segmentation. It follows ROAD_INDEX, MARKINGLINE_INDEX,
/// TERRAIN_INDEX
/// for the position in which each path will be stored.
void MoveMeshes(const FString &SrcPath, const TArray<FString> &DestPath);
/// Loads a UWorld object from a given path into a asset data structure.
/// @param SrcPath - Folder in which the world is located.
/// @param AssetData - Structure in which the loaded UWorld will be saved.
void LoadWorld(FAssetData &AssetData);
/// Add StaticMeshes from a folder into the World loaded as UPROPERTY.
/// @param SrcPath - Array containing the folders from which the Assets will be
/// loaded
/// @param bMaterialWorkaround - Flag that will trigger a change in the
/// materials to fix a known bug
/// in RoadRunner.
void AddMeshesToWorld();
/// Save a given Asset containing a World into a given path with a given name.
/// @param AssetData - Contains all the info about the World to be saved
/// @param DestPath - Path in which the asset will be saved.
/// @param WorldName - Name for the saved world.
bool SaveWorld(FAssetData &AssetData);
public:
/// Main method and entry of the commandlet
/// @param Params - Parameters of the commandlet.
virtual int32 Main(const FString &Params) override;
#endif // WITH_EDITORONLY_DATA
private:
UPROPERTY()
bool bOverrideMaterials;
// UProperties are necesary or else the GC will eat everything up
UPROPERTY()
FString MapName;
UPROPERTY()
UObjectLibrary *MapObjectLibrary;
UPROPERTY()
TArray<FAssetData> AssetDatas;
UPROPERTY()
UWorld *World;
UPROPERTY()
UObjectLibrary *AssetsObjectLibrary;
UPROPERTY()
TArray<FAssetData> MapContents;
/** All commandline tokens */
TArray<FString> Tokens;
/** All commandline switches */
TArray<FString> Switches;
/** All commandline params */
FString Params;
};

View File

@ -1,262 +0,0 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "MapProcessCommandlet.h"
#include "GameFramework/WorldSettings.h"
#include "UObject/MetaData.h"
//#include "CommandletPluginPrivate.h"
UMapProcessCommandlet::UMapProcessCommandlet()
{
IsClient = false;
IsEditor = true;
IsServer = false;
LogToConsole = true;
#if WITH_EDITORONLY_DATA
static ConstructorHelpers::FObjectFinder<UMaterial> MarkingNode(TEXT(
"Material'/Game/Carla/Static/GenericMaterials/LaneMarking/M_MarkingLane_W.M_MarkingLane_W'"));
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'"));
static ConstructorHelpers::FObjectFinder<UMaterial> TerrainNodeMaterial(TEXT(
"Material'/Game/Carla/Static/GenericMaterials/Grass/M_Grass01.M_Grass01'"));
MarkingNodeMaterial = (UMaterial *) MarkingNode.Object;
RoadNodeMaterial = (UMaterial *) RoadNode.Object;
MarkingNodeMaterialAux = (UMaterial *) RoadNodeAux.Object;
#endif
}
#if WITH_EDITORONLY_DATA
bool UMapProcessCommandlet::ParseParams(const FString& InParams)
{
TArray<FString> Tokens;
TArray<FString> Params;
TMap<FString, FString> ParamVals;
ParseCommandLine(*InParams, Tokens, Params, ParamVals);
const bool bEnoughParams = ParamVals.Num() > 1;
MapName = ParamVals.FindRef(TEXT("mapname"));
bOverrideMaterials = Params.Contains(TEXT("use-carla-materials"));
return bEnoughParams;
}
void UMapProcessCommandlet::MoveMeshes(const FString &SrcPath, const TArray<FString> &DestPath)
{
AssetsObjectLibrary = UObjectLibrary::CreateLibrary(UStaticMesh::StaticClass(), false, GIsEditor);
AssetsObjectLibrary->AddToRoot();
AssetsObjectLibrary->LoadAssetDataFromPath(*SrcPath);
AssetsObjectLibrary->LoadAssetsFromAssetData();
MapContents.Empty();
AssetsObjectLibrary->GetAssetDataList(MapContents);
UStaticMesh *MeshAsset;
FString PackagePath;
FString ObjectName;
if (MapContents.Num() > 0)
{
int ChosenIndex = 0;
FString AssetName;
FAssetToolsModule &AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
for (auto MapAsset : MapContents)
{
MeshAsset = CastChecked<UStaticMesh>(MapAsset.GetAsset());
ObjectName = MeshAsset->GetName();
MapAsset.AssetName.ToString(AssetName);
if (SrcPath.Len())
{
const FString CurrentPackageName = MeshAsset->GetOutermost()->GetName();
//UE_LOG(LogCommandletPlugin, Display, TEXT("DANIEL: %s"), *CurrentPackageName);
// This is a relative operation
if (!ensure(CurrentPackageName.StartsWith(SrcPath)))
{
continue;
}
if (AssetName.Contains("MarkingNode"))
{
ChosenIndex=MARKINGLINE_INDEX;
}
else if (AssetName.Contains("RoadNode"))
{
ChosenIndex=ROAD_INDEX;
} else if (AssetName.Contains("Terrain")) {
ChosenIndex=TERRAIN_INDEX;
}
const int32 ShortPackageNameLen = FPackageName::GetLongPackageAssetName(CurrentPackageName).Len();
const int32 RelativePathLen = CurrentPackageName.Len() - ShortPackageNameLen - SrcPath.Len() - 1; //
// -1
// to
// exclude
// the
// trailing
// "/"
const FString RelativeDestPath = CurrentPackageName.Mid(SrcPath.Len(), RelativePathLen);
PackagePath = DestPath[ChosenIndex] + RelativeDestPath;
}
else
{
// Only a DestPath was supplied, use it
PackagePath = DestPath[ChosenIndex];
}
MeshAsset->AddToRoot();
FString NewPackageName = PackagePath + "/" + ObjectName;
UPackage *AssetPackage = MapAsset.GetPackage();
AssetPackage->SetFolderName(*PackagePath);
AssetPackage->FullyLoad();
AssetPackage->MarkPackageDirty();
FAssetRegistryModule::AssetCreated(MeshAsset);
MeshAsset->MarkPackageDirty();
MeshAsset->GetOuter()->MarkPackageDirty();
FString CompleteFilename = FPackageName::LongPackageNameToFilename(NewPackageName,
FPackageName::GetAssetPackageExtension());
UPackage::SavePackage(AssetPackage, MeshAsset, EObjectFlags::RF_Public | EObjectFlags::RF_Standalone,
*CompleteFilename, GError, nullptr, true, true, SAVE_NoError);
}
}
}
void UMapProcessCommandlet::LoadWorld(const FString &SrcPath, FAssetData &AssetData)
{
MapObjectLibrary = UObjectLibrary::CreateLibrary(UWorld::StaticClass(), false, GIsEditor);
MapObjectLibrary->AddToRoot();
MapObjectLibrary->LoadAssetDataFromPath(*SrcPath);
MapObjectLibrary->LoadAssetsFromAssetData();
MapObjectLibrary->GetAssetDataList(AssetDatas);
if (AssetDatas.Num() > 0)
{
AssetData = AssetDatas.Pop();
}
}
void UMapProcessCommandlet::AddMeshesToWorld(
const TArray<FString> &SrcPath,
bool bMaterialWorkaround)
{
AssetsObjectLibrary = UObjectLibrary::CreateLibrary(UStaticMesh::StaticClass(), false, GIsEditor);
AssetsObjectLibrary->AddToRoot();
AssetsObjectLibrary->LoadAssetDataFromPaths(SrcPath);
AssetsObjectLibrary->LoadAssetsFromAssetData();
const FTransform zeroTransform = FTransform();
FVector initialVector = FVector(0, 0, 0);
FRotator initialRotator = FRotator(0, 180, 0);
FActorSpawnParameters SpawnInfo;
MapContents.Empty();
AssetsObjectLibrary->GetAssetDataList(MapContents);
UStaticMesh *MeshAsset;
AStaticMeshActor *MeshActor;
for (auto MapAsset : MapContents)
{
MeshAsset = CastChecked<UStaticMesh>(MapAsset.GetAsset());
MeshActor = World->SpawnActor<AStaticMeshActor>(AStaticMeshActor::StaticClass(),
initialVector,
initialRotator);
MeshActor->GetStaticMeshComponent()->SetStaticMesh(CastChecked<UStaticMesh>(MeshAsset));
if (bMaterialWorkaround)
{
FString AssetName;
MapAsset.AssetName.ToString(AssetName);
if (AssetName.Contains("MarkingNode"))
{
MeshActor->GetStaticMeshComponent()->SetMaterial(0, MarkingNodeMaterial);
MeshActor->GetStaticMeshComponent()->SetMaterial(1, MarkingNodeMaterialAux);
}
else if (AssetName.Contains("RoadNode"))
{
MeshActor->GetStaticMeshComponent()->SetMaterial(0, RoadNodeMaterial);
} else if (AssetName.Contains("Terrain"))
{
MeshActor->GetStaticMeshComponent()->SetMaterial(0, TerrainNodeMaterial);
}
}
}
World->MarkPackageDirty();
}
bool UMapProcessCommandlet::SaveWorld(FAssetData &AssetData, FString &DestPath, FString &WorldName)
{
FString PackageName = DestPath + "/" + WorldName;
UPackage *Package = AssetData.GetPackage();
Package->SetFolderName(*DestPath);
Package->FullyLoad();
Package->MarkPackageDirty();
FAssetRegistryModule::AssetCreated(World);
// Renaming stuff for the map
World->Rename(*WorldName, World->GetOuter());
FAssetRegistryModule::AssetRenamed(World, *PackageName);
World->MarkPackageDirty();
World->GetOuter()->MarkPackageDirty();
// Filling the map stuff
AOpenDriveActor *OpenWorldActor =
CastChecked<AOpenDriveActor>(World->SpawnActor(AOpenDriveActor::StaticClass(), new FVector(), NULL));
OpenWorldActor->BuildRoutes(WorldName);
OpenWorldActor->AddSpawners();
// Saving the package
FString PackageFileName = FPackageName::LongPackageNameToFilename(PackageName,
FPackageName::GetMapPackageExtension());
return UPackage::SavePackage(Package, World, EObjectFlags::RF_Public | EObjectFlags::RF_Standalone,
*PackageFileName, GError, nullptr, true, true, SAVE_NoError);
}
int32 UMapProcessCommandlet::Main(const FString &Params)
{
ParseParams(Params);
FString SrcPath = TEXT("/Game/Carla/Static/Imported/") + MapName;
FString BaseMap = TEXT("/Game/Carla/Maps/BaseMap");
FString WorldDestPath = TEXT("/Game/Carla/ExportedMaps");
FString RoadsPath = TEXT("/Game/Carla/Static/Road/") + MapName;
FString MarkingLinePath = TEXT("/Game/Carla/Static/RoadLines/") + MapName;
FString TerrainPath = TEXT("/Game/Carla/Static/Terrain/") + MapName;
TArray<FString> DataPath;
DataPath.Add(RoadsPath);
DataPath.Add(MarkingLinePath);
DataPath.Add(TerrainPath);
FAssetData AssetData;
MoveMeshes(SrcPath, DataPath);
LoadWorld(*BaseMap, AssetData);
World = CastChecked<UWorld>(AssetData.GetAsset());
AddMeshesToWorld(DataPath, bOverrideMaterials);
SaveWorld(AssetData, WorldDestPath, MapName);
return 0;
}
#endif

View File

@ -1,135 +0,0 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Commandlets/Commandlet.h"
#include <Engine/World.h>
#include <UObject/Package.h>
#include <Misc/PackageName.h>
#include "CoreMinimal.h"
#include <Runtime/Engine/Classes/Engine/ObjectLibrary.h>
#include "Carla/OpenDrive/OpenDriveActor.h"
#if WITH_EDITORONLY_DATA
#include <Developer/AssetTools/Public/IAssetTools.h>
#include <Developer/AssetTools/Public/AssetToolsModule.h>
#include <AssetRegistry/Public/AssetRegistryModule.h>
#endif //WITH_EDITORONLY_DATA
#include <Runtime/Engine/Classes/Engine/StaticMeshActor.h>
#include "MapProcessCommandlet.generated.h"
UCLASS()
class UMapProcessCommandlet
: public UCommandlet
{
GENERATED_BODY()
public:
/** Default constructor. */
UMapProcessCommandlet();
#if WITH_EDITORONLY_DATA
/**
* Parses the command line parameters
* @param InParams - The parameters to parse
*/
bool ParseParams(const FString& InParams);
/**
* Move meshes from one folder to another. It only works with StaticMeshes
* @param SrcPath - Source folder from which the StaticMeshes will be obtained
* @param DestPath - Posible folder in which the Meshes will be ordered following
* the semantic segmentation. It follows ROAD_INDEX, MARKINGLINE_INDEX, TERRAIN_INDEX
* for the position in which each path will be stored.
*/
void MoveMeshes(const FString &SrcPath, const TArray<FString> &DestPath);
/**
* Loads a UWorld object from a given path into a asset data structure.
* @param SrcPath - Folder in which the world is located.
* @param AssetData - Structure in which the loaded UWorld will be saved.
*/
void LoadWorld(const FString &SrcPath, FAssetData& AssetData);
/**
* Add StaticMeshes from a folder into the World loaded as UPROPERTY.
* @param SrcPath - Array containing the folders from which the Assets will be loaded
* @param bMaterialWorkaround - Flag that will trigger a change in the materials to fix a known bug
* in RoadRunner.
*/
void AddMeshesToWorld(const TArray<FString> &SrcPath, bool bMaterialWorkaround);
/**
* Save a given Asset containing a World into a given path with a given name.
* @param AssetData - Contains all the info about the World to be saved
* @param DestPath - Path in which the asset will be saved.
* @param WorldName - Name for the saved world.
*/
bool SaveWorld(FAssetData& AssetData, FString &DestPath, FString &WorldName);
public:
/**
* Main method and entry of the commandlet
* @param Params - Parameters of the commandlet.
*/
virtual int32 Main(const FString &Params) override;
#endif //WITH_EDITORONLY_DATA
private:
/** Materials for the workaround */
/**
* Workaround material for MarkingNodes mesh
*/
UMaterial* MarkingNodeMaterial;
/**
* Workaround material for the RoadNode mesh
*/
UMaterial* RoadNodeMaterial;
/**
* Workaround material for the second material for the MarkingNodes
*/
UMaterial* MarkingNodeMaterialAux;
/**
* Workaround material for the TerrainNodes
*/
UMaterial* TerrainNodeMaterial;
/**
* Index in which everything related to the road will be stored in inclass arrays
*/
static const int ROAD_INDEX = 0;
/**
* Index in which everything related to the marking lines will be stored in inclass arrays
*/
static const int MARKINGLINE_INDEX = 1;
/**
* Index in which everything related to the terrain will be stored in inclass arrays
*/
static const int TERRAIN_INDEX = 2;
UPROPERTY()
bool bOverrideMaterials;
//UProperties are necesary or else the GC will eat everything up
UPROPERTY()
FString MapName;
UPROPERTY()
UObjectLibrary* MapObjectLibrary;
UPROPERTY()
TArray<FAssetData> AssetDatas;
UPROPERTY()
UWorld* World;
UPROPERTY()
UObjectLibrary* AssetsObjectLibrary;
UPROPERTY()
TArray<FAssetData> MapContents;
};

View File

@ -1,135 +0,0 @@
#! /bin/bash
# ==============================================================================
# -- Set up environment --------------------------------------------------------
# ==============================================================================
source $(dirname "$0")/Environment.sh
if [ ! -d "${UE4_ROOT}" ]; then
fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable."
else
log "Using Unreal Engine at '$UE4_ROOT'"
fi
# ==============================================================================
# -- Parse arguments -----------------------------------------------------------
# ==============================================================================
DOC_STRING="Build and packs CarlaUE4's Imported FBX"
USAGE_STRING="Usage: $0 [--help] [--dir=outdir] [--file=filename] [--maps=maps_to_cook]"
OUTPUT_DIRECTORY=""
FILE_NAME=""
PATHS_TO_COOK=""
OPTS=`getopt -o h --long help,dir:,file:,maps: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2; fi
eval set -- "$OPTS"
while true; do
case "$1" in
--dir )
OUTPUT_DIRECTORY="$2"
shift 2;;
--file )
FILE_NAME="$2"
shift 2;;
--maps )
MAP_TO_COOK="$2"
shift 2;;
--help )
echo "$DOC_STRING"
echo "$USAGE_STRING"
exit 1
;;
* )
break ;;
esac
done
if [ -z "${OUTPUT_DIRECTORY}" ]; then
OUTPUT_DIRECTORY="${PWD}/ExportedFBX"
fi
if [ -z "${FILE_NAME}" ]; then
FILE_NAME="CookedExportedFBX"
fi
# ==============================================================================
# -- Package project -----------------------------------------------------------
# ==============================================================================
REPOSITORY_TAG=$(get_git_repository_version)
BUILD_FOLDER=${OUTPUT_DIRECTORY}
log "Packaging user content from version '$REPOSITORY_TAG'."
#rm -Rf ${BUILD_FOLDER}
mkdir -p ${BUILD_FOLDER}
pushd "${CARLAUE4_ROOT_FOLDER}" > /dev/null
log "Current project directory: '${PWD}'"
${UE4_ROOT}/Engine/Binaries/Linux/UE4Editor "${PWD}/CarlaUE4.uproject" -run=cook -cooksinglepackage -Map=${MAP_TO_COOK} -targetplatform="LinuxNoEditor" -OutputDir="${BUILD_FOLDER}/Cooked"
popd >/dev/null
# ==============================================================================
# -- Zip the project -----------------------------------------------------------
# ==============================================================================
DESTINATION=${BUILD_FOLDER}/${FILE_NAME}.tar.gz
SOURCE=${BUILD_FOLDER}/Cooked
FILES=$(find ${CARLAUE4_ROOT_FOLDER}/Content -type f -name "*PropRegistry.json")
mkdir -p ${SOURCE}/CarlaUE4/Content/Carla/Config
for file in $FILES
do
A="$(echo $file | grep -o 'Content\/.*' | cut -f2 -d/)"
mkdir -p ${SOURCE}/CarlaUE4/Content/${A}/Config
cp -rf $file ${SOURCE}/CarlaUE4/Content/${A}/Config
done
pushd "${SOURCE}" >/dev/null
log "Packaging build."
#rm -Rf ./Engine
rm -Rf ./CarlaUE4/Metadata
rm -Rf ./CarlaUE4/Plugins
# Remove TEMPMAP.umap and TEMPMAP.uexp
TEMPMAP_BASE_PATH="$CARLAUE4_ROOT_FOLDER${MAP_TO_COOK/Game/"Content"}"
rm -f $TEMPMAP_BASE_PATH.uexp
rm $TEMPMAP_BASE_PATH.umap
rm ./CarlaUE4/AssetRegistry.bin
tar -czvf ${DESTINATION} *
popd > /dev/null
# ==============================================================================
# -- Remove intermediate files and return everything to normal------------------
# ==============================================================================
log "Removing intermediate build."
rm -Rf ${BUILD_FOLDER}/Cooked
# ==============================================================================
# -- ...and we are done --------------------------------------------------------
# ==============================================================================
log "FBX Package created at ${DESTINATION}"
log "Success!"

View File

@ -1,139 +0,0 @@
#! /bin/bash
# ==============================================================================
# -- Set up environment --------------------------------------------------------
# ==============================================================================
source $(dirname "$0")/Environment.sh
if [ ! -d "${UE4_ROOT}" ]; then
fatal_error "UE4_ROOT is not defined, or points to a non-existant directory, please set this environment variable."
else
log "Using Unreal Engine at '$UE4_ROOT'"
fi
# ==============================================================================
# -- Parse arguments -----------------------------------------------------------
# ==============================================================================
DOC_STRING="Build and packs CarlaUE4's ExportedMaps"
USAGE_STRING="Usage: $0 [-h|--help] [-d|--dir] <outdir> [-f|--file] <filename>"
OUTPUT_DIRECTORY=""
FILE_NAME=""
MAP_PATH=""
OPTS=`getopt -o h --long help,dir:,file:,map: -n 'parse-options' -- "$@"`
if [ $? != 0 ] ; then echo "$USAGE_STRING" ; exit 2; fi
eval set -- "$OPTS"
while true; do
case "$1" in
--dir )
OUTPUT_DIRECTORY="$2"
shift 2;;
--file )
FILE_NAME="$2"
shift 2;;
--map )
MAP_PATH="$2"
shift 2;;
-h | --help )
echo "$DOC_STRING"
echo "$USAGE_STRING"
exit 1
;;
* )
break ;;
esac
done
if [ -z "${OUTPUT_DIRECTORY}" ]; then
OUTPUT_DIRECTORY="${PWD}/ExportedMaps"
fi
if [ -z "${FILE_NAME}" ]; then
FILE_NAME="CookedExportedMaps"
fi
# ==============================================================================
# -- Package project -----------------------------------------------------------
# ==============================================================================
REPOSITORY_TAG=$(get_git_repository_version)
BUILD_FOLDER=${OUTPUT_DIRECTORY}
log "Packaging user content from version '$REPOSITORY_TAG'."
#rm -Rf ${BUILD_FOLDER}
mkdir -p ${BUILD_FOLDER}
pushd "${CARLAUE4_ROOT_FOLDER}" > /dev/null
log "Current project directory: '${PWD}'"
MAP_LIST=""
if [ -z "${MAP_PATH}" ]; then
for filepath in `find ${PWD}/Content/ -type f -name "*.umap"`; do
if [[ $filepath == *"/ExportedMaps/"* ]]; then
filepath="/Game/"${filepath#"${PWD}/Content/"}
if [ -z "${MAP_LIST}" ]; then
MAP_LIST=$filepath
else
MAP_LIST=$MAP_LIST+$filepath
fi
fi
done
else
MAP_LIST=${MAP_PATH}
fi
${UE4_ROOT}/Engine/Binaries/Linux/UE4Editor "${PWD}/CarlaUE4.uproject" -run=cook -map=${MAP_LIST} -cooksinglepackage -targetplatform="LinuxNoEditor" -OutputDir="${BUILD_FOLDER}/Cooked"
popd >/dev/null
#if [[ ! -d ${BUILD_FOLDER}/LinuxNoEditor ]] ; then
# fatal_error "Failed to package the project!"
#fi
# ==============================================================================
# -- Zip the project -----------------------------------------------------------
# ==============================================================================
DESTINATION=${BUILD_FOLDER}/${FILE_NAME}.tar.gz
SOURCE=${BUILD_FOLDER}/Cooked
pushd "${SOURCE}" >/dev/null
log "Packaging build."
#rm -Rf ./Engine
rm -Rf ./CarlaUE4/Metadata
rm -Rf ./CarlaUE4/Plugins
rm ./CarlaUE4/AssetRegistry.bin
tar -czvf ${DESTINATION} *
popd > /dev/null
# ==============================================================================
# -- Remove intermediate files and return everything to normal------------------
# ==============================================================================
log "Removing intermediate build."
rm -Rf ${BUILD_FOLDER}/Cooked
# ==============================================================================
# -- ...and we are done --------------------------------------------------------
# ==============================================================================
log "ExportedMaps created at ${DESTINATION}"
log "Success!"

View File

@ -1,182 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""Bulk Import FBX"""
import os
import json
import subprocess
import shutil
import argparse
import re
if os.name == 'nt':
sys_name = 'Win64'
elif os.name == 'posix':
sys_name = 'Linux'
def main():
try:
args = parse_arguments()
folder_list = []
import_all_fbx_in_folder(args.folder, folder_list)
finally:
print('\ndone.')
def import_all_fbx_in_folder(fbx_folder, folder_list):
dirname = os.getcwd()
fbx_place = os.path.join(dirname, "..", fbx_folder)
for file in os.listdir(fbx_place):
if file.endswith(".PropRegistry.json"):
registry_name = file.replace(".PropRegistry.json", "")
with open(os.path.join(dirname, "..", fbx_folder, file)) as json_file:
data = json.load(json_file)
# This will take all the fbx registerd in the provided json files
# and place it inside unreal in the provided path (by the json file)
import_assets_commandlet(data, fbx_folder, registry_name, folder_list)
# This part will just gather all the folders in which an fbx has been placed
if(len(folder_list) > 0):
final_list = ""
for folder in folder_list:
if folder not in final_list:
final_list += folder + "+"
final_list = final_list[:-1]
# Destination map (the one that will be cooked)
dest_map_path = "/Game/Carla/Maps/TestMaps"
dest_map_name = "TEMPMAP"
# This should be a folder, because the commandlet will take anything inside.
# It is better if there is only one map inside
src_map_folder = "/Game/Carla/Maps/TestMaps"
prepare_cook_commandlet(final_list, src_map_folder, dest_map_path, dest_map_name)
launch_bash_script("BuildTools/ExportFBX.sh", "--maps=%s/%s" % (dest_map_path, dest_map_name))
def parse_arguments():
argparser = argparse.ArgumentParser(
description=__doc__)
argparser.add_argument(
'-f', '--folder',
metavar='F',
type=str,
default="FBXImporter",
help='FBX containing folder')
return argparser.parse_args()
def prepare_cook_commandlet(folder_list, source_map, dest_map_path, dest_map_name):
commandlet_name = "FBXExporterPreparator"
commandlet_arguments = "-MeshesDir=%s -SourceMap=%s -DestMapPath=%s -DestMapName=%s" % (
folder_list, source_map, dest_map_path, dest_map_name)
invoke_commandlet(commandlet_name, commandlet_arguments)
def import_assets_commandlet(json_data, fbx_folder, registry_name, folder_list):
importfile = "importsetting.json"
if os.path.exists(importfile):
os.remove(importfile)
populate_json_and_data(json_data, fbx_folder, importfile, registry_name, folder_list)
generate_prop_registry_file_for_unreal(json_data, registry_name)
dirname = os.getcwd()
commandlet_name = "ImportAssets"
import_settings = os.path.join(dirname, importfile)
commandlet_arguments = "-importSettings=\"%s\" -AllowCommandletRendering -nosourcecontrol -replaceexisting" % import_settings
invoke_commandlet(commandlet_name, commandlet_arguments)
# Clean up
os.remove(importfile)
def invoke_commandlet(name, arguments):
ue4_path = os.environ['UE4_ROOT']
dirname = os.getcwd()
editor_path = "%s/Engine/Binaries/%s/UE4Editor" % (ue4_path, sys_name)
uproject_path = os.path.join(dirname, "..", "Unreal", "CarlaUE4", "CarlaUE4.uproject")
full_command = "%s %s -run=%s %s" % (editor_path, uproject_path, name, arguments)
subprocess.check_call([full_command], shell=True)
def launch_bash_script(script_path, arguments):
dirname = os.getcwd()
full_command = "%s %s" % (os.path.join(dirname, script_path), arguments)
print("Executing: " + full_command)
subprocess.check_call([full_command], shell=True)
def populate_json_and_data(json_data, fbx_folder, json_file, registry_name, folder_list):
with open(json_file, "w+") as fh:
import_groups = []
file_names = []
import_settings = []
import_settings.append({
"bImportMesh": 1,
"bConvertSceneUnit": 1,
"bConvertScene": 1,
"bCombineMeshes": 1,
"bImportTextures": 1,
"bImportMaterials": 1,
"bRemoveDegenerates": 1,
"AnimSequenceImportData": {},
"SkeletalMeshImportData": {},
"TextureImportData": {},
"StaticMeshImportData": {
"bRemoveDegenerates": 1,
"bAutoGenerateCollision": 0,
"bCombineMeshes": 0
}
})
for prop in json_data['definitions']:
destination_path = "/Game/" + registry_name + "/Static/" + prop["tag"] + "/" + prop["name"]
file_names = []
fbx_path = os.path.join("..", "..", fbx_folder, "%s" % prop["source"])
file_names.append(fbx_path)
import_groups.append({
"ImportSettings": import_settings,
"FactoryName": "FbxFactory",
"DestinationPath": destination_path,
"bReplaceExisting": "true",
"FileNames": file_names
})
folder_list.append(destination_path)
fh.write(json.dumps({"ImportGroups": import_groups}))
fh.close()
def generate_prop_registry_file_for_unreal(json_data, registry_name):
data = {}
data["definitions"] = []
for prop in json_data['definitions']:
name = prop["name"]
size = prop["size"]
fbx_name = prop["source"].replace(".fbx", "")
path = "/Game/" + registry_name + "/Static/" + prop["tag"] + "/" + prop["name"] + "/" + fbx_name
data['definitions'].append({
"name": name,
"size": size,
"path": path
})
registry_path = os.path.join("../Unreal/CarlaUE4/Content/" + registry_name + "/Config/")
if not os.path.exists(registry_path):
try:
os.makedirs(registry_path)
except OSError as exc:
if exc.errno != errno.EEXIST:
raise
with open(registry_path + registry_name + "_generated" + ".PropRegistry.json", 'w+') as fh:
json.dump(data, fh)
if __name__ == '__main__':
main()

View File

@ -1,208 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma de
# Barcelona (UAB).
#
# This work is licensed under the terms of the MIT license.
# For a copy, see <https://opensource.org/licenses/MIT>.
"""Generate map from FBX"""
import os
import json
import subprocess
import shutil
import argparse
if os.name == 'nt':
sys_name = 'Win64'
elif os.name == 'posix':
sys_name = 'Linux'
def main():
try:
args = parse_arguments()
if(args.force):
generate_all_maps_but_list([], args)
else:
maps = get_map_names()
generate_all_maps_but_list(maps, args)
dirname = os.path.dirname(os.path.abspath(__file__))
relative_path = os.path.join(dirname, "..", "Unreal", "CarlaUE4", "Content", "Carla", "ExportedMaps")
print('Map(s) exported to %s' % os.path.abspath(relative_path))
finally:
print('\ndone.')
def get_map_names():
maps = []
dirname = os.getcwd()
map_place = os.path.join(dirname, "..", "Unreal", "CarlaUE4", "Content", "Carla", "ExportedMaps")
for filename in os.listdir(map_place):
if filename.endswith('.umap'):
maps.append(filename)
return maps
def generate_all_maps_but_list(existent_maps, args):
map_name = ""
dirname = os.getcwd()
fbx_place = os.path.join(dirname, "..", "RoadRunnerFiles")
for x in os.walk(fbx_place):
map_name = os.path.basename(x[0])
if map_name != "RoadRunnerFiles":
if not any(ext in "%s.umap" % map_name for ext in existent_maps):
print("Found map in fbx folder: %s" % map_name)
import_assets_commandlet(map_name)
# move_uassets(map_name)
print("Generating map asset for %s" % map_name)
generate_map(map_name, args)
print("Cleaning up directories")
cleanup_assets(map_name)
print("Finished %s" % map_name)
else:
print("WARNING: Found %s map in Content folder, skipping. Use \"--force\" to override\n" % map_name)
def parse_arguments():
argparser = argparse.ArgumentParser(
description=__doc__)
argparser.add_argument(
'-f', '--force',
action='store_true',
help='Force import. Will override maps with the same name')
argparser.add_argument(
'-m', '--map',
metavar='M',
type=str,
help='Map to import. If empty, all maps in the folder will be loaded')
argparser.add_argument(
'--usecarlamats',
action='store_true',
help='Avoid using RoadRunner materials. Use materials provided by Carla instead')
return argparser.parse_args()
def cleanup_assets(map_name):
dirname = os.getcwd()
content_folder = os.path.join(dirname, "..", "Unreal", "CarlaUE4", "Content", "Carla")
origin_folder = os.path.join(content_folder, "Static", "Imported", map_name)
for filename in os.listdir(origin_folder):
if map_name in filename:
removal_path = os.path.join(origin_folder, filename)
os.remove(removal_path)
def import_assets_commandlet(map_name):
generate_json(map_name, "importsetting.json")
dirname = os.getcwd()
commandlet_name = "ImportAssets"
import_settings = os.path.join(dirname, "importsetting.json")
commandlet_arguments = "-importSettings=\"%s\" -AllowCommandletRendering -nosourcecontrol -replaceexisting" % import_settings
file_xodr_origin = os.path.join(dirname, "..", "RoadRunnerFiles", map_name, "%s.xodr" % map_name)
file_xodr_dest = os.path.join(
dirname,
"..",
"Unreal",
"CarlaUE4",
"Content",
"Carla",
"Maps",
"OpenDrive",
"%s.xodr" %
map_name)
shutil.copy2(file_xodr_origin, file_xodr_dest)
invoke_commandlet(commandlet_name, commandlet_arguments)
# Clean up
os.remove("importsetting.json")
def generate_map(map_name, args):
commandlet_name = "MapProcess"
commandlet_arguments = "-mapname=\"%s\"" % map_name
if args.usecarlamats:
commandlet_arguments += " -use-carla-materials"
invoke_commandlet(commandlet_name, commandlet_arguments)
# This line might be needed if Epic tells us anything about the current
# way of doing the movement. It shouldn't but just in case...
def move_uassets(map_name):
dirname = os.getcwd()
content_folder = os.path.join(dirname, "..", "Unreal", "CarlaUE4", "Content", "Carla")
origin_folder = os.path.join(content_folder, "Static", map_name)
dest_path = ""
src_path = ""
marking_dir = os.path.join(content_folder, "Static", "RoadLines", "%sLaneMarking" % map_name)
road_dir = os.path.join(content_folder, "Static", "Road", "Roads%s" % map_name)
terrain_dir = os.path.join(content_folder, "Static", "Terrain", "%sTerrain" % map_name)
if not os.path.exists(marking_dir):
os.makedirs(marking_dir)
if not os.path.exists(road_dir):
os.makedirs(road_dir)
if not os.path.exists(terrain_dir):
os.makedirs(terrain_dir)
for filename in os.listdir(origin_folder):
if "MarkingNode" in filename:
dest_path = os.path.join(marking_dir, filename)
if "RoadNode" in filename:
dest_path = os.path.join(road_dir, filename)
if "TerrainNode" in filename:
dest_path = os.path.join(terrain_dir, filename)
src_path = os.path.join(content_folder, "Static", map_name, filename)
os.rename(src_path, dest_path)
def invoke_commandlet(name, arguments):
ue4_path = os.environ['UE4_ROOT']
dirname = os.getcwd()
editor_path = "%s/Engine/Binaries/%s/UE4Editor" % (ue4_path, sys_name)
uproject_path = os.path.join(dirname, "..", "Unreal", "CarlaUE4", "CarlaUE4.uproject")
full_command = "%s %s -run=%s %s" % (editor_path, uproject_path, name, arguments)
subprocess.check_call([full_command], shell=True)
def generate_json(map_name, json_file):
with open(json_file, "w+") as fh:
import_groups = []
file_names = []
import_settings = []
fbx_path = os.path.join("..", "..", "RoadRunnerFiles", map_name, "%s.fbx" % map_name)
file_names.append(fbx_path)
import_settings.append({
"bImportMesh": 1,
"bConvertSceneUnit": 1,
"bConvertScene": 1,
"bCombineMeshes": 1,
"bImportTextures": 1,
"bImportMaterials": 1,
"bRemoveDegenerates": 1,
"AnimSequenceImportData": {},
"SkeletalMeshImportData": {},
"TextureImportData": {},
"StaticMeshImportData": {
"bRemoveDegenerates": 1,
"bAutoGenerateCollision": 0,
"bCombineMeshes": 0
}
})
dest_path = "/Game/Carla/Static/Imported/%s" % map_name
import_groups.append({
"ImportSettings": import_settings,
"FactoryName": "FbxFactory",
"DestinationPath": dest_path,
"bReplaceExisting": "true",
"FileNames": file_names
})
fh.write(json.dumps({"ImportGroups": import_groups}))
fh.close()
if __name__ == '__main__':
main()