ShoulderThighIKData.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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, tgt_bone, false)
  8. {
  9. this.Effector = root_effector;
  10. this.Effector.target = base.IKTarget;
  11. this.IKMapping = ik_mapping;
  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. public readonly IKMappingLimb IKMapping;
  84. private ElbowKneeIKData m_ElbowKneeData;
  85. private HandFootIKData m_HandFootData;
  86. }