model-converter/src/model/material.rs

42 lines
1.0 KiB
Rust

//! This module contains everything related to materials.
use std::collections::HashMap;
use math::vector::Vector3;
/// A 3D material.
#[derive(Clone)]
pub struct Material {
/// The name of the material.
pub name: String,
/// The diffuse color of the material.
pub diffuse: Vector3<f32>,
/// Map linking each texture map to its file path.
pub textures: HashMap<String, (String, Vector3<f32>)>,
/// Instructions that are unknown.
///
/// They might be necessary for the export though.
pub unknown_instructions: Vec<String>,
}
impl Material {
/// Creates a material from its name, without texture.
pub fn new(name: &str) -> Material {
Material {
name: name.to_owned(),
diffuse: Vector3::new(1.0, 1.0, 1.0),
textures: HashMap::new(),
unknown_instructions: vec![],
}
}
/// Adds a unknown instruction into the material.
pub fn add_unknown_instruction(&mut self, instruction: String) {
self.unknown_instructions.push(instruction);
}
}