OBJ Export
intermediate featureExport any ModelDefinition or VoxelDefinition (including microvoxels with dual materials) to standard OBJ format with textures. Use the results in Blender, RapidIcon, or any other external tool.
From the Inspector
Select a ModelDefinition asset in the Project window. In the Inspector, click the Export OBJ button. Choose an output folder and the export generates:
modelName/
modelName.obj # geometry with material groups
modelName.mtl # material definitions
texture_a.png # original-resolution textures
texture_b.png
...
From Code
using VoxelPlay;
// Export a ModelDefinition
string objPath = VoxelPlayOBJExporter.ExportModelToOBJ(
modelDefinition,
outputFolder,
scale: Vector3.one // optional, defaults to 1:1
);
// Export a single VoxelDefinition (with its microvoxels)
string objPath = VoxelPlayOBJExporter.ExportVoxelToOBJ(
voxelDefinition,
outputFolder
);
Both methods return the path to the generated .obj file, or null on failure.
What Gets Exported
- Geometry: Optimized mesh with cuboid fusion and face deduplication (same as the runtime converter)
- Textures: Original Texture2D assets saved as PNG at full resolution. No quality loss from TextureArray packing.
- Materials: One material per unique texture. Triangles are grouped by material in the OBJ file.
- UVs: Correctly computed to match the in-engine rendering. Faces with local UV mapping (microvoxels) use prototype UVs. Faces with world-space mapping use the same triplanar formula as the VP shader.
- Coordinate conversion: Unity's left-handed coordinates are converted to OBJ's right-handed convention (Z negated, winding order adjusted).
Supported Content
| Content type | Supported |
|---|---|
| Regular textured voxels | Yes |
| Microvoxels (Default layout) | Yes |
| Microvoxels with Slabs/TopCap + secondary material | Yes |
| Mixed models (regular + microvoxel bits) | Yes |
| Rotated model bits (0/90/180/270) | Yes |
| Vertex colors only (no textures) | Geometry only, no colors (OBJ limitation) |
| Normal maps / PBR | Not yet (diffuse textures only in this version) |
Tips
- For inventory icons, export the model then render it in RapidIcon or a custom camera setup for consistent icon generation.
- Textures are exported non-destructively - the asset's Read/Write import setting is never modified.
- If a VoxelDefinition has no textures, the export produces geometry without materials. A warning is logged.
Was this page helpful?
Suggest an improvement
Help us improve this documentation page.