Added -s mtl option
This commit is contained in:
@@ -14,7 +14,7 @@ pub struct Material {
|
||||
pub diffuse: Vector3<f32>,
|
||||
|
||||
/// Map linking each texture map to its file path.
|
||||
pub textures: HashMap<String, String>,
|
||||
pub textures: HashMap<String, (String, Vector3<f32>)>,
|
||||
|
||||
/// Instructions that are unknown.
|
||||
///
|
||||
|
||||
+5
-5
@@ -102,7 +102,7 @@ pub struct Model {
|
||||
pub materials: HashMap<String, Material>,
|
||||
|
||||
/// Map associating the name of a texture and the real texture.
|
||||
pub textures: HashMap<String, Rc<SrgbTexture2d>>,
|
||||
pub textures: HashMap<String, (Rc<SrgbTexture2d>, Vector3<f32>)>,
|
||||
|
||||
/// The list of parts of the model.
|
||||
pub parts: Vec<Part>,
|
||||
@@ -544,15 +544,15 @@ impl Model {
|
||||
|
||||
/// Builds the SrgbTextures for rendering.
|
||||
pub fn build_texture_for_material(&mut self, material: &Material, renderer: &Renderer) {
|
||||
if let Some(path) = material.textures.get("map_Kd") {
|
||||
if let Some((path, size)) = material.textures.get("map_Kd") {
|
||||
let texture = renderer.make_texture(path);
|
||||
// Don't need to insert multiple times the same texture
|
||||
self.textures.entry(path.to_owned()).or_insert(Rc::new(texture));
|
||||
self.textures.entry(path.to_owned()).or_insert((Rc::new(texture), *size));
|
||||
};
|
||||
}
|
||||
|
||||
/// Returns the rendering texture.
|
||||
pub fn get_texture_by_name(&self, name: &str) -> Option<&Rc<SrgbTexture2d>> {
|
||||
pub fn get_texture_by_name(&self, name: &str) -> Option<&(Rc<SrgbTexture2d>, Vector3<f32>)> {
|
||||
self.textures.get(name)
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ impl Model {
|
||||
}
|
||||
|
||||
/// Returns a ref mut to the table of textures.
|
||||
pub fn textures_mut(&mut self) -> &mut HashMap<String, Rc<SrgbTexture2d>> {
|
||||
pub fn textures_mut(&mut self) -> &mut HashMap<String, (Rc<SrgbTexture2d>, Vector3<f32>)> {
|
||||
&mut self.textures
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user