Reading BLOB files in Lua

Willkommen in der Transport Fever Community

Wir begrüßen euch in der Fan-Community zu den Spielen Transport Fever und Train Fever, den Wirtschaftssimulatoren von Urban Games. Die Community steht euch kostenlos zur Verfügung damit ihr euch über das Spiel austauschen und informieren könnt. Wir pflegen hier einen freundlichen und sachlichen Umgang untereinander und unser Team steht euch in allen Fragen gerne beiseite.

 

Die Registrierung und Nutzung ist selbstverständlich kostenlos.

 

Wir wünschen euch viel Spaß und hoffen auf rege Beteiligung.

Das Team der Transport-Fever Community


  • Howdy.


    I have a need to read the blob file - because I need to know the bounding boxes of stuff. Mostly to determine realistic data for vehicles from workshop. Because some people seem to think that BR01 could do 270kN of tractive effort with three drivers and 114 of total locomotive weight :) But also because not all mods include bounding box for the models. Has anyone tried it? Maybe there is a tool for it? Or at least a comperhensive guide to the format?

  • I was hoping there is a complete module for this. Righty - time to experiment.

  • Errrm...? Isn't the bounding box defined in the MDL of a model, since it's in-game bounding box can differ from the dimensions of the 3D-Model itself?

    Example should be my offenes Monorail / offene Einschienenbahn Mod since there the models of the gaiters clip into each other...

    I don't know if this works in TpF2 though...


    Edit: and most notably this should be the "real" dimensions, since they are the dimensions the game uses to calculate train length etc.

    Meine Projekte und ausführliche Modding-Berichte hier im Forum:

    Feluno bastelt

    Einmal editiert, zuletzt von Feluno ()

  • I've found some models, like this one: https://steamcommunity.com/sha…iledetails/?id=2227192019 which do not have the bounding box. Thus I persume the engine just goes through all the meshes and uses them to calculate it.


    The issue is that from a mod I can't access this data. The other issue is that in order to determine the weight on drivers of a given locomotive I need to know its axle arrangemet. From that, and axle-loading I can get adhesive weight and thus get a realistic tractive effort without relying on other sources. Currently I am lookigh through the 'lods' of a model and cross-referencing them with 'axles' in metadata. I get a proper axle count this way. But to know which are the drivers I need to know the size of a given mesh. Those don't have bounding boxes in the game's resources.

  • But reading the boundingbox from a mesh does not makes sense.

    With my models, for example, it will never fit because I have the buffers in a different mesh than the body.

    It will never fit with electric locomotives because the pantos are always extra.

    It won't fit with steam locomotives because they have a tender as an extramesh, same problem with articulated buses and trucks with trailers.

    With the mod in my signature (Talent2) it would also break the Mod because the bounding box there is 0.5m shorter than the model.


    So if you don't want to check every mod by hand and want to write exclusions for all these mods that would break more like repairs.

    Grüße MaikC


    116494-emd-dda40x-nc-up-png116503-mc-br442-2-png

    Fehler- und Crashreports ausschließlich unter: MaikC - Fahrzeuge und anderes für TPF2 / 2471 TPF2 Modelle and counting.

    Meine Modelle auf Sketchfab anschauen.

  • You could try reading the Bounding Box not in the modifiers but in the postRunFn.

    Maybe there are the calculated values for the missing boundingInfo in the mdl files.

  • You need to read BLOB under the help from msh file, and maybe much easier with C++ (they are POD float arrays), you need to take account the tranfs.

    This guy is too lazy to create a signature. 8o

  • MaikC - obviously - the entire lod would need to be processed to get a reliable bounding box of a vehicle. For my purposes that would suffice.


    VacuumTube - I can't modify a vehicle in postRunFn, now can I. So even if that worked, then It would, at least, introduce two-stage model loading. Which is very not customer friendly.


    Enzojz - For my purposes I need to read and process the files during mod-loading in runFn. I can write c++ ( actually, I am pro programmer who actually does c++ ), but that would not fit my use-case. Unless I would be willing to off-line process all the mods ever produced for this game.

  • But note that the tractive effort in TPF2 has almost no effect in game, unless this was changed in some patch since I tested that.

  • For the vanilla game - it has a very little use. But, since it is pretty much low-speed ( 1-10km/h ) power limiter, so if you play around it and introduce realistic train weights ( as my mod does ) then it becomes really, really important. Low tractive effort and high power locomotives are most affected.

  • MaikC - obviously - the entire lod would need to be processed to get a reliable bounding box of a vehicle. For my purposes that would suffice.


    VacuumTube - I can't modify a vehicle in postRunFn, now can I. So even if that worked, then It would, at least, introduce two-stage model loading. Which is very not customer friendly.


    Enzojz - For my purposes I need to read and process the files during mod-loading in runFn. I can write c++ ( actually, I am pro programmer who actually does c++ ), but that would not fit my use-case. Unless I would be willing to off-line process all the mods ever produced for this game.


    Of course you can write in lua but just not that simple since I think in lua you need to use some loop to read each float one by one, but I think you don't have choice since written in c++ means you need to deal with platforms.

    Anyway it's not hard neither, since you are c++ programmer, it should be easy to understand. the data in .msh no more than a table of offset and count to guide to read blob. (read the vertices first then read the indices to find the vertices, it's general 3d data structure which you use in graphics buffer)

    The problem is the efficiency, since you need to read every mesh, apply the transf on every vertex then get the bbox, then sum up with other bbox to get the global bbox of an mdl, I think it will take a lot of time.


    I have F# code of my tpfmc on github, if you understand f# or ocaml or scalar maybe that would help

    TpFMC/Core.fs at master · Enzojz/TpFMC (github.com)


    Also livetext in F#

    LivetextTool/Output.fs at master · Enzojz/LivetextTool (github.com)

    This guy is too lazy to create a signature. 8o

    4 Mal editiert, zuletzt von Enzojz ()

    Gefällt mir 1
  • I have just made a check in the api, in fact for mdls without bbox they are recalculated and written in the repo, I don't know if at postRunFn stage but at least they do exists in the gameplay.


    You can make a test yourself by printing the data out.

    This guy is too lazy to create a signature. 8o

  • Enzojz - I was tinkering with stuff for the last few days and in fact - the bounding box is available at the postRunFn stage. Which means that I can at least dump it to file and reapply on the next run of my mod. Does not seem to help with meshes. But is available with models.