ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax
It is currently Sun Jan 29, 2023 1:32 pm

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Dec 06, 2022 8:18 am 

Joined: Wed Jun 01, 2016 5:53 pm
Posts: 165
Hi, can someone please know how to edit the code to output 2 struct results on same line?

This is output from template:
Code:
Vertex Offset = 0x000560      Block Size = 24
Vertex Offset = 0x001570      Block Size = 24
Vertex Offset = 0x001a80      Block Size = 24
Vertex Offset = 0x001f90      Block Size = 24
Vertex Offset = 0x0024a0      Block Size = 24
Vertex Offset = 0x0029b0      Block Size = 24
Vertex Offset = 0x003140      Block Size = 24
Vertex Offset = 0x003a90      Block Size = 24

Face Offset = 0x0013a0      Face Count = 228
Face Offset = 0x0019f0      Face Count = 72
Face Offset = 0x001f00      Face Count = 72
Face Offset = 0x002410      Face Count = 72
Face Offset = 0x002920      Face Count = 72
Face Offset = 0x003070      Face Count = 104
Face Offset = 0x003980      Face Count = 134
Face Offset = 0x004240      Face Count = 120

But i would like to output it as follows:
Code:
Vertex Offset = 0x000560      Block Size = 24      Face Offset = 0x0013a0      Face Count = 228
Vertex Offset = 0x001570      Block Size = 24      Face Offset = 0x0019f0      Face Count = 72
Vertex Offset = 0x001a80      Block Size = 24      Face Offset = 0x001f00      Face Count = 72
Vertex Offset = 0x001f90      Block Size = 24      Face Offset = 0x002410      Face Count = 72
Vertex Offset = 0x0024a0      Block Size = 24      Face Offset = 0x002920      Face Count = 72
Vertex Offset = 0x0029b0      Block Size = 24      Face Offset = 0x003070      Face Count = 104
Vertex Offset = 0x003140      Block Size = 24      Face Offset = 0x003980      Face Count = 134
Vertex Offset = 0x003a90      Block Size = 24      Face Offset = 0x004240      Face Count = 120

Here's template code:
Code:
//------------------------------------------------
//--- 010 Editor v11.0.1 Binary Template
//
//      File:
//   Authors:
//   Version:
//   Purpose:
//  Category:
// File Mask:
//  ID Bytes:
//   History:
//------------------------------------------------
OutputPaneClear();
local uint i,Align0,Align1,Align2,Align3;
FSeek(36);
uint MDL_COUNT;
FSeek(28);
uint VTX_TABLE_OFSFET;

FSeek(VTX_TABLE_OFSFET);
local uint FIRST_VTX_OFFSET_TMP=ReadUInt(FTell()+4);
local uint BASE_VTX_OFFSET=FTell();
local uint FIRST_VTX_OFFSET=BASE_VTX_OFFSET+FIRST_VTX_OFFSET_TMP;
struct {
    struct {
        local uint VERTICES_BASE_OFFSET=FTell();
        uint UNK0_TMP,VTX_OFFSET_TMP,UNK2_TMP,FILE_NUM_TMP,FACE_INDICES_CHUNKS_TMP,VTXB_SIZE_TMP,UNK6_TMP;
        local uint VERTEX_START=VERTICES_BASE_OFFSET+VTX_OFFSET_TMP,VTXB_SIZE=VTXB_SIZE_TMP,FACE_INDICES_CHUNKS=FACE_INDICES_CHUNKS_TMP;
        local struct {
                Printf("Vertex Offset = 0x%06x      Block Size = %u\n",VERTEX_START,VTXB_SIZE);
                }VTX[FACE_INDICES_CHUNKS]<optimize=false>;
        }ENTRY[MDL_COUNT]<optimize=false>;
        Align0=ReadInt(FTell());
        Align1=ReadInt(FTell()+4);
        Align2=ReadInt(FTell()+8);
        if (Align0 == 0 && Align1 == 0 && Align2 == 0)
        FSkip(12);
        if (Align0 == 0 && Align1 == 0 && Align2 != 0)
        FSkip(8);
        if (Align0 == 0 && Align1 != 0 && Align2 != 0)
        FSkip(4);
        if (Align0 != 0 );
        Printf("\n");
}VERTICES_INFO;

local uint FI_TABLE_BASE_OFFSET=FTell();
local uint TABLE_COUNT_TMP=FIRST_VTX_OFFSET-FI_TABLE_BASE_OFFSET;
local uint TABLE_COUNT=TABLE_COUNT_TMP/48;
struct {
    struct {
        local uint FACE_INDICES_BASE_OFFSET=FTell();
        float UNK0,UNK1,UNK2,UNK3,UNK4,UNK5,UNK6,UNK7;
        uint FLAG,FACE_COUNT_TMP,FACE_INDICES_OFFSET,NULL;
        local uint FACE_START=FACE_INDICES_BASE_OFFSET+FACE_INDICES_OFFSET;
        local uint FACE_INDICES_SIZE_TMP=FACE_COUNT_TMP+1;
        local uint FACE_BLOCK_SIZE=FACE_INDICES_SIZE_TMP*2;
        local uint FACE_COUNT=FACE_BLOCK_SIZE/2;
        local struct {
            Printf("Face Offset = 0x%06x      Face Count = %u\n",FACE_START,FACE_COUNT);
            }FI;
        }ENTRY[TABLE_COUNT]<optimize=false>;
}FACE_INDICES_INFO;

Thanks in advance!


Attachments:
pm_69761212.7z [4.58 KiB]
Downloaded 19 times
Top
   
PostPosted: Thu Dec 08, 2022 12:02 pm 

Joined: Mon Jun 07, 2021 8:20 pm
Posts: 42
Are you sure what count of face blocks is equal to vertex blocks? In template code num face blocks calculating by offsets and dividing to 48, so looks like faces and vertex block referencing to each other with some another way.

Anyway, there's more clear rewrited template with print like you want.
Code:
//------------------------------------------------
//--- 010 Editor v13.0.1 Binary Template
//
//      File:
//   Authors:
//   Version:
//   Purpose:
//  Category:
// File Mask:
//  ID Bytes:
//   History:
//------------------------------------------------

struct VERTBUFFER {
    uint32 unknown, offset, unknown, id, face_chunks, stride, unknown;
};

struct FACEBUFFER {
    float unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown;
    uint32 flag, num_faces, offset, unknown;
};

struct HEADER {
    float unknown, unknown, unknown, unknown;
    uint32 unknown, unknown, unknown, offset_vertbuffers, unknown, num_vertbuffers;
};



HEADER header;

FSeek(header.offset_vertbuffers);

VERTBUFFER vertex_buffer[header.num_vertbuffers];

local uint align0 = FTell(), align1 = FTell() + 4, align2 = FTell() + 8;

if (!align0 && !align1 && !align2) FSkip(12);
else if (!align0 && !align1 && align2) FSkip(8);
else if (!align0 && align1 && align2) FSkip(4);

local uint num_facebuffers = (header.offset_vertbuffers + vertex_buffer[0].offset - FTell()) / 48;
FACEBUFFER face_buffer[num_facebuffers];



local int i;

for( i = 0; i < header.num_vertbuffers; i++ )
{
    Printf("Vertex Offset = 0x%08x\tBlock Size = %u\tFace Offset = 0x%08x\tFace Count = %u\n",
        vertex_buffer[i].offset + startof(vertex_buffer[i]), vertex_buffer[i].stride,
            face_buffer[i].offset + startof(face_buffer[i]), face_buffer[i].num_faces + 1);
}


Top
   
PostPosted: Mon Dec 12, 2022 9:20 am 

Joined: Wed Jun 01, 2016 5:53 pm
Posts: 165
Thank you much! BTW i realized that every vertex entry has info about face entry and count so the count isn't always equal. Don't know why there are chunks for face indices.
That "id" in code is acctually face info offset and "face_chunks" is count of entries.
Try it on this one...

EDiT: Nevermind... I figured it out. Another ugly template. But thank you anyway for your template... I learned alot from it. For now it's limited on 3 face chunks.
Code:
//------------------------------------------------
//--- 010 Editor v11.0.1 Binary Template
//
//      File:
//   Authors:
//   Version:
//   Purpose:
//  Category:
// File Mask:
//  ID Bytes:
//   History:
//------------------------------------------------
LittleEndian(); OutputPaneClear();
local uint i,j,k,inc_0,inc_1;
local string FileName=GetFileName(),FilePath=FileNameGetPath(FileName,true),BaseName=FileNameGetBase(FileName,false);

struct MDL_HEADER {
    float POS[4];
    uint IDS[2],FLAG,VERTEX_INFO_OFFSET,TABLE_0_OFFSET,VERTEX_INFO_COUNT,NULL;
    float VALUES[3];
    uint TABLE_3_OFFSET,TABLE_3_SIZE,TABLE_4_OFFSET,TABLE_4_SIZE,TABLE_1_OFFSET,MATERIAL_INFO_OFFSET,MATERIAL_COUNT;
    uint POS_ROT_INFO_OFFSET,UNK_DATA_0_OFFSET,POS_ROT_INFO_COUNT,UNK_DATA_1_OFFSET,TABLE_2_OFFSET;
    ubyte COUNT_0,COUNT_1,COUNT_2,COUNT_3;
    uint ZERO;
};

struct POS_ROT_INFO {
    local float null=0.000000;
    float m00,m01,m02,w03,m10,m11,m12,w13,m20,m21,m22,w23,POS_X,POS_Y,POS_Z,POS_W;
    //Printf("xform -matrix %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %s_%d_Mesh; xform -t %f %f %f %s_%d_Mesh;\n",m00,m01,m02,w03,m10,m11,m12,w13,m20,m21,m22,w23,null,null,null,null,BaseName,SUBMDL_COUNT_TMP---1,POS_X,POS_Y,POS_Z,BaseName,SUBMDL_COUNT_TMP1---1);
};

struct VERTEX_INFO {
    uint FLAG0,VERTEX_DATA_OFFSET,FLAG1,FACE_INFO_OFFSET,FACE_CHUNKS,VTB_SIZE,FLAG2;
};

struct FACE_INFO {
    float VALUES[8];
    uint FACE_FLAG,FACE_COUNT,FACE_DATA_OFFSET,NULL;
};

struct MATERIAL_INFO {
    string MATERIAL_NAME;
};


MDL_HEADER MDLHeader;

FSeek(MDLHeader.VERTEX_INFO_OFFSET);
VERTEX_INFO VTXEntry[MDLHeader.VERTEX_INFO_COUNT];

for( i = 0; i < MDLHeader.VERTEX_INFO_COUNT; i++ ){
FSeek(VTXEntry[i].FACE_INFO_OFFSET + startof(VTXEntry[i]));
if (VTXEntry[i].FACE_CHUNKS == 1){
FACE_INFO FIEntryMain;}
else if (VTXEntry[i].FACE_CHUNKS == 2){
FACE_INFO FIEntryMain,FIEntrySecond;}
else if (VTXEntry[i].FACE_CHUNKS == 3){
FACE_INFO FIEntryMain,FIEntrySecond,FIEntryThird;}
}

FSeek(MDLHeader.MATERIAL_INFO_OFFSET+MDLHeader.MATERIAL_COUNT*4);
MATERIAL_INFO MATEntry[MDLHeader.MATERIAL_COUNT]<optimize=false>;

for( i = 0; i < MDLHeader.VERTEX_INFO_COUNT; i++ )
{
    if (VTXEntry[i].FACE_CHUNKS == 1){
    Printf("Vertex Offset = 0x%08x\tBlock Size = %u\tFace Offset = 0x%08x\tFace Count = %u\n",
        VTXEntry[i].VERTEX_DATA_OFFSET + startof(VTXEntry[i]), VTXEntry[i].VTB_SIZE,
            FIEntryMain[i].FACE_DATA_OFFSET + startof(FIEntryMain[i]), FIEntryMain[i].FACE_COUNT + 1);
    }
    else if (VTXEntry[i].FACE_CHUNKS == 2){
    Printf("Vertex Offset = 0x%08x\tBlock Size = %u\tFace Offset = 0x%08x\tFace Count = %u\n",
        VTXEntry[i].VERTEX_DATA_OFFSET + startof(VTXEntry[i]), VTXEntry[i].VTB_SIZE,
            FIEntryMain[i].FACE_DATA_OFFSET + startof(FIEntryMain[i]), FIEntryMain[i].FACE_COUNT+FIEntrySecond[j++].FACE_COUNT+2);
    }
    else if (VTXEntry[i].FACE_CHUNKS == 3){
    Printf("Vertex Offset = 0x%08x\tBlock Size = %u\tFace Offset = 0x%08x\tFace Count = %u\n",
        VTXEntry[i].VERTEX_DATA_OFFSET + startof(VTXEntry[i]), VTXEntry[i].VTB_SIZE,
            FIEntryMain[i].FACE_DATA_OFFSET + startof(FIEntryMain[i]), FIEntryMain[i].FACE_COUNT+FIEntrySecond[j++].FACE_COUNT+FIEntryThird[k++].FACE_COUNT+3);
    }
}


Attachments:
pm_1761372512.7z [20.43 KiB]
Downloaded 15 times
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited