project-navigation
Personal tools

Author Topic: A question about MDX files  (Read 37192 times)

Offline Andermaiden

  • Rookie
  • ***
  • Posts: 12
    • View Profile
A question about MDX files
« on: July 16, 2017, 11:13:33 pm »
Hi, does anybody know what the mdx file format stands for? What information carries and how to export them? I couldn't find any information here about the mdx but it seems like it's an important file format for the models as every model has one. From what I searched, it is a 3d mesh file format used in some blizzard games, but the md2 already stores the information for the mesh so I'm clueless as to how does it relate with the md2.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2560
    • View Profile
Re: A question about MDX files
« Reply #1 on: July 17, 2017, 04:31:25 pm »
Hi, does anybody know what the mdx file format stands for? What information carries and how to export them? I couldn't find any information here about the mdx but it seems like it's an important file format for the models as every model has one. From what I searched, it is a 3d mesh file format used in some blizzard games, but the md2 already stores the information for the mesh so I'm clueless as to how does it relate with the md2.

Our mdx files are generated by the ufomodel tool. It pre-calcuates normals and tangents to speed up model loading a bit. You can safely remove and recreate the mdx with the ufomodel tool. The game works without mdx-es fine.

-geever

Offline Andermaiden

  • Rookie
  • ***
  • Posts: 12
    • View Profile
Re: A question about MDX files
« Reply #2 on: July 22, 2017, 11:36:11 pm »
Our mdx files are generated by the ufomodel tool. It pre-calcuates normals and tangents to speed up model loading a bit. You can safely remove and recreate the mdx with the ufomodel tool. The game works without mdx-es fine.

-geever
Thanks a lot for the tip! Now by any chance do you know of any charitable soul who has an already compiled ufomodel.exe? 'cause I'm not being able to compile it with codeblocks (I've been having trouble trying to install a compiler in a proper way)

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: A question about MDX files
« Reply #3 on: July 24, 2017, 06:09:35 pm »
Our mdx files are generated by the ufomodel tool. It pre-calcuates normals and tangents to speed up model loading a bit. You can safely remove and recreate the mdx with the ufomodel tool.

It doesn't. Our talk over the IRC led me to investigate it again (forgot the previous results), and no, it does not store any normals. It is a bidirectional vertex<->index map for indexed representation of models, with duplicate vertices removed. And that's pretty much all. See the R_ModLoadMDX() for yourself -- it only processes the indices.

The game works without mdx-es fine.

It just recalculates it on every load by the O(n^2) algo with quite a big multiplier. See the  R_ModCalcUniqueNormalsAndTangents(), which does NOT exactly do what its name suggests. Normals get recalculated every frame anyway.

P.S.: Proper name should be something along the lines of R_ModFindSharedVerticesForReuse(), or something like it.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2560
    • View Profile
Re: A question about MDX files
« Reply #4 on: July 24, 2017, 07:06:53 pm »
Thanks Sandro for correcting me. As you know I'm not much into the Renderer or graphics in general and yeah, I guessed what it exactly does from the function name. Could you maybe update the code to better reflect what it does? Maybe adding some in-line documentation?

Andermaiden: I checked, ufomodel.exe is not shared by our buildbot, unfortunately. I'd need Windows or make a cross-compiler work on my computer to make one. Not that it is impossible but someone else might provide it faster than me. Btw. did you try the pre-packaged Code::Blocks we share? It wasn't updated for a while, so I cannot guarantee that it works, but may worth a try.

-geever

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: A question about MDX files
« Reply #5 on: July 24, 2017, 10:31:09 pm »
Thanks Sandro for correcting me. As you know I'm not much into the Renderer or graphics in general and yeah, I guessed what it exactly does from the function name. Could you maybe update the code to better reflect what it does? Maybe adding some in-line documentation?

While I'd like to, I haven't got a working environment, just a copy of source right now (of 2.5 release). So only things right now I can do is to make suggestions and perhaps provide some code snippets, if I'll be able to compile them.

Going back to the R_ModCalcUniqueNormalsAndTangents() function, it really calculates normals, but only to use them as intermediate data; they are discarded at the function returns.

After some thoughts, it looks to me that it will be better to call this function R_ModBuildIndexedMesh(), because it is what it actually does.

Offline Andermaiden

  • Rookie
  • ***
  • Posts: 12
    • View Profile
Re: A question about MDX files
« Reply #6 on: July 25, 2017, 01:00:49 am »
Andermaiden: I checked, ufomodel.exe is not shared by our buildbot, unfortunately. I'd need Windows or make a cross-compiler work on my computer to make one. Not that it is impossible but someone else might provide it faster than me. Btw. did you try the pre-packaged Code::Blocks we share? It wasn't updated for a while, so I cannot guarantee that it works, but may worth a try.

-geever
in the instructions for codeblocks there's a step that says:
"copy the dynamic libraries (*.dll) from contrib\dlls\ to the UFO:AI root dir, or into a directory in your path (e.g. c:\windows\system32). Or add the contrib\dlls directory to your path."
I suppose I have to include it to Compiler search dirs but I cannot find a directory called "dlls" in "MinGW\contrib\".

I tried to compile ufomodel as it goes just in case the latter isn't necessary but it gave 36 errors so I guess I'll need to follow all the steps (to having it properly configured) before ruling it out.

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2560
    • View Profile
Re: A question about MDX files
« Reply #7 on: July 25, 2017, 07:06:20 pm »
in the instructions for codeblocks there's a step that says:
"copy the dynamic libraries (*.dll) from contrib\dlls\ to the UFO:AI root dir, or into a directory in your path (e.g. c:\windows\system32). Or add the contrib\dlls directory to your path."
I suppose I have to include it to Compiler search dirs but I cannot find a directory called "dlls" in "MinGW\contrib\".

I tried to compile ufomodel as it goes just in case the latter isn't necessary but it gave 36 errors so I guess I'll need to follow all the steps (to having it properly configured) before ruling it out.

contrib directory is in the UFOAI Git repository

-geever

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2560
    • View Profile
Re: A question about MDX files
« Reply #8 on: July 25, 2017, 07:09:22 pm »
Damn, I was wrong. Actually we zip all win32 binaries in our snapshot releases:

2.5: http://ufoai.org/snapshots/ufoai-stable-win32.zip
2.6-dev: http://ufoai.org/snapshots/ufoai-latest-win32.zip

-geever

Offline Andermaiden

  • Rookie
  • ***
  • Posts: 12
    • View Profile
Re: A question about MDX files
« Reply #9 on: July 26, 2017, 01:34:39 am »
Damn, I was wrong. Actually we zip all win32 binaries in our snapshot releases:

2.5: http://ufoai.org/snapshots/ufoai-stable-win32.zip
2.6-dev: http://ufoai.org/snapshots/ufoai-latest-win32.zip

-geever
Thanks! That should do it

Offline Andermaiden

  • Rookie
  • ***
  • Posts: 12
    • View Profile
Re: A question about MDX files
« Reply #10 on: September 09, 2017, 05:17:07 am »
I've tried to use the ufomodel.exe with the following manual but I could not make it work (can't even call the help menu). Can someone confirm me that these comands arte the correct ones to use? also, should ufomodel be on the game root or in C:\?
http://manpages.ubuntu.com/manpages/zesty/man1/ufomodel.1.html

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2560
    • View Profile
Re: A question about MDX files
« Reply #11 on: September 09, 2017, 03:43:01 pm »
Any console output?

-geever

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: A question about MDX files
« Reply #12 on: September 11, 2017, 05:17:46 pm »
It should be in the game's directory, also on windows SDL will redirect the console output to stdout.txt and stderr.txt

Offline Andermaiden

  • Rookie
  • ***
  • Posts: 12
    • View Profile
Re: A question about MDX files
« Reply #13 on: September 16, 2017, 12:50:49 am »
I used the system symbol (ms-dos command prompt) typing "C:\Program Files (x86)\UFOAI-2.5\ufomodel.exe -h --help" just in to see if I got any response (that after trying the mdx convertion command) but it didn't return anything either. The DOS command prompt does not leave any log detailing why it didn't work.

Offline TBeholder

  • Rookie
  • ***
  • Posts: 54
    • View Profile
Re: A question about MDX files
« Reply #14 on: September 17, 2017, 03:07:26 pm »
It just recalculates it on every load by the O(n^2) algo with quite a big multiplier.
In this case, why not to remove them, but when the game pre-calculates all this data (both indices and those vectors, which will bloat it) once, dump to cache directory (defaulting to "~/.cache/ufoai" for linux, etc)?
And add settings for handling it. Then cache can be pre-made for every model for speed, or nuked to free space, no great loss.