Advertisement
cm3d2-01

LowerBodyScale

Aug 15th, 2015
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.02 KB | None | 0 0
  1. //***********************************************************************************
  2. // CM3D.MaidVoicePitch.Plugin 0.1.9 で本体に組み込まれました。
  3. // 0.1.9以降はこのコードを組み込む必要はありません。
  4. //***********************************************************************************
  5.  
  6.  
  7.  
  8. // LowerBodyScale : 下半身の大きさを調整する CM3D.MaidVoicePitch.Plugin.cs の追加メソッド
  9.  
  10. // ReiPatcherで CM3D2.PreLBS.Patcher (http://pastebin.com/VDZVUQED) を適用し、
  11. // CM3D.MaidVoicePitch.Plugin を適用し #WIDESLIDER# を有効にした状態で、メイドのフリーコメント欄に、
  12. // #PELSCL=1.0,1.0,1.0# の記述で骨盤周りのサイズ調整。表記順は、幅,奥行き,高さ。
  13. // #THISCL=1.0,1.0# の記述で足全体のサイズ調整。表記順は、幅,奥行き。
  14. // #THIPOS=1.0,1.0# の記述で足全体の位置調整。表記順は、左右,前後。
  15.  
  16. //1.
  17. //以下を CM3D.MaidVoicePitch.Plugin.cs の public class MaidVoicePitch {...} の任意の場所に挿入
  18.  
  19.         // 下半身の大きさを調整する
  20.         void LowerBodyScale(Maid maid, string freeComment)
  21.         {
  22.             Match pscl = Regex.Match(freeComment, @"#PELSCL=([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)#");
  23.             Match tscl = Regex.Match(freeComment, @"#THISCL=([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)#");
  24.             Match tpos = Regex.Match(freeComment, @"#THIPOS=([-+]?[0-9]*\.?[0-9]+),([-+]?[0-9]*\.?[0-9]+)#");
  25.  
  26.             if (pscl.Groups.Count < 4 && tscl.Groups.Count < 3 && tpos.Groups.Count < 3) return;
  27.  
  28.             BoneMorph_ bm_ = maid.body0.bonemorph;
  29.             List<Transform> tListP = new List<Transform>();
  30.             List<Transform> tListHL = new List<Transform>();
  31.             List<Transform> tListHR = new List<Transform>();
  32.             List<Transform> tListTL = new List<Transform>();
  33.             List<Transform> tListTR = new List<Transform>();
  34.  
  35.             if (pscl.Groups.Count >= 4)
  36.             {
  37.                 for (int i=0; i<bm_.bones.Count; i++)
  38.                 {
  39.                     if(bm_.bones[i].linkT == null) continue;
  40.                     if(bm_.bones[i].linkT.name == "Bip01 Pelvis_SCL_") tListP.Add(bm_.bones[i].linkT);
  41.                     if(bm_.bones[i].linkT.name == "Hip_L") tListHL.Add(bm_.bones[i].linkT);
  42.                     if(bm_.bones[i].linkT.name == "Hip_R") tListHR.Add(bm_.bones[i].linkT);
  43.                 }
  44.                 if (tListP.Count < 1 || tListHL.Count < 1 || tListHR.Count < 1) return;
  45.  
  46.                 float mw = Helper.FloatTryParse(pscl.Groups[1].Value);
  47.                 float md = Helper.FloatTryParse(pscl.Groups[2].Value);
  48.                 float mh = Helper.FloatTryParse(pscl.Groups[3].Value);
  49.  
  50.                 Vector3 sclrvs = new Vector3(mh, md, mw);
  51.  
  52.                 foreach(Transform t in tListP)  t.localScale = Vector3.Scale(t.localScale, sclrvs);
  53.                 foreach(Transform t in tListHL) t.localScale = Vector3.Scale(t.localScale, sclrvs);
  54.                 foreach(Transform t in tListHR) t.localScale = Vector3.Scale(t.localScale, sclrvs);
  55.             }
  56.             if (tscl.Groups.Count >= 3)
  57.             {
  58.                 for (int i=0; i<bm_.bones.Count; i++)
  59.                 {
  60.                     if(bm_.bones[i].linkT.name == "Bip01 L Thigh") tListTL.Add(bm_.bones[i].linkT);
  61.                     if(bm_.bones[i].linkT.name == "Bip01 R Thigh") tListTR.Add(bm_.bones[i].linkT);
  62.                 }
  63.                 if (tListTL.Count < 1 || tListTR.Count < 1) return;
  64.  
  65.                 float mw = Helper.FloatTryParse(tscl.Groups[1].Value);
  66.                 float md = Helper.FloatTryParse(tscl.Groups[2].Value);
  67.                 float mh = 1.0f;
  68.  
  69.                 Vector3 sclrvs = new Vector3(mh, md, mw);
  70.  
  71.                 foreach(Transform t in tListTL) t.localScale = Vector3.Scale(t.localScale, sclrvs);
  72.                 foreach(Transform t in tListTR) t.localScale = Vector3.Scale(t.localScale, sclrvs);
  73.             }
  74.             if (tpos.Groups.Count >= 3)
  75.             {
  76.                 for (int i=0; i<bm_.bones.Count; i++)
  77.                 {
  78.                     if(bm_.bones[i].linkT == null) continue;
  79.                     if(bm_.bones[i].linkT.name == "Hip_L") tListHL.Add(bm_.bones[i].linkT);
  80.                     if(bm_.bones[i].linkT.name == "Hip_R") tListHR.Add(bm_.bones[i].linkT);
  81.                     if(bm_.bones[i].linkT.name == "Bip01 L Thigh") tListTL.Add(bm_.bones[i].linkT);
  82.                     if(bm_.bones[i].linkT.name == "Bip01 R Thigh") tListTR.Add(bm_.bones[i].linkT);
  83.                 }
  84.                 if (tListHL.Count < 1 || tListHR.Count < 1 || tListTL.Count < 1 || tListTR.Count < 1) return;
  85.  
  86.                 float dx = Helper.FloatTryParse(tpos.Groups[1].Value);
  87.                 float dz = Helper.FloatTryParse(tpos.Groups[2].Value);
  88.                 float dy = 0.0f;
  89.    
  90.                 Vector3 posrvsL = new Vector3(dy, dz/1000f, -dx/1000f);
  91.                 Vector3 posrvsR = new Vector3(dy, dz/1000f, dx/1000f);
  92.  
  93.                 foreach(Transform t in tListTL) t.localPosition += posrvsL;
  94.                 foreach(Transform t in tListTR) t.localPosition += posrvsR;
  95.                 foreach(Transform t in tListHL) t.localPosition += posrvsL;
  96.                 foreach(Transform t in tListHR) t.localPosition += posrvsR;
  97.             }
  98.         }
  99.  
  100.  
  101. //2.
  102. //CM3D.MaidVoicePitch.Plugin.cs の void MaidUpdate(Maid maid, bool bEditUpdate) {...} の
  103. //WideSlider(maid, freeComment); 以降で LowerBodyScale 呼び出しを記述
  104.  
  105. //example (+行が追加箇所)
  106.  
  107.         void MaidUpdate(Maid maid, bool bEditUpdate)
  108.         {
  109.  
  110.             (...中略...)
  111.  
  112.             Pitch(maid, freeComment);
  113.             Mabataki(maid, freeComment);
  114.             WideSlider(maid, freeComment);
  115.             EyeBall(maid, freeComment);
  116. +           LowerBodyScale(maid, freeComment);
  117.             TestMabatakiSpeed(maid, freeComment, bEditUpdate);
  118.             TestPelvis(maid, freeComment);
  119.             TestLipSync(maid, freeComment);
  120.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement