cr88192

BGBTech3 Engine, possible mesh format.

Apr 19th, 2025
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.57 KB | Software | 0 0
  1. Mesh Model Format (Possible, for BGBTech3 Engine):
  2. * May contain basic non-animated meshes.
  3. ** May also allow for animated meshes.
  4. ** Single bone only for now.
  5. * One mesh per material, up to 1024 vertices per mesh.
  6. * Format will be image-like.
  7. ** Will be defined in terms of offsets relative to image base.
  8.  
  9. Mesh Vertex:
  10. * 64-bit
  11. ** (63:56): Bone ID (if animated, 0=Base)
  12. ** (55:44): T
  13. ** (43:32): S
  14. ** (31:27): Exponent
  15. ** (26:18): Frac Z
  16. ** (17: 9): Frac Y
  17. ** ( 8: 0): Frac X
  18.  
  19. S/T coordinates will be mapped roughly -0.500 to 1.499, with a fixed point accuracy of 1/2048 over the skin texture. Coordinates outside the range of 0.0 to 1.0 are primarily intended to deal with seams.
  20.  
  21. Vertex coordinates will be stored relative to the local coordinate space of the bone in question.
  22.  
  23. Mesh Triangle (32 bit):
  24. * (31:30): Tag
  25. * (29:20): V2
  26. * (19:10): V1
  27. * ( 9: 0): V0
  28.  
  29. Bone Tranform
  30. * (63:56): Rot R (F8A)
  31. * (55:48): Rot K (F8A)
  32. * (47:40): Rot J (F8A)
  33. * (39:32): Rot I (F8A)
  34. * (31:27): Org Exponent
  35. * (26:18): Frac Org Z
  36. * (17: 9): Frac Org Y
  37. * ( 8: 0): Frac Org X
  38.  
  39.  
  40. F8A: S.E3.F4, Unit Range
  41. * For I/J/K/R, these will be interpreted as a unit quaternion.
  42. ** After unpacking, the quaternion is to be normalized.
  43.  
  44. Anim Rotation (32 bit)
  45. * (31:24): Rot R (F8A)
  46. * (23:16): Rot K (F8A)
  47. * (15: 8): Rot J (F8A)
  48. * ( 7: 0): Rot I (F8A)
  49.  
  50. Anim Translation or Scale (32 bit)
  51. * (31:27): Exponent
  52. * (26:18): Frac Z
  53. * (17: 9): Frac Y
  54. * ( 8: 0): Frac X
  55.  
  56. The fraction will be a signed-extended non-normalized value which will be scaled by the exponent.
  57.  
  58.  
  59. Header {
  60. u32 magic1; //00, 'BMD1'
  61. u32 resv1; //04, MBZ
  62. u32 resv2; //08, MBZ
  63. u32 resv3; //0C, MBZ
  64. u32 ofs_meshes; //10, Mesh List
  65. u32 sz_meshes; //14, Size of Mesh List (bytes)
  66. u32 ofs_lods; //18, LODs List
  67. u32 sz_lods; //1C, Size of LODs List (bytes)
  68. u32 ofs_bones; //20, Bone List, MBZ if static
  69. u32 sz_bones; //24, Size of Bones (bytes), MBZ if static
  70. u32 ofs_anims; //28, Anim List, MBZ if static
  71. u32 sz_anims; //2C, Size of Anim List, MBZ if static
  72. }
  73.  
  74. MeshDef {
  75. u32 ofs_vtx; //00, offset of vertices list in image
  76. u32 ofs_tris; //04, offset of triangles list
  77. u32 ofs_mat; //08, material name string
  78. u16 n_vtx; //0C, number of vertices (0..1024)
  79. u16 n_tris; //0E, number of triangles
  80. }
  81.  
  82. LodDef {
  83. byte id_mesh; //00, Index of first mesh at LOD level
  84. byte n_mesh; //01, Number of meshes in LOD level
  85. byte ld_sc; //02, Nominal scale (F8A)
  86. byte resv1; //03, MBZ
  87. }
  88.  
  89. BoneDef {
  90. u64 xform; //00, base transform (MBZ for Bone 0)
  91. u32 ofs_name; //08, bone name string (Bones 1+)
  92. byte id_parent; //0C, parent bone (MBZ for 0, 0xFF for Pseudo-Bone)
  93. byte id_solid; //0D, mesh to use for solid def for bone.
  94. byte resv1; //0E, MBZ
  95. byte resv2; //0F, MBZ
  96. }
  97.  
  98. AnimDef {
  99. u32 ofs_name; //00, Offset of animation name
  100. byte n_framees; //04, number of frames in this animation loop
  101. byte fl_hz; //05, (7)=No Loop, (6:0): Anim Hz (in units of 0.25 Hz)
  102. byte resv1; //06, MBZ
  103. byte resv2; //07, MBZ
  104. u32 ofs_frames; //08, Offset of frames list
  105. u32 sz_frames; //0C, Size of frames list.
  106. }
  107.  
  108. If the mesh ofs_mat is 0 (Null String), this mesh nay not be drawn. However, non-drawn meshes may be used for bone solids.
  109.  
  110. Each LOD will be defined as a range of meshes. Only drawable meshes will be present in a LOD. Nominal scale algo will be defined as 1.0/(dist+1.0) with the distance defined in meters from the viewer.
  111.  
  112. Meshes used for bone solids need not be renderable, but may be renderable. They will be required to be in BREP form (fully enclosed volume, may be non-convex but may not self-intersect). The entire mesh is to be mapped to a single bone (equal to the bone for which the solid is being defined, or to bone 0). The coordinate space will be understood as relavite to the bone they are applied to (regardless of the bone specified for the vertex).
  113.  
  114. Note that if vertices are duplicated for sake of texture seam handling, even if at the same location in 3D space, the mesh will no longer be in BREP form.
  115.  
  116. Renderable meshes with more than 1024 vertices may be subdivided into meshes with fewer than 1024 vertices, which are also by definition not in BREP form. However, this format isn't really indended to be used for high triangle count models.
  117.  
  118. Possible, Pseudo-Bones:
  119. * Will be special bones.
  120. * xform will be understood as 4 bone IDs, and 4 F8A weights.
  121.  
  122. Pseudo bones will follow after any normal bones and their transforms will not be specified in animation frames. Their position in a given animation frame will be calculated based on the weights (after any interpolation for the normal bones). As for mesh vertex transform, they are handled the same as normal bones.
  123.  
  124.  
  125. Animation frames will nominally represent n_frames*n_bones sets of transformations.
  126.  
  127. However, animation frames will be stored in a compacted form, with a tag byte:
  128. * (7): Rotation Present
  129. * (6): Translation Present
  130. * (5): Scale Prsent
  131. * (4:0): Number of preceding bones to skip during this frame.
  132.  
  133. A tag of 00 will signal the end of the current frame.
  134. * Each tag will be followed by the rotation, translation, and scale, if present.
  135.  
  136. If a value is skipped in the current frame, its value will be interpolated.
  137. * If absent in all frames, it will assume a default (identity) value.
  138.  
  139. The defined interpolation will be to linearly interpolate values, with rotations being renormalized after interpolation. The combination of rotation, translation, and scale, may be used to construct a transformation matrix that may be applied when calculating final mesh vertex positions for a given frame.
  140.  
  141.  
Advertisement
Add Comment
Please, Sign In to add comment