MTS Editor

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

MTS Editor

by bzt » Fri Nov 29, 2019 13:51

Hi,

It's less than a week when I announced mtsconv, and now it's already obsoleted :-)

Let me introduce mtsedit, which knows everything that mtsconv knew, plus it can import Minecraft NBT .schematic files, and has an interactive GUI for quickly editing MTS files.

It was written in C (so it's small and fast), and has only one dependency, SDL2. I've tested it under Linux and Windows (compiled with mingw), it worked like a charm. Enjoy!

Image

Just for the records, because the Minetest wiki is very poor on documentation, I've also created a detailed description of the MTS file format (still incomplete).

Cheers,
bzt
Last edited by bzt on Fri Nov 29, 2019 13:55, edited 1 time in total.
 

User avatar
rubenwardy
Moderator
 
Posts: 5886
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: MTS Editor

by rubenwardy » Fri Nov 29, 2019 13:53

Oh wow!

What's the biggest MTS it can handle? CTF has some massive ones in its repo: https://github.com/mt-ctf/maps
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Fri Nov 29, 2019 13:58

Hi @rubenwardy,

The max size is 256 x 256 x 256. It's not for editing huge maps, but to edit structures. I've loaded detailed schematics of the Tower Bridge and the Notre Dame, both worked as expected.

Please note I've just put together this little tool in my spare time, it's free and Open Source. It does not want to compete with World Edit and such programs. It's main goal is to be small, fast and simple to use.

Cheers,
bzt
 

User avatar
rubenwardy
Moderator
 
Posts: 5886
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: MTS Editor

by rubenwardy » Fri Nov 29, 2019 14:50

bzt wrote:Please note I've just put together this little tool in my spare time, it's free and Open Source. It does not want to compete with World Edit and such programs. It's main goal is to be small, fast and simple to use.


I was just wondering, I well understand the constraints of spare time

This serves a different purpose to world edit though, as world edit is done in game but this is external. Being able to quickly create and modify schematics externally is pretty cool
 

BuckarooBanzay
Member
 
Posts: 320
Joined: Tue Apr 24, 2018 05:58
Location: Switzerland
GitHub: thomasrudin-mt
In-game: BuckarooBanzai

Re: MTS Editor

by BuckarooBanzay » Fri Nov 29, 2019 16:02

I really love the simplicity of it, even the code is well readable and structured :O
 

User avatar
texmex
Member
 
Posts: 1616
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Sat Nov 30, 2019 06:52

Hi,

Thank you, I'm glad that you enjoyed this little tool!

Here's a quick heads up on the last commit:

1. the cursor displaying part completely rewritten, now it is fast and responsive even with large files (comes at a price though, now when you clear blocks, you'll see the background color and you'll have to release the mouse button to refresh what's beneath)
2. now both CW and CCW directions supported
3. preview file dimensions fixed (depending on the contents, sometimes there was a big empty border)
4. added compilation instructions in the README.md under Linux and Windows
5. user interface translated to Hungarian, Spanish, French, German, Polish and Russian

I was wondering, which OS is used to play Minetest the most? For Linux, compiling the editor is trivial, but if there are many Windows users, I might provide pre-compiled binaries.

Cheers,
bzt
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Sun Dec 01, 2019 17:04

Hi,

New features! :-)

The GUI now supports history, you can undo and redo modifications. The block definitions file is almost entirely complete, and I've added default images for the nodes, so that the preview generation is working great (much better than mtsconv's).

So far MTSEdit lacked a very important component. It uses blocks.csv in the data directory to get the block node definitions. That file had to be written by hand, up until now, but no more! I've written an MTSEdit Export Minetest mod which is able to generate that csv using the Lua API from within the game. The mod is dependency-free, works with Mineclone2 and Minetest Game as well. As it can't export / import MTS files, only node definitions, therefore it suggests @Sokomine's excellent handle_schematics mod for that (that's the reason for the optional dependency).

Cheers,
bzt
 

User avatar
texmex
Member
 
Posts: 1616
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: MTS Editor

by texmex » Sun Dec 01, 2019 20:11

I was trying to compile on macOS but alas:
No ui driver can be detected. Install libsdl2-dev.

This is when running make with the sdl2 package installed, which is the one used for SDL development on macOS. Is it an issue of unset paths? I found some similar issue in a Rust project but I don't know how I would go about adapting it to a C environment. Halp!
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Wed Dec 04, 2019 10:49

Hi @texmex,

Yes, it is probably a path issue. The Makefile gives that message when it's unable to locate the SDL header files. Under MacOSX, it is usually looks for /Library/Frameworks/SDL2.framework/Headers. Please download the latest commit, I've added support for user home libraries. If even that fails, then please open up a Terminal, issue the following command and let me know it's output: "find / -name SDL.h".

Cheers,
bzt
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Wed Dec 04, 2019 11:09

It looks like this simple editor is not so simple any more (if we are looking at it's list of features :-) ). But it is still a single small executable (less than 256k).

The latest features:

1. not only the UI is translated, but the user can provide block name translations too (same format as the Minetest mods). I've provided quite a few translations (sorry about the quality, courtesy of Google Translate, but much better than nothing), see data/blocks_de.txt, blocks_ru.txt etc.
2. implemented brush feature. Now you can paint with sphere, dome, cylinder, cube, etc.
3. layer operations, you can insert or remove entire slices along each axis individually
4. flood fill, you can replace entire areas of the same block with another block type
5. redo / undo refactored and moved to a new source file to accomodate storing info on these new features
6. the Minetest mod part can now load and save MTS files easily using an intuitive tool, still without any dependency.

There's one feature that MTSEdit supports but which is not implemented in the Minetest Engine yet, biome specific names. With MTSEdit you can create schematics that does not contain "mcl_core:dirt" or "default:dirt" names directly, but instead "biome:node_filler" or "biome:node_top" for example. The purpose of this is to create structures that can be built-up in the world depending in which biome they are spawned. There's already a node name alias support in ME, so I'm hoping the developers will pick this up :-) It would be great, would allow houses made of sand in the desert and made of trees on the taiga using the same schematics.

Cheers,
bzt
 

User avatar
texmex
Member
 
Posts: 1616
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: MTS Editor

by texmex » Wed Dec 04, 2019 14:43

bzt wrote:Hi @texmex,

Yes, it is probably a path issue. The Makefile gives that message when it's unable to locate the SDL header files. Under MacOSX, it is usually looks for /Library/Frameworks/SDL2.framework/Headers. Please download the latest commit, I've added support for user home libraries. If even that fails, then please open up a Terminal, issue the following command and let me know it's output: "find / -name SDL.h".

Cheers,
bzt

Cheers, I’ll check it out!
 

warpnarget
New member
 
Posts: 9
Joined: Sat Oct 12, 2019 21:34
In-game: warpnarget

Re: MTS Editor

by warpnarget » Wed Dec 04, 2019 23:49

/usr/local/Cellar/sdl2/2.0.10/include/SDL2/SDL.h
/Library/Frameworks/SDL.framework/Versions/A/Headers/SDL.h
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Thu Dec 05, 2019 00:40

warpnarget wrote:/usr/local/Cellar/sdl2/2.0.10/include/SDL2/SDL.h
/Library/Frameworks/SDL.framework/Versions/A/Headers/SDL.h

Thanks! Looks like the "Version/A" part was missing, and they have removed the version from the path since I last used Mac? Good to know. Makefile fixed.

Cheers,
bzt
 

warpnarget
New member
 
Posts: 9
Joined: Sat Oct 12, 2019 21:34
In-game: warpnarget

Re: MTS Editor

by warpnarget » Thu Dec 05, 2019 15:57

ld: warning: option -b is obsolete and being ignored
ld: file not found: binary
make: *** [icons.o] Error 1
 

User avatar
Peppy
Member
 
Posts: 34
Joined: Sun Nov 06, 2016 07:34
Location: France
IRC: Peppy
In-game: Peppy

Re: MTS Editor

by Peppy » Thu Dec 05, 2019 20:11

Hi bzt

Would you add node force placement support ?
(some trees schematics from MTG do use this to get rid of sapling)

Thanks a lot for this very nice tool !
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Fri Dec 06, 2019 08:45

Hi,

@warpnarget: hahahaha, I can't stop laughing! Those loosers obsoleted a flag without knowing what it is used for! They have provided an alternative for just one of its usage but not the rest, hahahaha! I've created a workaround, you should try now. If you manage to compile it under MacOSX, it would be great if you could send the compiled executable to me somehow so that I can provide a pre-compiled package. There's only one feature left, when I'm finished with that, I'm planning to upload zipped versions, which the users can easily install without compilation.

@Peppy: thanks, you're welcome! Request granted. You can toggle the force placement bit with the key [D] (both F and P were already in use). Does not work with undo / redo, because it's easy to reverse, you can't really mess up a structure with this, and also because that would considerably increase the memory footprint of the history (right now only param0 and param2 are tracked, param1 is generated automatically on save, except for the force placement bit).

List of new features:
- now the Minetest mod is included in the editor, one can install it with "./mtsedit -i (minetest mods directory)".
- toggle force placement bit
- the executable now accepts not only mts files, but directories too as argument. If that's a directory, then the "Load Schematic from File" window will appear on start up. With this, you can add your world's schems folder in the shortcut.

Cheers,
bzt
 

warpnarget
New member
 
Posts: 9
Joined: Sat Oct 12, 2019 21:34
In-game: warpnarget

Re: MTS Editor

by warpnarget » Fri Dec 06, 2019 15:05

./bin2h icons.png font.psf.gz ../mt-mod/mtsedit >data.h
/bin/sh: line 1: 7251 Abort trap: 6 ./bin2h icons.png font.psf.gz ../mt-mod/mtsedit > data.h
make: *** [data.h] Error 134
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Sat Dec 07, 2019 13:59

Hi,
warpnarget wrote:./bin2h icons.png font.psf.gz ../mt-mod/mtsedit >data.h
/bin/sh: line 1: 7251 Abort trap: 6 ./bin2h icons.png font.psf.gz ../mt-mod/mtsedit > data.h
make: *** [data.h] Error 134
I honestly don't know what's wrong with your computer. That bin2h tool is just a small utility (less than 150 SLoC) which checks all function return values, I have no clue how it could throw a SIGABRT. I can run it without problems on Linux, BSD and Windows as well. As a workaround, here's the data.h which it should create. If you copy this into the src directory, then Makefile won't call bin2h to generate it.

If you manage to finally compile MTSEdit under MacOSX, then please send the executable to me! I definitely want to create a package if compilation is this problematic under Mac!

Cheers,
bzt
Attachments
data.h.zip
extract to src/data.h
(72.89 KiB) Downloaded 1 time
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Sat Dec 07, 2019 14:25

I've updated the source, please let me know if bin2h works now. If so, then the MacOSX core developers should really go back to school to learn a little bit of programming, as that would mean there's a serious bug in their libc's strcpy implementation... But what could you expect from someone who obsoletes a flag without knowing its function? :-)

Cheers,
bzt
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Mon Dec 09, 2019 03:43

Hi Everyone,

I've finished the last missing feature. I've also tested it a lot, fixed many-many minor issues, I think now it's bug-free. (But let me know and I'll fix.)

- block images can now be generated from game textures using the blockimgs.csv generated by the Minetest mod
- I've removed all rotation-specific code, now MTSEdit allows to use all rotations in param2 that has an image, and that's all. If you have many stair images (_00.png, _01.png ... _1F.png), then you can use all param2 values in MTS files. This also works for blocks which does not encode rotation in param2 (eg. snow layer with different heights).
- on UNIX systems if the path starts with ~, home will be substituted (shell does that automatically, but it's not done when you run it from a .desktop file)
- language code can be passed on the command line too (.desktop files does not allow setting extra environment variables)
- Linux and Windows packages are provided for those who don't want to compile. They include icons, startup config files, all the current block data etc. The Windows version also includes SDL2.dll to make it easy to install. Each zip is typically 1 - 1.5 Mb.

Missing features:
- I really would like to know how compilation under MacOSX goes, @texmex and @warpnarget. I'd like to provide a MacOSX package too. I can't test it, but I think all obsticles are removed.
- Importing NBT .schematic files works, but reading rotation info from Data section is not perfect, most of the time blocks are imported by default facing to North

Cheers,
bzt
 

User avatar
texmex
Member
 
Posts: 1616
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: MTS Editor

by texmex » Mon Dec 09, 2019 14:47

On the macOS side of things make gives error:

Code: Select all
No headers found, ui driver cannot be detected. Install libsdl2-dev.
Also check if the header files are in MINGSDL or MACSDL paths.
Try to run 'find / -name SDL.h' in a terminal to find the header.
make: *** [configure] Error 1


My SDL.h path is /usr/local/include/SDL2/SDL.h
Last edited by texmex on Mon Dec 09, 2019 19:32, edited 1 time in total.
 

ShadMOrdre
Member
 
Posts: 545
Joined: Mon Dec 29, 2014 08:07
Location: USA
GitHub: ShadMOrdre
In-game: shadmordre

Re: MTS Editor

by ShadMOrdre » Mon Dec 09, 2019 16:39

Not to distract from the MacOS issues, but I was wondering if there was an easier way to add node defs. My lib_materials, lib_ecology, and lib_shapes mods add a number of blocks. Like, a lot of blocks. And either the node list is now too long, or I am missing something in the installation. Granted, I need to update to this latest version, as opposed to the Friday version, ;), but so far, it doesn't seem to like my node list. (Yes, I used the mod to generate a block.csv file. This part does seem more complex than it should be. Why does one need to choose mcl_core or default? This will lock you into only supporting MCL2 and MTG, when there are other bases out there....)

As a side note, I like the idea of using biome nodes. Could you also add support for aliases, ie, single name aliases. Instead of default:stone or mcl_core:stone or lib_materials:stone, there is also mapgen:stone, and just stone. This will work well with a schematics library mod that I am working on, that allows schematics to be built, not with hardcoded node names, but with a predefined "code" value, that is then replaced with the desired node def. This seems to be similar to what you've described for MTEdit.

I'll download this latest version, and update this if I find anything relevant.


Shad
MY MODS: lib_ecology lib_materials lib_clouds lib_node_shapes ---- Inspired By: Open Source Virtual World Simulator Opensimulator.
 

bzt
Member
 
Posts: 32
Joined: Tue Sep 24, 2019 14:26

Re: MTS Editor

by bzt » Tue Dec 10, 2019 07:41

Hi,

texmex wrote:On the macOS side of things make gives error:

Code: Select all
No headers found, ui driver cannot be detected. Install libsdl2-dev.
Also check if the header files are in MINGSDL or MACSDL paths.
Try to run 'find / -name SDL.h' in a terminal to find the header.
make: *** [configure] Error 1


My SDL.h path is /usr/local/include/SDL2/SDL.h
Then you should follow the instruction in the message.
Open Makefile in a text editor, and right at the beginning specify MACSDL path as MACSDL=/usr/local/include/SDL2. I was wondering when will someone pop up with a manually compiled SDL :-D I'm so sorry that I don't have MacOSX, I really wish I could provide a pre-compiled package for you!

Just for completeness, if you were to use manually compiled SDL under linux, they you'd have to set LINUXSDL=/usr/local/include/SDL2, and for Windows you should set MINGWSDL.

ShadMOrdre wrote:I was wondering if there was an easier way to add node defs
Hi, thanks for trying out my editor! The thing is, you'll need two things for each node: a string (being the technical name of the node within the game), and images to be displayed by the editor (frankly, these latter are optional, but those "unknown node"s look terrible when you edit a schematic).

Right now, you have ways to automatically generate both:
1. use "/mtsedit export (game name)" chat command to generate a db with the technical names (you seem to be familiar with this).
2. use "/mtsedit imgs" chat command and then "./mtsedit -t blockimgs.csv" from the command line to generate the block images. This is a new feature.

The second is not perfect, I know, but better than nothing especially when you have to generate lots of blocks. This way you only have to manually fix/create that few images which "-t" weren't able to generate (in contrast to create all the images by hand). If you haven't tried this feature yet, please do so, and let me know how it went. I'm also planning to add param2's 04-1F rotations to be generated automatically.

I'm open to suggestions with this. The proper way would be to use GL and lift the node display code from the engine, I know, but unfortunately that's beyond what I can do in my spare-time.

ShadMOrdre wrote:Yes, I used the mod to generate a block.csv file. This part does seem more complex than it should be.
Couldn't agree more. The thing is, figuring out which node is which is not an easy task. First, more nodes might have share the same name (typically Something_Slab has three technical names, default:something_slab, default:something_slab_inner, default:something_slab_outter). Unfortunately Lua lists those in random order (which order changes by runs btw), so there's a need to explicit technical name checks. Then, there's a need for a canonical name check, otherwise you couldn't tell that mcl_core:tree is actually the same block as default:tree. Finally, you should manually check the generated list, because there's no guarantee that the Lua script got all nodes 100% correctly :-(

ShadMOrdre wrote:Why does one need to choose mcl_core or default? This will lock you into only supporting MCL2 and MTG, when there are other bases out there
Oh, but you're not locked to those two! You are free to add as many coloumns to the blocks.csv as you like, and there'll be as many options in the save window as coloumns you have! For example, if you'd use "/mtsedit export Lord of the Test", then a new "Lord of the Test" coloumn would be added to the csv, and with that you'd have 3 options on the save window. Block type mappings are not hardwired in the editor, they are fully configurable via the csv! :-)

ShadMOrdre wrote:As a side note, I like the idea of using biome nodes. Could you also add support for aliases, ie, single name aliases. Instead of default:stone or mcl_core:stone or lib_materials:stone, there is also mapgen:stone, and just stone.
This is something I was thinking about, but finally haven't implemented it. Now that I have at least one user asking for this feature, I probably will add it to the Lua script. The good thing is, you can do this without modifying the editor :-) Just add a "mapgen" coloumn to the csv.

ShadMOrdre wrote:This will work well with a schematics library mod that I am working on, that allows schematics to be built, not with hardcoded node names, but with a predefined "code" value, that is then replaced with the desired node def. This seems to be similar to what you've described for MTEdit.
Not exactly. Mapgen nodes are picked based on the mapgen used. What I'm proposing, and what I've already implemented in MTSEdit does not care about mapgen, it depends on the biome where the schematic is placed (thus using a different wood for roof for example in the desert and on the taiga, regardless if those biomes were generated by V7 or carpathian etc.).

ShadMordre wrote:I'll download this latest version, and update this if I find anything relevant.
Thank you, and all of you for helping me making MTSEdit better! Your feedback and participation is much appreciated!

EDIT: question, what do you mean by the list is too long and does not look like your nodes? The Lua script did not picked the right names or something?

Cheers,
bzt
 


Return to Minetest-related projects



Who is online

Users browsing this forum: No registered users and 0 guests