gameplay-binary.txt 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. gameplay Binary file format
  2. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. File Description
  4. ================
  5. A sample binary file format supporting definition of primitve and builtin objects.
  6. File Extension and Mime Type
  7. ============================
  8. File extension is '.bbb' and the mime type is 'application/bbb'
  9. File Structure
  10. ===============
  11. Section Name Type
  12. ------------------------------------------------------------------------------------------------------
  13. Header
  14. Identifier byte[9] = { '«', 'G', 'P', 'B', '»', '\r', '\n', '\x1A', '\n' }
  15. Version byte[2] = { 1, 1 }
  16. References Reference[]
  17. Data
  18. Objects Object[]
  19. Objects
  20. ===========
  21. Supported object types are defined in the table below. Object with unique ids are included
  22. in the Reference table (see below).
  23. References
  24. ===========
  25. A Reference is an Object that has a unique id. The Reference contains the unique id of the
  26. object, a uint for the TypeID a uint for the offset into the package for the object definition.
  27. ID's
  28. ===========
  29. Object ID's are represented as a string which is guaranteed to be unique per file.
  30. Any object which host an object id should be added to the header Reference table so that it can
  31. be consumed by reference internally and externally.
  32. Xrefs
  33. ===========
  34. Xrefs are string with a specific format used for referencing objects internal and external to
  35. a package. An xref with the format "#id" references an object within the current package with
  36. the given ID. Xrefs can also have the format "file#id", where "file" is the name of package file
  37. (relative to the locaiton of the current package) and "id" is the unique identifier of an object
  38. in that package.
  39. Primitives
  40. ===========
  41. Name Description
  42. ------------------------------------------------------------------------------------------------------
  43. string 8-bit char array prefixed by unint for length encoding.
  44. bool 8-bit unsigned char false=0, true=1.
  45. byte 8-bit unsigned char
  46. uint 32-bit unsigned int, stored as four bytes, lowest byte first.
  47. int 32-bit signed int, stored as four bytes, lowest byte first.
  48. float 32-bit float, stored as four bytes, with the least significant
  49. byte of the mantissa first, and the exponent byte last.
  50. enum X A uint which is restricted to values from the given enum name "X".
  51. Arrays
  52. ======
  53. Arrays of constant length are simply the array of data for the expected type.
  54. Arrays of dynamic size length(uint) encoded followed by expected type of data.
  55. Notation: byte[3] - constant length notation = byte[3]
  56. int[] - dynamic length notation = length+int[count]
  57. Mesh[] - dynamic length notation = length+Mesh[count]
  58. Enums
  59. =====
  60. enum VertexUsage
  61. {
  62. POSITION = 1,
  63. NORMAL = 2,
  64. COLOR = 3,
  65. TANGENT = 4,
  66. BINORMAL = 5,
  67. BLENDWEIGHTS = 6,
  68. BLENDINDICES = 7,
  69. TEXCOORD0 = 8,
  70. TEXCOORD1 = 9,
  71. TEXCOORD2 = 10,
  72. TEXCOORD3 = 11,
  73. TEXCOORD4 = 12,
  74. TEXCOORD5 = 13,
  75. TEXCOORD6 = 14,
  76. TEXCOORD7 = 15
  77. }
  78. enum FontStyle
  79. {
  80. PLAIN = 0,
  81. BOLD = 1,
  82. ITALIC = 2,
  83. BOLD_ITALIC = 4
  84. }
  85. enum PrimitiveType
  86. {
  87. TRIANGLES = GL_TRIANGLES (4),
  88. TRIANGLE_STRIP = GL_TRIANGLE_STRIP (5),
  89. LINES = GL_LINES (1),
  90. LINE_STRIP = GL_LINE_STRIP (3),
  91. POINTS = GL_POINTS (0)
  92. }
  93. enum IndexFormat
  94. {
  95. INDEX8 = GL_UNSIGNED_BYTE (0x1401),
  96. INDEX16 = GL_UNSIGNED_SHORT (0x1403),
  97. INDEX32 = GL_UNSIGNED_INT (0x1405)
  98. }
  99. enum NodeType
  100. {
  101. NODE = 1,
  102. JOINT = 2
  103. }
  104. Object Definitions
  105. ==================
  106. TypeID->Name Member Type
  107. ------------------------------------------------------------------------------------------------------
  108. Reference
  109. id string
  110. type uint
  111. offset uint
  112. ------------------------------------------------------------------------------------------------------
  113. 1->Scene
  114. nodes Node[]
  115. activeCameraNode xref:Node
  116. ambientColor float[3]
  117. ------------------------------------------------------------------------------------------------------
  118. 2->Node
  119. type enum NodeType
  120. transform float[16]
  121. children Node[]
  122. camera Camera
  123. light Light
  124. model Model
  125. ------------------------------------------------------------------------------------------------------
  126. 3->Animations
  127. animations Animation[]
  128. ------------------------------------------------------------------------------------------------------
  129. 4->Animation
  130. id string
  131. channels AnimationChannel[]
  132. -----------------------------------------------------------------------------------------------------
  133. 5->AnimationChannel
  134. targetId string
  135. targetAttribute uint
  136. keyTimes unsigned long[] (milliseconds)
  137. values float[]
  138. tangents_in float[]
  139. tangents_out float[]
  140. interpolation uint[]
  141. ------------------------------------------------------------------------------------------------------
  142. 11->Model
  143. mesh xref:Mesh
  144. meshSkin MeshSkin
  145. materials Material[]
  146. ------------------------------------------------------------------------------------------------------
  147. 16->Material
  148. parameters MaterialParameter[] { string name, float[] value, uint type }
  149. effect xref:Effect
  150. ------------------------------------------------------------------------------------------------------
  151. 17->Effect
  152. vertexShader string
  153. fragmentShader string
  154. ------------------------------------------------------------------------------------------------------
  155. 32->Camera
  156. cameraType byte {perspective|orthographic}
  157. aspectRatio float
  158. nearPlane float
  159. farPlane float
  160. [ cameraType : perspective
  161. fieldOfView float
  162. ]
  163. [ cameraType : orthographic
  164. magnification float[2]
  165. ]
  166. ------------------------------------------------------------------------------------------------------
  167. 33->Light
  168. lightType byte {directional|point|spot}
  169. color float[3]
  170. [ lightType : point
  171. range float
  172. ]
  173. [ lightType : spot
  174. range float
  175. innerAngle float (in radians)
  176. outerAngle float (in radians)
  177. ]
  178. ------------------------------------------------------------------------------------------------------
  179. 34->Mesh
  180. vertexFormat VertexElement[] { enum VertexUsage usage, unint size }
  181. vertices byte[]
  182. parts MeshPart[]
  183. boundingBox BoundingBox { float[3] min, float[3] max }
  184. boundingSphere BoundingSphere { float[3] center, float radius }
  185. ------------------------------------------------------------------------------------------------------
  186. 35->MeshPart
  187. primitiveType enum PrimitiveType
  188. indexFormat enum IndexFormat
  189. indices byte[]
  190. ------------------------------------------------------------------------------------------------------
  191. 36->MeshSkin
  192. bindShape float[16]
  193. joints xref:Node[]
  194. jointsBindPoses float[] // 16 * joints.length
  195. boundingBox BoundingBox { float[3] min, float[3] max }
  196. boundingSphere BoundingSphere { float[3] center, float radius }
  197. ------------------------------------------------------------------------------------------------------
  198. 128->Font
  199. family string
  200. style enum FontStyle
  201. size uint
  202. charset string
  203. glyphs Glyph[] { uint index, uint width, float[4] uvCoords }
  204. texMapWidth uint
  205. texMapHeight uint
  206. texMap byte[]