Silkroadonline bms
Posted: Tue Jun 21, 2011 4:21 pm
I found fatduck's post about the file format and it looked pretty simple so I decided to write a converter. Or at least try. Going through chrrox's tutorial on reading the format outline and looking at some blender scripts from Szkaradek123 gave me an idea how to write it.
But going through the file, it seems like there are some differences here and there (and I've noticed the extractor I used extracted too much data, so I don't know if the files I have are even correct).
Here's fatduck's post: http://gameresearch.5d6d.com/archiver/tid-156.html
Does anyone have an importer that works for them? Just so I know that the files I have are wrong lol
Here are some files. You can tell a lot of them are wrong just by going to the bottom of the file and noticing that a a couple dozen bytes from the next file is appended to it (is clear from the header and strings). Maybe it just means there's more data than necessary, so that shouldn't be a problem if I'm following the format correctly.
It's possible that the converters I found work, except corrupt files cause them to fail.
This is what I did in python so far up to and including vertices. I'm not sure if I am reading what fatduck posted correctly
But going through the file, it seems like there are some differences here and there (and I've noticed the extractor I used extracted too much data, so I don't know if the files I have are even correct).
Here's fatduck's post: http://gameresearch.5d6d.com/archiver/tid-156.html
Does anyone have an importer that works for them? Just so I know that the files I have are wrong lol
Here are some files. You can tell a lot of them are wrong just by going to the bottom of the file and noticing that a a couple dozen bytes from the next file is appended to it (is clear from the header and strings). Maybe it just means there's more data than necessary, so that shouldn't be a problem if I'm following the format correctly.
It's possible that the converters I found work, except corrupt files cause them to fail.
This is what I did in python so far up to and including vertices. I'm not sure if I am reading what fatduck posted correctly
Code: Select all
filetype, version = unpack('<8s4s', bmsFile.read(12*CHARSIZE))
if version == "0110":
vertArray = []
normArray = []
uvArray = []
#file starts at 0x48
bmsFile.seek(0x48)
#get mesh group
charCount = unpack('<l', bmsFile.read(LONGSIZE))[0]
meshGroup = unpack('<%ds' %charCount, bmsFile.read(charCount))[0]
#get material library
charCount = unpack('<l', bmsFile.read(LONGSIZE))[0]
matLib = unpack('<%ds' %charCount, bmsFile.read(charCount))[0]
#unknown int
unkInt = unpack('<l', bmsFile.read(LONGSIZE))[0]
vertCount = unpack('<l', bmsFile.read(LONGSIZE))[0]
print "%d vertices" %vertCount
for i in range(0, vertCount):
#get vert coords
verts = bmsFile.read(3*FLOATSIZE)
vx, vy, vz = unpack('<3f', verts)
#get normals
norms = bmsFile.read(3*FLOATSIZE)
nx, ny, nz = unpack('<3f', norms)
#get tex coords
tex = bmsFile.read(2*FLOATSIZE)
tu, tv = unpack('<2f', tex)
#ignore 12 bytes
bmsFile.read(12)

