MAXScript を使用して CATRig 階層をナビゲートする
         
           
         
          
             CATRig スケルトンのボーンにアクセスする 
            
 
            スケルトンでの名前によるボーンのアクセスでは、エラーが発生する傾向があります。例えば、アーチストがボーンの名前を変更すると、スクリプトが機能しなくなる場合があります。
               
            
 
             3ds Max CAT は、リグ内のボーンの名前を認識しなくても、スクリプトから階層をナビゲートできるよう設計されています。これは、使用する命名規則に関わらず、すべての CATRig で機能するスクリプトを記述することができることを意味します。
               
            
 
            CATRig はツリーのような構造になっています。 
            
 
            各ボーンには、子ボーンがあり、それに移動したり、子を取得することができます。 
            
 
            CATには、ツリーのパーツをまとめる特殊なコントローラがあります。ただし、これらのコントローラは 3ds Max の階層には表示されません。例えば、リム(腕または足)を維持する「リム」と呼ばれるコントローラがあります。リムの各ボーンは汎用であり、その特定のボーンに関連する情報のみが含まれます。リムに関する情報を得たい場合には、リム
               コントローラにアクセスすることができます。 
            
 
            基本ツリー構造は次のようになっています。 
            
 
            ハブ コントローラからリム コントローラにアクセスでき、リム コントローラから鎖骨コントローラにアクセスできます。 
            
 
            ハブ コントローラから尾コントローラにアクセスでき、尾コントローラから尾のボーン コントローラにアクセスできます。 
            
 
            ハブ コントローラから脊椎コントローラにアクセスでき、脊椎コントローラからすべての脊椎のボーン コントローラまたは脊椎の末端のハブ コントローラにアクセスできます。
               
            
 
            ハブ 
            
 
            ハブ -> リム 
            
 
            ハブ -> リム -> 鎖骨 
            
 
            ハブ -> リム-> リムのボーン 
            
 
            ハブ -> リム -> リムのボーン -> ボーン セグメント 
            
 
            ハブ -> リム -> 手のひら/足首 
            
 
            ハブ -> リム -> 手のひら/足首 -> 指 
            
 
            ハブ -> リム -> 手のひら/足首 -> 指のボーン 
            
 
            ハブ -> 尾 
            
 
            ハブ -> 尾 -> 尾のボーン 
            
 
            ハブ -> 脊椎 
            
 
            ハブ -> 脊椎 -> 脊椎のボーン 
            
 
            ハブ -> 脊椎 -> 末端のハブ 
            
 
          
          
             ボーン アドレスを使用する 
            
 
            3ds Max CAT スクリプト インタフェースには、ボーンの「アドレス」を使ってボーンにアクセスできるメソッドが含まれています。CATRig の各ボーンには、固有のアドレスがあります。
               
            
 
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                      
                        
--Select a bone, for example left elbow:
theAddress =$[3].address
--the result will be something like:
"SceneRootNode.Hub.Spine[0].Hub.Limb[0].LimbBone[1].BoneSeg[0]"
   
                      | 
                  
               
              
            アドレスを一度取得すれば、別のリグでも同じボーンを簡単に取得することができます。 
            
 
            CATParent には、アドレスを使ってスケルトンからボーンを取得するメソッドがあります。 
            
 
            このメソッドは  GetBoneUsingAddress:  と呼ばれます。 
            
 
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                      
                        
--Selectthe CATParent of a rig and call:
$.GetBoneByAddresstheAddress
--the result will be something like:
$Object:MaramaLForeArm1 @ [18.374180,2.811419,91.353607]
   
                      | 
                  
               
              
          
          
             CATRig を構成するすべてのボーンを取得する 
            
 
            CATParent は、CATRig のすべてのボーンのリストを含む CATRigNodes と呼ばれるプロパティを提供します。 
            
 
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                      
                        
--Select the CATParent of a CATRig andexecute:
$.CATRigNodes
#($Object:MaramaPelvis @ [0.643538,12.460782,56.982174], $IKTarget:MaramaLPlatform @ [-9.479717,45.484272,2.016279], $Object:MaramaLThigh @ [-5.399519,13.610688,52.234413], $Object:MaramaLCalf @ [-5.073243,42.623035,42.755692], $Object:MaramaLAnkle @ [-9.923340,42.132290,12.445667], $Object:MaramaLToe @ [-8.354513,46.355228,5.667924], $IKTarget:MaramaRPlatform @ [22.299629,-26.312172,2.125263], $Object:MaramaRThigh @ [7.615567,12.286880,53.555431], $Object:MaramaRCalf @ [18.307613,1.576054,27.048307], $Object:MaramaRAnkle @ [15.838839,-24.331221,10.763937], $Object:MaramaRToe @ [21.849598,-24.039907,5.285047], $Object:MaramaSpine1 @ [0.084267,13.617851,61.769054], $Object:MaramaSpine2 @ [0.155154,17.742903,70.302628], $Object:MaramaSpine3 @ [0.838520,20.302643,79.403381], $Object:MaramaRibcage @ [1.721320,22.587023,88.560089], $IKTarget:MaramaLIKTarget @ [-14.076582,23.387424,73.722427], $Object:MaramaLCollarbone @ [-0.265896,27.761074,90.442078], $Object:MaramaLUpperArm @ [-7.214790,19.994431,91.494965], $Object:MaramaLForeArm1 @ [-22.375963,8.502111,91.433647], $Object:MaramaLForeArm2 @ [-18.546179,13.426756,83.416336], ...)
   
                      | 
                  
               
              
            リグのすべてのボーンが収集され、配列に配置されます。これによって、CATRig 階層をナビゲートする方法を学ぶ必要がなくなります。 
            
 
          
          
             CATRig のすべてのレイヤ コントローラを取得する 
            
 
            CATParent は、CATRig のすべてのレイヤ コントロールの配列を含む CATRigLayerCtrls と呼ばれるプロパティも提供します。 
            
 
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                      
                        
-- Select the CATParent of a CATRig andexecute:
$.CATRigLayerCtrls
#(Controller:LayerWeights, Controller:LayerMatrix3, Controller:LayerFloat, Controller:LayerWeights, Controller:LayerFloat, Controller:LayerFloat, Controller:LayerFloat, Controller:LayerMatrix3, Controller:LayerMatrix3, Controller:LayerWeights, Controller:LayerMatrix3, Controller:LayerFloat, Controller:LayerMatrix3, Controller:LayerMatrix3, Controller:LayerWeights, Controller:LayerFloat, Controller:LayerFloat, Controller:LayerFloat, Controller:LayerMatrix3, Controller:LayerMatrix3, ...)
   
                      | 
                  
               
              
            ポーズ ミキサー ユーティリティは、この関数を使用して、キーフレーム設定されるすべてのコントローラを検出します。 
            
 
          
          
             ボーンをナビゲートする 
            
 
            CATRig のすべてのボーンはコントローラによってコントロールされます。 
            
 
            このコントローラは、CATNodeControl インタフェースを公開します。 
            
 
            これは、そのボーンに関する情報にアクセスすることができることを意味します。 
            
 
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                     |   ハブのボーンが選択されている状態で、そのハブにいくつのリムがアタッチされているかを知りたい場合は、次のスクリプト ラインを使用します。   
                      | 
                  
                  
                      
                        
$[3].address
"SceneRootNode.Hub.Spine[0].Hub.Limb[0].LimbBone[0].BoneSeg[2]"
   
                      | 
                  
               
              
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                     |   CATBone のレイヤ コントローラを取得するには、次のラインを使用します。   
                      | 
                  
                  
                      
                        
$[3].layertrans.controller
Controller:LayerMatrix3
   
                      | 
                  
                  
                     |   手続き型脊椎のボーンなど、いくつかのボーンには layertrans コントローラがありません。   
                      | 
                  
               
              
          
          
             ハブをナビゲートする 
            
 
            ハブは、3ds Max CAT 階層を「ジョイント」する役割を持ちます。 
            
 
            ハブには、リム(足や腕)、尾、脊椎およびそれらにアタッチされる追加のボーンが含まれます。 
            
 
            すべてのハブでは、アタッチされているリムの数を確認することができ、リムにアクセスして、そのリムのボーンを取得することができます。 
            
 
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                     |   ハブのボーンが選択されている状態で、そのハブにいくつのリムがアタッチされているかを知りたい場合は、次のスクリプト ラインを使用します。   
                      | 
                  
                  
                      
                        -- Select the CATParent of a CATRig andexecute:
$[3].limbs.count
2    
                      | 
                  
               
              
          
          
             リムをナビゲートする 
            
 
            リムは、次のコントローラで構成されています。リム、鎖骨、ボーン、ボーン セグメント、手のひら、IKTraget、Upvector。 
            
 
            リム コントローラは、名前など全体のリムに関するすべての情報、およびリム、鎖骨、足首、IKTarget のボーンへのポインタを保持します。 
            
 
            1 つのリムのボーンから CATRig のすべてにアクセスすることができるのです。 
            
 
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                      
                        --To get the limb controller from a limb bone use the following:
$[3].Limb
Controller:CATLimbData2
 
--If you have a Limb bone selected and you want to know how many
--bones in the Limb use the following:
$[3].Limb.bones.count
4
 
--To get the second bone in the Limb use the following:
$[3].Limb.bones[2]
Controller:CATBoneData
 
--If a limb bone is selected and you want to select all the bones
--in the limb, you can use the following:
select (for o in $[3].Limb.bonescollect o.node)
OK    
                      | 
                  
               
              
               
                  
                     
                  
                  
                     |    例: 
                          
                      | 
                  
                  
                     |   リムのボーンが選択されている状態で、リムの最初のボーンの名前を取得するには、次を使用することができます。   
                      | 
                  
                  
                      
                        
$[3].limb.bones[1].node.name
"MarineLUpperarm1"
 
--Here is a quick overview of bone hierarchy access:
$--> accesses the selected bone
$Object:MarineLUpperarm3 @ [32.745049,27.963869,14.721746]
$[3]--> accesses the selected bone's transform controller
SubAnim:Transform
$[3].limb--> accesses the selected bone's tail controller
Controller:CATLimbData2
$[3].limb.bones[1]--> accesses the 1st bone in the limb controller
Controller:CATBoneData
$[3].limb.bones[1].node--> accesses the node of the 1st bone.
$Object:MarineLUpperarm1 @ [30.869087,27.893547,14.979661]
$[3].limb.bones[1].node.name--> accesses the name of the node of the 1st bone in the Limb.
"MarineLUpperarm1"    
                      | 
                  
               
              
          
          
             尾をナビゲートする 
            
 
            尾は、TailData および TailTrans の 2 種類のコントローラで構成されています。 
            
 
             TailData は、名前など全体の尾に関する情報、尾の各ボーンへのポインタを保持します。 
            
 
            1 つの尾のボーンから CATRig のすべてにアクセスすることができるのです。 
            
 
               
                  
                     
                  
                  
                     |    例 
                          
                      | 
                  
                  
                      
                        
--To get the TailData controller from a tail bone use the following:
$[3].tail
 
--If you have a Tail bone selected and you want to know how many bones
--arein the tail, use the following:
$[3].tail.bones.count
 
--To get the second bone in the tail, use the following:
$[3].tail.bones[2]
 
--If you have one tail bone selected and you want to select all
--the bones in the tail, you can use the following:
select (for o in $[3].Limb.bones collect o.node)
OK
   
                      | 
                  
               
              
               
                  
                     
                  
                  
                     |    例 
                          
                      | 
                  
                  
                     |   尾のボーンが選択されている状態で、その尾の最初のボーンの名前を取得するには、次を使用することができます。   
                      | 
                  
                  
                      
                        
$[3].tail.bones[1].node.name
 
--Here is a detailed overview of the hierarchy access:
$--> accesses the selected bone
$[3]--> accesses the selected bone's transform controller
$[3].tail--> accesses the selected bone's tail controller
$[3].tail.bones[1]--> accesses the 1st bone in the tail controller
$[3].tail.bones[1].node--> accesses the node of the 1st bone.
$[3].tail.bones[1].node.name--> accesses the name of the node of the 1st bone in the tail.
   
                      |