Class: Collada::Conversion::Skeleton

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(library, scene, node, controller) ⇒ Skeleton

Returns a new instance of Skeleton.



27
28
29
30
31
32
33
34
35
# File 'lib/collada/conversion/skeleton.rb', line 27

def initialize(library, scene, node, controller)
	@library = library
	@scene = scene
	@node = node
	
	@controller = controller
	
	extract_skeleton(node)
end

Instance Attribute Details

#bonesObject (readonly)

Returns the value of attribute bones.



43
44
45
# File 'lib/collada/conversion/skeleton.rb', line 43

def bones
  @bones
end

#controllerObject (readonly)

Returns the value of attribute controller.



40
41
42
# File 'lib/collada/conversion/skeleton.rb', line 40

def controller
  @controller
end

#indexedObject (readonly)

Returns the value of attribute indexed.



44
45
46
# File 'lib/collada/conversion/skeleton.rb', line 44

def indexed
  @indexed
end

#libraryObject (readonly)

Returns the value of attribute library.



37
38
39
# File 'lib/collada/conversion/skeleton.rb', line 37

def library
  @library
end

#nodeObject (readonly)

Returns the value of attribute node.



39
40
41
# File 'lib/collada/conversion/skeleton.rb', line 39

def node
  @node
end

#sceneObject (readonly)

Returns the value of attribute scene.



38
39
40
# File 'lib/collada/conversion/skeleton.rb', line 38

def scene
  @scene
end

#topObject (readonly)

Returns the value of attribute top.



42
43
44
# File 'lib/collada/conversion/skeleton.rb', line 42

def top
  @top
end

Instance Method Details

#indexed_weightsObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/collada/conversion/skeleton.rb', line 46

def indexed_weights
	result = []
	
	@controller.weights.each do |vertex|
		output = []
		
		vertex.each do |weight|
			weight = Parser::Attribute.merge(weight)
			
			output << [@indexed[weight[:JOINT]], weight[:WEIGHT]]
		end
		
		# Sort bone weights in descending order:
		result << output.sort{|a,b| b[1] <=> a[1]}
	end
	
	return result
end