Jump to content

Alan Wake 2


michalss

Recommended Posts

8 hours ago, riverence said:

figured it out 🙂 it also seems as if the vertex size is inconsistent between meshes, which is why i was having trouble importing them. was able to get alan's revolver and his lamp as wellimage.thumb.png.926b1eaf73851c426e1b444601b908a3.pngimage.thumb.png.912231038f3222fc73e0229840d4e20d.png

Holy shit, nice! I've been wanting his lamp and revolver for a while now

Edited by Contro
Link to comment
Share on other sites

A new update for the Alan Wake 2 blender addon has been released. This update includes preliminary support for a good chunk of meshes present under /objects/weapons/. I also changed the mesh naming scheme a bit, and streamlined the process for adding any more supported meshes.
If you run into a struct error, the file you selected isn't supported.
 

The newly supported meshes are as follows;

crossbow_default_publish
crossbow_default_publish_physx
doublebarrelshotgun_default_publish
fbiservicepistol_compensator_publish
fbiservicepistol_default_publish
fbiservicepistol_magazine_extended_publish
flaregun_default_publish
flashlight_default_publish
lamp_default_publish
lamp_physx
pumpactionshotgun_compensator_publish
pumpactionshotgun_default_publish_physx
pumpactionshotgun_stock_pouch_publish
revolver_default_publish
rifle_cheek_pad_publish
rifle_default_publish
rifle_default_publish_physx
rifle_scope_publish
sawnoffshotgun_default_publish
sawnoffshotgun_physx

 

io_scene_binfbx.zip

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

I am completely new on digging resources from games and I have basically zero experience with coding. I found this thread when I was looking for a way to extract some of the in-game poster files to make me a real poster.

Could you help me and tell is that possible with these tool discussed in this thread and how advanced knowledge would it need to use it for such a task (e.g. is it worth the hustle without any prior knowledge).

Also, do you know if the in-game posters are even in some kind of very high quality scaleable format that it could be used to make some big prints?

I'm sorry that this is hardly related on the matter but figured to ask just in case.

Link to comment
Share on other sites

On 1/16/2024 at 5:55 PM, riverence said:

A new update for the Alan Wake 2 blender addon has been released. This update includes preliminary support for a good chunk of meshes present under /objects/weapons/. I also changed the mesh naming scheme a bit, and streamlined the process for adding any more supported meshes.
If you run into a struct error, the file you selected isn't supported.
 

The newly supported meshes are as follows;

crossbow_default_publish
crossbow_default_publish_physx
doublebarrelshotgun_default_publish
fbiservicepistol_compensator_publish
fbiservicepistol_default_publish
fbiservicepistol_magazine_extended_publish
flaregun_default_publish
flashlight_default_publish
lamp_default_publish
lamp_physx
pumpactionshotgun_compensator_publish
pumpactionshotgun_default_publish_physx
pumpactionshotgun_stock_pouch_publish
revolver_default_publish
rifle_cheek_pad_publish
rifle_default_publish
rifle_default_publish_physx
rifle_scope_publish
sawnoffshotgun_default_publish
sawnoffshotgun_physx

 

io_scene_binfbx.zip 10.01 kB · 15 downloads

Currently working on getting the rig out of the game, with some great progress made so far. 1; I was able to implement the boundary box for each submesh correctly, so, woohoo, and 2; I'm able to get the actual skeleton out, posed correctly and everything. After I get the weights out and get them applied to the mesh, I'll be working on possibly writing mesh data to an existing *.binfbx file (because creating new ones would probably be hell) as well as implementing a universal solution for the binfbx format that doesn't require manually finding the offsets. Once I have more news, I'll share it here, but in the meantime if anyone here is specifically proficient with Blender's Python API, and knows at least a little bit of the format, I'd love some help if possible.

22bea67f3c9ba75d283c0708ccd59390.png

604f409bb77181064fd2f049d68bd327.png

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

 

Update 2.00 - Alan Wake 2 *.binFBX Blender Addon

  • added rigged skeleton support, including non-human meshes (let me know if you get anything unexpected, still rough around the edges!)
  • added support for some other meshes i can't remember
  • more debug logs for anyone interested in the format
  • died and came back to life

Roadmap

  • material generation
  • proper reverse engineering of mesh file (every mesh file being supported without manually finding offsets)
  • mesh/submesh replacing (might be coming the soonest)

io_scene_binfbx.zip

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

On 2/5/2024 at 11:15 PM, riverence said:

 

Update 2.00 - Alan Wake 2 *.binFBX Blender Addon

  • added rigged skeleton support, including non-human meshes (let me know if you get anything unexpected, still rough around the edges!)
  • added support for some other meshes i can't remember
  • more debug logs for anyone interested in the format
  • died and came back to life

Roadmap

  • material generation
  • proper reverse engineering of mesh file (every mesh file being supported without manually finding offsets)
  • mesh/submesh replacing (might be coming the soonest)

io_scene_binfbx.zip 9.19 kB · 31 downloads

I'll also be updating it on GitHub, feel free to contribute or to open issues there (preferred); https://github.com/riverence/io_scene_binfbx

Edited by riverence
  • Like 2
Link to comment
Share on other sites

On 2/2/2024 at 7:02 AM, riverence said:

as well as implementing a universal solution for the binfbx format that doesn't require manually finding the offsets. Once I have more news, I'll share it here, but in the meantime if anyone here is specifically proficient with Blender's Python API, and knows at least a little bit of the format, I'd love some help if possible.

From what I understand...

The table_offset variable is used to specify the starting point within the .binFBX file from which the script begins to read mesh information? The correct value for table_offset depends on the specific .binFBX file being imported, as different files may have their data structured differently. Different assets have their mesh data tables starting at different points within the files.

The lod0_offset variable indicates the starting point within the .binFBX file for the mesh data corresponding to the Level of Detail 0 (LOD0). The offset is used to locate where the vertex and face data for this LOD begin in the file.

So the question now is, how are you inspecting the files to get the table offset and lod0 offset? Are you just opening them with notepad or some debugger tool? Is there an example?

Link to comment
Share on other sites

11 hours ago, bladers said:

From what I understand...

The table_offset variable is used to specify the starting point within the .binFBX file from which the script begins to read mesh information? The correct value for table_offset depends on the specific .binFBX file being imported, as different files may have their data structured differently. Different assets have their mesh data tables starting at different points within the files.

The lod0_offset variable indicates the starting point within the .binFBX file for the mesh data corresponding to the Level of Detail 0 (LOD0). The offset is used to locate where the vertex and face data for this LOD begin in the file.

So the question now is, how are you inspecting the files to get the table offset and lod0 offset? Are you just opening them with notepad or some debugger tool? Is there an example?

Yes, the data table offset is different between files, as the skeleton info at the beginning of the file is of a variable size, and there's sometimes some mystery data after that, and only then does the mesh data table actually begin.

What I've been doing to find it reliably is to open up a mesh file in ImHex, and search for the binary sequence of '01 07 02 00', which seems to be used as the beginning of a separator between submeshes in the data table. The number of times this separator appears is typically the amount of submeshes, and you can use that number to find the Mesh ID specified in the Blender addon. You may catch some strays of the sequence in other random mystery data, but in that case just find where the first instance of it occuring in the table starts and add the next 4 bytes to the search, as they are part of the same separator, just per-mesh type. It's only typical for the non 32-byte vertex meshes, from my experience.

After this, finding the lod0 offset is a bit trickier but typically you'll be able to find it by navigating to the vertex offset (you can find out more about the pattern per size if looking for it manually by checking the offsets in supported files output by Blender), taking the number of vertices and multiplying it by 8 to get the number of bytes of the UV table, which you can then use (as a negative number in ImHex's Ctrl-F > Relative tab, just make sure you've selected the exact byte the vertices start at) to navigate relatively from the vertex offset to the lod0 offset.

This process has generally worked for me, but it's incredibly finicky and sometimes won't work in mysterious cases (cough cough, Alan's typewriter).

Some meshes also require finding a specific offset for the skeleton located in the mesh, which is an entire other can of worms as Remedy has seemingly attached a completely different file to the beginning of some mesh files, thus displacing the start of the actual mesh file by a not-insignificant number of bytes. This is not the case for all files, and it's currently unknown what the appended data is actually doing.

This is all I know so far, let me know if you have any questions, I know some of my wording is confusing.

Edited by riverence
Link to comment
Share on other sites

Edit: It looks like the script only works for the files where the offset are known right! Sorry guys, still have to put a little work on the script! 🤔

Edit: File deleted. Please look for the last post of the search file.

 

Edited by Mike2023
  • Thanks 1
Link to comment
Share on other sites

17 hours ago, Mike2023 said:

Edit: It looks like the script only works for the files where the offset are known right! Sorry guys, still have to put a little work on the script! 🤔

AW2_search_offsets_us.py 3 kB · 4 downloads

Hey hey! While checking it out, I noticed that while the first 4 offsets given (for a mesh with 6 lods from 5-0) seem to be correct, the last one isn't and typically points to the end of the file or some other unknown offset. It also seems to ignore the first LOD offset, that being the LOD that begins right after the data table ends. Other than that, thank you for your work! I've begun integrating it into the Blender addon, but with not much luck. You can check out my progress on the most recent commit at https://github.com/riverence/io_scene_binfbx/blob/main/__init__.py

Link to comment
Share on other sites

5 hours ago, riverence said:

Hey hey! While checking it out, I noticed that while the first 4 offsets given (for a mesh with 6 lods from 5-0) seem to be correct, the last one isn't and typically points to the end of the file or some other unknown offset. It also seems to ignore the first LOD offset, that being the LOD that begins right after the data table ends. Other than that, thank you for your work! I've begun integrating it into the Blender addon, but with not much luck. You can check out my progress on the most recent commit at https://github.com/riverence/io_scene_binfbx/blob/main/__init__.py

It seems like the problem here is that the method for finding the LOD offset is unreliable, especially in non-human meshes, as the bytes searched for right before the beginning of the LOD aren't the same. I'll look into alternatives right now, or if you can find one, keep me updated 😄

Link to comment
Share on other sites

On 2/27/2024 at 8:20 PM, riverence said:

It seems like the problem here is that the method for finding the LOD offset is unreliable, especially in non-human meshes, as the bytes searched for right before the beginning of the LOD aren't the same. I'll look into alternatives right now, or if you can find one, keep me updated 😄

Table_offset is found correctly, but there are different block sizes with the same MAGIC_SIG. The standard script uses the block size of 127 bytes from cur_offset. If you now set this value to 119, the files will be read correctly by the table_offset.
LOD_0 also has a different padding of 4, instead of 26 as in the standard script.

Edit: I just saw it! block_offset = 119 in your Script! 😄

Edited by Mike2023
  • Like 1
Link to comment
Share on other sites

47 minutes ago, Mike2023 said:

Table_offset is found correctly, but there are different block sizes with the same MAGIC_SIG. The standard script uses the block size of 127 bytes from cur_offset. If you now set this value to 119, the files will be read correctly by the table_offset.
LOD_0 also has a different padding of 4, instead of 26 as in the standard script.

Edit: I just saw it! block_offset = 119 in your Script! 😄

Yeah, the block_offset changes depending on the vertex size. You can find the vertex size by looking at the int32 for the number of bones per vertex; 8 = 32 byte vertex and a 127 byte block offset, 4 = 16 byte vertex and a 123 byte block offset, 1 = 12 byte vertex and a 119 byte block offset, and if it's 0 it's an 8 byte vertex with a 115 byte block offset. You can find the bonesPerVertex int32 right after the face_offset int32. It may be something similar when it comes to the LOD0 offsets, but I'm not totally sure. It also seems like it's possible to navigate to the next LOD offset by simply navigating through the UV table, vertex table, and the face table by calculations, but there is a table or two after the face table that's completely unknown to us right now. However, after that table, the next LOD offset immediately begins.

  • Thanks 1
Link to comment
Share on other sites

On 2/28/2024 at 11:37 PM, riverence said:

Yeah, the block_offset changes depending on the vertex size. You can find the vertex size by looking at the int32 for the number of bones per vertex; 8 = 32 byte vertex and a 127 byte block offset, 4 = 16 byte vertex and a 123 byte block offset, 1 = 12 byte vertex and a 119 byte block offset, and if it's 0 it's an 8 byte vertex with a 115 byte block offset. You can find the bonesPerVertex int32 right after the face_offset int32. It may be something similar when it comes to the LOD0 offsets, but I'm not totally sure. It also seems like it's possible to navigate to the next LOD offset by simply navigating through the UV table, vertex table, and the face table by calculations, but there is a table or two after the face table that's completely unknown to us right now. However, after that table, the next LOD offset immediately begins.

Thank you for the explanation and sorry for getting in touch so late.
Here I have something new for you to test. In addition, the manual offsets were stored in a json file. I also have to put a little more time into calculating for the total LOD offsets of the files. Have a nice weekend everyone!

Edit: I have a revised version of the script here. Unfortunately, it's still not possible without the Hex Editor, but it's a great help in the search.

@riverence

For some meshes (e.g. npc_ <- at the beginning), your script must load the vertex data with 20 bytes (vertex size: 16) instead of 32 bytes.

Edit: File deleted. Please look for the last post of the search file.

 

Edited by Mike2023
  • Like 1
Link to comment
Share on other sites

Hi guys. This is the error that blender gives when importing any model.

 

Python: Traceback (most recent call last):
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 1151, in execute
    return import_binfbx(context, self.filepath, self.import_rig, self.file_structure)
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 1112, in import_binfbx
    main()
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 1105, in main
    read_mesh_skel(skel, file, skel_info, collection_name, objArray)
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 695, in read_mesh_skel
    bpy.data.scenes['Scene'].collection.objects.unlink(arm_obj)
RuntimeError: Error: Object "Armature" is not in the "Scene Collection"

Link to comment
Share on other sites

This error occurs when importing "kiran_estevez_healed_publish"

Python: Traceback (most recent call last):
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\io_scene_binfbx\__init__.py", line 1151, in execute
    return import_binfbx(context, self.filepath, self.import_rig, self.file_structure)
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\io_scene_binfbx\__init__.py", line 1112, in import_binfbx
    main()
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\io_scene_binfbx\__init__.py", line 1052, in main
    vertArray = read_mesh_vertices(file, mesh_info, skel_info, vertex_offset, minv, maxv, i - 1)
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\io_scene_binfbx\__init__.py", line 818, in read_mesh_vertices
    if xMin > lva[vi][0]:
IndexError: list index out of range
 

Link to comment
Share on other sites

15 hours ago, nexus2641 said:

Hi guys. This is the error that blender gives when importing any model.

 

Python: Traceback (most recent call last):
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 1151, in execute
    return import_binfbx(context, self.filepath, self.import_rig, self.file_structure)
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 1112, in import_binfbx
    main()
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 1105, in main
    read_mesh_skel(skel, file, skel_info, collection_name, objArray)
  File "C:\Users\nexus\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\io_scene_binfbx\__init__.py", line 695, in read_mesh_skel
    bpy.data.scenes['Scene'].collection.objects.unlink(arm_obj)
RuntimeError: Error: Object "Armature" is not in the "Scene Collection"

Remove the previous collection, and make sure that the topmost Scene Collection is selected when importing meshes. As for the 'list index out of range' issue, I'm still trying to figure out how to fix that.

Link to comment
Share on other sites

17 hours ago, riverence said:

Remove the previous collection, and make sure that the topmost Scene Collection is selected when importing meshes. As for the 'list index out of range' issue, I'm still trying to figure out how to fix that.

Thanks for the answer.

  • Like 1
Link to comment
Share on other sites

The files are really very complex and sometimes even built in layers. That is why a dynamic offset calculation of the LODS is necessary, as I will probably pair it to the byte sequence search. But here is a new version of the script with layer support and other improvements. 🙂

Edit: File deleted. Please look for the last post of the search file.

 

Edited by Mike2023
Link to comment
Share on other sites

Not sure if this is much use as there's still a lot of unknowns in the mesh files, but I've been looking at them for a while as well.

The block of unknown data after the faces starts with a bunch of tables containing offsets to some data.  The counts and offsets for these tables are in the LOD mesh entries just before the final table (if it exists).  Then each of these unknown tables has a bunch of offsets to some more data, then the next table follows.  After that there's yet more unknown data that looks like it's referenced from those submeshes that have the extra table in them, with some more offsets.  Then after that is the data for the next LOD.  But it's still a bit uncertain how to combine all that info to calculate everything.

 

 

  • Like 1
Link to comment
Share on other sites

On 3/10/2024 at 12:14 AM, DKDave said:

Not sure if this is much use as there's still a lot of unknowns in the mesh files, but I've been looking at them for a while as well.

The block of unknown data after the faces starts with a bunch of tables containing offsets to some data.  The counts and offsets for these tables are in the LOD mesh entries just before the final table (if it exists).  Then each of these unknown tables has a bunch of offsets to some more data, then the next table follows.  After that there's yet more unknown data that looks like it's referenced from those submeshes that have the extra table in them, with some more offsets.  Then after that is the data for the next LOD.  But it's still a bit uncertain how to combine all that info to calculate everything.

 

 

The files are so complex that some UV sets for a Lod start in the middle of a data block. Nevertheless, I tried to incorporate automation into the script, which supports different files, not only the characters.

An error message occurs to the script run if there are no offsets in the JSON for calculating. Then activate the Lod0_offset and run the script again. Then enter one of the offsets found at Lod0_offset and run the script again to carry out the calculations of the UV, Vertex and Face-Offsets.

I still write Parrallel on a script to correctly integrate the shaders from the material files. I have never had much to do with Shader, Tiling and Co in the past!😅

Here would be the next version of the search script for testing...

Edit: File deleted. Please look for the last post of the search file.

 

Edited by Mike2023
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...