mirror of
https://github.com/Theaninova/mhlib.git
synced 2025-12-11 03:56:18 +00:00
lwo2 parser feature complete
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# LightWave 3D Rust Parser
|
||||
|
||||
Complete LWO2 parser for Rust.
|
||||
|
||||
Basic Usage
|
||||
|
||||
```rust
|
||||
@@ -14,7 +16,7 @@ fn main() {
|
||||
|
||||
## LightWave Object (LWO2)
|
||||
|
||||
Progress: About 90% ([LWO2 Spec](http://static.lightwave3d.com/sdk/2015/html/filefmts/lwo2.html))
|
||||
Fully feature complete following the [LWO2 Spec](http://static.lightwave3d.com/sdk/2015/html/filefmts/lwo2.html).
|
||||
|
||||
| Chunk | Tag | Status |
|
||||
|--------------------------------------------|--------|--------|
|
||||
@@ -107,7 +109,7 @@ Progress: About 90% ([LWO2 Spec](http://static.lightwave3d.com/sdk/2015/html/fil
|
||||
|
||||
Ordinal Strings:
|
||||
* ✅ [Image Texture Map](#image-texture-map) `IMAP`
|
||||
* ❌ [Procedural Texture](#procedural-texture) `PROC`
|
||||
* ✅ [Procedural Texture](#procedural-texture) `PROC`
|
||||
* ✅ [Gradient Texture](#gradient-texture) `GRAD`
|
||||
* ✅ [Shader Plugin](#shaders) `SHDR`
|
||||
|
||||
@@ -150,9 +152,9 @@ Ordinal Strings:
|
||||
|
||||
| Chunk | Tag | Status |
|
||||
|--------------------------|--------|--------|
|
||||
| Axis | `AXIS` | ❌ |
|
||||
| Basic Value | `VALU` | ❌ |
|
||||
| Algorithm and Parameters | `FUNC` | ❌ |
|
||||
| Axis | `AXIS` | ✅ |
|
||||
| Basic Value | `VALU` | ✅ |
|
||||
| Algorithm and Parameters | `FUNC` | ✅ |
|
||||
|
||||
#### Gradient Texture
|
||||
|
||||
|
||||
@@ -2,15 +2,14 @@ use crate::binrw_helpers::until_size_limit;
|
||||
use crate::iff::SubChunk;
|
||||
use crate::lwo2::sub_tags::blocks::gradient_texture::GradientTextureSubChunk;
|
||||
use crate::lwo2::sub_tags::blocks::image_texture::SurfaceBlockImageTextureSubChunk;
|
||||
use crate::lwo2::sub_tags::blocks::shaders::ShaderAlgorithm;
|
||||
use crate::lwo2::sub_tags::blocks::procedural_texture::ProceduralTextureSubChunk;
|
||||
use crate::lwo2::sub_tags::EnableState;
|
||||
use crate::lwo2::vx;
|
||||
use binrw::binread;
|
||||
use binrw::{binread, NullString};
|
||||
|
||||
pub mod gradient_texture;
|
||||
pub mod image_texture;
|
||||
pub mod procedural_texture;
|
||||
pub mod shaders;
|
||||
pub mod texture_mapping;
|
||||
|
||||
#[binread]
|
||||
@@ -24,7 +23,11 @@ pub enum SurfaceBlocks {
|
||||
attributes: Vec<SurfaceBlockImageTextureSubChunk>,
|
||||
},
|
||||
#[br(magic(b"PROC"))]
|
||||
ProceduralTexture,
|
||||
ProceduralTexture {
|
||||
header: SubChunk<SurfaceBlockHeader>,
|
||||
#[br(parse_with = until_size_limit(length as u64 - (header.length as u64 + 2 + 4)))]
|
||||
attributes: Vec<ProceduralTextureSubChunk>,
|
||||
},
|
||||
#[br(magic(b"GRAD"))]
|
||||
GradientTexture {
|
||||
header: SubChunk<SurfaceBlockHeader>,
|
||||
@@ -35,10 +38,20 @@ pub enum SurfaceBlocks {
|
||||
ShaderPlugin {
|
||||
header: SubChunk<SurfaceBlockHeader>,
|
||||
#[br(magic(b"FUNC"))]
|
||||
algorithm: SubChunk<ShaderAlgorithm>,
|
||||
algorithm: SubChunk<Algorithm>,
|
||||
},
|
||||
}
|
||||
|
||||
#[binread]
|
||||
#[br(import(length: u32))]
|
||||
#[derive(Debug)]
|
||||
pub struct Algorithm {
|
||||
#[br(align_after = 2)]
|
||||
pub algorithm_name: NullString,
|
||||
#[br(count = length - (algorithm_name.len() as u32 + 1))]
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
|
||||
#[binread]
|
||||
#[br(import(length: u32))]
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
use crate::iff::SubChunk;
|
||||
use crate::lwo2::sub_tags::blocks::Algorithm;
|
||||
use binrw::binread;
|
||||
|
||||
#[binread]
|
||||
#[derive(Debug)]
|
||||
pub enum ProceduralTextureSubChunk {
|
||||
#[br(magic(b"AXIS"))]
|
||||
Axis(SubChunk<Axis>),
|
||||
#[br(magic(b"VALU"))]
|
||||
BasicValue(SubChunk<BasicValue>),
|
||||
#[br(magic(b"FUNC"))]
|
||||
AlgorithmAndParameters(SubChunk<Algorithm>),
|
||||
}
|
||||
|
||||
/// Procedurals are often modulations between the current channel value and another value, given
|
||||
/// here. This may be a scalar or a vector.
|
||||
#[binread]
|
||||
#[br(import(length: u32))]
|
||||
#[derive(Debug)]
|
||||
pub struct BasicValue {
|
||||
#[br(count = length / 4)]
|
||||
pub value: Vec<f32>,
|
||||
}
|
||||
|
||||
/// If the procedural has an axis, it may be defined with this chunk using a value of 0, 1 or 2.
|
||||
#[binread]
|
||||
#[br(import(_length: u32))]
|
||||
#[derive(Debug)]
|
||||
pub struct Axis {
|
||||
pub axis: u16,
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
use binrw::{binread, NullString};
|
||||
|
||||
#[binread]
|
||||
#[br(import(length: u32))]
|
||||
#[derive(Debug)]
|
||||
pub struct ShaderAlgorithm {
|
||||
#[br(align_after = 2)]
|
||||
pub algorithm_name: NullString,
|
||||
#[br(count = length - (algorithm_name.len() as u32 + 1))]
|
||||
pub data: Vec<u8>,
|
||||
}
|
||||
Reference in New Issue
Block a user