Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylancyclone committed May 24, 2022
2 parents 3805dad + d0f8ad1 commit f0e7a2e
Show file tree
Hide file tree
Showing 21 changed files with 1,959 additions and 237 deletions.
42 changes: 30 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,44 @@ Watch a demonstration video:

## How to run

From the root directory, run:
Download the latest version from the [Releases](https://github.com/Dylancyclone/VMF2OBJ/releases) page, then double click on the .jar file to open it.

`mvn package;java -jar ./target/VMF2OBJ-1.1.2-jar-with-dependencies.jar [VMF_FILE] [OUTPUT_FILE] [VPK_PATHS]`
![The VMF2OBJ GUI](demo/gui.jpg)

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](demo/example.jpg)

There is also a Command Line Interface:

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

```
usage: vmf2obj [VMF_FILE] [OUTPUT_FILE] [VPK_PATHS] [args...]
-e,--externalPath <arg> Semi-colon separated list of folders for
external custom content (such as materials or
models)
-h,--help Show this message
-q,--quiet Suppress warnings
-t,--tools Ignore tool brushes
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 .\output "D:\SteamLibrary\steamapps\common\Half-Life 2\hl2\hl2_misc_dir.vpk;D:\SteamLibrary\steamapps\common\Half-Life 2\hl2\hl2_textures_dir.vpk" -e "C:\path\to\custom\content\;C:\path\to\more\custom\content\" -t
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
```

## 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.
Expand All @@ -54,13 +72,13 @@ This project packages the following software and uses them during the conversion
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.

- [ ] prop\_\* skins
- Textures are defined per triangle in a model's decompiled SMD, but skins are defined in it's QC file. I don't know of a good way to line up skins with multiple textures to a single model. I would theoretically be possible to implement single-material skins, but the results may end up being inconsistant and produce unexpected results.
- Textures are defined per triangle in a model's decompiled SMD, but skins are defined in it's QC file. I don't know of a good way to line up skins with multiple textures to a single model. I would theoretically be possible to implement single-material skins, but the results may end up being inconsistent and produce unexpected results.
- [ ] Displacement blend materials
- All the data needed for a blend material is included in the displacement object, but in order to implement it into an obj object either a separate texture must be generated with the blend built in, or a per-vertex material must be applied and blended between. The downsides of the first option is that it requires a lot of processing before hand (and Java's compatibility with Targa files is kinda potato at best), and the resulting texture is not editable. The downside of the second option is that the each vertex has to be either entirely one texture or entirely the other, and the linear blend will always go between the two. This will make for very strange looking textures when comparing it to the hammer counterpart, and it would require a complete rework of how the application handles textures. The perfect-world solution is to use a format that supports this kind of thing out of the box, but then you loose compatibility pretty quickly.
- [ ] infodecal
- infodecal entities don't store any data about where the decal is displayed, meaning it is projected from it's origin to the brush and clipped/sized accordingly. I personally don't know enough about how this process is done, and I don't feel comfortable trying to brute force it. I looked around for the source code associated with it, but I could not find anything to reverse engineer. I know it's a pretty important feature, but I don't know how to make it work _correctly_.
- [ ] info_overlay
- info_overlay is basically nextgen infodecal. Instead of just projecting to one side, an info_overlay can be projected to multiple faces, including different orientations and brushes so that the decal can "wrap" around. Again, I honestly don't really know how to approach this without brute forcing every face to create a seperate object with it's own UV wrapping. And that doesn't even include the fact that info_overlays can be distorted before being placed.
- info_overlay is basically nextgen infodecal. Instead of just projecting to one side, an info_overlay can be projected to multiple faces, including different orientations and brushes so that the decal can "wrap" around. Again, I honestly don't really know how to approach this without brute forcing every face to create a separate object with it's own UV wrapping. And that doesn't even include the fact that info_overlays can be distorted before being placed.

## Other Notes

Expand Down
10 changes: 10 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
5/24/2022 2.0.0:
+ Added GUI version of application. The GUI is accessible by double-clicking on the .jar file, while the CLI is still accessible through the terminal
* Vertices that are within 0.2 units of each other will be merged together, greatly reducing the number of extraneous vertices when dealing with complex brushes
* Fix colinear and equidistant points causing a crash
* Fix brushes having inverted normals
* Fix displacements being exported incorrectly
* Fix compatibility with new large VMT files
* Fix compatibility with VMT files that have GPU conditional statements
* Fix achievement arrays causing crashes

4/27/2021 1.1.3:
* Improve transparent material compatibility
* Fix handling materials with keyless commands/values
Expand Down
Binary file added demo/example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/gui.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.lathrum.VMF2OBJ</groupId>
<artifactId>VMF2OBJ</artifactId>
<version>1.1.3</version>
<version>2.0.0</version>
<packaging>jar</packaging>

<name>VMF2OBJ</name>
Expand All @@ -24,18 +24,23 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<version>2.8.9</version>
</dependency>
<dependency>
<groupId>me.tongfei</groupId>
<artifactId>progressbar</artifactId>
<version>0.7.4</version>
<version>0.9.3</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<resources>
Expand All @@ -62,7 +67,7 @@
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.lathrum.VMF2OBJ.App</mainClass>
<mainClass>com.lathrum.VMF2OBJ.VMF2OBJLauncher</mainClass>
</manifest>
</archive>
</configuration>
Expand All @@ -79,10 +84,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/lathrum/VMF2OBJ/Job.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.lathrum.VMF2OBJ;

import java.nio.file.Path;
import java.util.ArrayList;
import com.lathrum.VMF2OBJ.fileStructure.VMFFileEntry;

public class Job {

public VMFFileEntry file;
public ArrayList<Path> resourcePaths = new ArrayList<Path>();
public boolean SuppressWarnings;
public boolean skipTools;
}
30 changes: 30 additions & 0 deletions src/main/java/com/lathrum/VMF2OBJ/SimpleFormatter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.lathrum.VMF2OBJ;

import java.util.logging.*;

public class SimpleFormatter extends Formatter {
@Override
public String format(LogRecord record) {
String output = "";
String level = record.getLevel().toString();
String message = record.getMessage();

if (record.getLevel() == Level.INFO) {
if (message.endsWith("/s")) {
// If progress bar, put on same line
output = "\r" + message;
} else {
// If INFO, don't put logging level
output = message + "\n";
}
} else {
if (!(record.getLevel() == Level.WARNING && VMF2OBJ.quietMode)) {
// Dont print warning messages in quiet mode
// [LEVEL]: [MESSAGE]
output = level + ": " + message + "\n";
}
}

return output;
}
}
Loading

0 comments on commit f0e7a2e

Please sign in to comment.