Jump to content

Need help regarding reverse engineer a model file


Go to solution Solved by DKDave,

Recommended Posts

On 5/25/2024 at 4:20 AM, Silence Exterminator said:

... and obj doesn't store weights info so for me to export weights have to write a tool for that i know c++ so i guess i have to write a .fbx file format in order to export weights ...

You may try AXE for that purpose:

https://github.com/Bigchillghost/AXE

blend indices:

blendindices.thumb.png.9203567fc46d954616f74eca465dbf6d.png

weights:

weights.thumb.png.2b741e3efabd613ed38932f65edbe122.png

On 5/25/2024 at 5:53 AM, Silence Exterminator said:

i think the weights are represented by a 4-byte float right?

Most formats use unsigned byte for weights, only a few might be in unsigned shorts or floats.

2 hours ago, Silence Exterminator said:

i researched first vertex buffer for normals using model researcher used the type as shorts

Normal/tangent/binormal vectors are easy to interpret since their square sums equal to 1.0. And the common case is that they're usually encoded as uint8 or signed char.

normal.thumb.png.e7720b39d170f3813c2d94b0dc104596.png

Link to comment
Share on other sites

Posted (edited)
9 minutes ago, Bigchillghost said:

You may try AXE for that purpose:

https://github.com/Bigchillghost/AXE

blend indices:

blendindices.thumb.png.9203567fc46d954616f74eca465dbf6d.png

weights:

weights.thumb.png.2b741e3efabd613ed38932f65edbe122.png

Most formats use unsigned byte for weights, only a few might be in unsigned shorts or floats.

Normal/tangent/binormal vectors are easy to interpret since their square sums equal to 1.0. And the common case is that they're usually encoded as uint8 or signed char.

normal.thumb.png.e7720b39d170f3813c2d94b0dc104596.png

yes it exports fbx nice also bro i will check the software out and use the offsets for normal u provided and weights to export a fbx also can u explain me again for specifically in the case of my file the normals are of which type and how to read them also weights according to my file provided are of which type and how to read them  i am asking this because i wish to create a script in c++ to automatically perform this function rather doing it using axe thanks

Edited by Silence Exterminator
Link to comment
Share on other sites

Posted (edited)
22 minutes ago, Silence Exterminator said:

thanks alot bro does this software exports weights as .fbx or which format cause i didn't used this software before

FBX in fact is the only option for export. You may read the demo for v1.1.1 to get a start.

https://github.com/Bigchillghost/AXE/releases/tag/v1.1.1

22 minutes ago, Silence Exterminator said:

for specifically in the case of my file the normals are of which type and how to read them also weights according to my file provided are of which type and how to read them  i am asking this because i wish to create a script in c++ to automatically perform this function rather doing it using axe thanks

As you can see in the screenshot they're all encoded as uint8. For normals you need to do something like "(vn / 255.0) * 2.0 - 1.0" to convert them back to ordinary floats. If you're going to write a script or something, your best choice might be using Noesis. Otherwise you'll have to implement an FBX writer on your own, or use the FBX SDK if you prefer to.

Also I need to remind you that the skining info would be useless without a proper skeleton. So that's a next problem you need to consider.

 

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

Posted (edited)
21 minutes ago, Bigchillghost said:

FBX in fact is the only option for export. You may read the demo for v1.1.1 to get a start.

https://github.com/Bigchillghost/AXE/releases/tag/v1.1.1

bro one more request this software is very new for me but to better understand it can u please fill all the info of my mesh file in AXE which include vertices, faces, uv, normals, weights so i can see those values and see those sections where to input stop so i would have a general idea and be able to export the fbx file would be a bigger help, thanks.

Edited by Silence Exterminator
Link to comment
Share on other sites

Posted (edited)
27 minutes ago, Bigchillghost said:

params.thumb.png.9acabc32bfe563a896cba1ff63aed075.png

preview.thumb.png.cbca177e9cba5dd271d7a3ffd101e9fa.png

 

Didn't care for the submesh division. You can apply material groups on them to split them logically. Read the demo for more details.

 

thanks i exported the fbx got model with uv and normal but there are no weights as when i opened the fbx in blender the vertex groups were empty any fix? cause we did wrote offsets to blend weights and blend tengents so why there is no weights showing in blender?

Screenshot 2024-05-26 091910.png

Edited by Silence Exterminator
Link to comment
Share on other sites

As I said before:

1 hour ago, Bigchillghost said:

Also I need to remind you that the skining info would be useless without a proper skeleton. 

If you just wish to export the weights regardless whether the skeleton is valid, add the param set to the list by clicking the Add button under the Parameter List group box, then navigate to Tools > Auto Bone Generation to generate a fake skeleton. Use the "Export from List" for export.

image.png.cfe148a67f8a70aaedeeeb5e242d67e3.png

  • Like 1
Link to comment
Share on other sites

14 minutes ago, Bigchillghost said:

As I said before:

If you just wish to export the weights regardless whether the skeleton is valid, add the param set to the list by clicking the Add button under the Parameter List group box, then navigate to Tools > Auto Bone Generation to generate a fake skeleton. Use the "Export from List" for export.

image.png.cfe148a67f8a70aaedeeeb5e242d67e3.png

ok i did it it generated skeleton but the problem now is the mesh size is too small almost invinsible anything to export the mesh in bigger size from AXE cause i can't scale up the mesh and its completely disappeared

Link to comment
Share on other sites

Posted (edited)
23 minutes ago, Bigchillghost said:

As I said before:

If you just wish to export the weights regardless whether the skeleton is valid, add the param set to the list by clicking the Add button under the Parameter List group box, then navigate to Tools > Auto Bone Generation to generate a fake skeleton. Use the "Export from List" for export.

image.png.cfe148a67f8a70aaedeeeb5e242d67e3.png

still no weights as u can see in blender i thought i would see weight on to the mesh in blender

Screenshot 2024-05-26 095218.png

Edited by Silence Exterminator
Link to comment
Share on other sites

1 minute ago, Bigchillghost said:

Maybe there's compatibility issues with blender. Works fine on my side in 3ds Max.

oh i checked in maya and it shows weights weird alright bro thanks alot i am super obliged also bro there is one more request if u can make me some tutorials about reverse engineering so i could more profoundly learn how to reverse models textures archives weight normal in any game file tutorials in PDF I will pay u for that if ur willing please let me know ur discord id, thanks.

Link to comment
Share on other sites

I used to wrote a tutorial about archive analysis on XenTax but there were hardly any audiences and nowadays I generally lack the enthusiasm for making any tuts. You may check the old archive and see if they can still be accessed. For textures though there's not much that I can shared. Understanding some concepts about pixel formats and properties like width/height etc.. Mostly you just learn along the way and generally it'll become a natural thing.

  • Thanks 1
Link to comment
Share on other sites

9 hours ago, Bigchillghost said:

Just installed Blender v4.1.1 for testing. Seems fine too on my end.

image.thumb.png.cb064923791f28878ce589e2a0502609.png

This Program is way more advanced than i thought i always had problems with programming part when importing skinned models into Noesis or Max,i was wondering would it be possible to implement feature for importing edited .fbx for injecting models in real time in AXE.Im not a programmer but i  think this should be possible in theory,like if a binary file is reversed enough to export as fbx with bones and weights it should be possible to reimport the fbx and inject the parts we want into corresponding data offsets,or is it way more complex than it sounds?

Link to comment
Share on other sites

27 minutes ago, sw-emre said:

i was wondering would it be possible to implement feature for importing edited .fbx for injecting models in real time in AXE.Im not a programmer but i  think this should be possible in theory,like if a binary file is reversed enough to export as fbx with bones and weights it should be possible to reimport the fbx and inject the parts we want into corresponding data offsets,or is it way more complex than it sounds?

What would be edited if I may ask? Note that when you use the word "injecting", that means you must NOT change the amount of vertices or any elements you export from the file to make it work. Even so, things are still more complicated than you thought. Coz once you "edited" the model, data like tangents/binormals or anything else dependent to the model you didn't care for during export, need to be re-generated which could be a huge task, let along you need to take care of data conversion to the original data types. Taking all of that into account it'll be a total nightmare trying to implement what you talked about in a general helper tool.

Link to comment
Share on other sites

14 minutes ago, Bigchillghost said:

What would be edited if I may ask? Note that when you use the word "injecting", that means you must NOT change the amount of vertices or any elements you export from the file to make it work. Even so, things are still more complicated than you thought. Coz once you "edited" the model, data like tangents/binormals or anything else dependent to the model you didn't care for during export, need to be re-generated which could be a huge task, let along you need to take care of data conversion to the original data types. Taking all of that into account it'll be a total nightmare trying to implement what you talked about in a general helper tool.

Yes by using "Injecting" it is what i meant,like doing simple edits ie moving vertex positions etc on the model while keeping the same amount of vertices or any element.Of course, adding a brand new custom model would be a huge task and would defeat the purpose of the Tool since its not a model editing or mod tool,such tasks usually done with Blender or Noesis scripts for various game formats anyway but there are some complex formats for some games which results in people not creating tools for those games, in which case I thought this kind of feature could be really useful to at least make simple edits on the mesh formats.

Link to comment
Share on other sites

  • Engineer
5 hours ago, Bigchillghost said:

 Taking all of that into account it'll be a total nightmare trying to implement what you talked about in a general helper tool.

Wisely spoken. 

Nethertheless I made a very simple converter 9 months ago on xentax for another game's model (monster_truck ). From the readme:

obj to hex converter, simple injector
-------------------------------------

// This is not intended to be a proper solution.
// It's just a showcase with limitations.
// Covers vertex floats and WORD FIs only
// Tested with a static mesh of one format only!

It used above mentioned model sample and injected another car's interior.

Not tested: repacking to an archive and trying to load it by the game.

(I'm willing to improve it sooner or later but definitely for static meshes only.)

Link to comment
Share on other sites

10 hours ago, sw-emre said:

but there are some complex formats for some games which results in people not creating tools for those games, in which case I thought this kind of feature could be really useful to at least make simple edits on the mesh formats.

You should be aware that your idea most likely could work for a rather simple format where anything else in the file is not affected by your modification. And you'll need a rather complete research to draw that conclusion. Whereas for those "complex formats" you mentioned, it's highly possible that this condition does not hold, which is why no one ever bother to create any modding tools for them.

  • Thanks 1
Link to comment
Share on other sites

On 5/26/2024 at 9:00 AM, Bigchillghost said:

params.thumb.png.9acabc32bfe563a896cba1ff63aed075.png

preview.thumb.png.cbca177e9cba5dd271d7a3ffd101e9fa.png

 

Didn't care for the submesh division. You can apply material groups on them to split them logically. Read the demo for more details.

 

one more question bro the in the normal tab in AXE in adress section where its written relative to and for normals u wrote 10 what this 10 represent offset or what and another thing is in AXE what does the letter OV means what its represent  and also can u explain me why u wrote stride 12 for normals, thanks

Screenshot 2024-05-26 092944222.png

Link to comment
Share on other sites

Posted (edited)
2 hours ago, Silence Exterminator said:

one more question bro the in the normal tab in AXE in adress section where its written relative to and for normals u wrote 10 what this 10 represent offset or what and another thing is in AXE what does the letter OV means what its represent  and also can u explain me why u wrote stride 12 for normals, thanks

It would be nice if you could use punctuation appropriately in your sentences.

In AXE, all addresses are in hex notation, any numbers other than that are in decimal notation. The check boxes along the editboxes of the address/stride/data type overwrite ("OW", not "OV") the individual values of corresponding attributes. For address however, the status of the OW flag indicates whether the address of corresponding attributes uses relative mode. If it's not checked, then the address would be an absolute one. Here for normal, the absolute address would be "0x8040 + 0x10 = 0x8050". As you can see the stride of normal is disabled and shown as grey. That means it's using the all-same stride, which is 24 in dec.

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

Posted (edited)
On 5/27/2024 at 7:58 PM, Bigchillghost said:

It would be nice if you could use punctuation appropriately in your sentences.

In AXE, all addresses are in hex notation, any numbers other than that are in decimal notation. The check boxes along the editboxes of the address/stride/data type overwrite ("OW", not "OV") the individual values of corresponding attributes. For address however, the status of the OW flag indicates whether the address of corresponding attributes uses relative mode. If it's not checked, then the address would be an absolute one. Here for normal, the absolute address would be "0x8040 + 0x10 = 0x8050". As you can see the stride of normal is disabled and shown as grey. That means it's using the all-same stride, which is 24 in dec.

hi bro how are u i just wanted to ask that i am working on a script in c++ for injecting the custom normals from obj file injected into the perm.bin file i know that normals type is byte and stride 24 and i know the starting offset and count i tried my best to make a function in c++ which could inject the bytes in a pattern provided as u can see in the pic the blue are normals and red is vertices data so can u provide me any c++ code example to read binary as byte and with other specification to the code for my need of work for normals so it can automatically know the pattern for normals and follow it so i can correctly read the normal data from binary file, thanks i can also provide my c++ code .cpp if u want to check? it injects normals from obj file but inject them in wrong order biscally altering the vertices data! also as u can see the AXE image i used the same data for normals and implemented it in my code it extracted normals but extracted wrongly was different as shown in AXE please help me out.

Screenshot 2024-05-29 030304.png

normal injector.zip

Screenshot 2024-05-29 061038.png

Edited by Silence Exterminator
Link to comment
Share on other sites

Posted (edited)
On 5/29/2024 at 6:11 AM, Silence Exterminator said:

...

It's really difficult to read your comment due to the lack of necessary punctuations and I always seem to lost focus on what you're actually trying to express. So I'm serious about this:

On 5/27/2024 at 10:58 PM, Bigchillghost said:

use punctuation appropriately in your sentences

 

On 5/29/2024 at 6:11 AM, Silence Exterminator said:

i know that normals ... stride 24

So why did you wrote the entire normal buffer from offset 0x8050 instead of one per vertex element?

file.seekp(32848);
int count = 0;
for (const auto& normal : normals) {
    if (count >= 2848) {
        break; // Reached the limit
    }
    for (float component : normal) {
        char byte = static_cast<char>((component + 1.0f) * 127.0f); // Convert float to Byte range
        file.write(&byte, sizeof(char));
    }
    // #### file.seekp(0x15, ios::cur) is required here!!! 0x15 == 24 - 3 bytes for the written normal
    ++count;
}

And what's this "remainingBytes" for and why did you insert the AB 00 00 00 pattern repeatedly?

// Check if we need to move to the next pattern
int bytesInjected = count * 12;
int remainingBytes = 32848 - 20 - bytesInjected;
if (remainingBytes > 0) {
    file.seekp(bytesInjected, std::ios::cur);
    for (int i = 0; i < remainingBytes; ++i) {
        char patternByte = (i % 4 == 0) ? 0xAB : 0x00;
        file.write(&patternByte, sizeof(char));
    }
}

 

On 5/29/2024 at 6:11 AM, Silence Exterminator said:

as u can see in the pic the blue are normals

The "blue" are the normal plus the tangent, the leading zero bytes might be an unused vertex color channel.

 

On 5/29/2024 at 6:11 AM, Silence Exterminator said:

so can u provide me any c++ code example to read binary as byte

Something like:

uint8_t aByte = 0;
file.read((char *)&aByte, 1);
float toFloat = (aByte / 255.0) * 2.0 - 1.0;

 

On 5/29/2024 at 6:11 AM, Silence Exterminator said:

and with other specification to the code for my need of work for normals so it can automatically know the pattern for normals and follow it so i can correctly read the normal data from binary file

Not sure what you mean by that. You hard-coded the address and count but expected it to be generic?

Edited by Bigchillghost
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...