#[derive(Debug, Clone)]
pub struct TextureData {
pub width: u32,
pub height: u32,
pub data: Vec<u8>,
}
#[derive(Debug, Clone)]
pub struct MaterialData {
pub base_color_texture: Option<TextureData>,
pub base_color_factor: [f32; 4],
pub metallic_factor: f32,
pub roughness_factor: f32,
pub normal_texture: Option<TextureData>,
pub normal_scale: f32,
pub metallic_roughness_texture: Option<TextureData>,
pub occlusion_texture: Option<TextureData>,
pub emissive_texture: Option<TextureData>,
pub emissive_factor: [f32; 3],
}
impl Default for MaterialData {
fn default() -> Self {
Self {
base_color_texture: None,
base_color_factor: [1.0, 1.0, 1.0, 1.0],
metallic_factor: 1.0,
roughness_factor: 1.0,
normal_texture: None,
normal_scale: 1.0,
metallic_roughness_texture: None,
occlusion_texture: None,
emissive_texture: None,
emissive_factor: [0.0, 0.0, 0.0],
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_texture_data() {
let tex = TextureData {
width: 2,
height: 2,
data: vec![255; 16],
};
assert_eq!(tex.data.len(), (tex.width * tex.height * 4) as usize);
}
#[test]
fn test_material_default() {
let mat = MaterialData::default();
assert_eq!(mat.base_color_factor, [1.0, 1.0, 1.0, 1.0]);
assert!(mat.base_color_texture.is_none());
assert!(mat.normal_texture.is_none());
assert_eq!(mat.normal_scale, 1.0);
assert!(mat.metallic_roughness_texture.is_none());
assert!(mat.occlusion_texture.is_none());
assert!(mat.emissive_texture.is_none());
assert_eq!(mat.emissive_factor, [0.0, 0.0, 0.0]);
}
}