Jump to content

vagonumero13 tools (REDELBE, rdbtool, g1mtools, doa6decsave) Update 17 Aug: REDELBE 3.0


Recommended Posts

17 hours ago, healingbrew said:

Depends on the value. Ryza uses 0x4 and 0x2 (Quat+Vec3 and Quat) Nights of Azure uses 0x6 and 0x1 (Vec3+Quat+Vec3, and Vec2.)

The value might be a type id, judging by the way it's checked.

So far it doesn't really make any other sense.

0x1 = 2 indices

0x2 = 4 indices

0x4 = 7 indices

0x6 = 10 indices

0x65 = 8 indices

0x66 = 9 indices

 

Ah, I see, I think I more or less understand the format now. The float data besides the time stamps, are always 4 floats in 0x66. I think the 4 floats have the data for the interpolation, with the 4th being the constant part, which is all I need in the conversion to fbx, at least.

 

Now I have to wonder why there are a total of 6 components for the rotation, apparently they are two 3-components rotations which the game operate using some complex shit that is probably some standard math thing that I will have to find out. I wonder if they are just rotations on two axis that they are operating to unify it as a single 3D rotation, maybe they don't need the rotation of the other axis, just like format 0x65 skips translation for -apparently- the Y axis.

Link to comment

REDELBE updated to version 2.1

 

Changelog:

- Layer 2 support for Sci-Fi costumes (COS_036, HAIR_036, ZAC_COS_100), maid costumes (COS_103, HAIR_103) and SP4 costumes (COS_022, HAIR_022)
- More filenames available (matching rdbtool 2.1)
- Fix: "enable_random_underwear" and "enable_random_glasses" now work in all battles (of versus, survival, arcade and timeattack), and not only in the first battle.

 

---------

 

rdbtool updated to version 2.1

 

Changelog:

- More filenames avaialble (from 1.18 update, and also all remaining *character* textures from 1.06-1.17)
- Support for 1.18 dead files.

 

---------

 

fid_utility updated to version 0.3

 

Changelog:

- Increased dictionary for the cracking.

Link to comment

Hey @vagonumero13

I tried a few things on the g1a format.

 

-So basically the 4 floats in what we call "quantized data" in the BT are used as coefficients for the interpolation, they are the equivalent of the component_x, component_y etc in the simplified code that I sent you before for the g2a interpolation. No need to do some weird casts or bit shifting for this format this time, just need to grab the times, calculate the ratio based on the previous and next time and then use the same formula as before to get the exact value. I'll share some python code with you once I've done a bit of cleanup

 

-Healing Brew's theory about the indices and number of components seems to be confirmed. I can confirm that 0x2 is for a Quaternion rotation keyframe and 0x4 for a Quaternion rotation + Vec3 Translation, will test other stuff to confirm the others. 0x6 is probably scale added on top of these. I wonder what 0x65 and 0x66 are then, didn't look into them yet but they could either have some missing components, have some custom stuff like a "look at" position since camera or have some format that is not quaternion maybe.

 

Here's the output on the Hyrule Warrior's Link model (framerate is bad cause of my capture, runs smooth otherwise). Cloth mesh is hidden cause it has to be animated in game by the physics engine, I just displayed the driver instead.

Spoiler

result7.gif.2f02fe763e87616abb1d5a85722d16ef.gif

 

Link to comment
4 hours ago, Joschuka said:

Hey @vagonumero13

I tried a few things on the g1a format.

 

-So basically the 4 floats in what we call "quantized data" in the BT are used as coefficients for the interpolation, they are the equivalent of the component_x, component_y etc in the simplified code that I sent you before for the g2a interpolation. No need to do some weird casts or bit shifting for this format this time, just need to grab the times, calculate the ratio based on the previous and next time and then use the same formula as before to get the exact value. I'll share some python code with you once I've done a bit of cleanup

 

-Healing Brew's theory about the indices and number of components seems to be confirmed. I can confirm that 0x2 is for a Quaternion rotation keyframe and 0x4 for a Quaternion rotation + Vec3 Translation, will test other stuff to confirm the others. 0x6 is probably scale added on top of these. I wonder what 0x65 and 0x66 are then, didn't look into them yet but they could either have some missing components, have some custom stuff like a "look at" position since camera or have some format that is not quaternion maybe.

 

Here's the output on the Hyrule Warrior's Link model (framerate is bad cause of my capture, runs smooth otherwise). Cloth mesh is hidden cause it has to be animated in game by the physics engine, I just displayed the driver instead.

  Reveal hidden contents

result7.gif.2f02fe763e87616abb1d5a85722d16ef.gif

 

 

When I get sometime, I will manually decompile the rotation operation that the game does with 0x66, but I'm pretty sure they were 6 components, divided into two groups of 3 components. There were some calls to some math functions like sqrtf (that was for magnitude calculations), sin, cos, asin, and atan2, and then there was some higher level functions operating in a vector.

Link to comment
8 minutes ago, vagonumero13 said:

 

When I get sometime, I will manually decompile the rotation operation that the game does with 0x66, but I'm pretty sure they were 6 components, divided into two groups of 3 components. There were some calls to some math functions like sqrtf (that was for magnitude calculations), sin, cos, asin, and atan2, and then there was some higher level functions operating in a vector.

Sounds like polar coordinates to me then http://www.euclideanspace.com/maths/geometry/space/coordinates/polar/spherical/index.htm

Link to comment
13 hours ago, Joschuka said:

 

This is some pseudo-code from a manual decompilation. It assumes rot1 is the data at index 0,1,2, rot2 the data at index 3,4,5 and trans the data at 6,7,8.

 

Spoiler

Vec3D rot1, rot2;
Vec3D trans;

float x = rot2.x - rot1.x;
float y = rot2.y - rot1.y;
float z =  rot2.z - rot1.z;

float distance = sqrtf(x*x + y*y + z*z);

Vec4D v;
v.x = rot2.x * 1.0f/distance;
v.y = rot2.y * 1.0f/distance;
v.z = rot2.z * 1.0f/distance;
v.w = 0.0f;

float as = asinf(v.y);
float s1 = sinf(as);
float c1 = cosf(as);
float at = atan2f(v.x, v.z);
float s2 = sinf(at);
float c2 = cosf(at);

float x2 = s1 * -1.0f * s2;
float y2 = c1;
float z2 = s1 * -1.0f * c2;

float sq = sqrtf(x2*x2 + y2*y2 + z2*z2);

float matrix[4][4];
Vec4D v2;

v2.x = x2 * 1.0f/sq;
v2.y = y2 * 1.0f/sq;
v2.z = z2 * 1.0f/sq;
v2.w = 0.0f;

func1(matrix, v, v2); // matrix is output only, v1 and v2 input only

Quat q;
extract_rotation_from_matrix(q, matrix); // q is output only, matrix is input only

float result[11];

result[0] = rot1.x;
result[1] = rot1.y;
result[2] = rot1.z;
result[3] = q.x; result[4] = q.y; result[5] = q.z; result[6] = qw;
result[7] = distance;
result[8] = trans.x;
result[9] = trans.y; // on 0x65, this is skipped as trans.y doesn't exist.
result[10] = trans.z;

// On 0x65, some flags result are set to 0x5FF
// on 0x66, some flags result are set to 0x5FF | 0x200 = 0x7FF (I guess the 0x200 is the bit for trans.y)

 

I have yet to look waht "func1" is. But at the end of the day, there are still two rotations?, (one vector and one quaternion) and that distance thing. These may be things specific for camera.

Link to comment
5 hours ago, vagonumero13 said:

 

This is some pseudo-code from a manual decompilation. It assumes rot1 is the data at index 0,1,2, rot2 the data at index 3,4,5 and trans the data at 6,7,8.

 

  Reveal hidden contents

Vec3D rot1, rot2;
Vec3D trans;

float x = rot2.x - rot1.x;
float y = rot2.y - rot1.y;
float z =  rot2.z - rot1.z;

float distance = sqrtf(x*x + y*y + z*z);

Vec4D v;
v.x = rot2.x * 1.0f/distance;
v.y = rot2.y * 1.0f/distance;
v.z = rot2.z * 1.0f/distance;
v.w = 0.0f;

float as = asinf(v.y);
float s1 = sinf(as);
float c1 = cosf(as);
float at = atan2f(v.x, v.z);
float s2 = sinf(at);
float c2 = cosf(at);

float x2 = s1 * -1.0f * s2;
float y2 = c1;
float z2 = s1 * -1.0f * c2;

float sq = sqrtf(x2*x2 + y2*y2 + z2*z2);

float matrix[4][4];
Vec4D v2;

v2.x = x2 * 1.0f/sq;
v2.y = y2 * 1.0f/sq;
v2.z = z2 * 1.0f/sq;
v2.w = 0.0f;

func1(matrix, v, v2); // matrix is output only, v1 and v2 input only

Quat q;
extract_rotation_from_matrix(q, matrix); // q is output only, matrix is input only

float result[11];

result[0] = rot1.x;
result[1] = rot1.y;
result[2] = rot1.z;
result[3] = q.x; result[4] = q.y; result[5] = q.z; result[6] = qw;
result[7] = distance;
result[8] = trans.x;
result[9] = trans.y; // on 0x65, this is skipped as trans.y doesn't exist.
result[10] = trans.z;

// On 0x65, some flags result are set to 0x5FF
// on 0x66, some flags result are set to 0x5FF | 0x200 = 0x7FF (I guess the 0x200 is the bit for trans.y)

 

I have yet to look waht "func1" is. But at the end of the day, there are still two rotations?, (one vector and one quaternion) and that distance thing. These may be things specific for camera.

Yeah a quick look at your code seem to confirm that these are polar coordinates indeed. Not sure if you're familiar with these, take a look at this link if not (the from spherical to cartesian part) https://math.oregonstate.edu/home/programs/undergrad/CalculusQuestStudyGuides/vcalc/coord/coord.html

Basically the asin and atan2 operations seem to retrieve theta and phi and then the muliplication are the equations to get the components in cartesian, with rho being equal to 1, probably due to the normalization at the beginning.

Not sure what the matrix is for though, maybe a LookAt 4x4 as I suspected. Also no clue about the trans stuff lol

 

Yeah this seems to be really specific to cameras, for the 0x2,0x4x0x6 there's no such thing. If you want me to look more into it and be more accurate about the transformation done in the pseudocode I can do so when I'll have some time, otherwise I'm not particularly interested into camera stuff myself for the moment

Link to comment
On 4/16/2019 at 8:12 AM, vagonumero13 said:

g1m_import: this tool allows to perform the opposite operatin to above, import .vb/.ib files into .g1m files. (Note: currently the tool ignores the .fmt file, and assumes the vertex and index format is the same that the one in the .g1m, I will fix that in the future).

 

Usage: Put your vb/ib files in a folder with the same name that the g1m file (but without the extension). Name your ib/vb files like this: "0.vb", "0.ib", "1.vb", "1.ib", etc, where the number, is the index of the mesh to modify. Drag and drop the .g1m file  into the program, and it will update the meshes that had a matching .vb/.ib file.

I'm trying to use the import tool, but it appears to be corrupting the .g1m file after import. I'm wondering if it might be because the .fmt file has changed for my new mesh, which is fairly radically different than the existing mesh on the costume. What do you suggest we do if the .fmt file has changed after exporting a mesh?

Link to comment
4 hours ago, zackissuper said:

I'm trying to use the import tool, but it appears to be corrupting the .g1m file after import. I'm wondering if it might be because the .fmt file has changed for my new mesh, which is fairly radically different than the existing mesh on the costume. What do you suggest we do if the .fmt file has changed after exporting a mesh?

Currently, the tool ignores the .fmt file on import.

Even if I added support to change the format, the g1m would likely crash or create a monster, as the info in the section 9 of the G1MG, the one that seem to tell the game which shader to use, would need a specific vertex format.

 

This cannot be properly implemented yet unless I export another file with the missing info, and then on import use that info.

Link to comment
19 hours ago, Joschuka said:

Yeah a quick look at your code seem to confirm that these are polar coordinates indeed. Not sure if you're familiar with these, take a look at this link if not (the from spherical to cartesian part) https://math.oregonstate.edu/home/programs/undergrad/CalculusQuestStudyGuides/vcalc/coord/coord.html

Basically the asin and atan2 operations seem to retrieve theta and phi and then the muliplication are the equations to get the components in cartesian, with rho being equal to 1, probably due to the normalization at the beginning.

Not sure what the matrix is for though, maybe a LookAt 4x4 as I suspected. Also no clue about the trans stuff lol

 

Yeah this seems to be really specific to cameras, for the 0x2,0x4x0x6 there's no such thing. If you want me to look more into it and be more accurate about the transformation done in the pseudocode I can do so when I'll have some time, otherwise I'm not particularly interested into camera stuff myself for the moment

 

The "func1" turned out to be this:

Spoiler

void Func1(Matrix44 &m, const Vector4D &v1, const Vector4D &v2)
{
    float length1 = sqrtf(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z);
    
    m._31 = v1.x * 1.0f / length1;
    m._32 = v1.y * 1.0f / length1;
    m._33 = v1.z * 1.0f / length1;
    
    float x = (v2.z * v1.x) - (v2.x * v1.z);
    float y = (v2.y * v1.z) - (v2.z * v1.y);
    float z = (v2.x * v1.y) - (v2.y * v1.x);
    
    float sq = sqrtf(x*x + y*y + z*z);
    
    m._11 = y * 1.0f / sq;
    m._12 = x * 1.0f / sq;
    m._13 = z * 1.0f / sq;
    
    m._21 = (m._13 * m._32) - (m._12 * m._33);
    m._22 = (m._11 * m._33) - (m._13 * m._31);
    m._23 = (m._12 * m._31) - (m._11 * m._32);    
    
    m._14 = 0.0f;
    m._24 = 0.0f;
    m._34 = 0.0f;
    m._41 = 0.0f;
    m._42 = 0.0f;
    m._43 = 0.0f;
    m._44 = 1.0f;    
}

 

Link to comment

Thanks, I'll take a look. What made me think it was some LookAt stuff was these are apparently built using 3 vectors as parameters https://docs.microsoft.com/en-us/previous-versions/windows/desktop/bb281710(v%3Dvs.85)

This function seems to build some kind of rotation matrix though so not sure, even though that guy (first answer) seems to do something similar https://stackoverflow.com/questions/349050/calculating-a-lookat-matrix Let me know if you do some experiments on it, I'll look a bit more into it when I have the time.

 

Btw I'll release my script soon, do you want to be credited with your pseudo here or do you have any xentax/zenhax pseudo that you'd like me to use too ?

Link to comment
4 hours ago, vagonumero13 said:

Currently, the tool ignores the .fmt file on import.

Even if I added support to change the format, the g1m would likely crash or create a monster, as the info in the section 9 of the G1MG, the one that seem to tell the game which shader to use, would need a specific vertex format.

 

This cannot be properly implemented yet unless I export another file with the missing info, and then on import use that info.

Section 9 is actually used to specify some LOD information and cloth types used. I use it to determine which cloth equations must be used to process the vertex clothes and to only display the highest LOD version of each mesh.

I think HB suspected section 3 to be the one with shader info

Link to comment
5 hours ago, Joschuka said:

Thanks, I'll take a look. What made me think it was some LookAt stuff was these are apparently built using 3 vectors as parameters https://docs.microsoft.com/en-us/previous-versions/windows/desktop/bb281710(v%3Dvs.85)

This function seems to build some kind of rotation matrix though so not sure, even though that guy (first answer) seems to do something similar https://stackoverflow.com/questions/349050/calculating-a-lookat-matrix Let me know if you do some experiments on it, I'll look a bit more into it when I have the time.

 

Btw I'll release my script soon, do you want to be credited with your pseudo here or do you have any xentax/zenhax pseudo that you'd like me to use too ?

Use "eternity" for the credit. I don't have an account in xentax/zenhax though.

Link to comment

Yeah my script will be for extraction only for now, will support cloth meshes, physics bones, textures and skeletal animations for all kind of Koei Tecmo games, regardless of the endianness.

Use vago's tools for DOA6 animations importing, if I ever do a g1m importer it'd be for Fire Emblem Three houses. Although the formats are really similar some stuff will be different. I actually need to test if your G1A2FBX works for FE btw

Link to comment
19 hours ago, vagonumero13 said:

 

Technically it can already be done, there is both a g1a2fbx and fbx2g1a. At the moment it is only body animations, it won't work with camera.

Now we just need animators...

huh never noticed that one coz no one has been talking about it much before lol sorry

i'll check it out

Link to comment
1 minute ago, Joschuka said:

Talking about animations @vagonumero13, did you try to tamper the frame data of existing anims and see the results in game ? Just wondering if the hitboxes and such are somewhat tied to it, kinda like animation notifies in Unreal Engine.

 

Never tried, only tests I did were in animations of character selection/entry/victory/defeat.

Link to comment

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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use