2018-04-17 10:45:44 +02:00
|
|
|
//! This module contains everything related to materials.
|
|
|
|
|
|
|
|
use std::collections::HashMap;
|
2018-06-15 17:36:51 +02:00
|
|
|
use math::vector::Vector3;
|
2018-04-17 10:45:44 +02:00
|
|
|
|
|
|
|
/// A 3D material.
|
2018-04-18 11:49:27 +02:00
|
|
|
#[derive(Clone)]
|
2018-04-17 10:45:44 +02:00
|
|
|
pub struct Material {
|
|
|
|
|
|
|
|
/// The name of the material.
|
|
|
|
pub name: String,
|
|
|
|
|
2018-06-15 17:36:51 +02:00
|
|
|
/// The diffuse color of the material.
|
|
|
|
pub diffuse: Vector3<f32>,
|
|
|
|
|
2018-04-17 10:45:44 +02:00
|
|
|
/// Map linking each texture map to its file path.
|
2018-06-20 17:24:33 +02:00
|
|
|
pub textures: HashMap<String, (String, Vector3<f32>)>,
|
2018-04-17 10:45:44 +02:00
|
|
|
|
|
|
|
/// 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(),
|
2018-06-15 17:36:51 +02:00
|
|
|
diffuse: Vector3::new(1.0, 1.0, 1.0),
|
2018-04-17 10:45:44 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|