KatsBits Community

Game Editing => General Content Creation => Topic started by: kat on November 18, 2016, 12:29:01 PM

Title: [Unity] Convert a .map to Unity 3D (map to model)
Post by: kat on November 18, 2016, 12:29:01 PM


Unity 3D is not able to use brush-volume based, MAP formatted, or BSP styled, data structures by default, they need to be converted to a supported 3D mesh format. Although this is a relatively straightforward process it's not expressly practical to use the end result of the conversion directly, to convert and use the map as is, largely because it will likely still contain the game specific entities and objects, which need to be cleared from the file.



Beyond this its simply a question of BSP-only compiling the level (optionally using "-meta" and/or "-patchmeta" as required) and then converting the resulting *.bsp by running the compile process again with the "-ase" switch. This produces an intact *.ase model that can then be opened in another 3D application for further editing and/or export to a Unity 3D supported format (https://docs.unity3d.com/Manual/HOWTO-importObject.html), typically *.fbx or *.dae for dynamic models, *.obj for static (when editing, texture path information will need to be updated before use).
Quote
Design note: converting a level or map for use in Unity 3D presents a number of optimisation issues that will need to be addressed - namely that the resulting model is likely to be extremely large, polygon dense, and carrying a lot of material information that has to be loaded into game at the same time. This raises the probability of there being an 'overflow', memory or processing problem because the data is being parsed as a single unit rather than in smaller chunks or batches. Further editing may be (is typically) required.

IMPORTANT
Using third-party content may present Copyright issues - seek permission where necessary.

Step 1: strip game entities
Open the level into GtkRadiant, QuArK or other *.map editor, select and delete all game entities (this may include brush-based entities so special consideration should be allowed for these, either delete or break them down into standard brush volumes as reference for additional modelling). In Radiant hide "World" objects, "View » Filter » World", leaving only game entities visible (which also includes static models). In the XYZ grid draw a brush volume large enough that it encompasses everything that needs to be removed and click the "Select Inside" button (or click "Selection » Select » Select Inside").

Step 2: encase the entire level in a caulk hull
Once the entities have been cleared, re-place an "info_player_start" entity somewhere in the level then draw out a second brush volume encasing the entire map - allow some overlap. Click the "CSG Hollow" button (or "Selection » CSG » Make Hollow") creating a box around the entire level.
Quote
Design note: the process being described is essential the exporting of a large model not specifically a 'map'. As such the process is the same, i.e., info_player_start and enclosing the brushwork in a caulk box.

Step 3: compile as BSP only
Once the map is ready compile it to BSP (produces as *.bsp file) using the standard "BSP" compile switch (https://www.katsbits.com/tutorials/idtech/make-models-from-bsp-maps-or-brushes.php#map_to_bsp), or optionally with "BSP - meta" to optimise the resulting triangle 'soup', or "BSP -meta -patchmeta" to include patch mesh objects in the optimisation.
Quote
Design note: where possible build as much of the level from brush volumes.

Step 4: convert *.bsp to *.ase
Once the *.bsp file is available convert it to an ASE model using the "ase" compile switch - this might typically be done opening the BSP file into Q3Map2Toolz and running "BSP" on the selected *.bsp file with "ase" as the "convert" option (https://www.katsbits.com/tutorials/idtech/make-models-from-bsp-maps-or-brushes.php#bsp_to_ase). The map will be parsed, converted and saved to the "maps" folder.
Quote
Design note: conversion includes structure, materials, UV map and texture information.

Step 5: import into 3D application
Once the level is converted it needs to be imported into the 3D application cleaned up and exported to *.fbx, *.dae, etc. For Blender this is a two step process, first import the ASE into Blender 2.49 (https://www.katsbits.com/smforum/index.php?topic=816.0) using the available import script (Blender 2.49 (http://download.blender.org/release/Blender2.49b/) + GoofosASE (https://www.katsbits.com/files/ase/goofosASE_import_15Aug06.zip)), then once saved, open the resulting *.blend file into whatever version is being used for production and export.
Quote
Design note: the imported mesh may need varying degree of prep depending on requirements, at the very least textures will need to be reassigned and objects joined to for more sensible file organisation. For export to *.fbx meshes may need to be rotated -90° on the "X" axis ([Unity] fixing Blender model rotation (https://www.katsbits.com/smforum/index.php?topic=799.0)).

IMPORTANT: Unity's unit of measurement is the same as Blenders so models converted from Radiant will be several (c. 100x) times larger than might be necessary - a door being 72 units tall in Radiant, is 72 units in Blender and Unity but because Unity's default measurement system is "metres", such a door would stand 72 metres high in the editor. The size disparity also makes using Unity's editor clunky because the size of game entities and objects is based on the much smaller unit scale (a lamp icon is minuscule in comparison to the lamp mesh it may be illuminating, making it difficult to see, select and/or manipulate).


Additional Resources
- Overview of the process of converting brush volumes into models and importing the result into Blender (https://www.katsbits.com/smforum/index.php?topic=816.0).
- Making models from BSP brushes or maps (export maps as models) (https://www.katsbits.com/tutorials/idtech/make-models-from-bsp-maps-or-brushes.php#map_to_bsp).
- Make ASE models from brush volumes (map) (https://www.katsbits.com/smforum/index.php?topic=810.0).
- [Blender] brush-based structures (https://www.katsbits.com/smforum/index.php?topic=623.0).