(UPDATE 2 - 2/14/2016) Coding an external ship editor

    Joined
    Jun 25, 2013
    Messages
    200
    Reaction score
    41
    • Legacy Citizen 2
    • Purchased!
    • Legacy Citizen 3
    I can upload an example ship blueprint if you want to see exactly what kind of design you would need for optimal conversion
    could u i would be interested to see
    I'll see what I can do. I'll need someone with a mac to help me test it though.
    if u can get to a stage that u need it tested with in a year then i can help after that i loose my mac
     
    Joined
    Aug 25, 2015
    Messages
    55
    Reaction score
    30
    could u i would be interested to see

    if u can get to a stage that u need it tested with in a year then i can help after that i loose my mac

    Here's a small example for a tiny fighter ship


    To determine ship size, just use the image size. That will be the size of your ship!

    Rule breakdown for processing [or Legend]

    +Black - negative space
    +White - Hallway
    +Silver - hull wall
    +Dark Gray - doors
    +Bright Silver - glass
    +Gray - chair [chair, bed, furniture, etc. Basically, it's a half slab]
    +red - anti-matter cannons [with dark red being it's control block. the Editor will automatically assign all connectable blocks to their control block if you define it]
    + Yellow/Dark Yellow - Shield capacitor / recharger
    +Blue - engines
    +Green/Dark Green - Power capacitor / reactor
    +Cyan - Core

    [I think that's all the colors?]

    After placing this image into the converter part of the editor, all you would need to do is define the wall height [which is 3 by default] and let it run. The Converter will give you an operational [but not very optimized] ship.
     
    Joined
    Jun 25, 2013
    Messages
    200
    Reaction score
    41
    • Legacy Citizen 2
    • Purchased!
    • Legacy Citizen 3
    will it support wedges and other shaped blocks? or will it do the same as SMEdit and give u a ship that needs to be smoothed?
     
    Joined
    Aug 25, 2015
    Messages
    55
    Reaction score
    30
    will it support wedges and other shaped blocks? or will it do the same as SMEdit and give u a ship that needs to be smoothed?
    You will be able to fully define what colors represent what blocks [including wedges, slabs, etc] in the image you upload... but there will hopefully be an auto-smooth feature in the editor itself that will add all the smoothing that StarMade itself can support.
     
    Joined
    Jun 25, 2013
    Messages
    200
    Reaction score
    41
    • Legacy Citizen 2
    • Purchased!
    • Legacy Citizen 3
    there will hopefully be an auto-smooth feature in the editor itself that will add all the smoothing that StarMade itself can support
    this i am really really looking forward to.
    [DOUBLEPOST=1454983281,1454983245][/DOUBLEPOST]by the way what language are you wrighting this in?
     
    Joined
    Jul 8, 2013
    Messages
    122
    Reaction score
    13
    • Legacy Citizen 5
    • Purchased!
    Because for large database crap my god is it fast. Plus it's fun because it's makes you look cool.
     
    Joined
    Jun 25, 2013
    Messages
    200
    Reaction score
    41
    • Legacy Citizen 2
    • Purchased!
    • Legacy Citizen 3
    Thank you! It's entirely possible that I will need your help in the future. Can I message you with any editor-related questions I have? Also, have you done a lot of bitwise and or HEX stuff in the past?
    happy to help where i can. beyond hex colours and hexadecimal numbers i haven't used hex operations. but i am a quick study if i find it interesting.
     
    Joined
    Feb 13, 2016
    Messages
    6
    Reaction score
    0
    Heyo, I've done some coding for myself today and it seems like the rawChunkData block in the smd2 file has changed with file version 2 (files starting with 00 00 00 02).
    I have tested it with a few blocks and the ids/hp seems to match, as well as the new 5 bit orientatin seems to fit since the are for e.g. the corner block 24 possible rotations. (⌈log(2,24)⌉ = 5)
    For anyone interested, my new block look like this (C#):
    Code:
        [StructLayout(LayoutKind.Sequential)]
        public class BlockDataV2
        {
            public byte _a;
            public byte _b;
            public byte _c;
    
            public byte Orientation { get; set; } // 5 bit
            public byte Hitpoints { get; set; }   // 8 bit
            public ushort BlockID { get; set; }   // 11 bit
    
            public void RawToProp()
            {
                int buildint = _a << 16 | _b << 8 | _c;
                BlockID = (ushort)(buildint & 0x7FF);
                buildint >>= 11;
                Hitpoints = (byte)(buildint & 0xFF);
                buildint >>= 8;
                Orientation = (byte)(buildint & 0x1F);
            }
        }
     
    Last edited:
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    Heyo, I've done some coding for myself today and it seems like the rawChunkData block in the smd2 file has changed with file version 2 (files starting with 00 00 00 02).
    I have tested it with a few blocks and the ids/hp seems to match, as well as the new 5 bit orientatin seems to fit since the are for e.g. the corner block 24 possible rotations. (⌈log(2,24)⌉ = 5)
    For anyone interested, my new block look like this (C#):
    Code:
        [StructLayout(LayoutKind.Sequential)]
        public class BlockDataV2
        {
            public byte _a;
            public byte _b;
            public byte _c;
    
            public byte Orientation { get; set; } // 5 bit
            public byte Hitpoints { get; set; }   // 8 bit
            public ushort BlockID { get; set; }   // 11 bit
    
            public void RawToProp()
            {
                int buildint = _a << 16 | _b << 8 | _c;
                BlockID = (ushort)(buildint & 0x7FF);
                buildint >>= 11;
                Hitpoints = (byte)(buildint & 0xFF);
                buildint >>= 8;
                Orientation = (byte)(buildint & 0x1F);
            }
        }
    That is the format for any block with 24 orientations. Logic blocks have:
    orientation : 3
    active : 1
    hp : 9
    blockID : 11
    Other blocks have:
    orientation : 4
    hp : 9
    blockID : 11

    Apart from the bits for the blockID, the exact allocation of the bits depends on how many orientations the block with the given id has.
    This is why I use the following union of structs(on machines operating in bigendian, littleendian has the same structs in reverse order, so that reversing the 3 bytes does not remove bits from their field. The compiler has to group bitfieds in structs together for this to be directly applicable):
    Code:
    union block {
      char raw[3];
      struct logicBlock {
        short orientation : 3;
        bool active : 1;
        int hp : 9;
        int id : 11;
      } logic;
      struct normalBlock {
        short orientation : 4;
        int hp : 9;
        int id : 11;
      } normal;
      struct fullRot {
        short orientation : 5;
        int hp : 8;
        int id : 11;
      } fullRotation;
    };
     
    Joined
    Aug 25, 2015
    Messages
    55
    Reaction score
    30
    Thank you! These are quite helpful. I do have a question, though. The Header code for the wiki references blocks AND elements. What's the difference between these, if there is one?

    Also, is what's a good [and hopefully, free] program to open up the StarMade ship files? [I'm writing this program on an astonishing 0$ budged] I've been using HexEdit, but it doesn't really seem to produce anything readable. I'm still trying to figure out why the Header is longer than it should be.
     
    Joined
    Jul 21, 2013
    Messages
    2,932
    Reaction score
    460
    • Hardware Store
    From File format - StarMade Wiki (may not be up to date anymore, unknown bytes may have been introduced)
    In essence an 'element' in a header file, is just a blockId with the number of times it is used on the blueprint in question. When spawning a blueprint, starmade actually checks whether or not this differs, and may prevent the use of blueprints, where the mismatch exceeds a threshold, and may even ban the user in question, if the server.cfg specifies that.