Difference between revisions of "FF7/Field/BSX"

From Final Fantasy Inside
< FF7‎ | Field
Jump to navigation Jump to search
my_wiki>Lazy Bastard
(Animation data section)
my_wiki>Lazy Bastard
(Models section)
Line 85: Line 85:
 
|}
 
|}
  
== Models section ==
+
== Models Section ==
  
 
This section begins first with a model header of 16 bytes :
 
This section begins first with a model header of 16 bytes :

Revision as of 17:24, 14 August 2012

BSX file structure (thanks to Micky's tool, Akari's work, and Lazy Bastard's work)

BSX Header

The BSX file, after it is decompressed, begin with a header of 8 bytes : <cpp> struct StrBsxHeader {

   u32 size_file;     // Size of the file
   u32 offset_models; // Offset to the models section

}; </cpp>

Note: The end of the BSX Header is directly before the beginning of the Skeleton Data Section.

Skeleton Data Section

This section contains the parts of the model's skeleton. For each model, there is :

Offset Size Data
offset_vertices = offset_vertex + 4 size_vertices = num_vertex * 8 Vertices
offset_texcoords = offset_vertex + offset_texcoord size_texcoords = num_texcoord * 2 Textures coord
offset_qct = offset_vertex + offset_poly size_qct = 1 + num_quad_color_tex * 0x18 Quad color textures
offset_tct = offset_qct + size_qct size_tct = 1 + num_tri_color_tex * 0x14 Tri color textures
offset_qmt = offset_tct + size_tct size_qmt = 1 + num_quad_mono_tex * 0x0C Quad mono textures
offset_tmt = offset_qmt + size_qmt size_tmt = 1 + num_tri_mono_tex * 0x0C Tri mono textures
offset_tm = offset_tmt + size_tmt size_tm = num_tri_mono * 8 Tri mono
offset_qm = offset_tm + size_tm size_qm = num_quad_mono * 8 Quad mono
offset_tc = offset_qm + size_qm size_tc = num_tri_color * 0x10 Tri color
offset_qc = offset_tc + size_tc size_qc = num_quad_color * 0x14 Quad color

Animation Data Section

First, there are the channels, at offset <cpp>offset_data + 4</cpp>, which size is <cpp>num_channel * 8</cpp>. Then, for each channel :

Offset Size Data
offset_data + offset_frames_translation num_frames_translation * num_frames Translation frames
offset_data + offset_static_translation num_static_translation * 2 Static translation frames
offset_data + offset_frames_rotation num_frames_rotation * num_frames Rotation frames

Models Section

This section begins first with a model header of 16 bytes : <cpp> struct StrModelHeader {

   u32 psx_memory;  // Memory address to load the section into, maybe ?
   u32 num_models;  // Number of models.
   u32 texture_pointer; // Pointer to texture data.
   u32 unknown_pointer; // Pointer to something. We copy environment settings for models to where it points.

} </cpp>

Which is followed by num_models number of : <cpp> struct StrModel {

   u16 model_id;          // ID of the model
   u16 scale;             // (12 bit fixed point)
   u32 offset_skeleton;   // Offset to the parts, bones and animations of the model
   byte r, g, b;
   byte unknown[7];
   byte index_bones;      // Start index of bones
   byte unknown;
   byte r1, g1, b1;
   byte num_bones;        // Additional number of bones in the model's skeleton
   byte unknown[6];
   byte index_parts;      // Start index of parts
   byte unknown;
   byte r2, g2, b2;
   byte num_parts;        // Additional number of parts in the model's skeleton
   byte unknown[6];
   byte index_animations; // Start index of animations
   byte unknown;
   byte r3, g3, b3;
   byte num_animations;   // Additional number of animations

} // sizeof = 48 </cpp>

Please note that this is additional number of animations in case of settings for models that has BCX file. They load BCX animations, parts and bones first, then add BSX parts. For example cloud's sword in some fields added to normal BCX cloud file.

Then, for each model, we have the parts, bones and animations (at the offset offset_skeleton) :

<cpp> // Bones (if num_bones > 0) struct StrBone {

   byte unknown[4];

} // Parts (if num_parts > 0) struct StrPart {

   byte unknown;            // 0 - not calculate stage lighting and color. 1 - calculate.
   byte bone_index;         // bone to which this part attached to.
   byte num_vertex;         // Number of vertices
   byte num_texcoord;       // Number of Texture coord
   byte num_quad_color_tex; // number of textured quads (Gourad Shading)
   byte num_tri_color_tex;  // number of textured triangles (Gourad Shading)
   byte num_quad_mono_tex;  // number of textured quads (Flat Shading)
   byte num_tri_mono_tex;   // number of textured triangles (Flat Shading)
   byte num_tri_mono;       // number of monochrome triangles
   byte num_quad_mono;      // number of monochrome quads
   byte num_tri_color;      // number of gradated triangles
   byte num_quad_color;     // number of gradated quads
   u16 num_flags;           // number of data in block 4 (flags).
   u16 offset_poly;         // Relative offset to ?
   u16 offset_texcoord;     // Relative offset to ?
   u16 offset_flags;        // Relative offset to texture settings. Indexed by 5th block data (control).
   u16 offset_control;      // Relative offset to one byte stream for every packet with texture.
   u16 buffer_size;         // Relative offset to ?
   u32 offset_vertex;       // Offset to skeleton data section
   u32 offset_prec;         // Offset to ?

} // Animations (if num_animations > 0) struct StrAnimation {

   u16 num_frames;                // Number of frames
   byte num_bones;                // Number of bones
   byte num_frames_translation;   // Number of translation frames
   byte num_static_translation;   // Number of static translation frames
   byte num_frames_rotation;      // Number of rotation frames
   u16 offset_frames_translation; // Relative offset to translation frames
   u16 offset_static_translation; // Relative offset to static translation frames
   u16 offset_frames_rotation;    // Relative offset to rotation frames
   u32 offset_data;               // Offset to animation data section

} </cpp>

Rest of the file

The rest of the file is unknown for now.