Advertisement
cm3d2-01

ForeArmFix

Aug 18th, 2015
1,871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.94 KB | None | 0 0
  1. // ForeArmFix : 前腕の歪みを修正する CM3D.MaidVoicePitch.Plugin.cs の追加メソッド
  2.  
  3. // CM3D.MaidVoicePitch.Plugin を適用しメイドのフリーコメント欄に #FARMFIX# の記述で前腕の歪みを修正する。
  4.  
  5. //1.
  6. //以下を CM3D.MaidVoicePitch.Plugin.cs の public class MaidVoicePitch {...} の任意の場所に挿入
  7.  
  8.  
  9.         // 前腕歪みバグを修正
  10.         void ForeArmFixAwake()
  11.         {
  12.             string tag = "sintyou";
  13.             string bname = "Bip01 ? Forearm";
  14.             string key = string.Concat("min+" + tag, "*", bname.Replace('?', 'L'));
  15.  
  16.             if (BoneMorph.dic.ContainsKey(key))
  17.             {
  18.                 return;
  19.             }
  20.  
  21.             BoneMorphSetScale(tag, bname, 1f, 1f, 1f, 1f, 1f, 1f);
  22.         }
  23.  
  24.         void ForeArmFix(Maid maid, string freeComment)
  25.         {
  26.             if (freeComment.IndexOf("#FARMFIX#") < 0) return;
  27.  
  28.             BoneMorph_ bm_ = maid.body0.bonemorph;
  29.             List<Transform> tListFAL = new List<Transform>();
  30.             List<Transform> tListFAR = new List<Transform>();
  31.             float sclUAx = -1f;
  32.  
  33.             for (int i=0; i<bm_.bones.Count; i++)
  34.             {
  35.                 if (bm_.bones[i].linkT == null) continue;
  36.                 if (bm_.bones[i].linkT.name == "Bip01 L Forearm") tListFAL.Add(bm_.bones[i].linkT);
  37.                 if (bm_.bones[i].linkT.name == "Bip01 R Forearm") tListFAR.Add(bm_.bones[i].linkT);
  38.                 if (sclUAx < 0f && bm_.bones[i].linkT.name == "Bip01 L UpperArm") sclUAx = bm_.bones[i].linkT.localScale.x;
  39.             }
  40.             if (sclUAx < 0f || tListFAL.Count < 1 || tListFAR.Count < 1) return;
  41.  
  42.             Vector3 sclUA = new Vector3(sclUAx, 1f, 1f);
  43.  
  44.             Vector3 antisclUA_d = new Vector3(1f/sclUAx-1f, 0f, 0f);
  45.  
  46.             Vector3 eaFAL = tListFAL[0].localRotation.eulerAngles;
  47.             Vector3 eaFAR = tListFAR[0].localRotation.eulerAngles;
  48.  
  49.             Quaternion antirotFAL = Quaternion.Euler(eaFAL - new Vector3(180f,180f,180f));
  50.             Quaternion antirotFAR = Quaternion.Euler(eaFAR - new Vector3(180f,180f,180f));
  51.             Vector3 sclFAL_d = antirotFAL * antisclUA_d;
  52.             Vector3 sclFAR_d = antirotFAR * antisclUA_d;
  53.  
  54.             Vector3 antisclFAL = new Vector3(1f, 1f ,1f) + new Vector3(Mathf.Abs(sclFAL_d.x), Mathf.Abs(sclFAL_d.y), Mathf.Abs(sclFAL_d.z));
  55.             Vector3 antisclFAR = new Vector3(1f, 1f ,1f) + new Vector3(Mathf.Abs(sclFAR_d.x), Mathf.Abs(sclFAR_d.y), Mathf.Abs(sclFAR_d.z));
  56.  
  57.             foreach (Transform t in tListFAL) t.localScale = Vector3.Scale(antisclFAL, sclUA);
  58.             foreach (Transform t in tListFAR) t.localScale = Vector3.Scale(antisclFAR, sclUA);
  59.         }
  60.  
  61.  
  62. //2.
  63. //CM3D.MaidVoicePitch.Plugin.cs の public void Awake() {...} 内に、
  64. //ForeArmFixAwake 呼び出しを記述
  65.  
  66. //example (+行が追加箇所)
  67.  
  68.         public void Awake()
  69.         {
  70.             UnityEngine.GameObject.DontDestroyOnLoad(this);
  71.             FlushTemplatesCache();
  72.             FlushCache();
  73.             TestPropSet();
  74.             LowerBodyScaleAwake();
  75. +           ForeArmFixAwake();
  76.         }
  77.  
  78.  
  79. //3.
  80. //CM3D.MaidVoicePitch.Plugin.cs の void MaidUpdate(Maid maid, bool bEditUpdate) {...} の
  81. //WideSlider(maid, freeComment); 以降で ForeArmFix 呼び出しを記述
  82.  
  83. //example (+行が追加箇所)
  84.  
  85.         void MaidUpdate(Maid maid, bool bEditUpdate)
  86.         {
  87.  
  88.             (...中略...)
  89.  
  90.             Pitch(maid, freeComment);
  91.             Mabataki(maid, freeComment);
  92.             WideSlider(maid, freeComment);
  93.             EyeBall(maid, freeComment);
  94.             LowerBodyScale(maid, freeComment);
  95.             EyeScaleRotate(maid, freeComment);
  96. +           ForeArmFix(maid, freeComment);
  97.             TestMabatakiSpeed(maid, freeComment, bEditUpdate);
  98.             TestPelvis(maid, freeComment);
  99.             TestLipSync(maid, freeComment);
  100.             TestSliderTemplate(maid, freeComment);
  101.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement