Data Packer (read directly from stream)

About Monkey 2 Forums Monkey 2 Projects Data Packer (read directly from stream)

This topic contains 7 replies, has 4 voices, and was last updated by  nerobot 1 year, 4 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #11740

    nerobot
    Participant

    Hi guys.

    I was playing with data packing – pack any resources like images into single pack-file and then read them directly from file stream.

    This time I done with pack/unpack images.

    How to pack files:

    How to read images:

    Packer produce two files – binary one and json one.

    I decided to use 2 files to simplify process, to pack info into single file we must precalculate sizes, check this info size in bytes…

    See attached demo.

    Is it useful for anyone?

    Attachments:
    1. datapacker.zip
    #11742

    EdzUp
    Participant

    Nice it’s definitely something I’m going to look into for Star Rogue 🙂

    I will go for the one data file approach that I started with MX1 this was easier to distribute and allowed for all types of media to be packed. However the reading from stream is something I will definitely look at as it will simplify the whole process if it can be used for meshes, textures etc.

    #11749

    scurty
    Participant

    Wonderful! Very useful indeed. 😀

    #11756

    nerobot
    Participant

    This solution depends on Stream.Seek( position:Int ) method, but not all streams are seek-able.

    This time I know only that it works fine for desktops.

    Also need to test very big pack file – about 500 mb and monitoring RAM usage.

    I expect to see low RAM usage because it just jumps to resource offset in file stream and read only needed data part.

    #11766

    nerobot
    Participant

    Some ideas about using data packer.

    I want to use it for release but don’t want to re-pack every time while developing.

    My approach is to have 2 imports with different ‘configs’ for resource manager:

    We use one of them at a time – just comment/uncomment two lines.

    Inside of them we have something like:

    Don’t forget to call our InitAssets() in Main():

    Of course, we should use our Assets class for any loading stuff to get all discussed here benefits (easy swapping between loading-from-single-files and loading-from-packs).

    Also, we can try to find single-files in assets folder if not found in pack-file.

    Attachments:
    #11775

    nerobot
    Participant

    In addition to GUI app:

    • there is a single output file now, info section with names / offsets / sizes placed alogn with binaries;
    • addet GetText() method to extract textual files.
    #11963

    Amon
    Participant

    Now this, I would find very useful.

    #11969

    nerobot
    Participant

    I really like that monkey2 work with raw bytes to create resourses like images, strings, fonts.

    I’m going to add font loading from pack file.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.