Updated doc and renamed commandlet

This commit is contained in:
Manish 2019-07-08 17:29:45 +02:00 committed by Néstor Subirón
parent 24e53a8081
commit 91d815e115
7 changed files with 46 additions and 109 deletions

View File

@ -8,13 +8,15 @@ The main objective for importing and exporting assets is to reduce the size of t
The first step is to create an empty folder inside the Carla `Import` folder and rename it with the name of the package desired. For simplifying the package folder structure,we recommend to have as many subfolders as maps to import and one single subfolder containing all the props to import. Inside each subfolder, we will place all the files needed for importing.
So basically, for a **map** subfolder, we will need to place the following files:
- The map itself in `.FBX` format.
- Optionally, the textures required by the map.
- Optionally, the `.xodr` OpenDrive file corresponding to that map.
* The map itself in `.FBX` format.
* Optionally, the textures required by the map.
* Optionally, the `.xodr` OpenDrive file corresponding to that map.
And for the **props** folder, we will need the following files:
- The prop itself in `.FBX` format.
- Optionally, the textures required by the prop.
* The prop itself in `.FBX` format.
* Optionally, the textures required by the prop.
Therefore, the package folder should have this similar structure:
```
@ -52,6 +54,8 @@ Import
└── PropToImport04.fbx
```
*Please note that the maps exported from **RoadRunner** are also supported for importing them inside Carla. So, basically, once created your **RoadRunner** map, you just need to export it, take the required files and place them following the structure listed above.*
Once set this project structure, a JSON file needs to be created for each package that will contain necessary information about the assets inside it. The format of this file must be `.json`. We recommend for the JSON file to have the same name as the package name in order to keep it organized.
The content of this JSON file should be similar to the following:
@ -59,28 +63,28 @@ The content of this JSON file should be similar to the following:
{
"maps": [{
"name": "MyTown01",
"source": "./Town01/Town01.fbx",
"source": "./MapToImport01/MapToImport01.fbx",
"use_carla_materials": true,
"xodr": "./Town01/Town01.xodr"
"xodr": "./MapToImport01/MapToImport01.xodr"
},
{
"name": "MyTown02",
"source": "./Town02/Town02.fbx",
"use_carla_materials": true,
"xodr": "./Town02/Town02.xodr"
"source": "./MapToImport02/MapToImport02.fbx",
"use_carla_materials": false,
"xodr": "./MapToImport02/MapToImport02.xodr"
}
],
"props": [{
"name": "MyProp01",
"size": "medium",
"source": "./MyProp01Mesh.fbx",
"tag": "SegmentationTag01"
"source": "./AssetsToImport/PropToImport01/PropToImport01.fbx",
"tag": "SemanticSegmentationTag01"
},
{
"name": "MyProp02",
"size": "small",
"source": "MyProp02Mesh.fbx",
"tag": "SegmentationTag02"
"source": "./AssetsToImport/PropToImport02/PropToImport02.fbx",
"tag": "SemanticSegmentationTag02"
}
]
}
@ -89,21 +93,26 @@ The content of this JSON file should be similar to the following:
As you can observe in the JSON file content, we have defined a JSON array of **maps** and **props**.
Each item inside the **maps** array has the following parameters:
- *name*: The name of the map. It is possible to import the same map mesh but with different name and, if so, it will create separate mesh files inside Unreal for each different name.
- *source*: Source path of the map inside the package folder.
- *use_carla_materials*: If true, we will use Carla materials, otherwise, we will use RoadRunner materials.
- *xodr*: Path to the `.xodr` Opendrive file for that map.
* **name**: The name of the map. It is possible to import the same map mesh but with different name and, if so, it will create separate mesh files inside Unreal for each different name.
* **source**: Source path of the map inside the package folder.
* **use_carla_materials**: If true, we will use Carla materials, otherwise, we will use RoadRunner materials.
* **xodr**: Path to the `.xodr` Opendrive file for that map.
And each item inside the **props** array has the following parameters:
- *name*: The name of the prop. It is possible to import the same prop mesh but with different name and, if so, it will create separate mesh files inside Unreal for each different name.
- *source*: Source path of the prop inside the package folder.
- *size*: Size of the prop, possible values are:
* **name**: The name of the prop. It is possible to import the same prop mesh but with different name and, if so, it will create separate mesh files inside Unreal for each different name.
* **source**: Source path of the prop inside the package folder.
* **size**: Size of the prop, possible values are:
- `tiny`
- `small`
- `medium`
- `big`
- `huge`
- *tag*: Semantic segmentation tag. Possible values are:
- **tag**: Semantic segmentation tag. Possible values are:
- `None`
- `Buildings`
- `Fences`
@ -117,6 +126,7 @@ And each item inside the **props** array has the following parameters:
- `Vegetation`
- `Vehicles`
- `Walls`
Note that if the tag is not spelled correctly, it will interpret it as `None` value by default.
Now we have everything ready for importing the packages. To do so, you just need to run the command:

View File

@ -1,71 +0,0 @@
<h1>Automatically generate a map from RoadRunner</h1>
!!! important
The given scripts only works if the files are kept in the folders
detailed below.
This script is aimed to reduce the time needed to setup a map inside Carla's project.
Also, in combination of the [import / export scripts](export_import_dist.md) will allow
the user to generate a simple map without opening Unreal Engine.
!!! important
The script does heavy use of Unreal's capabilities, so it is needed to be installed
and setup, as the import fbx action is done directly over the code project, not a
distribution build.
<h4>How to import a fbx</h4>
The current script only work for files placed with the follow structure (RoadRunnerFiles is
located in the root folder):
```sh
RoadRunnerFiles/
├── MapToImport01
│   ├── Asphalt1_Diff.png
│   ├── Asphalt1_Norm.png
│   ├── Asphalt1_Spec.png
│   ├── Grass1_Diff.png
│   ├── Grass1_Norm.png
│   ├── Grass1_Spec.png
│   ├── LaneMarking1_Diff.png
│   ├── LaneMarking1_Norm.png
│   ├── LaneMarking1_Spec.png
│   ├── MapToImport01.fbx
│   └── MapToImport01.xodr
└── MapToImport02
├── Asphalt1_Diff.png
├── Asphalt1_Norm.png
├── Asphalt1_Spec.png
├── Concrete1_Diff.png
├── Concrete1_Norm.png
├── Concrete1_Spec.png
├── Grass1_Diff.png
├── Grass1_Norm.png
├── Grass1_Spec.png
├── LaneMarking1_Diff.png
├── LaneMarking1_Norm.png
├── LaneMarking1_Spec.png
├── MapToImport02.fbx
└── MapToImport02.xodr
```
Under <i>RoadRunnerFiles</i> folder located at the Carla Root, place each "Export"
folder obtained from RoadRunner and rename it with the name of the map to be imported.
It have to match the <b>.fbx</b>
and <b>.xodr</b> files.
Now, simply go into the _"Util"_ folder and run <b>generate_map.py</b>
!!! important
The script, by default, checks the <i>/Unreal/CarlaUE4/Content/Carla/ExportedMaps</i> for matching names.
If a map with the same name as a to-be-imported map is found, it will notify the user and won't do anything.
To override this, <b>generate_map.py</b> can be invoked with the <b>--force</b> flag.
After the script finishes, all a map with the same name of the folder and files will be located under
<i>/Unreal/CarlaUE4/Content/Carla/Maps</i> with all the static meshes and placed, textures, waypoints and routes
generated.
!!! important
There is a bug in RoadRunner that generates wrong materials automatically and they get broken inside Unreal.
By adding the flag <b>--usecarlamats</b> the meshes will use the materials provided by Carla's project,
that will also <b>react to the weather</b>.

View File

@ -25,7 +25,6 @@
* [Running in a Docker](carla_docker.md)
* [How to make a new map with RoadRunner](how_to_make_a_new_map.md)
* [How to link Epic's Automotive Materials](epic_automotive_materials.md)
* [How to automatically generate a map from RoadRunner](generate_map_from_fbx.md)
* [How to export and import maps and props for distribution builds](export_import_dist.md)
* [How to add friction triggers](how_to_add_friction_triggers.md)
* [How to control vehicle physics](how_to_control_vehicle_physics.md)

View File

@ -1,6 +1,6 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "CookAssetsCommandlet.h"
#include "PrepareAssetsForCookingCommandlet.h"
#include "GameFramework/WorldSettings.h"
#include "HAL/PlatformFilemanager.h"
#include "HAL/PlatformFile.h"
@ -9,7 +9,7 @@
// #include "CommandletPluginPrivate.h"
UCookAssetsCommandlet::UCookAssetsCommandlet()
UPrepareAssetsForCookingCommandlet::UPrepareAssetsForCookingCommandlet()
{
IsClient = false;
IsEditor = true;
@ -33,7 +33,7 @@ UCookAssetsCommandlet::UCookAssetsCommandlet()
}
#if WITH_EDITORONLY_DATA
FPackageParams UCookAssetsCommandlet::ParseParams(const FString &InParams) const
FPackageParams UPrepareAssetsForCookingCommandlet::ParseParams(const FString &InParams) const
{
TArray<FString> Tokens;
TArray<FString> Params;
@ -48,7 +48,7 @@ FPackageParams UCookAssetsCommandlet::ParseParams(const FString &InParams) const
return PackageParams;
}
void UCookAssetsCommandlet::LoadWorld(FAssetData &AssetData)
void UPrepareAssetsForCookingCommandlet::LoadWorld(FAssetData &AssetData)
{
FString BaseMap = TEXT("/Game/Carla/Maps/BaseMap");
@ -64,7 +64,7 @@ void UCookAssetsCommandlet::LoadWorld(FAssetData &AssetData)
}
}
TArray<AStaticMeshActor *> UCookAssetsCommandlet::AddMeshesToWorld(
TArray<AStaticMeshActor *> UPrepareAssetsForCookingCommandlet::AddMeshesToWorld(
const TArray<FString> &AssetsPaths,
bool bUseCarlaMaterials,
bool bIsPropsMap)
@ -136,7 +136,7 @@ TArray<AStaticMeshActor *> UCookAssetsCommandlet::AddMeshesToWorld(
return SpawnedMeshes;
}
void UCookAssetsCommandlet::DestroySpawnedActorsInWorld(TArray<AStaticMeshActor *> &SpawnedActors)
void UPrepareAssetsForCookingCommandlet::DestroySpawnedActorsInWorld(TArray<AStaticMeshActor *> &SpawnedActors)
{
for (auto Actor : SpawnedActors)
{
@ -146,7 +146,7 @@ void UCookAssetsCommandlet::DestroySpawnedActorsInWorld(TArray<AStaticMeshActor
World->MarkPackageDirty();
}
bool UCookAssetsCommandlet::SaveWorld(
bool UPrepareAssetsForCookingCommandlet::SaveWorld(
FAssetData &AssetData,
FString &PackageName,
FString &DestPath,
@ -193,7 +193,7 @@ bool UCookAssetsCommandlet::SaveWorld(
return bPackageSaved;
}
FAssetsPaths UCookAssetsCommandlet::GetAssetsPathFromPackage(const FString &PackageName) const
FAssetsPaths UPrepareAssetsForCookingCommandlet::GetAssetsPathFromPackage(const FString &PackageName) const
{
FString PackageConfigPath = FPaths::ProjectContentDir() + PackageName + TEXT("/Config/");
@ -265,7 +265,7 @@ bool SaveStringTextToFile(
return true;
}
bool UCookAssetsCommandlet::SavePackage(const FString &PackagePath, UPackage *Package) const
bool UPrepareAssetsForCookingCommandlet::SavePackage(const FString &PackagePath, UPackage *Package) const
{
FString PackageFileName = FPackageName::LongPackageNameToFilename(PackagePath,
FPackageName::GetMapPackageExtension());
@ -274,7 +274,7 @@ bool UCookAssetsCommandlet::SavePackage(const FString &PackagePath, UPackage *Pa
*PackageFileName, GError, nullptr, true, true, SAVE_NoError);
}
int32 UCookAssetsCommandlet::Main(const FString &Params)
int32 UPrepareAssetsForCookingCommandlet::Main(const FString &Params)
{
FPackageParams PackageParams = ParseParams(Params);

View File

@ -16,7 +16,7 @@
#include <AssetRegistry/Public/AssetRegistryModule.h>
#endif // WITH_EDITORONLY_DATA
#include <Runtime/Engine/Classes/Engine/StaticMeshActor.h>
#include "CookAssetsCommandlet.generated.h"
#include "PrepareAssetsForCookingCommandlet.generated.h"
USTRUCT()
struct CARLA_API FPackageParams
@ -51,7 +51,7 @@ struct CARLA_API FAssetsPaths
};
UCLASS()
class UCookAssetsCommandlet
class UPrepareAssetsForCookingCommandlet
: public UCommandlet
{
GENERATED_BODY()
@ -59,7 +59,7 @@ class UCookAssetsCommandlet
public:
/** Default constructor. */
UCookAssetsCommandlet();
UPrepareAssetsForCookingCommandlet();
#if WITH_EDITORONLY_DATA
/**

View File

@ -273,7 +273,7 @@ def move_uassets(package_name, maps):
def prepare_cook_commandlet(package_name):
commandlet_name = "CookAssets"
commandlet_name = "PrepareAssetsForCooking"
commandlet_arguments = "-PackageName=%s" % package_name
invoke_commandlet(commandlet_name, commandlet_arguments)

View File

@ -21,7 +21,6 @@ nav:
- 'Running in a Docker': 'carla_docker.md'
- "How to make a new map with RoadRunner": 'how_to_make_a_new_map.md'
- "How to link Epic's Automotive Materials": 'epic_automotive_materials.md'
- "How to automatically generate a map from RoadRunner": 'generate_map_from_fbx.md'
- "How to export and import maps and props for distribution builds": 'export_import_dist.md'
- "How to record and replay": 'recorder_and_playback.md'
- "Recorder binary file format": 'recorder_binary_file_format.md'