Class: Engine::Mesh
- Inherits:
-
Object
- Object
- Engine::Mesh
- Defined in:
- lib/engine/mesh.rb
Instance Attribute Summary collapse
-
#index_data ⇒ Object
readonly
Returns the value of attribute index_data.
-
#vertex_data ⇒ Object
readonly
Returns the value of attribute vertex_data.
Class Method Summary collapse
- .for(mesh_file) ⇒ Object
- .index_cache ⇒ Object
- .mesh_cache ⇒ Object
- .open_index(mesh_file) ⇒ Object
- .open_vertex(mesh_file) ⇒ Object
- .vertex_cache ⇒ Object
Instance Method Summary collapse
-
#initialize(mesh_file) ⇒ Mesh
constructor
A new instance of Mesh.
Constructor Details
#initialize(mesh_file) ⇒ Mesh
Returns a new instance of Mesh.
8 9 10 11 |
# File 'lib/engine/mesh.rb', line 8 def initialize(mesh_file) @vertex_data = Mesh.open_vertex(mesh_file) @index_data = Mesh.open_index(mesh_file) end |
Instance Attribute Details
#index_data ⇒ Object (readonly)
Returns the value of attribute index_data.
5 6 7 |
# File 'lib/engine/mesh.rb', line 5 def index_data @index_data end |
#vertex_data ⇒ Object (readonly)
Returns the value of attribute vertex_data.
5 6 7 |
# File 'lib/engine/mesh.rb', line 5 def vertex_data @vertex_data end |
Class Method Details
.for(mesh_file) ⇒ Object
13 14 15 |
# File 'lib/engine/mesh.rb', line 13 def self.for(mesh_file) mesh_cache[mesh_file] end |
.index_cache ⇒ Object
37 38 39 40 41 |
# File 'lib/engine/mesh.rb', line 37 def self.index_cache @index_data_cache ||= Hash.new do |hash, key| hash[key] = File.readlines(key).reject{|l| l == ""}.map(&:to_i) end end |
.mesh_cache ⇒ Object
17 18 19 20 21 |
# File 'lib/engine/mesh.rb', line 17 def self.mesh_cache @mesh_cache ||= Hash.new do |hash, key| hash[key] = new(key) end end |
.open_index(mesh_file) ⇒ Object
33 34 35 |
# File 'lib/engine/mesh.rb', line 33 def self.open_index(mesh_file) index_cache[File.join(GAME_DIR, "_imported", mesh_file + ".index_data")] end |
.open_vertex(mesh_file) ⇒ Object
23 24 25 |
# File 'lib/engine/mesh.rb', line 23 def self.open_vertex(mesh_file) vertex_cache[File.join(GAME_DIR, "_imported", mesh_file + ".vertex_data")] end |
.vertex_cache ⇒ Object
27 28 29 30 31 |
# File 'lib/engine/mesh.rb', line 27 def self.vertex_cache @index_data_cache ||= Hash.new do |hash, key| hash[key] = File.readlines(key).reject{|l| l == ""}.map(&:to_f) end end |