ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Wed Nov 25, 2020 10:20 am

All times are UTC




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Chinese Game "Fengbao"
PostPosted: Fri Oct 09, 2020 12:34 pm 

Joined: Fri Oct 09, 2020 12:27 pm
Posts: 1
Hello,

I'm trying to import the models from this game named "fengbao" into 3dsmax. I have written an MAXScript to import it but I'm failing at the indices / faces and vertices part.

Script:
Code:
fn readStr binstr strLen = --reads a fixed-size string
(
   str = ""
   for w=1 to strLen do(str += (bit.intasChar(readByte binstr #unsigned)))
   return str
)

fn clamp minVal maxVal val =
(
   if val < minVal then val = minVal
   else if val > maxVal then val = maxVal
   return val
)

binfile = fopen "C:\\aoshan_bingshan.mesh" "rb"

version = readLong binfile
print version

subMeshNum = readLong binfile

fseek binfile 72 #seek_cur

subMeshNum = 1
for i = 0 to subMeshNum - 1 do(
   smNameLen = readLong binfile #unsigned
   smName = readStr binfile smNameLen
   print(smName)
   
   mtrlLen = readLong binfile #unsigned
   mtrlPath = readStr binfile mtrlLen
   print(mtrlPath)
   
   m_isUseNormal = (readByte binfile == 1)
   m_isUseVertexColor = (readByte binfile == 1)   
   m_isUseLightmapUV = (readByte binfile == 1)
   m_isUseTangentBinormal = (readByte binfile == 1)
   lightmapResolution = readLong binfile
   lightmapResolution = clamp 8 12 lightmapResolution
   
   fseek binfile 72 #seek_cur
   
   vertCount = readLong binfile #unsigned
   vertices = #()
   for x = 0 to vertCount by 3 do (
      f1 = readByte binfile
      f3 = readByte binfile
      f2 = readByte binfile
      append vertices ([f1,f2,f3])
   )
   --readLong binfile #unsigned
   
   faceCount = readLong binfile #unsigned
   idxBuffSize = faceCount
   indices = #()
   for x = 0 to idxBuffSize by 3 do (
      f1 = readByte binfile
      f3 = readByte binfile
      f2 = readByte binfile
       append indices ([f1, f2, f3])
   )
   
   -- AABB
   vMinX = readFloat binfile
   vMinY = readFloat binfile
   vMinZ = readFloat binfile
   
   vMaxX = readFloat binfile
   vMaxY = readFloat binfile
   vMaxZ = readFloat binfile
   
    submesh = mesh vertices:vertices faces:indices
)


I have no clue if the reading part of the indices and vertices is correct. If anything else is needed I'll supply everything thats needed. I have just barebone knowledge how vertices and indices work in this game they use vertex strides.

I've figured out that the vertex stride size is 48. Reading 4 floats for vertices does give some better output like so:

Code:
   for j = 0 to vertCount by 4 do (
      x = readFloat binfile
      y = readFloat binfile
      z = readFloat binfile
      unknown = readFloat binfile
      
      append vertices ([x,y,z])
   )


But messes up the indices...


Attachments:
aoshan_bingshan.rar [213.32 KiB]
Downloaded 33 times
Top
   
PostPosted: Mon Nov 16, 2020 1:14 am 

Joined: Sat Jun 20, 2015 3:38 pm
Posts: 21
Maybe you should post the game's Chinese name or some sample file to there?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 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