BigBang1112 / gbx-net

General purpose library for Gbx files - data from Nadeo games like Trackmania or Shootmania, written in C#/.NET. It supports high performance serialization and deserialization of 200+ Gbx classes.
https://explorer.gbx.tools
86 stars 20 forks source link

Need some Guidance for TMNF #89

Closed jitendracheripally2003 closed 8 months ago

jitendracheripally2003 commented 8 months ago

Hi, can you please tell me how can I parse a TMNF track. The purpose of this is to extract track edges to build an AI. For context I don't have basic knowledge of how these map files work, C# and also .Net . Can you please give some guidance for me and resources for my idea possible. Thank you.

BigBang1112 commented 8 months ago

Hi, it is a possible yet difficult path to get there (as long as you need precise collision curves).

Maps only store block references (see the map file size, you would definitely not fit mesh into this small size). These block references target to internal data that is stored in Packs, in .pak files.

You can read NadeoPAK files with GBX.NET.PAK. You first get the NadeoPakList and then NadeoPak. In Stadium.pak then you can see the block names in Stadium folder further down as EDClassic.Gbx and EDRoad.Gbx files. The block names in Map.Gbx don't have to exactly match the file name. The next steps would be at least 15 more sentences so I'll simplify: in EDClassic.Gbx, there's a path to Solid.Gbx, which has mesh and collision data. But it's not easy to get there (file names are hashed etc). You would then build a dictionary of these block names (with placement specifics) and these solid.gbx files and join them together with position and direction offsets.

If you really want to go this path but simplify it, then I can recommend getting TMNESWC game, which would have these Solid.Gbx files available without a .pak, and I believe the shapes are also similar near identical (but dirt blocks are not available there).

See https://gbxexplorer.net/ and import a Map.Gbx, EDClassic.Gbx or Solid.Gbx to see what i mean in practice.

jitendracheripally2003 commented 8 months ago

Hi, thank you for responding! I understand that .pak files will cause the parsing problem, so we have to avoid them. I wanted to build an AI, using the distance between the car and track edges given as input, so this pack data will not help for this? Sorry for not understanding correctly; I don't know anything about GBX files. The TMN ESWC game doesn't have TMInterface to get game data so it will not be helpful. I have tried gbxexplorer with Map.GBX files but I was not able to get EDClassic.GBX files from the game folder.

BigBang1112 commented 8 months ago

You dont need to retrieve the edges in real time no? This info can be static and doesnt matter if TMInterface or not, so you can take this using data from ESWC, storing it externally and using it with whatever algorithms.

Track edges is still quite a vague term for me, but if you need to get collision edges of your blocks, you won't be able to avoid Solid.Gbx for accurate results. But it will just take as much time as doing it manually tbh.

I mentioned EDClassic because there are multiple variants of a single block name and it links to multiple solid files, where just one is picked according to placement parameters seen on the CGameCtnBlock class.

jitendracheripally2003 commented 8 months ago

Yes, I don't need to retrieve track edges in real time, but I'm using TMInterface for extracting the car position, which is then used to calculate the distance between the car and the track edges (which are in an array extracted from the track file; these distances are given to the model input as LIDAR input data).

I feel like this process is very complicated for me, so I'm choosing not to continue. I've decided to use another environment, TORCS.

Thank you so much for your guidance and explanation.