Actions

Making Might and Magic maps with Trenchbroom: Difference between revisions

From MM6 Wiki

Line 7: Line 7:
<br />
<br />


====Setting up the editor====
===Setting up the editor===


=====Exporting textures from the game=====
=====Exporting textures from the game=====
Line 14: Line 14:
''PAL or palette files are not required and can be deleted after extraction.''
''PAL or palette files are not required and can be deleted after extraction.''


=====Project structure=====
====Project structure====
Now for Trenchbroom to find the textures a specific folder structure needs to be created
Now for Trenchbroom to find the textures a specific folder structure needs to be created


Line 49: Line 49:




=====Trenchbroom configuration=====
====Trenchbroom configuration====


[https://mm6.wiki/files/mods/trenchbroom/MightAndMagic.zip Might and Magic game preset for Trenchbroom]
[https://mm6.wiki/files/mods/trenchbroom/MightAndMagic.zip Might and Magic game preset for Trenchbroom]
Line 66: Line 66:
[[File:Mm6 trenchbroom adding texture group.png|right|frameless|975x975px]]
[[File:Mm6 trenchbroom adding texture group.png|right|frameless|975x975px]]


====Making a map / object====
===Making a map / object===




Line 78: Line 78:
<br />
<br />


=====Limitations=====
====Limitations====


Might and Magic engine has its own limitations that are not present in Quake engine.
Might and Magic engine has its own limitations that are not present in Quake engine.
Line 100: Line 100:
[[File:Mm6 trenchbroom object ready 2.png|frameless|1280x1280px]]<br />
[[File:Mm6 trenchbroom object ready 2.png|frameless|1280x1280px]]<br />
<br />
<br />
=====Optimizing the object with _Invisible_ texture=====
====Optimizing the object with _Invisible_ texture====
[[File:Invisible .png|frame|The texture used to make the sample model. It needs to be renamed to _Invisible_ in order to work.|alt=|border]]
[[File:Invisible .png|frame|The texture used to make the sample model. It needs to be renamed to _Invisible_ in order to work.|alt=|border]]


Line 112: Line 112:
It is recommended to mark all faces that are not supposed to be visible during gameplay with that texture. After importing the object into MMEditor later on it will remove all the faces marked with that texture.
It is recommended to mark all faces that are not supposed to be visible during gameplay with that texture. After importing the object into MMEditor later on it will remove all the faces marked with that texture.


====Export to MMEditor====
===Export to MMEditor===


Once the object is finished export the model by using '''File -> Export -> Wavefront OBJ ...'''
Once the object is finished export the model by using '''File -> Export -> Wavefront OBJ ...'''
Line 120: Line 120:
<br />
<br />


=====Altering MTL file to work with MMEditor  For now Trenchbroom exports .MTL files without texture entries. Without them MMEditor will not be able to find the textures required by a model.=====
==== Altering MTL file to work with MMEditor  ====
For now Trenchbroom exports .MTL files without texture entries. Without them MMEditor will not be able to find the textures required by a model.
 
Ways to fix that:
Ways to fix that:
<br />
<br />
<br />
<br />


======Manual  Open .MTL file and you will see a lot of lines similar to this:======
=====Manual  Open .MTL file and you will see a lot of lines similar to this:=====
<br /><pre>
<pre>
newmtl MM6/CsBr128
newmtl MM6/CsBr128
</pre>
</pre>
Line 151: Line 152:
</pre><br />
</pre><br />


======Bash script======
=====Bash script=====
[https://gist.github.com/Anerag/dccef061d24c606dce1f6c07002f0c85 mtlc.sh]
[https://gist.github.com/Anerag/dccef061d24c606dce1f6c07002f0c85 mtlc.sh]


Line 158: Line 159:
<br />
<br />


=====Importing the model=====
====Importing the model====
   
   


Line 204: Line 205:
[[File:Mm6 trenchbroom ingame.png|frameless|641x641px]]
[[File:Mm6 trenchbroom ingame.png|frameless|641x641px]]


====Possible enhancements====
===Possible enhancements===





Revision as of 17:21, 7 June 2020

Making maps for Might and Magic is a little bit tricky since it requires usage of some 3D software like Blender or 3Ds Max. To make it easier map editor can be used. MMEditor which is used to edit Might and Magic maps can import 3D models in OBJ format, that means that any program that can export such models can be used for making objects or even entire maps for the game.


Trenchbroom is a map editor for Quake-based games.


Setting up the editor

Exporting textures from the game

To extract the textures MMArchive can be used. The textures are stored in the /data/bitmaps.lod archive.

PAL or palette files are not required and can be deleted after extraction.

Project structure

Now for Trenchbroom to find the textures a specific folder structure needs to be created

It needs to look like that:


- Project name
  - Bitmaps
    - Any folder name
      ... (textures) ...
    - Any folder name
      ... (textures) ...
    - Any folder name
      ... (textures) ...


Trenchbroom uses texture collections / packs / groups to manage sets of textures, that is why there is a need to create and additional folder in the Bitmaps directory. Structure like that allows to enable or disable folders on the maps when needed.


As an example the following structure will be used:

- Might and Magic Trenchbroom
  - Bitmaps
    - MM6
      ...(textures)...


Now the textures can be placed in the MM6 directory to be further visible by the editor.

However, by default it seems that BMP image support is not enabled. That can be solved by creating custom configuration file for a game that needs it.


Trenchbroom configuration

Might and Magic game preset for Trenchbroom

To add this configuration: extract the ZIP file into Trenchbroom/Games directory. If the configuration files worked then a new entry will be visible when creating a new map:



Now Trenchbroom needs a path to the project directory, with textures, created earlier. To set it, press the Open preferences... button. And set the path for Might and Magic to the Might and Magic Trenchbroom folder.





Making a map / object

Now creating new map with Might and Magic preset will be loading the project folder and the textures will be available. To proceed start a new map using Might and Magic preset.


The textures will be available once texture collection is selected. Open the Face tab and in the Texture Collections section double click on the bitmaps\MM6 collection. Once the texture collection is loaded the textures should be visible in the Texture Browser.


From now on the process is very similar to making a custom map for Quake, so the general tutorials for Trenchbroom apply.

Limitations

Might and Magic engine has its own limitations that are not present in Quake engine.


  • The textures can not be rotated
  • The textures can not be flipped
  • The textures can not be scaled


None of that will be applied after the model is exported and will lead to inconsistent results between the editor and the game.


To avoid some of those things untick Texture Lock and UV lock in the Edit menu:




Optimizing the object with _Invisible_ texture

The texture used to make the sample model. It needs to be renamed to _Invisible_ in order to work.


In Might and Magic engine if two model faces overlap each other they will blink / flicker and such, that effect is also known as Z-fighting. Face overlapping is very common when modelling with a Quake editor. That happens because instead of modeling with polygons directly, shapes are made using boxes.


To remove the faces they need to be marked using a texture named _Invisible_. The texture itself can be anything, the only rule is that it has to be named exactly like that. The texture can be made in any image editor and then loaded within any texture collection.


It is recommended to mark all faces that are not supposed to be visible during gameplay with that texture. After importing the object into MMEditor later on it will remove all the faces marked with that texture.

Export to MMEditor

Once the object is finished export the model by using File -> Export -> Wavefront OBJ ...

Doing that will create 2 files: .OBJ and .MTL


Altering MTL file to work with MMEditor

For now Trenchbroom exports .MTL files without texture entries. Without them MMEditor will not be able to find the textures required by a model.

Ways to fix that:

Manual Open .MTL file and you will see a lot of lines similar to this:
newmtl MM6/CsBr128


Note the name after slash, that is a texture name.

A texture entry looks like that:


map_Kd CsBr128


map_Kd is an attribute and doesn't change, CsBr128 is a texture name.

Line like that needs to be added after each newmtl entry.


So the final material definition would look like:


newmtl MM6/CsBr128
map_Kd CsBr128


Bash script

mtlc.sh

Automates the process described above.


Importing the model

MMEditor is used for editing maps in the game.

If a map compiled by the editor crashes the solution is here.


Once the game loaded press alt + F1 and open any internal map.

To import a model click on the Import button.

Select Cancel when asked to delete models, that will keep the rest of the map in tact.

If the model was created not far from the center of coordinates in Trenchbroom it will be placed somewhere around 0,0,0 coordinates in the game, which is the center of the map. The newly imported object should be there.



Many building in the game are considered to be a single object by the engine. Those had many shapes merged in one using 3D software. In Trenchbroom objects are built using brushes and usually there are many brushes that constitute one object. When Trenchbroom exports a model it keeps the shapes separate. That means that the object can not be selected all at once.

To move imported object:

  1. Click on any face on the model
  2. Press the Model button
  3. Hold the Left Shift key and select the other parts


Now there are 2 options:

  • Use arrow keys + Page Up / Down to move the object around
  • Move the party to the destination and press the Move To Party button

! Note that the Land function will not help to align the object to the ground since it will align every segment individually and not the entire group.

The result:


Possible enhancements

The steps described above are proof of concept. The things that can be improved are:

  • A way to merge Trenchbroom brushes without using 3D Software (merge everything on import in MMEditor for example)
  • Better support for texture alignment in Might and Magic (texture flipping, offsets, scaling)
  • Convert existing maps to OBJ to use as a reference in the editor
  • Crossplatform MTL conversion