Anyone already written an .smtpl<->.schematic converter? EDIT: was ".smd3<->.schematic"

    Joined
    Aug 23, 2016
    Messages
    758
    Reaction score
    129
    EDIT: I think I'm just going to stop this project here now. It's not a huge job, I could do it in a weekend, but I'm so busy that a weekend's worth of time will take me weeks or months to achieve, and all the while I don't actually get to play the game. I have ideas for ships I want to build, and I don't want to put them off any longer. It's possible I may come back to it in the future, but for now it's dead.

    What I did actually get done was some custom blocks in MCEdit, and their corresponding mapping.
    The 010 template for smtpl files is functional and in a usable state.
    Also, my converter reads and writes smtpl files. If anyone want more info on these pm me, I'll be happy to oblige.
    -----------------------------------------

    I'm currently in the process of modifying MCEdit into a SM editor.

    I was planning to just let SMEdit be the bridge between the editor and the game (file conversion-wise), but have just realised that SMEdit doesn't export smd3 files, and the current version of the game won't import smd2 files.

    So I'm going to have to write a converter between the .schematic files that MCEdit exports and the .smd3 files that StarMade imports....unless someone has already done so.

    Has anyone? I can't offer you anything for it (I'm just doing this for fun to release to the community for free) except full credit and attribution.

    Failing a converter like that, even something like an smd3 reader, that parses the files and displays the contents to the user (for example) would be very useful, as it would save me part of the work. Preferrably in Java, but any language will do.
     
    Last edited:
    Joined
    Aug 23, 2016
    Messages
    758
    Reaction score
    129
    Perhaps I'm not patient enough, but I guess I'll hvae to assume that's a "no"...

    Oh well, down into the salt mines I go :(
     
    Joined
    Jun 24, 2013
    Messages
    45
    Reaction score
    12
    • Legacy Citizen 2
    • Legacy Citizen
    I'm not sure how easy the conversion would be, starmade uses a lot of blocks with rotations, minecraft doesn't, also block conversions to normal minecraft blocks so that it doesn't appear as a massive blob of pink could be tricky (unless mcedit supports custom block descriptions)

    as for reading and writing the files, smd3 is a reasonably simple file type to read for blocks, although the logic and slave master relationships are slightly harder to read
     
    Joined
    Aug 23, 2016
    Messages
    758
    Reaction score
    129
    I'm not sure how easy the conversion would be, starmade uses a lot of blocks with rotations, minecraft doesn't, also block conversions to normal minecraft blocks so that it doesn't appear as a massive blob of pink could be tricky (unless mcedit supports custom block descriptions)

    as for reading and writing the files, smd3 is a reasonably simple file type to read for blocks, although the logic and slave master relationships are slightly harder to read
    MCedit has the data value for blocks and stores them in .schematic files, they will be used for rotation (like MC already does for some blocks).
    Yes, most of the so-called "modding" I'm doing (at least in the early stages) is just custom block definitions and textures.

    Linking blocks won't be an early feature. The first step is just to get a very basic editor actually fully working and later build on that. Unfortunately I can't test what I've already done at the moment without this converter....
    I was hoping one already existed, at least partially, to save me the extra work involved.

    Here's a screenshot of the extremely early stages. Technically the MCEdit side of things already functions, but there are many block definitions to go (the yellow and red blocks visible are some undefined blocks), and a .schematic output is no use unless I can convert it to smd3 (or would sment be better?).
    I'm also currently unsure whether I have rotation writing correctly to the .schematic file, as SMEdit doesn't show rotations at all, so I haven't checked.

    EDIT: oops, I should pay more attention - a sment file is what I need, which is all the ship definition files packaged together.
     
    Last edited:
    Joined
    Aug 23, 2016
    Messages
    758
    Reaction score
    129
    Ah! I've just found out about templates (I'm new, I hadn't heard of them).

    They're the perfect vessel for my .schematic conversions (just a single file, no compression, and templates give the freedom to either design a whole ship or just part of one).

    Based on der_scheme's post here:The StarMade Template file format (smtpl)
    I've made a 010 Editor template for .smtpl files, below.

    It's only a rough first draft, I'll refine it later, and hopefully also remove some of the "unknown" values.
    Possibly also my naming convention isn't ideal...
    I'll post it to the wiki when it's finished, unless the devs are kind enough to post their own 010 template first.


    EDIT: updated. Unknowns 1 to 3 are core location (with an offset), and 4 to 6 are the bounding box size (also offset)

    EDIT 2: second update.
    Connections were not correct, but are now.
    Defined the trailer. Introduced some more unknowns (that appear to always be constant) here and in connections..
    Bits from the block three bytes are now defined - note that I've just used 4 bits for rotation, when in fact some blocks use 3 or 5. It was simply too much effort to write all the individual id checks in here to fix this (my .smtpl converter performs these checks though)

    EDIT 3: third update of template.
    Uknowns 1 to 3 are obviously not the location of the core (Duh! a template may not have a core...).
    They are the location of something though - not a corner, nor centre, perhaps something to do with alignment to chunks? Anyway, they are used with unknowns 4 to 6 to calculate the bounding box size.


    Code:
    //------------------------------------------------
    //--- 010 Editor v7.0.2 Binary Template
    //
    //      File:
    //   Authors:
    //   Version:
    //   Purpose:
    //  Category:
    // File Mask:
    //  ID Bytes:
    //   History:
    //------------------------------------------------
    
    //make sure 010 is set to big endian
    
    BitfieldDisablePadding();
    
    
    typedef struct
    {
        int32 x;
        int32 y;
        int32 z;
    } Vector3i;
    
    typedef struct
    {
        byte version;
        int32 unknown1; //16 - core.x ----these give <something> location
        int32 unknown2; //16 - core.y
        int32 unknown3; //16 - core.z
        int32 unknown4; //width(x) + 16 - core.x  ----- these give bounding box size
        int32 unknown5; //height(y) + 16 - core.y
        int32 unknown6; //length(z) + 16 - core.z
    } Header;
    
    
    typedef struct
    {
        Vector3i coords;
        int orientation : 4; //note this will be wrong for corners and activated blocks, but I can't see how to easily identify them
        int hitPoints   : 9;
        int blockID     : 11;
    } Block;
    
    typedef struct
    {
        int32 blockCount;
        Block bloData[ blockCount ];
    } BlockDefs;
    
    typedef struct
    {
        int16 unknown7; //always 0?
        int16 slaveZ;
        int16 slaveY;
        int16 slaveX;
        int32 unknown8; //always 1?
        int16 unknown9; //always 0?
        int16 masterZ;
        int16 masterY;
        int16 masterX;
    } Connection;
    
    typedef struct
    {
        int32 connCount;
        Connection connData[ connCount ];
    } ConexDefs;
    
    typedef struct
    {
        int32 unknown10; //always 0?
        int32 unknown11; //always 0?
        int32 unknown12; //always 0?
    } Trailer;
    
    typedef struct
    {
        Header header;
        BlockDefs blocks;
        ConexDefs connections;
        Trailer trailer;
    } Template;
    
    Template template;
     
    Last edited:
    Joined
    Jun 24, 2013
    Messages
    45
    Reaction score
    12
    • Legacy Citizen 2
    • Legacy Citizen
    They're the perfect vessel for my .schematic conversions (just a single file, no compression, and templates give the freedom to either design a whole ship or just part of one).
    can you really get full ships in template format? if so that would make writing importers so much easier (currently trying to decode the new header and meta formats for the new sm3 files) but i have yet to find a way of spawning in a ship from its template file
     
    Joined
    Aug 23, 2016
    Messages
    758
    Reaction score
    129
    can you really get full ships in template format? if so that would make writing importers so much easier (currently trying to decode the new header and meta formats for the new sm3 files) but i have yet to find a way of spawning in a ship from its template file
    I don't know, but I don't see why not.

    The problem is most likely to be the size restriction servers place on copy/paste areas. A whole ship might have to be split up....

    Also, perhaps placing it in the correct location with respect to the core might be difficult, although if it were split into small pieces this shouldn't be a problem.
     
    Joined
    Aug 23, 2016
    Messages
    758
    Reaction score
    129
    can you really get full ships in template format? if so that would make writing importers so much easier (currently trying to decode the new header and meta formats for the new sm3 files) but i have yet to find a way of spawning in a ship from its template file
    I've been thinking more about this and my previous reply to it terra.
    Obviously I can't do anything about server restrictions, but I can assist in using templates for entire ships:

    A player can convert a .smtpl to a blueprint by placing a core in their local single player creative server, pasting in the .smtpl, and then saving the resulting ship.

    The problem is that paste areas are always placed by their bottom right aft (I think) corner. So placing a full ship template correctly around the core will be difficult.
    To make this easy, my conversion program will have an option to produce another accompanying guide .smtpl that is just a single block positioned in the location that the main .smtpl needs to be pasted in from.

    So the player will lay down a core, then place the guide .smtpl at the aft face of the core (which will insert a single block), then place the ship .smtpl at the aft face of the guide block, and the ship will be placed aligned correctly to the core. (The player then removes the guide block)

    Problem solved, without much work for me, and without much effort for users!

    My work on this converter is slow (I'm busy with work and a toddler, I only get spare time in 20 minute chunks!) but progressing. It now reads and writes .smtpl files, so I only have .schematic reads and writes to go, and a basic little GUI.

    EDIT: I think I'm just going to stop this project here now. It's not a huge job, I could do it in a weekend, but I'm so busy that a weekend's worth of time will take me weeks to achieve, and all the while I don't actually get to play the game. I have ideas for ships I want to build, and I don't want to put them off any longer.
    It's possible I may come back to it in the future, but for now it's dead.

    What I did actually get done was some custom blocks in MCEdit, and their corresponding mapping.
    The 010 template for smtpl files is functional and in a usable state.
    Also, my converter reads and writes smtpl files. If anyone want more info on these pm me, I'll be happy to oblige.
     
    Last edited: