model formats (3ds..lwo): comments are specs only
This commit is contained in:
1 parent
0bd7b87d2b
commit
3bddd582bc
35 files changed
+233
-697
No files matched your search
@@ -1,21 +1,7 @@
|
||||
--!strict
|
||||
-- model/b3d: Blitz3D .b3d (BB3D chunk format, version 1), read. Written from the Blitz3D file format description
|
||||
-- (blitzbasic.com "b3dfile_specs.txt") and checked against assimp's B3D importer.
|
||||
-- Reads: TEXS (texture files -> scene.textures, data through opts.files / opts.resolve, clamp flags -> sampler,
|
||||
-- position / scale / rotation -> the first texture's KHR_texture_transform, flag 65536 = second UV set), BRUS (brushes ->
|
||||
-- materials: colour + alpha, shininess -> roughness, FX 1 = unlit, 16 = double sided, 32 = blend; the first texture is
|
||||
-- baseColorTexture, the others are listed in extras.b3d.textures; texture flags 2 / 4 -> blend / mask), the NODE tree
|
||||
-- (name, position, scale, rotation; MESH -> one Mesh per node: VRTS -> POSITION / NORMAL / COLOR_0 (f32 RGBA) /
|
||||
-- TEXCOORD_0..7 shared by the mesh's primitives, one "triangles" primitive per TRIS chunk with its brush, else the
|
||||
-- mesh's master brush), BONE vertex weights -> a skin on the mesh read last before the bone (the 4 strongest weights
|
||||
-- per vertex, normalised, JOINTS_0 / WEIGHTS_0; vertices no bone moves follow the mesh node, which then joins the
|
||||
-- joints; inverse bind matrices from the bind pose), KEYS (position / scale / rotation keys) + ANIM (frames, fps,
|
||||
-- default 60) -> one animation of LINEAR channels at frame / fps seconds.
|
||||
-- Blitz3D is left-handed and Y up: z is mirrored (positions, normals, translations, keys), the triangle winding
|
||||
-- reversed and the rotations mirrored, so the scene is glTF's right-handed Y up (meta.up = "y"). UVs keep their
|
||||
-- top-left origin (= glTF). meta.source = { format, version, brushes, frames?, fps?, handedness = "left" }.
|
||||
-- Not supported: writing; multiple VRTS chunks in one MESH (the first is used); per-brush blend modes beyond the
|
||||
-- extras; texture coordinate sets of 3 / 4 components keep their first two.
|
||||
-- model/b3d: Blitz3D .b3d (BB3D chunks, version 1; blitzbasic.com "b3dfile_specs.txt", checked against assimp).
|
||||
-- Supports: TEXS, BRUS, NODE / MESH / VRTS / TRIS, BONE skins, KEYS + ANIM; left-handed, so z is mirrored.
|
||||
-- Not supported: writing; several VRTS chunks in one MESH (the first is used); 3 / 4 component texture coordinates.
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ requires
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -35,10 +21,10 @@ local B3d = {
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ types
|
||||
export type DecodeOptions = {
|
||||
resolve: ((uri: string) -> any)?, -- texture files (the api sets it for paths)
|
||||
files: { [string]: any }?, -- or: the files by name
|
||||
resolve: ((uri: string) -> any)?,
|
||||
files: { [string]: any }?,
|
||||
maxVertices: number?, -- default 2^24
|
||||
maxDepth: number?, -- node nesting (default 256)
|
||||
maxDepth: number?, -- default 256
|
||||
}
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ sniff
|
||||
@@ -54,7 +40,6 @@ function B3d.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Scene?, Err.E
|
||||
if r:peek(4) ~= "BB3D" then
|
||||
return nil, Err.new(Err.CORRUPT, "no BB3D chunk")
|
||||
end
|
||||
-- the scene builder is plain (not native) code: a bug there must not escape as an error
|
||||
local ok, scene, msg, kind = pcall(Read.scene, r, opts)
|
||||
if not ok then
|
||||
return nil, Err.new(Err.CORRUPT, "bad chunk tree: " .. tostring(scene))
|
||||
|
||||
Reference in new issue
Block a user