1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! Supported MDX versions as types.
use std::fmt::Debug;
use crate::model::geometry::GeosetLayout;
use crate::model::materials::MaterialLayout;
use crate::model::scene::{CameraLayout, LightLayout};
use crate::model::Version;
mod sealed {
pub trait Sealed {}
}
/// A version whose record layout is known by this library.
pub trait ModelVersion:
sealed::Sealed + MaterialLayout + GeosetLayout + CameraLayout + LightLayout + Clone + Debug + Eq
{
/// Numeric format version written in the `VERS` chunk.
const NUMBER: Version;
}
macro_rules! versions {
($($name:ident = $number:literal),* $(,)?) => {$ (
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[doc = concat!("A marker selecting model format version ", stringify!($number), " and its record layout.")]
pub struct $name;
impl sealed::Sealed for $name {}
impl ModelVersion for $name {
const NUMBER: Version = $number;
}
)* };
}
versions!(
V800 = 800,
V900 = 900,
V1000 = 1000,
V1100 = 1100,
V1200 = 1200,
V1300 = 1300,
V1400 = 1400,
V1600 = 1600,
V1800 = 1800
);
macro_rules! version_capabilities {
($(
$(#[$meta:meta])*
$vis:vis trait $name:ident for $($version:ident),+;
)+) => {
$(
$(#[$meta])*
$vis trait $name: ModelVersion {}
$(impl $name for $version {})+
)+
};
}
version_capabilities! {
/// A model version supporting the `BPOS`, `FAFX`, and `CORN` chunks.
///
/// ```compile_fail
/// use wc3::model::{Model, V800};
/// Model::<V800>::new().bind_poses();
/// ```
pub trait SupportsReforgedChunks for V900, V1000, V1100, V1200, V1300, V1400, V1600, V1800;
/// Versions with a material shader path.
pub trait SupportsMaterialShaderPath for V900, V1000;
/// Versions with layer emissive gain.
pub trait SupportsEmissiveGain for V900, V1000, V1100, V1200, V1300, V1400, V1600, V1800;
/// Versions with layer Fresnel fields.
pub trait SupportsFresnel for V1000, V1100, V1200, V1300, V1400, V1600, V1800;
/// Versions with layer shader type IDs.
pub trait SupportsLayerShaderTypeId for V1100, V1200, V1300, V1400, V1600, V1800;
/// Versions with layer texture slots.
pub trait SupportsLayerTextureSlots for V1100, V1200, V1300, V1400, V1600, V1800;
/// Versions with a serialized light shadow intensity.
///
/// ```compile_fail
/// use wc3::model::{scene::{Light, LightType, Node}, V1100};
/// Light::<V1100>::new(Node::new("Lamp", 1).unwrap(), LightType::Omnidirectional).set_shadow_intensity(0.5);
/// ```
pub trait SupportsLightShadowIntensity for V1200, V1300, V1400, V1600, V1800;
/// Versions with light shadow casting and its range.
///
/// ```compile_fail
/// use wc3::model::{scene::{Light, LightType, Node}, V1200};
/// Light::<V1200>::new(Node::new("Lamp", 1).unwrap(), LightType::Omnidirectional).set_shadow_casting(true);
/// ```
pub trait SupportsLightShadowCasting for V1300, V1400, V1600, V1800;
/// Versions with serialized light falloff coefficients.
///
/// ```compile_fail
/// use wc3::model::{scene::{Light, LightType, LightFalloff, Node}, V1400};
/// Light::<V1400>::new(Node::new("Lamp", 1).unwrap(), LightType::Omnidirectional).set_falloff(LightFalloff::default());
/// ```
pub trait SupportsLightFalloff for V1600, V1800;
}