model formats (mca..x3d): comments are specs only
This commit is contained in:
1 parent
0bd7b87d2b
commit
b952c10222
49 files changed
+310
-936
No files matched your search
@@ -1,11 +1,6 @@
|
||||
--!strict
|
||||
-- model/md5/Read: Doom 3 / Quake 4 MD5 text (MD5Version 10) to Scenes. md5mesh: joints (model-space bind pose:
|
||||
-- position + unit quaternion with w = -sqrt(1 - x² - y² - z²)) -> joint nodes and a Skin, each mesh -> a primitive
|
||||
-- (positions from the weights in the bind pose, normals computed, texture coordinates as stored, triangles reversed
|
||||
-- to counter-clockwise, JOINTS_0 / WEIGHTS_0 from the weights), its shader -> a material / texture URI. md5anim:
|
||||
-- hierarchy + baseframe (parent-relative) + frames of animated components -> translation / rotation channels at
|
||||
-- frameRate, applied to the joint nodes of the same names. Written from the format notes of the Doom 3 modding
|
||||
-- community (modwiki "MD5 (file format)", David Henry's "The MD5 Mesh and Animation Formats"); no code taken.
|
||||
-- model/md5/Read: MD5Version 10 text, from modwiki "MD5 (file format)" and David Henry's "The MD5 Mesh and Animation
|
||||
-- Formats"; no code taken. The bind pose is model space, the baseframe parent-relative.
|
||||
local Types = require("@rosetta/Types")
|
||||
local Rig = require("@rosetta/codecs/model/Rig")
|
||||
|
||||
@@ -93,7 +88,7 @@ local function vec(L: Lexer, n: number): { number }
|
||||
return v
|
||||
end
|
||||
|
||||
-- the unit quaternion from its x, y, z (w <= 0, as id's tools store it)
|
||||
-- w = -sqrt(1 - x² - y² - z²) (w <= 0, as id's tools store it)
|
||||
local function quat(x: number, y: number, z: number): { number }
|
||||
local t = 1 - x * x - y * y - z * z
|
||||
return { x, y, z, if t < 0 then 0 else -math.sqrt(t) }
|
||||
@@ -109,7 +104,6 @@ end
|
||||
-- ------------------------------------------------------------------------------------------------ md5mesh
|
||||
type MeshJoint = { name: string, parent: number, pos: { number }, q: { number } }
|
||||
|
||||
-- mesh(text, opts) -> Scene, joint node indices by name | nil, message
|
||||
function Read.mesh(text: string, opts: Options?): (Types.Scene?, any)
|
||||
local L: Lexer = { text = text, pos = 1, err = nil }
|
||||
local joints: { MeshJoint } = {}
|
||||
@@ -277,7 +271,6 @@ export type Anim = {
|
||||
tracks: { Rig.Track }, -- per joint: translation / rotation keys, one per frame
|
||||
}
|
||||
|
||||
-- anim(text) -> Anim | nil, message
|
||||
function Read.anim(text: string): (Anim?, string?)
|
||||
local L: Lexer = { text = text, pos = 1, err = nil }
|
||||
local a: Anim = { frameRate = 24, frames = 0, joints = {}, base = {}, tracks = {} }
|
||||
@@ -396,7 +389,6 @@ function Read.anim(text: string): (Anim?, string?)
|
||||
return a, nil
|
||||
end
|
||||
|
||||
-- addAnim(scene, nodes by joint name, anim, name) -> channels added
|
||||
function Read.addAnim(scene: Types.Scene, byName: { [string]: number }, a: Anim, name: string): number
|
||||
local nodes: { number } = {}
|
||||
local tracks: { [number]: Rig.Track } = {}
|
||||
@@ -416,7 +408,6 @@ function Read.addAnim(scene: Types.Scene, byName: { [string]: number }, a: Anim,
|
||||
return #scene.animations[ai].channels
|
||||
end
|
||||
|
||||
-- animScene(a, name) -> a Scene of the animation's skeleton (baseframe pose) with the animation
|
||||
function Read.animScene(a: Anim, name: string): Types.Scene
|
||||
local scene = Scene.new()
|
||||
scene.meta.up = "z"
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
--!strict
|
||||
-- model/md5: Doom 3 / Quake 4 MD5 models (MD5Version 10 text): .md5mesh (skeleton, skin, meshes) and .md5anim
|
||||
-- (skeletal animation), read into a Scene through model/md5/Read. A .md5mesh loads its animations from
|
||||
-- opts.anims = { "idle.md5anim", ... } (each found through opts.files[name] or opts.resolve(name); joints matched by
|
||||
-- name; the animation is named after the file without its extension); a missing one fails with UNSUPPORTED unless
|
||||
-- opts.skipMissing. A .md5anim alone loads as its skeleton (baseframe pose) with the animation. Units are Doom
|
||||
-- units, z up. Not supported: writing, .md5camera.
|
||||
-- model/md5: Doom 3 / Quake 4 MD5 (MD5Version 10 text): .md5mesh and .md5anim (model/md5/Read); a mesh loads
|
||||
-- opts.anims, joints matched by name. Not supported: writing, .md5camera.
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ requires
|
||||
local Err = require("@rosetta/core/Err")
|
||||
@@ -26,11 +22,11 @@ local Md5 = {
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ types
|
||||
export type DecodeOptions = {
|
||||
anims: { string }?, -- .md5anim files to load with a .md5mesh
|
||||
anims: { string }?,
|
||||
resolve: ((uri: string) -> (buffer | string)?)?,
|
||||
files: { [string]: buffer | string }?,
|
||||
skipMissing: boolean?, -- ignore animations that cannot be found (default false: UNSUPPORTED)
|
||||
name: string?, -- the file name (names a standalone animation)
|
||||
skipMissing: boolean?, -- default false: UNSUPPORTED
|
||||
name: string?,
|
||||
maxVertices: number?, -- default 2^24
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user