How to use the code,sir,I don't know about C source too muchshakotay2 wrote: ↑Mon Mar 16, 2020 12:45 pmThis 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:by(You'll need to patch this code again in case there's more than 2 submeshes!)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)) ; }
The rules have been updated, read them now: Rules!
Make_obj (C source)
Re: Make_obj (C source)
- shakotay2
- MEGAVETERAN
- Posts: 3233
- Joined: Fri Apr 20, 2012 9:24 am
- Location: Nexus, searching for Jim Kirk
- Has thanked: 886 times
- Been thanked: 1776 times
Re: Make_obj (C source)
But this thread is for people who know how to use code: "compile this project with CodeBlocks 13.12 for example".
(PMed u)
Bigchillghost, Reverse Engineering a Game Model: viewtopic.php?f=29&t=17889
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."
extracting simple models: viewtopic.php?f=29&t=10894
Make_H2O-ForzaHor3-jm9.zip
"You quoted the whole thing, what a mess."