Jump to content

*.gm2 age of wulin


moonpaladin

Recommended Posts

Hello I was checking alot of information about this kind of filetype in xentax archive but the old script doesn't work also trying to get them with hex2obj with the help of shakotay but still cannot achieve to get the model, any kind of help gonna be awesome! current values of hex2obj : credits to shalotay :p

0x994 10440
Vb1
44 99
0x5B3C 2218
020000
0x0 255

3471051701C.7z

Link to comment
Share on other sites

2 hours ago, shak-otay said:

Forget what I wrote - UVpos should be 36 as you can see from the point cloud. But there's much fiddling required to find the suiting face indices' address.

really thanks for your time shakotay! im testing many values XD

Link to comment
Share on other sites

  • Engineer

010 Editor Template... I am sooo lazy to rewrite it to the noesis python script.

//------------------------------------------------
//--- 010 Editor v14.0 Binary Template
//
//      File: 
//   Authors: 
//   Version: 
//   Purpose: 
//  Category: 
// File Mask: 
//  ID Bytes: 
//   History: 
//------------------------------------------------
OutputPaneClear();LittleEndian();
local string FileName=GetFileName(),FilePath=FileNameGetPath(FileName,true),BaseName=FileNameGetBase(FileName,false);
local uint32 i,j,k,l;
local string ShapeNum;

typedef struct Matrix4x4 {
    float Mat00,Mat01,Mat02,Mat03,
          Mat10,Mat11,Mat12,Mat13,
          Mat20,Mat21,Mat22,Mat23,
          PosX,PosY,PosZ,PosW;
};

struct {
    char Sign[4];
    uint32 Unk0,TypeInfoOffset,TypeNameIndex,Unk3,Unk4,Unk5,BoneNameIndex,ShapeNameIndex,Unk8,Unk9;
    float Value[7];
}Header;

struct {
    FSeek(sizeof(Header)+Header.TypeInfoOffset);
    uint32 TypeNameOffset[Header.TypeNameIndex];
    uint32 ShapeNameOffset[3];
}TypeIndexInfo;

struct {
    float Unknown[12];
}UnknownInfo;

if (Header.BoneNameIndex != 0)
struct {
    struct {
        uint32 BoneNameOffset,SkinNameOffset,Dummy;
        Matrix4x4 matrix4x4;
        uint32 BoneIndex;
        uint32 Null[7];
    }BoneIndex[Header.BoneNameIndex]<optimize=false>;
}BoneIndexInfo;

struct {
    struct {
        uint32 Unk0,ShapeNameOffset,Unk1;
        float Unk2,Unk3,Unk4,Unk5;
        uint32 ShapeIndexNum,IndexCount,IndexOffset,VtxCount,Unk6,Unk7,Unk8[14];
        local string ShapeNameStr=ReadString(sizeof(Header)+ShapeNameOffset,-1);
    }ShapeIndex[Header.ShapeNameIndex]<optimize=false>;
}ShapeInfo;


struct {
    local uint32 IndexBaseOffset=FTell();
    for (i=0; i < Header.ShapeNameIndex; i++)
    {
        FSeek(IndexBaseOffset+ShapeInfo.ShapeIndex[i].IndexOffset*6);
        struct {
            byte IndexData[ShapeInfo.ShapeIndex[i].IndexCount*6];
        }IndexBuffer;
    }
}IndexBuffers;

struct {
    for (i=0; i < Header.ShapeNameIndex; i++)
    {
        struct {
            uint32 Unknown,VtxBufferSize;
            local uint32 Stride=VtxBufferSize/ShapeInfo.ShapeIndex[i].VtxCount;
        }StrideInfo;
    }
    for (i=0; i < Header.ShapeNameIndex; i++)
    {
        struct {
            byte VertexData[StrideInfo[i].VtxBufferSize];
        }VertexBuffer;
    }
}VertexBuffers;

FSeek(startof(VertexBuffers));
struct SHAPE {
    for (i=0; i < Header.ShapeNameIndex; i++)
    {
        SPrintf(ShapeNum,"_%u",l++);
        FSeek(startof(VertexBuffers.VertexBuffer[i]));
        if (VertexBuffers.StrideInfo[i].Stride == 44)
        struct {
            float VPosX,VPosY,VPosZ,Unk0,Unk1,VNPosX,VNPosY,VNPosZ,Unk2,UVPosX,UVPosY;
            Printf("v %f %f %f\nvn %f %f %f\nvt %f %f\n",VPosX,VPosY,VPosZ,VNPosX,VNPosY,VNPosZ,UVPosX,-UVPosY);
        }VtxBuffer[ShapeInfo.ShapeIndex[i].VtxCount]<optimize=false>;
        else if (VertexBuffers.StrideInfo[i].Stride == 48)
        struct {
            float VPosX,VPosY,VPosZ,Unk0,Unk1,Unk2,VNPosX,VNPosY,VNPosZ,Unk3,UVPosX,UVPosY;
            Printf("v %f %f %f\nvn %f %f %f\nvt %f %f\n",VPosX,VPosY,VPosZ,VNPosX,VNPosY,VNPosZ,UVPosX,-UVPosY);
        }VtxBuffer[ShapeInfo.ShapeIndex[i].VtxCount]<optimize=false>;
        else if (VertexBuffers.StrideInfo[i].Stride == 52)
        struct {
            float VPosX,VPosY,VPosZ,Unk0,Unk1,Unk2,Unk3,VNPosX,VNPosY,VNPosZ,Unk4,UVPosX,UVPosY;
            Printf("v %f %f %f\nvn %f %f %f\nvt %f %f\n",VPosX,VPosY,VPosZ,VNPosX,VNPosY,VNPosZ,UVPosX,-UVPosY);
        }VtxBuffer[ShapeInfo.ShapeIndex[i].VtxCount]<optimize=false>;

        Printf("g shape_%s_%u\n",BaseName,ShapeInfo.ShapeIndex[i].ShapeIndexNum);
        FSeek(startof(IndexBuffers.IndexBuffer[i]));
        struct {
            uint16 F1,F2,F3;
            Printf("f %u/%u/%u %u/%u/%u %u/%u/%u\n",F1+1,F1+1,F1+1,F2+1,F2+1,F2+1,F3+1,F3+1,F3+1);
        }IdxBuffer[ShapeInfo.ShapeIndex[i].IndexCount]<optimize=false>;
        
        OutputPaneSave(FilePath+BaseName+ShapeNum+".obj");
        OutputPaneClear();
    }
};

//local SHAPE Shape;

If you want export them just remove two slashes on last line

  • Like 2
Link to comment
Share on other sites

  • Engineer
20 minutes ago, h3x3r said:

010 Editor Template... I am sooo lazy to rewrite it to the noesis python script.

Thanks!

Since years I'm thinking about a "010 Editor Template" toC converter, but I'm too lazy, too.:classic_sad:

Plus, there's not so many examples to find.

I'm asking myself whether I can (in 'C') simply replace struct {... } indexbuffers; and the like

by void indexbuffers {...}

?

I'm unsure how to dissolve struct {
    struct {

Do I need to use two points?

(I C I'm using one point with verts[index].addr and verts[index].count which are based on an unnested struct.)

Edited by shak-otay
Link to comment
Share on other sites

  • Engineer

Thanks. That could help to rewrite 010 templates, I guess.

Seems I can get a 30 days trial version.

On another note - this appears to me as a combination of code and a struct declaration. Correct?

So I'll have to separate it in 'C' assumedly.

5 hours ago, h3x3r said:
for (i=0; i < Header.ShapeNameIndex; i++)
    {
        struct {
            uint32 Unknown,VtxBufferSize;
            local uint32 Stride=VtxBufferSize/ShapeInfo.ShapeIndex[i].VtxCount;
        }StrideInfo;
    }

  edit: maybe someone solved my problem somehow already...

Well, it's python. Maybe only a shift of the problem.:D

Need pip for the setup. Ohh - no.

Build/install manually ends up with

    import regex as re
"ModuleNotFoundError: No module named 'regex'"

Seems I need to get familiar with "pip on windows". Next year, maybe...

ok, I dared the hassle...

While pngtemplate.bt worked (with a small png) your gm2 bt script broke PFP (python format parser):

error

, line 104, in FileNameGetPath
    raise NotImplementedError()
NotImplementedError

Edited by shak-otay
  • Like 1
Link to comment
Share on other sites

  • Engineer

Seems, PFP is not as mighty as I thought. (I could try use the built-in debugger but it's awkward.)

edit: using Int(3) invokes the debugger:

     53         uint32 Unk0,ShapeNameOffset,Unk1;
     54         float Unk2,Unk3,Unk4,Unk5;
     55         uint32 ShapeIndexNum,IndexCount,IndexOffset,VtxCount,Unk6,Unk7,Unk8[14];
     56         Int3();
-->  57         local string ShapeNameStr=ReadString(sizeof(Header)+ShapeNameOffset,-1);
     58     }ShapeIndex[Header.ShapeNameIndex]<optimize=false>;
     59 }ShapeInfo;
     60
     61
LE pfp> peek
6f 01 00 00 53 01 00 00 01 08 00 00 00 00 00 b3 o...S...........
LE pfp> n
Traceback (most recent call last):
  File " \lib\site-packages\pfp\interp.py", line 1044,

compat_io.py", line 428, in ReadString
    raise NotImplementedError()

Current processed bone:

Quote

            BoneIndex[13] = struct {
                    BoneNameOffset = UInt(309 [00000135])
                    SkinNameOffset = UInt(322 [00000142])
                    Dummy      = UInt(0 [00000000])
                    matrix4x4  = struct {
                        Mat00      = Float(1.0)
                        Mat01      = Float(4.5145075233676835e-08)
                        Mat02      = Float(1.42923482826518e-07)
                        Mat03      = Float(0.0)
                        Mat10      = Float(-4.514505391739476e-08)
                        Mat11      = Float(1.0)
                        Mat12      = Float(-1.275043786108654e-07)
                        Mat13      = Float(0.0)
                        Mat20      = Float(-1.42923482826518e-07)
                        Mat21      = Float(1.275043786108654e-07)
                        Mat22      = Float(1.0)
                        Mat23      = Float(0.0)
                        PosX       = Float(-0.3636668622493744)
                        PosY       = Float(0.13261717557907104)
                        PosZ       = Float(0.6157079339027405)
                        PosW       = Float(1.0)
                    }
                    BoneIndex  = UInt(108 [0000006c])
                    Null       = UInt[7]
                }
    }
    ShapeInfo  = struct {
    }

Nice going but "step into" doesn't work. So I'm lost here...

Edited by shak-otay
Link to comment
Share on other sites

  • Engineer

Seems like python doesn't give a fck about local variables.

You can also dissable that line > local string ShapeNameStr=ReadString(sizeof(Header)+ShapeNameOffset,-1);

It's not used. I just put it here to check string name which can be obtained without it.

But not sure how you deal with this one which calculates Stride > local uint32 Stride=VtxBufferSize/ShapeInfo.ShapeIndex.VtxCount;

 

 

 

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

  • Engineer
18 hours ago, h3x3r said:

Seems like python doesn't give a fck about local variables.

You can also dissable that line > local string ShapeNameStr=ReadString(sizeof(Header)+ShapeNameOffset,-1);

It's not used. I just put it here to check string name which can be obtained without it.

But not sure how you deal with this one which calculates Stride > local uint32 Stride=VtxBufferSize/ShapeInfo.ShapeIndex.VtxCount;

Thanks!

Local vars could be the problem on reading from the input stream. The author of Pfp, James "d0c_s4vage" Johnson, wrote:

Quote

Variables are also allowed that do not cause data to be read from the input stream. Prefixing a declaration with const
or local will create a temporary variable that can be used in the script.

Anyways. //local string.... did the trick.

Furthermore I got

Quote

    IndexBuffers = struct {
        _skipped_0 = Char[0] ('')
        IndexBuffer_0 = struct {
            IndexData  = Char[13986] ('´\x00µ\x00¶\x00\x95\x00\x96\x00\x97\x00\x97\x00\x98\x00\x95\x00\x98\x00')
        }
        _skipped_1 = Char[0] ('')
        IndexBuffer_1 = struct {
            IndexData  = Char[5886] ('C\x00\x89\x00\x8a\x00C\x00D\x00E\x00E\x00D\x00K\x00E\x00')
        }
        _skipped_2 = Char[0] ('')
        IndexBuffer_2 = struct {
            IndexData  = Char[1008] ('7\x008\x009\x00\x82\x00\x83\x00\x84\x00\x84\x00\x85\x00\x82\x00T\x00')
        }
    }

If Pfp didn't ignore FTell() and OutputPaneSave("D:\\test"+ShapeNum+".obj");

I'd be happy, but anyways, I would have taken any bet that Pfp would NOT parse this .bt to it's end.:classic_biggrin:

edit: this worked: local uint32 b = FTell();

Edited by shak-otay
Link to comment
Share on other sites

  • Engineer

I converted the bt script up to struct IndexBuffers into 'C' (then got tired).

It gave the required parameters but offered one wrong offset (0x8DD6). Should be 0x5734= 0x4036 + 981x6 (dec.)

 ShapeIndex, 0x850 (NameOffs, IndexNum, faceCount, offs, vCount)
 0: 153 0 2331 0 2218
 1: 153 1 981 91b 970
 2: 153 2 168 cf0 160

 IndexBaseOffset 0x994
0. Index Offset 0x994
1. Index Offset 0x4036
2. Index Offset 0x8dd6 ?? 0x5734

I didn't find my fault but 3 sub meshes (see H2O files) where I had to mulitply the face counts by 3 to get FIs counts:

0x994 6993
Vb1
44 36
0x5B3C 2218
020000
0x0 255

0x4036 2943
Vb1
44 36
0x1D874 970
020000
0x0 255

0x5734 504
Vb1
48 40
0x27F2C 160
020000
0x0 255

Can someone tell me the parameters for the missing mesh (see picture)?

2Heads.png

Edited by shak-otay
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...