Class: Collada::Parser::Controller::Skin::VertexWeights
- Includes:
- Enumerable
- Defined in:
- lib/collada/parser/controller.rb
Instance Attribute Summary collapse
-
#counts ⇒ Object
readonly
Returns the value of attribute counts.
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
Attributes inherited from Sampler
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(id, inputs, counts, vertices) ⇒ VertexWeights
constructor
A new instance of VertexWeights.
- #size ⇒ Object
-
#vertex(index) ⇒ Object
Vertices by index:.
Methods inherited from Sampler
Constructor Details
#initialize(id, inputs, counts, vertices) ⇒ VertexWeights
Returns a new instance of VertexWeights.
33 34 35 36 37 38 39 40 41 |
# File 'lib/collada/parser/controller.rb', line 33 def initialize(id, inputs, counts, vertices) super id, inputs @counts = counts @vertices = vertices # The number of indices per vertex: @stride = @inputs.sort_by(&:offset).last.offset + 1 end |
Instance Attribute Details
#counts ⇒ Object (readonly)
Returns the value of attribute counts.
43 44 45 |
# File 'lib/collada/parser/controller.rb', line 43 def counts @counts end |
#vertices ⇒ Object (readonly)
Returns the value of attribute vertices.
44 45 46 |
# File 'lib/collada/parser/controller.rb', line 44 def vertices @vertices end |
Class Method Details
.parse(doc, element, sources) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/collada/parser/controller.rb', line 76 def self.parse(doc, element, sources) inputs = parse_inputs(doc, element, sources) counts = element.elements['vcount'].text.split(/\s+/).collect &:to_i vertices = element.elements['v'].text.split(/\s+/).collect &:to_i self.new(element.attributes['id'], inputs, counts, vertices) end |
Instance Method Details
#each ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/collada/parser/controller.rb', line 61 def each vertex_offset = 0 @counts.each do |count| # Grap all the vertices weights = count.times.collect do |vertex_index| vertex(vertex_offset + vertex_index) end yield weights vertex_offset += count end end |
#size ⇒ Object
46 47 48 |
# File 'lib/collada/parser/controller.rb', line 46 def size @counts.size end |