Multilayered Tiles

MarrtMarrt Posts: 6
edited November 2015 in Feature requests
The thing that would give PyxelEdit the edge against other pixel-editors would be a Sub-layering feature with the purpose of creating Multilayered-Tiles. It is a pretty heavy feature request though, it needs some discussion before even considering it since it is really hard to design in a good way.

I explain how i think it could be implemented. I want to mention beforehands that simply adding a Layer-Folder system would not be sufficient to have multilayered tiles (or it would at least completely complicate everything).

So, here's the concept:

1. You have a global subgroup of layers, every normal-layer has them as sublayers
Example: You have 3 normal layers: N1, N2, N3 and 2 sublayers S1, S2 defined in your file. S1 and S2 are global for every layer, so N1 can be unfolded to show S1, S2 so can N2 and N3. If you edit the names or the amount of sublayers they change globally, e.g. if you add a sublayer S3, every normal layer will now have S1,S2 and S3.

image

2. You can select normal layers for Tile Placement. Editing a normal layer always affects its first sublayer but in general sublayers must be selected in order to be edited. Normal layers themselves can only hold Tile-References in that sense

3. When using the selection tool on a normal layer, all sublayers are copied/transformed etc. , pasting into a normal layer then pastes the sublayers accordingly ( this adds the requested feature of multilayered copying in a weak sense).

4. Selection Tool on a Sublayer works like it does now, copying/transforming bitmap data

5. On a new file there is only one sublayer declared. By design the whole system then behaves like no sublayers are defined and looks like it does now, when you draw on the selected Normal-layer, you really draw on S1 but since only one sublayer is defined it shows no folding in the Layer-Hierarchy. Selection tool is really affecting S1, TilePlacerTool is normally affecting the Normal-layer.

6. Tile references are put on normal layers, and the Tiles layered content can be edited through the sublayers

7. Speciality: Title-Reference in Sublayer: Tiles can also be placed in sublayers, but then only its merged-texture (see Datastructure in Part3 ) is used for display on that sublayer. Drawing onto this merged texture only adds to S1 of the original tile (since you have no further folding in sublayers you cannot resolve where to draw).
This allows Tiles to have a reference to another tile in themselves. This is very useful if you have base tiles and transitions.

Part1 End

Comments

  • MarrtMarrt Posts: 6
    edited November 2015
    Part2 

    Special new Functions that emerge:
    -Merge Sublayer merges two sublayers (remember, this applies globally)
    -Duplicate Sublayer create a new sublayer with the content of the original

    Why do you even need this?
    • When drawing characters you often use different layers for capes, weapons and body but cannot move them in union
    • Same is true for tilesets, you have a base tile and on top different tiles with augments for transitions and variations
    • Or a base floor layer that is the same for all tiles, but some have small overlay-variations like borders, grass or cracks
    image

    Why global subgroup-layers instead of a general sublayer system?
    • You would have to configure every Tile that you create. It needs a list of "isOnLayer"-Flags representing each layer if you don't make it global.
    • You couldn't link layers to tiles effectively
    • Having this single subclass of general sublayers, homogeneous for all layers, means that you can ensure that every layer has all needed sublayers for any tile
    Part2 End
  • MarrtMarrt Posts: 6
    edited November 2015
    Part3
    A naive Programming draft for the new MultilayeredTile class to help comprehension:
    class MultilayeredTile{
    int tileIndex;
    List<TileLayer>() layers; //list of TileLayers-struct below
    Texture mergedLayers; //combination of all layers, this texture is used within sublayers of other
    //Tiles when a TileLayer struct has a value for tileRef other than -1 and
    //is updated when that Tile's sublayers change
    }

    struct TileLayer{
    Texture texture = null; //bitmap content of that layer, obsolete if tileRef is not -1
    int tileRef  = -1;  //no reference by default
    bool visible = true; //not sure if this should be an option for tiles, where to put that checkbox?
    int width, height//,... //stuff
    }

    Alternatives?
    Yes, you could also make another system where you mark layers as dedicated tile-Layers. When creating tiles those layers are kept separate within the tile. But then you could not place Tile-References on different layers and dedicated Tile Layers must be excluded from containing Tile references since their tile contents always refer to a Tile reference themselve. Very restrictive
Sign In or Register to comment.