How terrains work (scene)?

Users who are viewing this thread

Hello everyone, I would like to understand everything about the terrains in the Mount and Blade's engine (generation, vertex count, textures, water level...).
I want to understand this to create a third party tool wich represents the terrain in 3d like in the game.
Thanks for the support.
 
There is Swyter's Cartographer for that job which is open source.
Quite a long time ago, i tried to figure out the 'map.txt' file's content to create a simple 2d image of the maps. It sucked though and i discarded the related code :lol:
'map.txt file' has two parts.
First is a list of points.
Count of points then list of triple value tuples which represent x, y, z of values of that point.
Second is list of triangles.
Count of rectangles then list of 6 value tuples. First is the texture to fill the rectangle. Second and third look like always 0 and 3. I don't know what they are exactly. Last 3 values are corners of the rectangle. They are index values which refers to the points at the first part.
You can figure out what those textures refer to in the 'header_ground_types.py' file in the module system. 'module.ini' file in the mod folder also has some variables related to the map.
That's all i know :smile: You can learn more by checking the source code of Swyter's tool.
Edit: After writing all these stuff i realized you're most likely asking for the terrain in the scenes not the world map :facepalm:
 
I will use Warband as an example, but the post might refer to any title from M&B franchise pre-Bannerlord.

I cannot do anything but to redirect you to Warband's Terrain Edit Mode. Essentially, everything you are planning to do is contained within that extensive feature of the game engine (it is hardcoded into Warband, basically). Enable Edit Mode from the launcher and head to single-player mode in order to access the above-mentioned option. From that place, you will be able to generate a terrain and see its interactive preview, to adjust sliders in order to see how the hexadecimal code changes or to witness how different options affect the terrain. Three-dimensional preview is possible and prevalent.

Even though you will be able to understand how terrain works in Warband, you will not be able to reproduce the tool accurately in full due to the fact that Terrain Edit Mode is hardcoded (unless you decompile the executable file). The demand for a similar tool might be scarce because Warband's scening is not that popular as it was and also due to the presence of the sheer option in-game. It all is implemented in Warband already...
 
I misunderstood the term 'terrain source code' in the context and thought it to be hexadecimal value that defined a given terrain; it could be acquired from Terrain Edit Mode. As a result, I asked a question about the way WSE2 and B&G got the terrain code.

Now, I get the notion. WSE2 probably uses the same editor (the code was not touched at all) and B&G likely has it ported to the engine.
 
You can check the mirror of the original M&B Modding wiki here to see a list of terrain code bitfields, information comes from @cmpxchg8b:
https://mbmodwiki.github.io/Terrain_code.html

There's also a mirrored tool here that can compute the various fields and even generate bigger scenes:
http://web.archive.org/web/20130723110254if_/http://mbcommands.ollclan.eu/terrain

It's self-contained JavaScript. So you can download it and take a look. Open your developer console with F12 to see how the masks work.

That's all the information I have about them, I have tried rescuing all these offline pages from oblivion. Hope that helps.
 
I'm trying to remember and I think there's actual source code @cmpxchg8b dropped somewhere in the forum and that I may keep in some old hard drive with the terrain generation code, shedding light on the steps the game takes to seed the 2D Simplex noise (I think) and then generating procedural rivers, materials and triangulating it all.

You can use something like Intel GPA to take frame snapshots of the game and inspect the material layers.

I have done it before, it's a modern tool that unlike stuff like RenderDoc still supports DirectX 9 games like this one.

If someone is really interested into this I can try digging up the files. Maybe it's part of the public WSE code.
 
Yeah, I think this is what I'm looking for.
I hope you will find the files because right now I'm trying to reverse Warband and this is very difficult.
And the bit fields are useful.
 
Turns out my old spinny disk drive is faulty. I haven't been able to recover them yet. I'll let ddrescue do its job, but I'll probably prepare for losing a few modding files from 2009-2015. So far it doesn't look like they are there, which I find strange. Don't cheap out on storage, kids.
 
I managed to rescue this C++ file, which seems to contain the crux of the matter:

Maybe I'll be able to dig into the data a bit more and get more pieces, but I grabbed it from a raw disk dump using an hex editor. The filesystem is in pretty bad shape.
 
Recovered the Perlin code, both the implementation and the header. The remaining files (Vector2.h, Vector4.h and Utils.h) should be pretty straightforward and generic.
 
Recovered Utils.cpp and Utils.h. Those contain the pseudo-random function code, which seems game-specific to get the same results. With this we are only missing the 2D and 4D vector files.

 
Back
Top Bottom