Class: Collada::Conversion::WeightFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/collada/conversion/mesh.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(count) ⇒ WeightFormat

Returns a new instance of WeightFormat.



68
69
70
# File 'lib/collada/conversion/mesh.rb', line 68

def initialize(count)
	@count = count
end

Class Method Details

.[](count) ⇒ Object



82
83
84
# File 'lib/collada/conversion/mesh.rb', line 82

def self.[] (count)
	self.new(count)
end

Instance Method Details

#call(vertex_weights) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/collada/conversion/mesh.rb', line 72

def call(vertex_weights)
	# Ensure that we have the correct number:
	vertex_weights = @count.times.collect do |offset|
		vertex_weights[offset] || [0, 0.0]
	end
	
	# Go from [[bone1, weight1], [bone2, weight2]] => [bone1, bone2, weight1, weight2]
	return vertex_weights.collect{|(bone,_)| bone}, vertex_weights.collect{|(_,weight)| weight}
end