Giter Club home page Giter Club logo

io_export_qmap's Introduction

Blender MAP Exporter

This addon allows exporting Blender scenes to idTech .map file format.

Supported Blender versions: 2.83 - 4.0+
Supported game formats: Quake, Half-Life, Quake 2, Quake 3, Doom 3, Quake 4
Other Quake-derived games (Jedi Academy, Call of Duty, etc) are untested, but hopefully also compatible.

Meshes will be exported to brushes (either as individual faces, or as convex hulls of each mesh). Curves and metaballs are treated as meshes. NURBS surfaces can either be exported as patches, or be converted to meshes on export. The addon will also export lights, cameras, and empty objects as point entities, with any custom properties they may have.

The addon offers UVs in "Standard Quake", "Valve220" and "Brush Primitives" formats, custom grid and precision, automatic triangulation of concave surfaces, detail flag assignment, export to clipboard in plaintext and GTK formats, geometry scaling with adaptive light intensity, and automatic spotlight creation.

Installation

Download io_export_qmap.py, then select it under "Edit > Preferences > Add-ons > Install".
Older Blender versions may show an error about missing preferences on first setup - try enabling the addon again.
The addon preferences allow you to change the default settings used in the export dialogue. They only take effect after restarting Blender.
prefs

Mesh Options

The map format requires each brush to be convex.
There are many ways to represent a mesh with brushes, each with their pros and cons.
mesh

For complex scenes, you can override mesh export mode on a per-object basis:
override

Formats

In most cases .map file is an intermediary between the editor and the compiler. So in practice, the output format can be anything, as long as it's supported by the other tools. For example, Quake 1 tools have broad support for Valve220 UV format, but only very limited support for patches.

Planes

Brushes are defined by planes, rather than by individual vertices. This is an important distinction to keep in mind, because when exporting detailed geometry, you will need enough precision to represent each plane. Otherwise, any face with more than three verts may end up leaving gaps. Soft maximum of 17 decimal places roughly matches TrenchBroom's precision.

Most games use the original Quake format, defining planes by three verts. Doom 3 introduced a new format, using a plane equation. While the original format meant that verts of neighboring triangles never drift apart, with Doom 3 planes you get no such guarantee, so you might want to use higher precision even on simple meshes.

UVs

UV scale depends on texture size. The exporter will use the first texture it finds in the material's node tree, or, failing that, the user-definable fallback size.

Texture coordinates in the legacy "Standard Quake" format have the broadest support, but also potentially lose a lot of information, as it doesn't support shearing (only rotation and scale along world axes). The two other formats, "Valve220" and "Brush Primitives", are more advanced and have similar capabilities to each other. The choice depends on whether your editor and compiler support them.

Since the .map format doesn't store individual vertices, it doesn't store individual verts' UVs either. Instead, it defines texture coordinates per plane. The exporter uses two arbitrarily selected edges for this task. In practice, this means that it is impossible to maintain perspective warp (e.g. on curved pipes), unless you triangulate every face in advance.

Flags

Quake 2 introduced flags for defining various special properties (lights, etc). The flags carried over to Quake 3, still remained in vestigial form in Doom 3, and were removed in the Quake 4 format.
The exporter currently only supports the Detail flag. For any face belonging to an object, a collection, or assigned a non-zero attribute with "detail" anywhere in their name, the exported surface will get its Detail flag set.

Clipboard

For convenience, the exporter can put the map data into the system clipboard, instead of writing it to a .map file. In this case, the filename in the export dialogue is ignored, and the data is ready to be pasted directly into an open map in your editor of choice. Some functionality may depend on the editor automatically re-assigning the entity names and targets.

Supported formats: text clipboard (TrenchBroom), GTK clipboard (GTKRadiant, NetRadiant, etc).
GTK clipboard is currently Windows-only. DarkRadiant clipboard is not supported.

io_export_qmap's People

Contributors

c-d-a avatar joeedh avatar

Stargazers

 avatar  avatar Warren Marshall avatar Eoin O'Neill avatar Pedro Valencia avatar  avatar sixsik6 avatar Victor Stan avatar  avatar  avatar  avatar  avatar Timothy avatar Christopher Webb avatar Joseph Knight avatar  avatar  avatar  avatar Sophie Kirschner avatar  avatar James O'Neill avatar dest1yo avatar Chase James avatar Freya Alminde avatar  avatar Yui avatar  avatar mpg avatar  avatar  avatar Random avatar ValCacer avatar FV7VR3 avatar Pavel Oborin avatar  avatar Amelith avatar Gaspar avatar  avatar xaGe  avatar ryker avatar CLANG-CLANG avatar  avatar  avatar Martin Eigel avatar  avatar Diego Ahumada avatar erysdren avatar Brandon Lopez avatar  avatar Christophe Mateos avatar  avatar Vegard Fjogstad avatar  avatar Peter Donald avatar Krispy avatar  avatar lordee avatar Charza Kitsune avatar  avatar  avatar Andzejs Poprockis avatar Jared Ketterer avatar Jazztache avatar  avatar Steven Gann avatar  avatar Anthony Rey avatar  avatar Tiaan avatar Mehmet Yüce avatar  avatar Lossy avatar Hermann Rolfes avatar Admer avatar  avatar  avatar Michal Zagrodzki avatar Razvan B. avatar  avatar Mr.Yeah! avatar  avatar  avatar Andreas Gaschka avatar Benjamin Stanley avatar

Watchers

Peter Donald avatar Benjamin Stanley avatar  avatar  avatar Razvan B. avatar Hermann Rolfes avatar xaGe  avatar Piotr Sadlik avatar  avatar Jazztache avatar  avatar RedSky avatar  avatar

io_export_qmap's Issues

[Request] Import Conversion

Like the title say, could we request a version of the script to import instead, are there any plans for it in sight?

Any plans to improve standard UVs?

I'm working on a tool that converts Source Engine maps (which use the Valve 220 format) to Call of Duty maps (which use the standard UV format). It basically generates the geometry by intersecting planes and creating patch meshes (similar to Quake 3's bezier patches) instead of brushes. Having a lot of meshes in the map makes it very difficult to edit it though, so I decided to borrow a small part of this repo, but it doesn't yield very accurate results, so I was wondering if there were any plans to improve the part where it exports brush faces with Quake's standard texture coordinate format.

I've tried to use the part of this repo where it converts UV coordinates of three vertices to Quake's standard format in my own tool and did some tests with some brushes. Simple brushes that only have straight faces seem to work well as seen in the pictures below.

This one is from Hammer Editor.
hammer
And this one is from CodRadiant.
radiant

When I tested it with more complex brushes, I realized it doesn't always yield accurate results.

hammer
radiant

The inaccuracies become more obvious when it is tested on an actual map.
mirage1
mirage2

[feature] Grid settings panel (presets)

I started making a map in Blender (more or less a proper map) and quickly found out that it's a chore to adjust grid settings while modeling.
Would it be possible to make something like a floating icon that opens up a panel (or maybe right-click menu instead of icon) with predefined grid settings (1,2,4,8,16,32,64,128,256,512,1024,2048, 4096, etc.) and grid subdiv settings ?

Getting error exporting "terrain"

Ugh, I am getting this error trying to export my terrain mesh as terrain type:

Read blend: D:\projects\blender\scenes\steelstorm2\maps\start_terrain2c_lq_export_aas.blend
Traceback (most recent call last):
File "E:\Apps\blender-3.4.0\3.4\scripts\addons\io_export_qmap.py", line 849, in execute
self.process_mesh(obj, fw, template)
File "E:\Apps\blender-3.4.0\3.4\scripts\addons\io_export_qmap.py", line 661, in process_mesh
bottom = self.gridsnap(bottom - self.option_depth)
File "E:\Apps\blender-3.4.0\3.4\scripts\addons\io_export_qmap.py", line 338, in gridsnap
return [round(co/grid)*grid for co in vector]
TypeError: 'float' object is not iterable

Here is .blend file
start_terrain2c_lq_export_aas.zip

Export Planes as a Patch

Would it be possible to write out each plane as a patch? I'm thinking of a way to reduce the number of brushes that are written out by this program. The program currently doesn't work very well with concave mesh. This is the format I'm looking for:
// entity 0
{
"classname" "worldspawn"
// brush 0
{
mesh
{
toolFlags splitGeo dontSplitLights;
$default
lightmap_gray
5 5 16 8
(
v -168 -120 8 t 0 -0 -10.5 7.5
v -168 8 8 t 0 -32768 -10.5 -0.5
v -168 136 8 t 0 -65536 -10.5 -8.5
v -168 264 8 t 0 -98304 -10.5 -16.5
v -168 392 8 t 0 -131072 -10.5 -24.5
)
(
v -74 -120 8 t 24064 -0 -4.625 7.5
v -74 8 8 t 24064 -32768 -4.625 -0.5
v -74 136 8 t 24064 -65536 -4.625 -8.5
v -74 264 8 t 24064 -98304 -4.625 -16.5
v -74 392 8 t 24064 -131072 -4.625 -24.5
)
(
v 20 -120 8 t 48128 -0 1.25 7.5
v 20 8 8 t 48128 -32768 1.25 -0.5
v 20 136 8 t 48128 -65536 1.25 -8.5
v 20 264 8 t 48128 -98304 1.25 -16.5
v 20 392 8 t 48128 -131072 1.25 -24.5
)
(
v 114 -120 8 t 72192 -0 7.125 7.5
v 114 8 8 t 72192 -32768 7.125 -0.5
v 114 136 8 t 72192 -65536 7.125 -8.5
v 114 264 8 t 72192 -98304 7.125 -16.5
v 114 392 8 t 72192 -131072 7.125 -24.5
)
(
v 208 -120 8 t 96256 -0 13 7.5
v 208 8 8 t 96256 -32768 13 -0.5
v 208 136 8 t 96256 -65536 13 -8.5
v 208 264 8 t 96256 -98304 13 -16.5
v 208 392 8 t 96256 -131072 13 -24.5
)
}
}
}

cod5_map

How to export info_player_start ?

I attached a simple scene I've been working on. Geo exports fine, but I am wondering how can I export info_player_start with the map. This setup is basically to aid visualization of the size of the entity and the direction it's facing.

The expected output:

{
"classname" "info_player_start" << default, but would be nice to change it in Blender because it can vary
"name" "info_player_start_1" << Entity's name (default)
"angle" "90.000000" << get this from parent cube rotation (yaw)
"origin" "-108 -82 11" << get this from the world location of the Empty
}

test_cityblock1a.zip

Export mesh as a patch

Would it be possible to write out each plane as a patch? I'm thinking of a way to reduce the number of brushes that are written out by this program. It currently doesn't work very well with concave mesh.
cod5_map

Feature Request - Export Brushes from disjunct surfaces in one Mesh

When exporting terrain to TriSoup Brushes it becomes very hard for blender to handle more than a few thousand individual meshes.

Since backfacing pyramideon extrusion costs a lot more .bsp filesize and collision planes - I've decided to go with TriSoup for terrain extruded on Z and snapped to grid otherwise.

When exporting this mesh I have to split up each of these brushblocks by using separate by loose parts. This process alone takes about half an hour.

I was wondering if it's feasible to have the exporter create brushes from discjunct convex surfaces inside the mesh - skipping the split by loose parts workflow - however not in a sense that the plugin overtakes this process, but can avoid it alltogether - saving on time.

Missing paragraph at the end of valve 220 format

Hey there.
When exporting to the Valve 220 format there needs to be one extra newline/paragraph at the end of the file, or else Hammer Editor won't be able to open the generated map file. Other editors might be immune to this issue, however Hammer is not.
It's an easy fix at line 354 I think.

Anyway, thanks for the good work with this addon!

Making level with models and brushes - what's the best way to export .map ?

I have a bunch of architectural models, all already exported as ASE with materials, to be used in Doom 3 (or idTech4 in general). I would like to make my map with those model in Blender and then block out rooms with caulk, separated by visportals (brushes behind/inside the models).
What would be the best way to export .map so that when I load it in Dark Radiant (or whatever editor of choice), models in the Editor are located/oriented where they were located/oriented in Blender (when add-on exports func_static entities, they should reference proper models and have proper origin/rotations)

Exporting entities only ?

I'd like to build a map using modular meshes. Instead of exporting geometry, I'd like to be able to export .map with entities only, which would reference entity class, origin, reference ASE or LWO model on the disk and a few parameters.
This way I could load this .map file into DarkRadiant, for example, and have level automatically assembled from previously exported ASE/LWO meshes.
Could you please extend this add-on to do that ?
If it's actually already possible, how do I go about exporting this kind of setup ?
Thanks

P.S. I just noticed it's related to this issue I posted a while back #13

Mesh option per object ?

Would it be possible to add functionality to export into .map where individual meshes export according to mesh option set via custom properties on that mesh and with meshes that have no custom property set to be exported according to mesh option selected in the add-on's UI ?

This would allow for a lot greater flexibility when making complex maps (as some objects/meshes might require specific mesh option).

Export Connected Mesh as a Patch *(Pls read)

I think I found a way to represent pretty much every connected mesh (whatever you'd actually call that) as a patch. Use the following Blender operations on the scene with the specified settings:

  1. Limited Dissolve with Max Angle of 0.1°.
  2. Triangulate Faces:
    Quad Method: Longest Diagonal
    N-gon Method: Clip
    I think what was making it impossible were those t-junc verts created at bsp compile.
    With the current method of exporting each face as a patch I get 156,911 brushes in my map file, whereas with the proposed method I could get roughly between 700-1500 brushes.

So basically then the only problem is fixing irregular mesh / mesh with divots at what should be corners. Any part of a mesh with the 'lightning' shape is what needs fixed. I'm working on that solution I just don't have time at the moment since I have to go to work. But basically you fill where the corner should be with necessary vertices then apply the 2 steps above to the new mesh.

Something like this won't work because the faces don't all meet (left hand side cut-quad doesn't meet the right quad with
its entire length):
q
Whereas something like this should work:
g

Terrain export

The "Terrain" export option appears to throw an exception in the later versions of Blender (3.4.1+).
Also, is it possible to specify a different axis for Terrain? That would be handy for cliffsides, etc.

Support for DarkRadiant layers

I probably overstayed your welcome with all these reports 😅 , but, would it be possible to add support for DarkRadiant layers (using maybe Collections) ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.