Skip to content

Stratkit MapMaker

The MapMaker is used to create custom maps for Bytro games.

Getting Flatbuffer file from the old MapMaker: Currently the old MapMaker can directly export FlatBuffer files that we can use in the new MapMaker. To generate the C# files you can do the following: please refer to the docs of FlatBuffer (https://flatbuffers.dev/flatbuffers_guide_using_schema_compiler.html). 1- Download the latest flatbuffers compiler from here: https://github.com/google/flatbuffers/releases 2- Download the latest "map-serde-schema" from here: https://github.com/bytro/map-serde-schema/blob/AX_FF-630_New_map_format/src/main/fbs/MapData.fbs 3- Execute the following command in the terminal "flatc --csharp MapData.fbs -o "

Scattering: Scattering is split into two main parts:

1-Sampling
    In this step, an algorithm is used to generate samples/points on the mesh. The samples are then used
    in a later step to place the generated objects.
    Each sample has position, zoneIndex and borderIndex parameters to identify which area on the mesh
    the sample belongs to.
    Currently we have the following algorithms to generate the samples.

A-Poisson
    In this algorithm, a uniform number of samples are generated within the area of the given mesh. 
    a grid with a configurable cell size is then generated and samples are placed inside each 
    gird cell based on some rules. The algorithm uses a number of tries to make sure the generated samples
    occupy as much as possible from the area of the mesh taking into account that samples should not 
    interpenetrate. There is a distance parameter to control the distance between the genrated samples.
    Smaller value will result in more samples being created at the cost of time required to generate them.
    The Poisson algorithm is the slowest of all sampling algorithms implemented because it needs
    to be multithreaded.

B-Uniform
    In the uniform sampling, the algorithm iterates over all the required number of samples and generates
    a sample in the mesh bounding box.
    For each generated sample, the algorithm checks whether the sample is actually inside the mesh border or not;
    If the sample lies outside the border polygon it is then discarded and a new one is generated until
    the required number of samples are generated. The algorithm is fast and produces nature looking result
    but does not currently provide a way to  control the distance between samples and therefore smaller 
    areas/provinces will look as though they have more props than bigger areas because the sample number of 
    samples occupy the smaller area. An addition to the algorithm to take the polygon area into account 
    can be added to counter that limitation.

C-Regular
    In this algorithm, the samples are generated on a gird with a a predefined offset between samples.
    The algorithm iterates on all the gird cells generating the sample then checking whether it lies inside
    the border polygon; if it doesn't it is then discarded. No new sample is created to replace the discarded
    sample as it is not needed.

    Finally, a jittering is added to each generated sample position to make sure the generated samples look
    random enough to please the eye.

2-Scattering
    in this second step, the position of the generated samples from the first step is used to place the 
    instantiated props and place them on the map. Props are placed currently based on the following rules:
        A-Distance from Center
            This rule will place bigger props closer to the center of the area (zone or province border) and smaller
            props away from the center of the area.

        B-Distance from boundary
            This rule will place bigger props at the furthest distance from the boundary of the area (zone or province border) and smaller
            props closer to the boundary of the area.

        C-Random
            This rule will choose the prop to be placed randomly.

Coastline generation: Each province has an ElementBatch struct containing info about where it's vertices and tirangles start and end in the big mesh vertex and tirangle arrays. An algorithm is created utilizing the information in that ElementBatch to place the instantiated coastline object. Each province has multiple vertex segments.

Each of those vertex segments contains information
about it's neighbour as well as where it's vertices start in the big mesh vertex array.
The algorithm iterates over all the segments in each province and find if the neighbour Id of that segment is -1
which means it has no neighbours and therefore considered for placing instantiated coastline objects.
After finding a suitable vertex segment with no neighbour for the province, the algorithm then iterates over all 
the vertices in that segment, calculating the number of required coastline objects and instantiates them.