A Unity project that parses OpenDRIVE (.xodr) road network files and generates 3D road geometry using EasyRoads3D for autonomous vehicle simulation and traffic analysis.
- Features
- Requirements
- Installation
- Quick Start
- Usage
- Project Structure
- Architecture
- OpenDRIVE Maps
- API Reference
- Customization
- Troubleshooting
- Performance
- Contributing
- License
- Credits
- OpenDRIVE 1.4+ Parsing: Full support for standard OpenDRIVE XML format
- Automatic Road Generation: Converts OpenDRIVE geometry to 3D Unity roads
- Multiple Geometry Types:
- ✅ Line segments (straight roads)
- ✅ Arc segments (curved roads with constant curvature)
- ⏳ Spiral segments (planned)
- Smart Junction Handling: Automatically distinguishes junctions from regular roads
- EasyRoads3D Integration: Professional road mesh generation
- Traffic Object Support: Parses and positions traffic signals from OpenDRIVE data
- Inspector-Friendly: All settings configurable from Unity Inspector
| Component | Version | Notes |
|---|---|---|
| Unity | 6000.0.60f1+ (LTS) | Required |
| EasyRoads3D v3 | Latest | Must be purchased separately (Unity Asset Store) |
| .NET | 4.x or later | Standard with Unity |
| Platform | Windows/macOS/Linux | Cross-platform |
Note: EasyRoads3D is a paid third-party plugin and is not included in this repository. You must purchase and import it separately before using this project. See Installation for details.
Recommended System:
- RAM: 8GB+
- GPU: DirectX 11/Metal compatible
- Storage: 2GB+ for project
Option A: Clone Repository
git clone https://github.com/ingTikna/autoMaster.git
cd autoMasterOption B: Download ZIP
- Download the latest release
- Extract to your desired location
EasyRoads3D is a paid plugin not included in this repository. You must install it manually:
- Purchase EasyRoads3D Pro v3 from the Unity Asset Store
- Open the project in Unity (see below)
- Go to Window → Package Manager
- Select "My Assets" from the dropdown
- Find EasyRoads3D Pro v3 and click "Download" then "Import"
- Import all files — this will create the
Assets/EasyRoads3D/folder - Wait for Unity to recompile scripts
Without EasyRoads3D, the project will show compilation errors since the core scripts depend on the
EasyRoads3Dv3namespace.
- Open Unity Hub
- Click "Add" → "Add project from disk"
- Navigate to the
autoMaster/directory - Click "Select Folder"
- Unity will load and compile the project
Launch Unity Hub and open the AutoMaster project (see Installation)
Option A: New Scene
1. File → New Scene
2. GameObject → Create Empty (name it "RoadGenerator")
3. Add Component → Scripts → OpenDriveParser
4. Press Play
Option B: Existing Scene
1. Open Assets/Scenes/SampleScene
2. Select existing GameObject or create new one
3. Add Component → OpenDriveParser
4. Press Play
Watch the Console window for:
✅ Type: line, S: 0, X: 123.45, Y: 67.89...
✅ Road network generation complete
The roads will appear in your Scene view automatically!
The simplest way to generate roads:
-
Create GameObject
Hierarchy → Right-click → Create Empty Name: "RoadNetworkGenerator" -
Add Component
Inspector → Add Component → OpenDriveParser -
Configure (Optional)
Map File Path: Assets/AutoMaster/Data/Maps/Town01.xodr -
Run
Press Play button (or Ctrl/Cmd + P)
You can switch between maps directly in the Inspector:
- Select GameObject with OpenDriveParser component
- In Inspector, find "Map File Path" field
- Change to:
Assets/AutoMaster/Data/Maps/Town01.xodr(smaller map)Assets/AutoMaster/Data/Maps/Town02.xodr(larger map)
- Press Play to load the new map
using AutoMaster.Core;
public class MapSwitcher : MonoBehaviour
{
public OpenDriveParser parser;
public void LoadTown02()
{
parser.mapFilePath = "Assets/AutoMaster/Data/Maps/Town02.xodr";
// Reload logic here
}
}Ensure your OpenDRIVE file:
- Uses
.xodrextension - Follows OpenDRIVE 1.4+ standard
- Contains valid
<road>and<geometry>elements
# Copy to project
cp your_map.xodr autoMaster/Assets/AutoMaster/Data/Maps/
# Or drag-and-drop into Unity's Project windowIn Unity Inspector:
OpenDriveParser Component
└─ Map File Path: Assets/AutoMaster/Data/Maps/your_map.xodr
Press Play and check Console for any errors.
In Inspector (if exposed):
OpenDriveParser Component
└─ Road Width: 12.0
In Code:
Edit OpenDriveParser.cs (lines 33, 52):
// Junction roads
roadType_jnc.roadWidth = 15.0f; // Change from 12.0f
// Ordinary roads
roadType.roadWidth = 15.0f; // Change from 12.0f- Navigate to
Assets/AutoMaster/Resources/Materials/Roads/ - Select material (e.g.,
twoLaneRoadMat.mat) - In Inspector, modify:
- Shader properties
- Textures
- Colors
- Changes apply immediately in Play mode
autoMaster/ # Unity project root
├── Assets/
│ ├── AutoMaster/ # Main project assets
│ │ ├── Scripts/ # C# source code
│ │ │ ├── Core/
│ │ │ │ └── OpenDriveParser.cs # Main parser controller
│ │ │ ├── Data/
│ │ │ │ ├── ParsedRoadSegment.cs # Road data model
│ │ │ │ └── TrafficObject.cs # Traffic object data
│ │ │ ├── Geometry/
│ │ │ │ ├── PathBase.cs # Abstract base class
│ │ │ │ ├── LinePath.cs # Straight roads
│ │ │ │ └── ArcPath.cs # Curved roads
│ │ │ └── Utilities/
│ │ │ ├── PathType.cs # Geometry type enum
│ │ │ └── XmlFileLoader.cs # XML parsing helper
│ │ ├── Data/
│ │ │ ├── Maps/ # OpenDRIVE map files
│ │ │ │ ├── Town01.xodr # Sample map 1 (498 KB)
│ │ │ │ └── Town02.xodr # Sample map 2 (1.1 MB)
│ │ │ └── Scenarios/
│ │ │ └── scenario01.mat # Scenario config
│ │ └── Resources/ # Unity Resources folder
│ │ ├── Materials/
│ │ │ └── Roads/ # Road materials
│ │ │ ├── twoLaneRoadMat.mat
│ │ │ ├── noBoundaries.mat
│ │ │ ├── lanelessRoadMat.mat
│ │ │ ├── lanelessRoadLeft.mat
│ │ │ └── lanelessRoadRight.mat
│ │ └── Textures/
│ │ └── Roads/ # Road textures
│ │ ├── twoLaneRoad.jpg
│ │ ├── lanelessRoad.jpg
│ │ ├── lanelessRoadLeft.jpg
│ │ ├── lanelessRoadRight.jpg
│ │ └── lanelessRoadNoBDR.jpg
│ ├── EasyRoads3D/ # Third-party plugin (NOT included — install from Asset Store)
│ ├── Scenes/ # Unity scenes
│ └── Settings/ # Project settings
├── Packages/ # Package dependencies
│ └── manifest.json
├── ProjectSettings/ # Unity configuration
├── Library/ # Unity cache (auto-generated)
├── Temp/ # Temporary files (auto-generated)
├── Logs/ # Unity logs (auto-generated)
├── .gitignore # Git ignore rules
└── README.md # This file
┌─────────────────────────────────────────────────────┐
│ Unity Scene │
│ ┌───────────────────────────────────────────────┐ │
│ │ OpenDriveParser (MonoBehaviour) │ │
│ │ ┌─────────────────────────────────────────┐ │ │
│ │ │ 1. Load .xodr file via XmlFileLoader │ │ │
│ │ │ 2. Parse road geometry & junctions │ │ │
│ │ │ 3. Create LinePath/ArcPath objects │ │ │
│ │ │ 4. Generate ERRoadNetwork │ │ │
│ │ │ 5. Apply materials & build mesh │ │ │
│ │ └─────────────────────────────────────────┘ │ │
│ └───────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘
↓ ↓ ↓
[EasyRoads3D] [Unity Rendering] [3D Roads]
- Role: Main controller, orchestrates entire process
- Responsibilities:
- Loads OpenDRIVE XML file
- Configures road types and materials
- Creates road geometry via EasyRoads3D
- Manages traffic object placement
- Role: XML parsing helper
- Methods:
getRoadList()- Returns all<road>elementsgetGeoList()- Returns all<geometry>elementsgetSignalsList()- Returns traffic signal datagetPlanViewList()- Returns plan view nodes
- ParsedRoadSegment: Stores road geometry data
- Type (line/arc/spiral)
- Position (X, Y)
- Heading (Hdg)
- Length, Curvature
- Junction ID
- TrafficObject: Stores traffic signal data
- Position (xPos, yPos, sPos, tPos)
- Path reference
- Placement flags
- PathBase: Abstract base class for all paths
- LinePath: Implements straight road segments
- Calculates start/end points
- Generates marker array for EasyRoads3D
- ArcPath: Implements curved road segments
- Computes arc radius and central angle
- Interpolates points along curve
- Handles clockwise/counterclockwise curves
OpenDRIVE XML File
↓
XmlFileLoader.Load()
↓
Parse <road> & <geometry> elements
↓
Create ParsedRoadSegment objects
↓
Determine if Junction or Ordinary road
↓
Create LinePath or ArcPath objects
↓
Generate Vector3[] markers
↓
ERRoadNetwork.CreateRoad()
↓
EasyRoads3D mesh generation
↓
3D Road in Unity Scene
| Map | Size | Lines | Roads | Junctions | Source |
|---|---|---|---|---|---|
| Town01.xodr | 498 KB | 7,778 | 50+ | 10+ | RoadRunner 2019 |
| Town02.xodr | 1.1 MB | 13,234 | 100+ | 20+ | RoadRunner 2019 |
- Description: Small urban environment
- Features: Basic intersections, straight roads, simple curves
- Use Case: Testing, development, quick iterations
- Parse Time: ~0.5 seconds
- Description: Larger complex urban network
- Features: Multiple junctions, complex geometry, roundabouts
- Use Case: Performance testing, realistic scenarios
- Parse Time: ~1.2 seconds
Supported Elements:
<OpenDRIVE>
<road junction="-1|id"> ✅ Supported
<planView> ✅ Supported
<geometry s="" x="" y="" hdg="" length="">
<line/> ✅ Supported
<arc curvature=""/> ✅ Supported
<spiral/> ⏳ Planned
</geometry>
</planView>
<signals> ✅ Parsed (not visualized)
<signal s="" t="" name=""/>
</signals>
</road>
</OpenDRIVE>namespace AutoMaster.Core
{
public class OpenDriveParser : MonoBehaviour
{
// Public Fields (Inspector-configurable)
public string mapFilePath; // Path to .xodr file
public ERRoadNetwork roadNetwork; // EasyRoads3D network
// Methods
void Start(); // Auto-runs on scene start
List<ParsedRoadSegment> ParseOpenDrive(string filePath);
}
}Usage:
// Access from another script
OpenDriveParser parser = GetComponent<OpenDriveParser>();
parser.mapFilePath = "Assets/AutoMaster/Data/Maps/Town02.xodr";namespace AutoMaster.Utilities
{
public class XmlFileLoader
{
public XmlFileLoader(string filePath);
public XmlNodeList getRoadList();
public XmlNodeList getGeoList();
public XmlNodeList getSignalsList();
public XmlNodeList getPlanViewList();
}
}namespace AutoMaster.Geometry
{
public class LinePath : PathBase
{
public LinePath(
int road_index,
float x_Start,
float y_Start,
float z,
float length,
float hdg
);
public Vector3[] markers; // Road waypoints
}
}namespace AutoMaster.Geometry
{
public class ArcPath : PathBase
{
public ArcPath(
int road_index,
float x_Start,
float y_Start,
float z,
float length,
float hdg,
float curvature
);
public Vector3[] markers; // Road waypoints
}
}Located in Assets/AutoMaster/Resources/Materials/Roads/:
| Material | Usage | Features |
|---|---|---|
| twoLaneRoadMat | Ordinary roads | Two-lane markings, yellow center line |
| noBoundaries | Junctions | No lane markings, plain surface |
| lanelessRoadMat | Alternative | No markings, gray surface |
| lanelessRoadLeft | Directional | Left-side marking variant |
| lanelessRoadRight | Directional | Right-side marking variant |
Edit Existing:
- Navigate to
Resources/Materials/Roads/ - Double-click material
- Modify shader properties in Inspector
- Adjust albedo texture, smoothness, metallic, etc.
Create New:
// In OpenDriveParser.cs
Material customMaterial = Resources.Load("Materials/Roads/MyCustomMat") as Material;
roadType.roadMaterial = customMaterial;Located in Assets/AutoMaster/Resources/Textures/Roads/:
twoLaneRoad.jpg(158 KB) - Two-lane texturelanelessRoad.jpg(79 KB) - Plain road texture- Additional variants for different road types
To use custom textures:
- Import image to
Textures/Roads/ - Create new Material
- Assign texture to material
- Update
OpenDriveParser.csto load your material
Global Change:
Edit OpenDriveParser.cs:
// Line 33 (Junction roads)
roadType_jnc.roadWidth = 15.0f; // Default: 12.0f
// Line 52 (Ordinary roads)
roadType.roadWidth = 15.0f; // Default: 12.0fPer-Road Change (Advanced):
// Create different road types
ERRoadType narrowRoadType = new ERRoadType();
narrowRoadType.roadWidth = 8.0f;
ERRoadType wideRoadType = new ERRoadType();
wideRoadType.roadWidth = 16.0f;
// Use conditionally based on road attributesError Message:
Material 'twoLaneRoadMat' not found in Resources/Materials/Roads!
Solutions:
- ✅ Verify material exists:
Assets/AutoMaster/Resources/Materials/Roads/twoLaneRoadMat.mat - ✅ Check spelling in
OpenDriveParser.cs - ✅ Ensure folder is named exactly "Resources" (case-sensitive)
- ✅ Reimport material: Right-click → Reimport
Error Message:
FileNotFoundException: Could not find file "Assets/..."
Solutions:
- ✅ Verify file path uses forward slashes:
/not\ - ✅ Check file is in
Assets/AutoMaster/Data/Maps/ - ✅ Ensure extension is
.xodr - ✅ Use absolute path from Assets:
Assets/AutoMaster/Data/Maps/Town01.xodr
Symptoms:
- Scene runs but no roads appear
- No errors in Console
Solutions:
- ✅ Check Console for warnings
- ✅ Verify
roadNetworkis not null (Inspector) - ✅ Ensure OpenDRIVE file has
<geometry>elements - ✅ Adjust camera position (roads may be far from origin)
- ✅ Check Scene view, not just Game view
Error Message:
error CS0246: The type or namespace name 'X' could not be found
Solutions:
- ✅ Reimport all scripts: Assets → Reimport All
- ✅ Check all namespace
usingstatements - ✅ Restart Unity Editor
- ✅ Delete
Libraryfolder and reopen project
Error Message:
The type or namespace name 'EasyRoads3Dv3' could not be found
Solutions:
- ✅ EasyRoads3D is not included in this repository — you must purchase and import it separately from the Unity Asset Store
- ✅ Verify EasyRoads3D folder exists at
Assets/EasyRoads3D/after importing - ✅ If already imported, check that the folder is not empty
- ✅ Reimport via Window → Package Manager → My Assets → EasyRoads3D → Import
- ✅ Contact EasyRoads3D support if the plugin has issues after import
Tested on: Intel i7-9700K, 16GB RAM, GTX 1080
| Map | File Size | Parse Time | Roads Generated | FPS (Editor) |
|---|---|---|---|---|
| Town01 | 498 KB | 0.5s | 50+ | 60+ |
| Town02 | 1.1 MB | 1.2s | 100+ | 45+ |
-
Streaming Loading
// Load map in chunks IEnumerator LoadMapAsync(string path) { // Parse section by section // Yield between sections }
-
LOD System
- Generate high-detail roads near camera
- Use low-poly meshes for distant roads
- Implement culling for off-screen roads
-
Async XML Parsing
async Task<List<ParsedRoadSegment>> ParseOpenDriveAsync(string path) { // Use async XML reading await Task.Run(() => ParseXML()); }
-
Object Pooling
- Reuse road segment objects
- Pool EasyRoads3D components
We welcome contributions! Here's how to get started:
-
Fork the repository
git clone https://github.com/ingTikna/autoMaster.git
-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes
- Follow C# coding conventions
- Add XML comments to public methods
- Update README if needed
-
Test thoroughly
- Test with both sample maps
- Verify no Console errors
- Check performance impact
-
Commit and push
git commit -m "Add: Brief description of feature" git push origin feature/your-feature-name -
Create Pull Request
- Describe changes clearly
- Reference any related issues
- Include screenshots if applicable
// Good: PascalCase for classes and methods
public class RoadGenerator
{
public void ParseRoadNetwork() { }
}
// Good: camelCase for private fields
private float roadWidth = 12.0f;
// Good: XML comments for public APIs
/// <summary>
/// Parses an OpenDRIVE file and generates roads.
/// </summary>
/// <param name="filePath">Path to .xodr file</param>
/// <returns>List of parsed road segments</returns>
public List<ParsedRoadSegment> ParseOpenDrive(string filePath)This project is provided as-is for educational and research purposes.
| Component | License | Usage |
|---|---|---|
| EasyRoads3D v3 | Commercial (not included — purchase separately) | Road mesh generation |
| OpenDRIVE Format | Open Standard (ASAM) | Map file format |
| Unity Engine | Unity EULA | Game engine |
| RoadRunner | Commercial | Map creation tool |
Note: EasyRoads3D is a commercial plugin and is not distributed with this repository. You must purchase it separately from the Unity Asset Store.
- Project: AutoMaster
- Purpose: OpenDRIVE to Unity conversion for autonomous vehicle simulation
- Year: 2026
- EasyRoads3D: Professional road creation by VanderV
- Unity Engine: Game development platform by Unity Technologies
- Unity Sensors: Sensor simulation by Field Robotics Japan
Special thanks to:
- Unity community for tutorials and support
- EasyRoads3D community for documentation
- ASAM for maintaining the OpenDRIVE standard
- All contributors and testers
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Unity Forum: Unity Forums - EasyRoads3D
- OpenDRIVE Specification: ASAM OpenDRIVE
- EasyRoads3D Documentation: Official Docs
- Unity Manual: Unity Documentation
- ⭐ Star this repository
- 👀 Watch for updates
- 🐛 Report bugs
- 💡 Suggest features
Version 1.0.0 | Unity 6000.0.60f1 (LTS) | Last Updated: February 2026