Class: Bayonetta::BoneInfos
- Inherits:
-
LibBin::Structure
- Object
- LibBin::Structure
- Bayonetta::BoneInfos
- Defined in:
- lib/bayonetta/wmb.rb
Instance Method Summary collapse
- #get_indexes ⇒ Object
- #get_indexes_and_weights ⇒ Object
- #get_weights ⇒ Object
-
#initialize ⇒ BoneInfos
constructor
A new instance of BoneInfos.
- #remap_indexes(map) ⇒ Object
- #set_indexes_and_weights(bone_info) ⇒ Object
- #to_a ⇒ Object
Constructor Details
Instance Method Details
#get_indexes ⇒ Object
544 545 546 |
# File 'lib/bayonetta/wmb.rb', line 544 def get_indexes get_indexes_and_weights.collect { |bi, _| bi } end |
#get_indexes_and_weights ⇒ Object
534 535 536 537 538 539 540 541 542 |
# File 'lib/bayonetta/wmb.rb', line 534 def get_indexes_and_weights res = [] 4.times { |i| bi = (@indexes.data >> (i*8)) & 0xff bw = (@weights.data >> (i*8)) & 0xff res.push [bi, bw] if bw > 0 } res end |
#get_weights ⇒ Object
548 549 550 |
# File 'lib/bayonetta/wmb.rb', line 548 def get_weights get_indexes_and_weights.collect { |_, bw| bw } end |
#remap_indexes(map) ⇒ Object
552 553 554 555 556 |
# File 'lib/bayonetta/wmb.rb', line 552 def remap_indexes(map) new_bone_info = get_indexes_and_weights.collect { |bi, bw| [map[bi], bw] } set_indexes_and_weights(new_bone_info) self end |
#set_indexes_and_weights(bone_info) ⇒ Object
558 559 560 561 562 563 564 565 566 567 568 569 570 |
# File 'lib/bayonetta/wmb.rb', line 558 def set_indexes_and_weights(bone_info) raise "Too many bone information #{bone_info.inspect}!" if bone_info.length > 4 @indexes.data = 0 @weights.data = 0 bone_info.each_with_index { |(bi, bw), i| raise "Invalid bone index #{bi}!" if bi > 255 || bi < 0 @indexes.data |= ( bi << (i*8) ) bw = 0 if bw < 0 bw = 255 if bw > 255 @weights.data |= (bw << (i*8) ) } self end |
#to_a ⇒ Object
572 573 574 |
# File 'lib/bayonetta/wmb.rb', line 572 def to_a get_indexes_and_weights end |