diff --git a/rust/Cargo.lock b/rust/Cargo.lock index ecf4184..5be4d1f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -242,6 +242,12 @@ dependencies = [ "weezl", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "half" version = "2.2.1" @@ -357,6 +363,7 @@ dependencies = [ name = "mhex" version = "0.1.0" dependencies = [ + "glob", "lightwave", "starforcelib", ] diff --git a/rust/lightwave/README.md b/rust/lightwave/README.md index 4210063..4d98514 100644 --- a/rust/lightwave/README.md +++ b/rust/lightwave/README.md @@ -1,3 +1,4 @@ # LightWave 3D Rust Parser -* [LWO2 Spec](http://static.lightwave3d.com/sdk/2015/html/filefmts/lwo2.html) \ No newline at end of file +* [LWO2 Spec](http://static.lightwave3d.com/sdk/2015/html/filefmts/lwo2.html) + * Progress: about 90% (?) complete, so most things should load. \ No newline at end of file diff --git a/rust/lightwave/src/lwo2/mod.rs b/rust/lightwave/src/lwo2/mod.rs index 203132b..e470608 100644 --- a/rust/lightwave/src/lwo2/mod.rs +++ b/rust/lightwave/src/lwo2/mod.rs @@ -16,7 +16,7 @@ where R: Read + Seek, { let kind: u16 = reader.read_type(endian)?; - Ok(if (kind & 0xff) != 0xff { + Ok(if kind < 0xff00 { kind as u32 } else { (((kind as u32) & 0xff) << 16) | (reader.read_type::(endian)? as u32) diff --git a/rust/lightwave/src/lwo2/tags/image_clip.rs b/rust/lightwave/src/lwo2/tags/image_clip.rs new file mode 100644 index 0000000..469c1f2 --- /dev/null +++ b/rust/lightwave/src/lwo2/tags/image_clip.rs @@ -0,0 +1,146 @@ +use crate::binrw_helpers::until_size_limit; +use crate::iff::SubChunk; +use crate::lwo2::tags::surface_definition::ValueEnvelope; +use binrw::{binread, NullString}; + +/// Describes an image or a sequence of images. Surface definitions specify images by referring to +/// CLIP chunks. The term "clip" is used to describe these because they can be numbered sequences +/// or animations as well as stills. The index identifies this clip uniquely and may be any non-zero +/// value less than 0x1000000. The filename and any image processing modifiers follow as a variable +/// list of subchunks, which are documented below in the Clip Subchunks section. +#[binread] +#[br(import(length: u32))] +#[derive(Debug)] +pub struct ImageClip { + pub index: u32, + #[br(parse_with = until_size_limit(length as u64 - 4))] + pub attributes: Vec, +} + +#[binread] +#[derive(Debug)] +pub enum ImageClipSubChunk { + #[br(magic(b"STIL"))] + StillImage(SubChunk), + #[br(magic(b"ISEQ"))] + ImageSequence(SubChunk), + #[br(magic(b"XREF"))] + Reference(SubChunk), + #[br(magic(b"FLAG"))] + Flag(SubChunk), + #[br(magic(b"STCC"))] + ColorCyclingStill(SubChunk), + #[br(magic(b"TIME"))] + Time(SubChunk