model-converter/src/model/material.rs

42 lines
1.0 KiB
Rust
Raw Normal View History

2018-04-17 10:45:44 +02:00
//! This module contains everything related to materials.
use std::collections::HashMap;
use glium::texture::SrgbTexture2d;
/// A 3D material.
pub struct Material {
/// The name of the material.
pub name: String,
/// Map linking each texture map to its file path.
pub textures: HashMap<String, String>,
/// Instructions that are unknown.
///
/// They might be necessary for the export though.
pub unknown_instructions: Vec<String>,
/// The texture that will be used for rendering.
pub rendering_texture: Option<SrgbTexture2d>,
}
impl Material {
/// Creates a material from its name, without texture.
pub fn new(name: &str) -> Material {
Material {
name: name.to_owned(),
textures: HashMap::new(),
unknown_instructions: vec![],
rendering_texture: None,
}
}
/// Adds a unknown instruction into the material.
pub fn add_unknown_instruction(&mut self, instruction: String) {
self.unknown_instructions.push(instruction);
}
}