Dylancyclone / VMF2OBJ

Convert source-engine VMF files into OBJ files with materials (including brushes, displacements, entities, and models)
MIT License
109 stars 6 forks source link
3d-models source-engine valve vmf

VMF2OBJ

Convert source-engine VMF files from any game into OBJ files with materials (including brushes, displacements, entities, and models)

Watch a demonstration video:

Youtube demonstration

How to run

Download the latest version from the Releases page, then double click on the .jar file to open it.

The VMF2OBJ GUI

Then, simply fill out which VMF file you'd like to convert, and the VPK files (and custom folders) that house the models, materials, etc for the map.

An example

There is also a Command Line Interface:

java -jar ./VMF2OBJ.jar [VMF_FILE] [args...]

usage: vmf2obj [VMF_FILE] [args...]
 -h,--help                  Show this message
 -o,--output <arg>          Name of the output files. Defaults to the name
                            of the VMF file
 -q,--quiet                 Suppress warnings
 -r,--resourcePaths <arg>   Semi-colon separated list of VPK files and
                            folders for external custom content (such as
                            materials or models)
 -t,--tools                 Ignore tool brushes

Example:

java -jar .\vmf2obj.jar .\input.vmf -o .\output -r "D:\SteamLibrary\steamapps\common\Half-Life 2\hl2\hl2_misc_dir.vpk;D:\SteamLibrary\steamapps\common\Half-Life 2\hl2\hl2_textures_dir.vpk;C:\path\to\custom\content\;C:\path\to\more\custom\content\" -t

To use external resources that are not in a VPK file, simply add the path to the folder that contains the "models"/"materials" folders.

custom-content/        <----- Select this folder
├── materials/         <----- DON'T select this folder
│   └── models/
│       └── props/
│           ├── clock.vmt
│           └── clock.vtf
└── models/            <----- DON'T select this folder
    └── props/
        ├── clock.dx80.vtx
        ├── clock.dx90.vtx
        ├── clock.mdl
        ├── clock.phy
        ├── clock.sw.vtx
        └── clock.vvd

Building

To build the app from source, simply run:

mvn package

The compiled .jar file will be placed in the target directory.

Packaged Dependencies

This project packages the following software and uses them during the conversion process. This project would not be possible without them.

Support

Unsupported Features

These are features that I don't have any plans to implement, either because I don't know how to, or the feature is too inconsistant, or would require extreme reworks to the current implementation. Of course, if you have an idea on how to implement any of these please feel free to submit a PR or issue discussing the idea.

Other Notes

Depending on where you import the converted result to, you might run into a problem where all the geometry looks very dark. This is due to the Source engine using additional normal data that might cause side effects in other software. In Blender, this can be solved with this quick script. Simply select all the objects, and run this script in a new text editor. See this for more information.