Advertisement
cm3d2-01

EyeScaleRotate

Aug 15th, 2015
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.33 KB | None | 0 0
  1. //***********************************************************************************
  2. // CM3D.MaidVoicePitch.Plugin 0.1.8 で本体に組み込まれました。
  3. // 0.1.8以降はこのコードを組み込む必要はありません。
  4. //***********************************************************************************
  5.  
  6.  
  7.  
  8. // EyeScaleRotate : 目のサイズと角度変更する CM3D.MaidVoicePitch.Plugin.cs の追加メソッド
  9.  
  10. // CM3D.MaidVoicePitch.Plugin を適用し #WIDESLIDER# を有効にした状態で、メイドのフリーコメント欄に、
  11. // #EYESCL=1.0,1.0# の記述で縦・横拡大が有効。表記順は、幅,高さ。
  12. // #EYEANG=0,0,0# の記述で回転が有効。表記順は、回転(度),横位置補正,縦位置補正。
  13.  
  14. //※注意
  15. // EYEANGは現状仕様上の不具合があって、一度有効にすると上方向に目の基準位置がずれる。
  16. // EYEANG有効中は補正してあるけど、無効にしたら目のズレだけが残る。(#EYEANG=0,0,0#でとりあえず有効にしておけば補正は効く)
  17. // 一度発生したズレを解消したい場合は、ゲームを再起動するか、
  18. // 一回エディット画面抜けて、別のメイドのエディット呼び出して、再度ズレたメイドを呼び出す必要がある。
  19.  
  20. //1.
  21. //以下を CM3D.MaidVoicePich.Plugin.cs の public class MaidVoicePitch {...} の任意の場所に挿入
  22.  
  23.         void EyeScaleRotate(Maid maid, string freeComment)
  24.         {
  25.             Match scl = Regex.Match(freeComment, @"#EYESCL=([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)#");
  26.             Match ang = Regex.Match(freeComment, @"#EYEANG=([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)#");
  27.  
  28.             if (scl.Groups.Count < 3 && ang.Groups.Count < 4) return;
  29.  
  30.             Transform tL = null;
  31.             Transform tR = null;
  32.  
  33.             for (int i=0; i<maid.body0.bonemorph.bones.Count; i++)
  34.             {
  35.                 if(maid.body0.bonemorph.bones[i].linkT == null) continue;
  36.                 if(maid.body0.bonemorph.bones[i].linkT.name == "Eyepos_L") tL = maid.body0.bonemorph.bones[i].linkT;
  37.                 if(maid.body0.bonemorph.bones[i].linkT.name == "Eyepos_R") tR = maid.body0.bonemorph.bones[i].linkT;
  38.             }
  39.             if (tL == null || tR == null) return;
  40.  
  41.             if (scl.Groups.Count >= 3)
  42.             {
  43.                 Vector3 sclrvs = new Vector3(1.00f, Helper.FloatTryParse(scl.Groups[2].Value), Helper.FloatTryParse(scl.Groups[1].Value));
  44.                 tL.localScale = Vector3.Scale(tL.localScale, sclrvs);
  45.                 tR.localScale = Vector3.Scale(tR.localScale, sclrvs);
  46.             }
  47.             if (ang.Groups.Count >= 4)
  48.             {
  49.                 Vector3 pv = new Vector3(-1, 0f, 0f);
  50.                 Vector3 ry_d = new Vector3(0f, -0.0125f, 0f);
  51.                 float ra = Helper.FloatTryParse(ang.Groups[1].Value);
  52.                 float rx = Helper.FloatTryParse(ang.Groups[2].Value);
  53.                 float ry = Helper.FloatTryParse(ang.Groups[3].Value);
  54.  
  55.                 tL.localRotation = Quaternion.AngleAxis(ra,pv);
  56.                 tR.localRotation = Quaternion.AngleAxis(-180f-ra,pv);
  57.                 tL.localPosition += ry_d;
  58.                 tR.localPosition += ry_d;
  59.                
  60.                 if (rx != 0 || ry != 0)
  61.                 {    
  62.                     Vector3 posrvsL = new Vector3(0f, ry/1000f, rx/1000f);
  63.                     Vector3 posrvsR = new Vector3(0f, ry/1000f, -rx/1000f);
  64.                    
  65.                     tL.localPosition += posrvsL;
  66.                     tR.localPosition += posrvsR;
  67.                 }
  68.             }
  69.         }
  70.  
  71.  
  72. //2.
  73. //CM3D.MaidVoicePitch.Plugin.cs の void MaidUpdate(Maid maid, bool bEditUpdate) {...} の
  74. //WideSlider(maid, freeComment); 以降で EyeScaleRotate 呼び出しを記述
  75.  
  76. //example (+行が追加箇所)
  77.  
  78.         void MaidUpdate(Maid maid, bool bEditUpdate)
  79.         {
  80.  
  81.             (...中略...)
  82.  
  83.             Pitch(maid, freeComment);
  84.             Mabataki(maid, freeComment);
  85.             WideSlider(maid, freeComment);
  86.             EyeBall(maid, freeComment);
  87. +           EyeScaleRotate(maid, freeComment);
  88.             TestMabatakiSpeed(maid, freeComment, bEditUpdate);
  89.             TestPelvis(maid, freeComment);
  90.             TestLipSync(maid, freeComment);
  91.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement