[WIP] Silkroad File Formats (.bsr .bms .bmt .bsk .ban )

07/10/2012 16:05 theonly112#1
I'm currently trying to work out some of the different structures of the files within the pk2's
[Only registered and activated users can see links. Click Here To Register...]

.bsr Resource file. References meshes, materials, animations, skeletons etc.
.bms Meshes
.bmt Material file that references different .ddj textures
.ban Animation
.bsk Skeleton


.bsr Structure
Code:
12 byte Header
52 byte unknown. Havnt look into those
int bsrType; ranges from 0x20000 to 0x20006 (could be more)
string bsrTitle;
From here on out they seem to differ depending on their bsrType
28 byte unknown
string meshReference Not in every .bsr. References a .bms file. Although the .bms file referenfces come later.
float[2,6] boundingBox; outlines the mesh
int unknown;

int bmtFileCount;
int unknown;
string[btmFileCount] paths to the different materials used on the model

int bmsFileCount;
string[bmsFileCount] paths to the different meshes used 

int unknown
int unknown

int banFileCount;
string[banFileCount] paths to the different animation files 

int bskFileCount; should be 1 for most models
string[bskFileCount] path to the skeleton files.

this is how far im parsing these files right now
.bms Structure
Code:
12 Bytes header
int index; position in the stream where the vertex information start
48 bytes uknown
int lightmapResolution; as far as i can tell. didnt check yet
int uknown
string meshname;
string materialname;*
int unknown;
int vertexCount;

for(int i = 0; i < vertexCount;i++)
{
   float[3] vertices
   float[3] normals
   float[2] textureUV
   if(lightmapResolution != 0)
   {
     float[2] lightmapUV
   }
  12 bytes uknown //didnt look into this yet
}

if(lightmapResolution != 0)
{
   string lightmapPath;
}
int boneCount;*
string[boneCount] bones

if(boneCount != 0)
{
   //This is needed for animation.
   for(i = 0; i < vertexCount;i++)
   {
	byte BoneIndex_1  //Index of bonename in array above
	ushort BoneWeight_1 //used for animation to weigh the two transformation matricies
	byte BoneIndex_2  
	ushort BoneWeight_2
   }
}

int faceCount

for(int i = 0; i < faceCount;i++)
{
   int16[i,3] faces;
}
.bmt structure
Code:
12 byte header
int textureCount
for(int i = 0; i < textureCount;i++)
{
   string name; // will be used in the mesh to identify which texture to use
   48 bytes of unknown data 
   string texturefilename;
   7bytes of unkown data
}
.ban structure
Code:
12 byte header
int unk
int unk 
string name;  //name of the animation
int duration
int framesPerSecond
int unk
int keyframeCount;
int[keyframeCount] keyframes;  //timings of the keyframes, so you can interpolate between two poses.
int boneCount //Amount of bones that have transformations that are diffrent from their bind poses.
for(int i = 0; i < boneCount;i++)
{
   string boneName;
   int count; same as keyframeCount
   for(int p = 0; p < count;p++)
   {
       Quaternion rotation; 
       Vector3 translation; 
        //These two together give you the transformation Matrix relative to it's partent bone/joint.
   }
}
//End of file
.bsk structure
So thanks to this [Only registered and activated users can see links. Click Here To Register...]
Code:
12 byte header
int boneCount;
for(int i = 0; i < boneCount;i++)
{
      if(not first bone)
      {
            int count; // Number of bones with same parent bone. Bone itself included
            for(int x = 0; x < count; x++)
            {
                  string boneName;
            }
      }
      byte unk;
      string boneName;
      string parentBoneName;
      //This next part is taken from Cruor's post.
      Vec4 rotationToParent;
      Vec3 translationToParent;
      Vec4 rotationToOrigin;
      Vec3 translationToOrigin
      Vec4 rotationUnkown;
      Vec3 translationUnkown;     
}
int unk;
int unk;
int unk;

//End of file
I will edit my post as i learn more about the structures.

Please excuse the poor structure of my post and also my bad english.
07/10/2012 20:13 PortalDark#2
seems cool for me
07/10/2012 21:14 qoaway#3
in bsr structure

Quote:
int bmsFileCount;
string[bmsFileCount] paths to the different meshes used

int unknown
int unknown
first unknow would be efp file count
07/10/2012 21:45 theonly112#4
Quote:
Originally Posted by qoaway View Post
in bsr structure



first unknow would be efp file count
for which bsrType? Cause it's not true for 0x20001.
EDIT: efp's seem to be alot further down.
07/11/2012 00:28 illstar#5
The header is followed by indexes to the different parts of the file in the bsr/bms

bsr:
Code:
[12 byte] header 
[04 byte] bmtIndex
[04 byte] bmsIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] bmsIndex // Only one i was interested in
....
07/11/2012 19:16 theonly112#6
Thanks illstar. i noticed the bms index earlier but didnt really think about it.

Please note that the naming of the variables is purely based on assumptions.
Code:
.bsk structure
So thanks to this post 
Code:
12 byte header
int boneCount;
for(int i = 0; i < boneCount;i++)
{
      if(not first bone)
      {
            int count; // Number of bones with same parent bone. Bone itself included
            for(int x = 0; x < count; x++)
            {
                  string boneName;
            }
      }
      byte unk;
      string boneName;
      string parentBoneName;
      //This next part is taken from Cruor's post.
      Vec4 rotationToParent;
      Vec3 translationToParent;
      Vec4 rotationToOrigin;
      Vec3 translationToOrigin
      Vec4 rotationUnkown;
      Vec3 translationUnkown;     
}
int unk;
int unk;
int unk;

//End of file
03/22/2013 01:17 Kicia123#7
Quote:
Originally Posted by illstar View Post
The header is followed by indexes to the different parts of the file in the bsr/bms

bsr:
Code:
[12 byte] header 
[04 byte] bmtIndex
[04 byte] bmsIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] unkIndex
[04 byte] bmsIndex // Only one i was interested in
....
bsr:
Code:
[12 byte] header 
[04 byte] bmtIndex
[04 byte] bmsIndex
[04 byte] sklIndex
[04 byte] banIndex
[04 byte] defaultIndex 
[04 byte] defaultIndex
[04 byte] ambientIndex
[04 byte] bmsIndex
03/22/2013 18:37 DaxterSoul#8
Well, i'd like to add something too.
I ran the format through every bsr file without errors, same with cpd.

Code:
02/22/2014 18:34 theonly112#9
Was a little bored the last couple of days so i've been working on animations.
Had to read a couple of articles about skeleton animation, but it's been easier than i expected.



Right now i simply take a framerate of 30 FPS and assume that the duration between two keyframes is 1/30 of a second. Which is of course not correct for many animations. Which is why the animations look so choppy sometimes. But for demo purposes i thought it looked nice enough.

Here's the updated format of the .ban files:
Code:
12 byte header
int unk
int unk 
string name;  //name of the animation
int duration
int framesPerSecond
int unk
int keyframeCount;
int[keyframeCount] keyframes;  //timings of the keyframes, so you can interpolate between two poses.
int boneCount //Amount of bones that have transformations that are diffrent from their bind poses.
for(int i = 0; i < boneCount;i++)
{
   string boneName;
   int count; same as keyframeCount
   for(int p = 0; p < count;p++)
   {
       Quaternion rotation; 
       Vector3 translation; 
        //These two together give you the transformation Matrix relative to it's partent bone/joint.
   }
}
//End of file

Also in case you're trying to do something similar in say OpenGL, you have to take into account that DirectX (which is being used in sro) uses a right-handed coordinate system, but OpenGL on the other hand uses a left-handed system by default. There are obviously workarounds but just something to keep in mind.
02/23/2014 02:54 Lolill0#10
I doubt we can expect to see Models imported in SRO with their own Animations soon and by that I mean Models which were made from the scratch.

Wouldn't 60 FPS work? It's more smoother then 30 FPS (Don't come with that "Your Eye handles only 30 FPS thingy").
02/23/2014 10:24 theonly112#11
Quote:
Originally Posted by Lolill0 View Post
I doubt we can expect to see Models imported in SRO with their own Animations soon and by that I mean Models which were made from the scratch.
Importing your own Animations would be pretty easy. Someone probably already did it. The .ban file format is rather easy to figure out.
An entire new Model would be more difficult since there's a lot more files you would have get 100% correct.

Quote:
Originally Posted by Lolill0 View Post
Wouldn't 60 FPS work? It's more smoother then 30 FPS (Don't come with that "Your Eye handles only 30 FPS thingy").
I'm not sure, i haven't tried the changing the value in the file to 60. But that's something you could try pretty easily. It's just that every animation i've come across so far was either 24 FPS or 30 FPS.
Which doesn't mean they HAVE to run the game at 30 FPS. You can run it at 60 FPS you just have to interpolate between lets say the pose at keyframe 10 and keyframe 11 to create the pose at keyframe 10.5.
02/23/2014 12:19 Snow*#12
Quote:
Originally Posted by theonly112 View Post
Importing your own Animations would be pretty easy. Someone probably already did it. The .ban file format is rather easy to figure out.
An entire new Model would be more difficult since there's a lot more files you would have get 100% correct.
Importing own animation is the hard part(ban, bsk), but adding the new model is the easy part of the progress(bsr, ddj, bms, efp). Also that "Someone" isn't into SRO anymore.
02/23/2014 13:28 theonly112#13
Quote:
Originally Posted by SnowStorm1 View Post
Importing own animation is the hard part(ban, bsk), but adding the new model is the easy part of the progress(bsr, ddj, bms, efp). Also that "Someone" isn't into SRO anymore.
That's just completely not true. You can add a new Animation without having to do anything but add 1 new entry to the list of .ban Files in the .bsr file of the Model the animation is for.

To add an entirely new Model:
1. you would have to create new meshes ( .bms ), that's easy ( for the most part, but you already have to have a .bsk file if you want to be able to have any animation for this model. Otherwise it's just a boring mesh sitting around somewhere.)
2. you would have to correctly rig the meshes ( .bsk ), not so easy but doable. still no complete documentation of the file format.
3. you would have to texture the meshes ( .bmt ) more or less easy.
4. create a new .bsr file linking everything together correctly. ( actually pretty hard since there's still no complete documentation on .bsr files)

So it's just completely untrue that creating 1 file that's already nicely documented is harder than creating 4 that are not at all well documented.

Also about that part about that certain "someone"? I have no idea who you're talking about but that's just complete bullshit. Anyone with a decent understanding of a tool like 3ds Max can do it.

EDIT: I've updated the first post ( animation stuff in .bms files ) to show what information i currently have about the file formats.
02/23/2014 20:56 Lolill0#14
Quote:
Originally Posted by theonly112 View Post
That's just completely not true. You can add a new Animation without having to do anything but add 1 new entry to the list of .ban Files in the .bsr file of the Model the animation is for.

To add an entirely new Model:
1. you would have to create new meshes ( .bms ), that's easy ( for the most part, but you already have to have a .bsk file if you want to be able to have any animation for this model. Otherwise it's just a boring mesh sitting around somewhere.)
2. you would have to correctly rig the meshes ( .bsk ), not so easy but doable. still no complete documentation of the file format.
3. you would have to texture the meshes ( .bmt ) more or less easy.
4. create a new .bsr file linking everything together correctly. ( actually pretty hard since there's still no complete documentation on .bsr files)

So it's just completely untrue that creating 1 file that's already nicely documented is harder than creating 4 that are not at all well documented.

Also about that part about that certain "someone"? I have no idea who you're talking about but that's just complete bullshit. Anyone with a decent understanding of a tool like 3ds Max can do it.

EDIT: I've updated the first post ( animation stuff in .bms files ) to show what information i currently have about the file formats.
I guess he refered to perry who made the OBJ to BMS Converter [Only registered and activated users can see links. Click Here To Register...]

Implementing stuff (Static Models) ain't hard at all, the thing is, the Model itself is missing Animations, Skeleton.

Let's say I got a Model with a Animation already, Animation is called "ANI.AA", I will convert it to a different format and a SRO XXX to BAN Converter will convert the Animation to the .BAN Format.

Pretty much like that, since then we could have new Monsters, Items which are animated, new Characters and pretty much more.

The only thing we're able to do by now is to implement some Static Models, the rest like creating entire new Skill Effects, Maps, UI and more isn't possible now.

Replacing NPC's, Monsters or Objects isn't the way to add new things like this


I even haven't encountered someone who could implement some Cactus as a NPC in Taklamakan which sells some pretty nasty Stuff *lol*
03/07/2014 16:20 ravullu79#15
Where is Program Download Link