AdrianoDiDio / Medal-Of-Honor-PSX-File-Viewer

A set of tools to open and view files from the PSX games Medal Of Honor And Medal Of Honor:Underground.
GNU General Public License v3.0
30 stars 1 forks source link

support for exporting and viewing Medal of Honor: Underground files? #3

Closed mrSuave00 closed 2 years ago

mrSuave00 commented 2 years ago

hello there, I recently stumbled across this tool as a means for aiding a passion project regarding these games and I wondered if you could include a 3D export feature and the ability to scan and extract/view MoH:U's files as well?

AdrianoDiDio commented 2 years ago

Hello, I've just added the ability to export the current level along with the objects to a Wavefront OBJ file. In the next week I'll try to build a new release for both Windows and Linux (I'm still trying to figure out how to include the texture files along with the model). MOH:Underground uses the same engine as MOH but the files are different between the two games...the current tool set is able to extract only TAF and RSC file (which are the same in both games) but not BSD and TSP (containing level data) due to the different file format.

mrSuave00 commented 2 years ago

honestly, if you could just make sure the model could get exported intact, the textures wouldn't be such a big deal to export with because you have a TIMExtractor too, the rest would just be drag and drop since I'm guessing the UV's would export correctly too.

also aaaa thank you a lot, the work you do with this tool is really impressive and I can't thank you enough for making this work. can't wait for the update!

vrpixel commented 2 years ago

can't wait for this!

AdrianoDiDio commented 2 years ago

Published a new release containing the new feature that lets you export level and objects into a wavefront obj/mtl file by pressing the 'e' key after loading the level. The output will be in the current executable folder under the export directory (E.G Export/MSN1LVL1/). At the moment the only missing feature is to render/export the enemy/weapon game objects that uses a completely different format.

mrSuave00 commented 2 years ago

works as intended, can't wait for the underground support!

mrSuave00 commented 2 years ago

minor nitpick, importing into blender, the models are way too huge and a big hassle to get into the viewport, other than that, it's 100% muy bien

AdrianoDiDio commented 2 years ago

Thanks for the feedback, I didn't notice it since I was using a different tool. Anyway now It should be fixed (I tested it with blender) and I will try to update the current release to include this commit. EDIT: I've updated the released file to include the latest commit.

vrpixel commented 2 years ago

I can't open the MOHLevelViewer.exe. Nothing happens after opening exe file. I used to use older version without exporting and it worked fine. What's wrong here?

AdrianoDiDio commented 2 years ago

Make sure to pass the command line arguments before starting the program (either by using the command prompt or by creating a shortcut and passing the arguments there) containing the path to MOH folder, mission number and the level number (C:\Path\To\MOH\ 1 1). If it still doesn't work, please post the output from the command prompt to see what's the issue.

mrSuave00 commented 2 years ago

another thing, SOME textures come off transparent for some reason, like the entire texture is at 70% opacity

some showcase using your exporter: https://www.reddit.com/r/psx/comments/sq5krs/medal_of_honor_with_pbr_textures_showcase_only/?utm_source=share&utm_medium=web2x&context=3

really can't wait for Underground compatibility!

AdrianoDiDio commented 2 years ago

If you are talking about the empty exported texture, then it is normal and due to to the way textures works on psx. The way it works it's a bit different than normal textures since all the images (TIM) are loaded all at once onto this memory and later referenced by the levels/models using only 3 information's ( texture page, color mode and UV coordinates ). This means that we don't know beforehand which pages are needed by the model and thus the tool is exporting the whole VRAM ( for both 4-bit and 8-bit color mode) without checking if the page is empty or not (VRAM is made of 32 pages for both 4 and 8 bit mode). If that's the issue it can be ignored for now and in the future I'm thinking to merge all the pages in a single file although it would require to recalculates the UV coordinates.

mrSuave00 commented 2 years ago

i mean, the textures are intact, they just come out transparent (see through) for some reason, like if i were to take down the opacity of the image by 20% and for that reason the textures show up washed off in 3D, it's really a minor thing since i'm fiddling with the textures anyways but yeah, not sure if this is a problem with the ripped file or something

mrSuave00 commented 2 years ago

image

AdrianoDiDio commented 2 years ago

I've pushed a commit to remove the alpha color when the STP bit is set ( alpha color was around 78% ) .

mrSuave00 commented 2 years ago

you work quick!

is there a chance an object viewer/exporter (for viewing the first person view models and the allies/enemies models) could be made? or are the animated parts of the game too difficult to mine up?

AdrianoDiDio commented 2 years ago

Thank you, enemy/weapon models file are a planned feature but, as you said, will take some time to complete due to the complexity of the file format.

mrSuave00 commented 2 years ago

here are some more screens to show off your exporter

https://www.artstation.com/artwork/xYqn8r

mrSuave00 commented 2 years ago

any news? :o

AdrianoDiDio commented 2 years ago

I'm currently working on parsing the menu files (sst scripts) and, in particular, the 3D models that are present inside the main title screen (hoping that the file format is similar to the one used to render in-game models). I'm also thinking on how we should support MOH:Underground since the file format are different I'm not sure whether to create another Level Viewer specifically for it or it is better to use the same code for both (although I'm not sure on how to distinguish between the two versions).

mrSuave00 commented 2 years ago

there could be two different level viewers to be honest, since the programs need different ROMS anyways. are the file formats vastly different?

AdrianoDiDio commented 2 years ago

They uses the same format but with different sizes. This is not a problem for the TSP file (which contains the level geometry and can be worked around) but it is for the BSD file. BSD file can be seen as a container of multiple file formats and it's a little bit trickier to load since a minimal change in size causes a variable shift of n-bytes that makes harder to know where the actual data starts.

mrSuave00 commented 2 years ago

I just hope you'll have enough motivation to go through it, what you have done with the exporter so far is already nothing short of amazing!

AdrianoDiDio commented 2 years ago

Thanks, support for MOH:Underground has been added to 'MOHUndergroundSupport' branch and I'm planning to create a new release in the next few days.

vrpixel commented 2 years ago

Can't wait

AdrianoDiDio commented 2 years ago

I've published a new release containing all the changes made to support MOH:Underground. Let me know if you find any problem with the new release.

mrSuave00 commented 2 years ago

loving the new level viewer! one thing, various parts of the map are rendered incorrectly, unsure if it's the actual geometry or the wrong texture is applied, but there are holes in the map in a few places. works flawless otherwise

image

AdrianoDiDio commented 2 years ago

You are right, it seems that there are some UV coordinates in the TSP file that do not make any sense. I'm trying to understand if it is a problem related to the code that loads these faces or a problem with the data itself.

mrSuave00 commented 2 years ago

one more issue, upon exporting the level, the VRAM texture that is dumped looks like this image

mrSuave00 commented 2 years ago

AND! one more, i'm not sure if this is something you can remedy but half the normals come off as inverted. it's as simple as recalculating them though so it's not really a problem

image

AdrianoDiDio commented 2 years ago

The exported texture is expected to be that way since I've changed how the VRAM works. Instead of using many pages I've merged all the textures into a single file and fixed the UV coordinates to fetch the texture from the correct location. Normals can be fixed and I will try to do that after I fix the texture issue with MOH:Underground.

mrSuave00 commented 2 years ago

do you also think there would be a way to export the vertex colors of the maps too? i'm not too sure OBJ is capable of vertex colors though

AdrianoDiDio commented 2 years ago

Vertex colors are already exported and they can be found in the vertex definition (there are 6 number per vertex x,y,z,r,g,b) as normalized numbers ( divided by 255 ). However, as you said, this format isn't supported by OBJ files and depends from the loader.

mrSuave00 commented 2 years ago

that's a shame, i'd love to retain the original look by having the vertex colors, as well as having the new lighting system be toggleable in this project i'm making

AdrianoDiDio commented 2 years ago

~~I've tried to implement a ply exporter (the format used by blender) but it has a problem: the number of files that would be generated. Ply file format doesn't allow multiple object inside a single file, and if you look at the level geometry, you can see that it is split into multiple compartments that would require at least 1 file for each compartment. Even if I merge all the compartment data inside a single file there would be another problem due to all the objects inside the level that would be duplicated ( for example a box that you can find in two different location inside the same level). If you know any 3D format that it is ASCII based and support multiple objects as well as Vertex Color/Texturing I may try to update the current exporter code to support it.~~ EDIT: I've managed to fix the issues with MOH:Underground level's rendering and I will be releasing a new version in the next few days. This only fixes the graphical glitches (due to the textures) that you see on the level viewer but not in the exporter. This means that the exported level will still have the same problem and I'm not sure whether or not this can be fixed, The problem is due to the use of paletted textures that are swapped during level load and these changes can only be implemented trough an OpenGL shader and cannot be exported without creating a new texture. I will also try to include the Ply exporter as well but note that Blender (at least in the current version) will only show the vertex color without any texture applied due to the inability of loading per face UV coordinates. EDIT2: I've found a way to export the level as a ply file supporting both vertex color and texturing ( you will need to add a default material to blender and manually mix the vertex/texture color in order to see it). The exporter will generate two files: one for all the objects contained inside the level and another one for the level itself that you will have to manually import into blender, and for each imported object add a material and mix the colors. The other issue will not be solved (at least in the exporter) and this means that several MOH:Underground files will have weird texture applied to random surfaces.

mrSuave00 commented 2 years ago

you are a literal god walking among us mortals, this is really outstanding work man!

AdrianoDiDio commented 2 years ago

Thank you very much, I'm glad it is working as expected. I'm going to close this issue since it is resolved, but feel free to open a new issue if you have a suggestion or encounter a problem.