ShoulderThighIKData.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System;
  2. using RootMotion.FinalIK;
  3. using UnityEngine;
  4. [Serializable]
  5. public class ShoulderThighIKData : LimbIKData
  6. {
  7. public ShoulderThighIKData(IKEffector root_effector, FBIKChain chain, IKMappingLimb ik_mapping, FullBodyIKCtrl ik_ctrl, Transform tgt_bone) : base(ik_ctrl, chain, ik_mapping, tgt_bone, false)
  8. {
  9. this.Effector = root_effector;
  10. this.Effector.target = base.IKTarget;
  11. this.m_IsUpperBody = (this.TargetBone == this.MyIKCtrl.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_L) || this.TargetBone == this.MyIKCtrl.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_R));
  12. this.m_ForceIKEnable = true;
  13. }
  14. public override float PositionWeight
  15. {
  16. get
  17. {
  18. return this.Effector.positionWeight;
  19. }
  20. set
  21. {
  22. this.Effector.positionWeight = value;
  23. }
  24. }
  25. public override float RotationWeight
  26. {
  27. get
  28. {
  29. return this.Effector.rotationWeight;
  30. }
  31. set
  32. {
  33. this.Effector.rotationWeight = value;
  34. }
  35. }
  36. public ElbowKneeIKData ElbowKneeData
  37. {
  38. get
  39. {
  40. return this.m_ElbowKneeData;
  41. }
  42. }
  43. public HandFootIKData HandFootData
  44. {
  45. get
  46. {
  47. return this.m_HandFootData;
  48. }
  49. }
  50. protected override void SetTargetTransform(IKCtrlData.IKSettingData data, Vector3 pos, Quaternion rot)
  51. {
  52. base.SetTargetTransform(data, pos, rot);
  53. Transform iktarget = this.m_HandFootData.IKTarget;
  54. Transform iktarget2 = this.m_ElbowKneeData.IKTarget;
  55. Vector3 position = this.TargetBone.InverseTransformPoint(this.m_ElbowKneeData.TargetBone.position);
  56. Vector3 position2 = this.m_ElbowKneeData.TargetBone.InverseTransformPoint(this.m_HandFootData.TargetBone.position);
  57. if (!data.IsPointAttach)
  58. {
  59. if (!this.m_ElbowKneeData.GetIKSettingData(IKCtrlData.IKAttachType.Rotate).IsIKExec)
  60. {
  61. iktarget2.rotation = base.IKTarget.rotation * this.m_ElbowKneeData.TargetBone.localRotation;
  62. }
  63. if (!this.m_HandFootData.GetIKSettingData(IKCtrlData.IKAttachType.Rotate).IsIKExec)
  64. {
  65. iktarget.rotation = iktarget2.rotation * this.m_HandFootData.TargetBone.localRotation;
  66. }
  67. }
  68. if (!this.m_ElbowKneeData.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint).IsIKExec)
  69. {
  70. iktarget2.position = base.IKTarget.TransformPoint(position);
  71. }
  72. if (!this.m_HandFootData.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint).IsIKExec)
  73. {
  74. iktarget.position = iktarget2.TransformPoint(position2);
  75. }
  76. }
  77. public void SetChainData(HandFootIKData handfoot_data, ElbowKneeIKData elbowknee_data)
  78. {
  79. this.m_HandFootData = handfoot_data;
  80. this.m_ElbowKneeData = elbowknee_data;
  81. }
  82. public readonly IKEffector Effector;
  83. private ElbowKneeIKData m_ElbowKneeData;
  84. private HandFootIKData m_HandFootData;
  85. }