Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Make_obj (C source)

Read or post any tutorial related to file format analysis for modding purposes.
asphyxiazation
ultra-n00b
Posts: 3
Joined: Wed Sep 13, 2017 6:19 am
Has thanked: 2 times

Re: Make_obj (C source)

Post by asphyxiazation »

shakotay2 wrote:
asphyxiazation wrote:so, out of curiosity, what are the other contents of the prefab file that its size reaches 1.829kb while the actual mesh is only 126kb
It's normals which I usually skip; and weight data, I guess; there's positions and rotations for the skeleton bones, and some other data that would require a deeper look.
thanks for the insight, shakotay2! 8)
leyme
advanced
Posts: 50
Joined: Wed Apr 04, 2012 10:17 am
Has thanked: 10 times
Been thanked: 3 times

Re: Make_obj (C source)

Post by leyme »

shakotay2 wrote:Scion of Fate, 101.YOM tested only (may fail on others, adding of unrecognized FI blocks to the source is required then).
Make_obj.zip
yeah, that's not nice: all objects are clumped together. Maybe there's offsets in the 101.txt file to move them into correct positions (position in World Matrix is a candidate).
Also uvs of some objects seem to be missing.

You have the source, so don't complain, improve it.
Image
Please help me.
Some files cause problems
Last edited by leyme on Sun Dec 23, 2018 10:00 am, edited 1 time in total.
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4284
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1146 times
Been thanked: 2242 times

Re: Make_obj (C source)

Post by shakotay2 »

thanx for reporting, leyme! :)
Here's an update for the SuperHeroGeneration auto correction (which had a problem; checked hg009_0001_01_m01.mbg only!):
Make_obj-ZoE.zip
(no source update this time because ZoE source part is not ready for release and I'm too lazy to cut it from the actual source)
You do not have the required permissions to view the files attached to this post.
Last edited by shakotay2 on Tue Dec 25, 2018 3:01 pm, edited 2 times in total.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
leyme
advanced
Posts: 50
Joined: Wed Apr 04, 2012 10:17 am
Has thanked: 10 times
Been thanked: 3 times

Re: Make_obj (C source)

Post by leyme »

shakotay2 wrote:thanx for reporting, leyme! :)
Here's an update for the SuperHeroGeneration auto correction (which had a strange bug; checked hg009_0001_01_m01.mbg only!):
Make_obj-ZoE.zip
(no source update this time because ZoE source part is not ready for release and I'm too lazy to cut it from the actual source)
Image
Thanks shakotay2.
Other files are error.
https://www.mediafire.com/file/j322x7ag ... g.zip/file
Last edited by leyme on Sun Dec 23, 2018 9:40 pm, edited 1 time in total.
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4284
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1146 times
Been thanked: 2242 times

Re: Make_obj (C source)

Post by shakotay2 »

well, too bad. The "bug" was not a bug, it worked as expected but I didn't get the real problem so far (need more time, next year, I assume (: )

I made a workaround (see updated zip in my previous post) so that you can load the meshes at least into blender for example. Then erase the spoiled submeshes (hopefully one intact one will remain):
SHeroGen-probs.png
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4284
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1146 times
Been thanked: 2242 times

Re: Make_obj (C source)

Post by shakotay2 »

well, thing is, there's unrecognized vertex blocks:
hg010_0002-SM02.png
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
leyme
advanced
Posts: 50
Joined: Wed Apr 04, 2012 10:17 am
Has thanked: 10 times
Been thanked: 3 times

Re: Make_obj (C source)

Post by leyme »

shakotay2 wrote:well, thing is, there's unrecognized vertex blocks:
hg010_0002-SM02.png
wow.I salute you for your enthusiasm
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4284
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1146 times
Been thanked: 2242 times

Re: Make_obj (C source)

Post by shakotay2 »

yeah, I'm totally surprised, too. :D (made an update to the previous zip) But I really need a break here.

Still some spoiled meshes, with er045_0001_02_m01.mbg for example.
You may check out for yourself (using hex2obj for example) which correction might be false;
or maybe vBlock and FIblock pairs don't fit together.

(abbreviations: vCnt= vertex count; FIcnt= face indices count)
# start of vertices
#0 59e
# UV01 0x7859c (2574) (name is uv01, but appears to be a vertex block for me)
#1 b6517
#2 c30de
#3 d202d
#4 e933a
#5 13cd61
# UV01 0x1db03f (2574)
#6 233baa
#7 247c2c
#8 270d6e

# FIs at:
# 0x70819
# 0xb36c9
# 0xc1d74
# 0xc3783
# 0xd12d9
# 0xe8058
# 0x10a80d
# 0x1acfdc
# 0x21616c
# 0x23f407
# 0x25dc57
# 0x292241
# SubMesh count and FIs block count are different!
Some SM may be missing. 11 != 12
#0 vCnt: 7461 (at 0x496), FIcnt: 21738
correction counts: 4887 / 16002
#1 vCnt: 502 (at 0xb6413), FIcnt: 2292
corr: FIcnt 5736
#2 vCnt: 613 (at 0xc2fd6), FIcnt: 1557
corr: FIcnt 2292
#3 vCnt: 959 (at 0xd1f29), FIcnt: 2226
corr: FIcnt 42
#4 vCnt: 1451 (at 0xe9236), FIcnt: 6603
corr: FIcnt 1515
#5 vCnt: 7461 (at 0x13cc59), FIcnt: 21738
corr: 4887 / 2226
#6 vCnt: 502 (at 0x233aa6), FIcnt: 2292
corr: FIcnt 6603
#7 vCnt: 959 (at 0x247b28), FIcnt: 2226
corr: FIcnt 16002
#8 vCnt: 1451 (at 0x270c6a), FIcnt: 6603
corr: FIcnt 5736
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
wjj162446
ultra-n00b
Posts: 7
Joined: Wed Jul 10, 2019 12:01 pm
Has thanked: 3 times

Re: Make_obj (C source)

Post by wjj162446 »

Thanks sir,they are helpful
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4284
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1146 times
Been thanked: 2242 times

Re: Make_obj (C source)

Post by shakotay2 »

"One for all" pmd models, tested chr_body_rank_104_a_slender.pmd only!
Make_obj-pmd.zip
(no source code update this time because the pmd2obj code is dead ugly :eek: )

last source code version (without .pmd support) to be found in the opening post:
shakotay2 wrote: Mon Mar 06, 2017 11:01 am
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
wjj162446
ultra-n00b
Posts: 7
Joined: Wed Jul 10, 2019 12:01 pm
Has thanked: 3 times

Re: Make_obj (C source)

Post by wjj162446 »

Sir,I have a question,when I ues make_boj to extract kamen rider thouser from citywar,it has some trouble
You do not have the required permissions to view the files attached to this post.
wjj162446
ultra-n00b
Posts: 7
Joined: Wed Jul 10, 2019 12:01 pm
Has thanked: 3 times

Re: Make_obj (C source)

Post by wjj162446 »

wjj162446 wrote: Thu Mar 12, 2020 10:42 am Sir,I have a question,when I ues make_boj to extract kamen rider thouser from citywar,it has some trouble
https://drive.google.com/file/d/1hvxbP4 ... sp=sharing
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4284
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1146 times
Been thanked: 2242 times

Re: Make_obj (C source)

Post by shakotay2 »

yeah, I see. It's the first submesh only - will take some time to patch the tool.

Feel free to do it for yourself - the 'C' source code is available here:
shakotay2 wrote: Mon Mar 06, 2017 11:01 am
.
2_submeshes.png
(need to check the patch before releasing it..)
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
wjj162446
ultra-n00b
Posts: 7
Joined: Wed Jul 10, 2019 12:01 pm
Has thanked: 3 times

Re: Make_obj (C source)

Post by wjj162446 »

shakotay2 wrote: Thu Mar 12, 2020 1:30 pm yeah, I see. It's the first submesh only - will take some time to patch the tool.

Feel free to do it for yourself - the 'C' source code is available here:
shakotay2 wrote: Mon Mar 06, 2017 11:01 am
.
2_submeshes.png
(need to check the patch before releasing it..)
Will sir update the tool
User avatar
shakotay2
MEGAVETERAN
MEGAVETERAN
Posts: 4284
Joined: Fri Apr 20, 2012 9:24 am
Location: Nexus, searching for Jim Kirk
Has thanked: 1146 times
Been thanked: 2242 times

Re: Make_obj (C source)

Post by shakotay2 »

This is the patch for KamenRider, submesh 2, very ugly but works for MDL__B00092_92.prefab (only tested model, so don't blame me).
.
submesh_2.png
Replace the function void SM_of_KR_CW_loop(HWND hwnd, char szPathname[], DWORD dwStart) in the source here:
shakotay2 wrote: Mon Mar 06, 2017 11:01 am
by

Code: Select all

void SM_of_KR_CW_loop(HWND hwnd, char szPathname[], DWORD dwStart)      //
{                                                                         // Kamen Rider City Wars
   char * pFBuf, *pTmp ;            // , szNo[4]
   BYTE cnt= 0 ;
   int nValue[16] ;
   //WORD wFaceIndCnt, wVertsCnt, wOffs2VBlock ;         //
   DWORD FIaddr_arr[9], FIcnt, FIcnt_arr[9], uvCnt, vCnt, UVaddr_arr[9], Vaddr_arr[9], vCnt_arr[9] ;  //
   DWORD minFaceInd = 16777215, maxFaceInd = 0, lastFaceInd=0 ;
   DWORD addrFI=0, addrUV, addrV, offs2 ;  //
   DWORD j=0 ;
   bool bUV ;

   pFBuf = (char *) lpFBuf ; pTmp= pFBuf ;
   //if ((*pFBuf!=0xww)&&(*(pFBuf+3)!=0xyy)) {
   //     chMB("This doesn't seem to be a Kamen Rider CW prefab file!") ; return ;
   //}
   dwStart = 0 ; pFBuf += dwStart ;            //Triangles 54 72 69 61 Positions  50 6F 73 69
   SendMessage(GetDlgItem(hwnd, ID_LIST), LB_ADDSTRING, 0, (LPARAM) " creating obj:") ;
   cnt= 0 ; lastJ= 0 ;
   nValue[0]= 0x54; nValue[1]= 0x72; nValue[2]= 0x69; nValue[3]= 0x61;          // Tria

        offs2 = FindBytes(lpFBuf, j, dwFileSize-j, nValue, 4) ;       // j is offset here
        if (offs2!=0) {
            pFBuf += offs2 ; j += offs2 ; fprintf( stream, "#") ;
            if (*(pFBuf+8)!= 0x73) {
                chMB("String 'Triangles' not found! - EXIT") ; return ;
            }
            addrFI = j ;
            fprintf( stream, " Triangles string at %lx\n", j) ;
        }
        else {
            chMB("String 'Triangles' not found! - EXIT") ; return ;
        }

   nValue[0]= 0; nValue[1]= 0; nValue[2]= 1; nValue[3]= 0; nValue[4]= 2; nValue[5]= 0;          // 0000 0100 0200
   do {
        offs2 = FindBytes(lpFBuf, j, dwFileSize-j, nValue, 6) ;       // j is offset here
        if (offs2!=0) {
            pFBuf += offs2 ; j += offs2 ;
            addrFI = j ;
            fprintf( stream, "# 0000 0100 0200 at %lx\n", j) ;
        }
        else
            if (cnt==0) { chMB("0000 0100 0200 not found! - EXIT") ; return ; }
        FIaddr_arr[cnt]= j ; pFBuf -= 4 ; j -= 4 ;
        GetDW(pFBuf, j, FIcnt, false) ; FIcnt_arr[cnt]= FIcnt /2 ;
        fprintf( stream, "# FIs: %ld\n", FIcnt_arr[cnt]) ;
        log_FIs(stream, FIaddr_arr[cnt], minFaceInd, maxFaceInd, lastFaceInd, FIcnt_arr, cnt, false) ;
        pFBuf += 6 ; j += 6 ; if (cnt<7) cnt++ ; else {chMB("Too many submeshes!"); return ; }
        if (cnt==2) offs2= 0 ;  //break
   } while ((offs2!=0)&&(j<dwFileSize)) ;
   cnt= 0 ;
   nValue[0]= 7; nValue[1]= 0; nValue[2]= 0; nValue[3]= 0; nValue[4]= 3;    // Normals, BiNormals, Positions
   do {
        pFBuf = pTmp ; pFBuf += FIaddr_arr[cnt] ; j = FIaddr_arr[cnt] ;
        offs2 = FindBytes(lpFBuf, FIaddr_arr[cnt], dwFileSize-FIaddr_arr[cnt], nValue, 5) ;       // j is offset here
        if (offs2!=0) {
            pFBuf += offs2 ; j += offs2 ;
            if (*(pFBuf+8)==1) {
                    //fprintf( stream, "sig 07000000 at %lx\n", j) ;
                addrV= j + 17  ; Vaddr_arr[cnt]= addrV ;
                pFBuf += 8 + 5 ; j += 8 + 5 ;
                GetDW(pFBuf, j, vCnt, false) ;      //  size vBlock
                vCnt = vCnt/12 ; vCnt_arr[cnt]= vCnt ;
                fprintf( stream, "# verts at %lx, count: %ld\n", addrV, vCnt) ;
                cnt++ ; if (cnt==2) offs2= 0 ;
                //if (cnt==3) {             // we search behind FIS, so Normals/BiNorm sig is skipped
                //    offs2= 0 ; addrV= j + 17 ;
                //    fprintf( stream, "verts at %lx\n", addrV) ;
                //}
            }
        }
   } while ((offs2!=0)&&(j<dwFileSize)) ;
        //if (cnt!= 3) chMB("not all sigs for Norm/BiNorm/Pos found!\nModel will be faulty.") ;
   if (cnt==0) { chMB("Pos sig not found, no verts in model!\nExit.") ; return ; }
   log_Verts(Vaddr_arr[0], vCnt_arr[0], 12) ;
   fprintf( stream, "# SM 1 at %lx\n", Vaddr_arr[1]) ;
   log_Verts(Vaddr_arr[1], vCnt_arr[1], 12) ;

   pFBuf = (char *) lpFBuf ; j= 0 ; cnt=0 ;
   nValue[0]= 7; nValue[1]= 0; nValue[2]= 0; nValue[3]= 0; nValue[4]= 2;    // UVx
   do {
        offs2 = FindBytes(lpFBuf, j, dwFileSize-j, nValue, 5) ;       // j is offset here
        if (offs2!=0) {
            pFBuf += offs2 ; j += offs2 ; fprintf( stream, "#") ;
            if (*(pFBuf+8)==1) {
                bUV= true ;
                //fprintf( stream, "sig 07000000 at %lx\n", j) ;
                addrUV= j + 17 ; UVaddr_arr[cnt]= addrUV ;
                fprintf( stream, "uvs at %lx\n", addrUV) ;
            }
            else bUV= false ;
        }

           pFBuf += 13 ; j += 13 ;                  // advance to UVs blocksize, DWord
           GetDW(pFBuf, j, uvCnt, false) ; uvCnt = uvCnt/8 ;
           if (uvCnt!=vCnt_arr[cnt]) {
               chMB("uv cnt doesn't match vCnt!") ;
               fprintf( stream, "uvs_%d cnt: %d at %lx != %d\n", cnt, uvCnt, j-4, vCnt_arr[cnt]) ;
               if (vCnt_arr[cnt]>100000) vCnt_arr[cnt]= 11174 ;
           }
           addrUV= UVaddr_arr[cnt] ;
           logUVs(addrUV, vCnt_arr[cnt], 8) ;
           if (cnt<1) cnt++ ; else offs2=0 ;        //break after submesh 2

    } while ((offs2!=0)&&(j<dwFileSize)) ;
}
(You'll need to patch this code again in case there's more than 2 submeshes!)
You do not have the required permissions to view the files attached to this post.
Tuts: a) Bigchillghost, viewtopic.php?f=29&t=17889
b) Extracting simple models: http://forum.xentax.com/viewtopic.php?f=29&t=10894
"Quoting the whole thing. Would u ever stop this nonsense?"
Post Reply