Advertisement
Guest User

rename_bones.pl

a guest
Oct 17th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 4.69 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3.  
  4. my $filename = $ARGV[0];
  5. my $data;
  6. my $fh;
  7. my $fhw;
  8. my $row;
  9.  
  10. open($fh, $filename)
  11.   or die "Could not open file '$filename' $!";
  12.  
  13. print "Parsing $filename\n";
  14.  
  15. while ($row = <$fh>) {
  16.  
  17.     chomp $row;
  18.    
  19.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_pelvis"/"j_mainroot"/i;
  20.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_spine(_0)?"/"j_spine1"/i;
  21.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_spine_?1"/"j_spine2"/i;
  22.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_spine_?2"/"j_spine3"/i;
  23.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_spine_?[34]"/"j_spine4"/i;
  24.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_neck(\d)?"/"j_neck"/i;
  25.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_head(\d)?"/"j_head"/i;
  26.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(collar_R|R_Clavicle)"/"j_clavicle_ri"/i;
  27.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(collar_L|L_Clavicle)"/"j_clavicle_le"/i;
  28.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(upperArm_R|R_UpperArm)"/"j_shoulder_ri"/i;
  29.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(upperArm_L|L_UpperArm)"/"j_shoulder_le"/i;
  30.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_R_Trapezius"/"j_shouldertwist_ri"/i;
  31.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_L_Trapezius"/"j_shouldertwist_le"/i;
  32.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(lowerArm_R|R_Forearm)"/"j_elbow_ri"/i;
  33.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(lowerArm_L|L_Forearm)"/"j_elbow_le"/i;
  34.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(hip_L|L_Thigh)"/"j_hip_le"/i;
  35.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(hip_R|R_Thigh)"/"j_hip_ri"/i;
  36.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(knee_L|L_Calf)"/"j_knee_le"/i;
  37.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(knee_R|R_Calf)"/"j_knee_ri"/i;
  38.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(foot_R|R_Foot)"/"j_ankle_ri"/i;
  39.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(foot_L|L_Foot)"/"j_ankle_le"/i;
  40.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(toe_L|L_Toe(\d)?)"/"j_ball_le"/i;
  41.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(toe_R|R_Toe(\d)?)"/"j_ball_ri"/i;
  42.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(hand_R|R_Hand)"/"j_wrist_ri"/i;
  43.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(hand_L|L_Hand)"/"j_wrist_le"/i;
  44.     $row =~ s/"(ValveBiped)?.?Anim_Attachment_RH"/"tag_weapon_right"/i;
  45.     $row =~ s/"(ValveBiped)?.?Anim_Attachment_LH"/"tag_weapon_left"/i;
  46.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_R_Wrist"/"j_wristtwist_ri"/i;
  47.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_L_Wrist"/"j_wristtwist_le"/i;
  48.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(thumb_0_R|R_Finger0)"/"j_thumb_ri_1"/i;
  49.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(thumb_0_R|R_Finger01)"/"j_thumb_ri_2"/i;
  50.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(thumb_0_R|R_Finger02)"/"j_thumb_ri_3"/i;
  51.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(thumb_0_L|L_Finger0)"/"j_thumb_le_1"/i;
  52.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(thumb_0_L|L_Finger01)"/"j_thumb_le_2"/i;
  53.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(thumb_0_L|L_Finger02)"/"j_thumb_le_3"/i;
  54.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(index_0_R|R_Finger1)"/"j_index_ri_1"/i;
  55.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(index_0_R|R_Finger11)"/"j_index_ri_2"/i;
  56.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(index_0_R|R_Finger12)"/"j_index_ri_3"/i;
  57.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(index_0_L|L_Finger1)"/"j_index_le_1"/i;
  58.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(index_0_L|L_Finger11)"/"j_index_le_2"/i;
  59.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(index_0_L|L_Finger12)"/"j_index_le_3"/i;
  60.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(middle_0_R|R_Finger2)"/"j_mid_ri_1"/i;
  61.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(middle_0_R|R_Finger21)"/"j_mid_ri_2"/i;
  62.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(middle_0_R|R_Finger22)"/"j_mid_ri_3"/i;
  63.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(middle_0_L|L_Finger2)"/"j_mid_le_1"/i;
  64.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(middle_0_L|L_Finger21)"/"j_mid_le_2"/i;
  65.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(middle_0_L|L_Finger22)"/"j_mid_le_3"/i;
  66.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(ring_0_R|R_Finger3)"/"j_ring_ri_1"/i;
  67.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(ring_0_R|R_Finger31)"/"j_ring_ri_2"/i;
  68.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(ring_0_R|R_Finger32)"/"j_ring_ri_3"/i;
  69.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(ring_0_L|L_Finger3)"/"j_ring_le_1"/i;
  70.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(ring_0_L|L_Finger31)"/"j_ring_le_2"/i;
  71.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(ring_0_L|L_Finger32)"/"j_ring_le_3"/i;
  72.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(pinky_0_R|R_Finger4)"/"j_pinky_ri_1"/i;
  73.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(pinky_0_R|R_Finger41)"/"j_pinky_ri_2"/i;
  74.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(pinky_0_R|R_Finger42)"/"j_pinky_ri_3"/i;
  75.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(pinky_0_L|L_Finger4)"/"j_pinky_le_1"/i;
  76.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(pinky_0_L|L_Finger41)"/"j_pinky_le_2"/i;
  77.     $row =~ s/"(ValveBiped)?.?bip(\d+)?_(pinky_0_L|L_Finger42)"/"j_pinky_le_3"/i;
  78.  
  79.     $data .= "$row\n";
  80. }
  81.  
  82. close $fh;
  83.  
  84. open($fhw, '>', $filename);
  85. print $fhw "$data\n";
  86. close $fhw;
  87.  
  88. print "Done!";
  89. exit 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement