Class: Bestguigui::Render3D::MaterialCollection
- Inherits:
-
Object
- Object
- Bestguigui::Render3D::MaterialCollection
- Defined in:
- lib/bestguigui/render_3d/obj_model.rb
Overview
Associe chaque matériau nommé du .mtl à sa texture (map_Kd). Chargée
automatiquement par ObjModel via la ligne mtllib du .obj.
Instance Method Summary collapse
-
#initialize(mtl_path) ⇒ MaterialCollection
constructor
A new instance of MaterialCollection.
- #texture_for(material) ⇒ Object
Constructor Details
#initialize(mtl_path) ⇒ MaterialCollection
Returns a new instance of MaterialCollection.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/bestguigui/render_3d/obj_model.rb', line 193 def initialize(mtl_path) @textures = {} current = nil dir = File.dirname(mtl_path) File.readlines(mtl_path).each do |line| infos = line.chomp.split(" ") case infos[0] when "newmtl" current = infos[1] when "map_Kd" @textures[current] = Texture.new(File.join(dir, infos[1])) end end end |
Instance Method Details
#texture_for(material) ⇒ Object
210 211 212 |
# File 'lib/bestguigui/render_3d/obj_model.rb', line 210 def texture_for(material) @textures.fetch(material) end |