Module b3d_reader

parse .b3d files into a lua table.

This is apart of the LEEF-b3d module

note: capitlization of name indicates a "chunk" defined by the blitz3d format (see b3d_specification.txt)

Functions

read_model (modelname, node_only) read b3d models by their name.
read_from_stream (stream, ignore_chunks) read directly from file

Tables

ignore_chunks an unordered list of chunks to be ignored.
keyframe table which specifies a keyframe.
node_paths node paths a list of nodes indexed by a hieracrchy of nodes i.e.

chunks

VRTS vertices
TRIS triangle/poly sets
MESH the mesh chunk table
BONE bone table a list of vertex weights indexed by their vertex_id
KEYS keyframes.
ANIM defines the animation of a model
NODE node a node chunk possibly containing the following chunks.
BB3D b3d table structure outputted by the b3d reader.


Functions

read_model (modelname, node_only)
read b3d models by their name. This simplifies read_from_stream.

Parameters:

  • modelname string, the name of model you are trying to read.
  • node_only bool, specifies wether to ignore textures, meshes, or anything else. Use this if you're only trying to solve bone transforms.

Returns:

    BB3D
read_from_stream (stream, ignore_chunks)
read directly from file

Parameters:

  • stream the file object (from the io library) to read from. Make sure you open it as "rb" (read binary.)
  • ignore_chunks a list in the format of ignore_chunks

Returns:

    BB3D

Tables

ignore_chunks
an unordered list of chunks to be ignored. "NODE" and "BB3D" are ommitted as they are not allowed.

Fields:

  • 1 "TEXS" texture information
  • 2 "BRUS" brushes (materials)
  • 3 "MESH" (sub-chunks of "MESH" include "VERTS" & "TRIS")
  • 4 "TRIS" sets of triangles
  • 5 "VRTS" vertices
  • 6 "BONE" node vertex weights
  • 7 "ANIM" animation information
  • 8 "KEYS" keyframes
keyframe
table which specifies a keyframe. This is apart of the node chunk

Fields:

  • position position relative to parent {x,y,z}
  • rotation quaternion rotation {x,y,z,w}
  • scale scale of the node {x,y,z}
node_paths
node paths a list of nodes indexed by a hieracrchy of nodes i.e. "path.to.node"

Fields:

  • ... ) node

chunks

VRTS
vertices

Fields:

  • flags uknown
  • tex_coord_sets the number of texture coordinate sets
  • tex_coord_set_size unknown
  • ... a list of vertices, the integer index defines their vertexids { pos={x,y,z}, color={r, g, b, a}, texcoords=... }
TRIS
triangle/poly sets

Fields:

  • brush_id
  • vertex_ids a list of three vertex IDs {i, j, k} which make it up
MESH
the mesh chunk table

Fields:

  • brush_id (may not exist) brush from brush chunk to use
  • vertices VRTS vertices and indexed by their ID and additional info
  • triangle_sets TRIS a list of three vertices to be used in
BONE
bone table a list of vertex weights indexed by their vertex_id
KEYS
keyframes. a list of keyframes

Fields:

  • flags defines if position rotation and scale exists (further explanation needed)
  • ... a list of keyframes
ANIM
defines the animation of a model

Fields:

  • flags unused?
  • frames number of frames
  • fps framerate of the model
NODE
node a node chunk possibly containing the following chunks. there are three possible "types" of nodes. All bones will contain the following chunks: position, rotation, scale. Bones will have a bone field which will contain IDs from it's parent node's mesh chunk.

Fields:

  • name
  • type string which is either "pivot", "bone" or "mesh"
  • children a list of child {nodes, Transformations (position, rotation, scale) will be applied to the children.
  • position position {x, y, z} of the bone
  • rotation quaternion {x, y, z, w} rotation of the bone at rest
  • scale {x, y, z} scale of the bone at rest
  • mesh MESH chunk. Found in mesh node
  • bone BONE chunk. Found in bone node
  • keys KEYS chunk. Found in bone node
  • animation ANIM chunk. Typically found in root node (uknown wether it can be elsewhere.)
  • parent the parent node. (The node in which this node is in the children table)
BB3D
b3d table structure outputted by the b3d reader. Note: in the b3d writer the node_paths field is ignored

Fields:

  • node_paths all of the nodes in the model b3d_nodes
  • node a table containing the root NODE of the model.
  • textures TEXS texture information. TEXS not currently documented as not currently useful for minetest purposes
  • brushes BRUS material information. BRUS not currently documented as not currently useful for minetest purposes
  • version {major=float, minor=float} this functionally means nothing, but it's version information.
generated by LDoc 1.5.0 Last updated 2025-01-20 00:28:08