MuneIKCtrl.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using kt.ik;
  3. using UnityEngine;
  4. [Serializable]
  5. public class MuneIKCtrl : FreeFBIKCtrl
  6. {
  7. public MuneIKCtrl(FullBodyIKMgr ik_mgr, FullBodyIKMgr.IKEffectorType effector_type) : base(ik_mgr, effector_type, true, FullBodyIKMgr.IKBoneType.None)
  8. {
  9. }
  10. private string AttachPointName
  11. {
  12. get
  13. {
  14. return (this.effectorType != FullBodyIKMgr.IKEffectorType.Bust_L) ? "乳首右" : "乳首左";
  15. }
  16. }
  17. public override void SetIKSetting(IKAttachParam param)
  18. {
  19. base.SetIKSetting(param);
  20. base.isNeedAttachTargetUpdatePreExec = true;
  21. }
  22. protected override void SetTargetTransform(AIKCtrl.IKSettingData data, Vector3 pos, Quaternion rot)
  23. {
  24. if (data.isPointAttach)
  25. {
  26. Vector3 b = base.bone.position - this.GetNipplePosRot().pos;
  27. pos += b;
  28. }
  29. base.SetTargetTransform(data, pos, rot);
  30. }
  31. private AIKCtrl.PosRotPair GetNipplePosRot()
  32. {
  33. AIKCtrl.PosRotPair result = default(AIKCtrl.PosRotPair);
  34. int slotNo = this.myIKMgr.body.GetSlotNo("body");
  35. if (this.myIKMgr.body.goSlot[slotNo].morph == null)
  36. {
  37. return result;
  38. }
  39. Vector3 pos;
  40. Quaternion rot;
  41. Vector3 vector;
  42. if (this.myIKMgr.body.goSlot[slotNo].morph.GetAttachPoint(this.AttachPointName, out pos, out rot, out vector, false))
  43. {
  44. result.pos = pos;
  45. result.rot = rot;
  46. }
  47. return result;
  48. }
  49. }