BipedLimbOrientations.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace RootMotion {
  4. /// <summary>
  5. /// Contains the information about which way the limbs should be bent.
  6. /// </summary>
  7. [System.Serializable]
  8. public class BipedLimbOrientations {
  9. [System.Serializable]
  10. public class LimbOrientation {
  11. public Vector3 upperBoneForwardAxis;
  12. public Vector3 lowerBoneForwardAxis;
  13. public Vector3 lastBoneLeftAxis;
  14. public LimbOrientation(Vector3 upperBoneForwardAxis, Vector3 lowerBoneForwardAxis, Vector3 lastBoneLeftAxis) {
  15. this.upperBoneForwardAxis = upperBoneForwardAxis;
  16. this.lowerBoneForwardAxis = lowerBoneForwardAxis;
  17. this.lastBoneLeftAxis = lastBoneLeftAxis;
  18. }
  19. }
  20. public LimbOrientation leftArm, rightArm, leftLeg, rightLeg;
  21. /// <summary>
  22. /// Initializes a new instance of the <see cref="RootMotion.FinalIK.FullBodyBipedBendDirections"/> class.
  23. /// </summary>
  24. public BipedLimbOrientations (LimbOrientation leftArm, LimbOrientation rightArm, LimbOrientation leftLeg, LimbOrientation rightLeg) {
  25. this.leftArm = leftArm;
  26. this.rightArm = rightArm;
  27. this.leftLeg = leftLeg;
  28. this.rightLeg = rightLeg;
  29. }
  30. /// <summary>
  31. /// Gets the local bend directions of the standard UMA skeleton.
  32. /// </summary>
  33. public static BipedLimbOrientations UMA {
  34. get {
  35. return new BipedLimbOrientations(
  36. new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.forward),
  37. new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.back),
  38. new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.down),
  39. new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.down)
  40. );
  41. }
  42. }
  43. /// <summary>
  44. /// Gets the local bend directions of the standard 3ds Max Biped skeleton.
  45. /// </summary>
  46. public static BipedLimbOrientations MaxBiped {
  47. get {
  48. return new BipedLimbOrientations(
  49. new LimbOrientation(Vector3.down, Vector3.down, Vector3.down),
  50. new LimbOrientation(Vector3.down, Vector3.down, Vector3.up),
  51. new LimbOrientation(Vector3.up, Vector3.up, Vector3.back),
  52. new LimbOrientation(Vector3.up, Vector3.up, Vector3.back)
  53. );
  54. }
  55. }
  56. /*
  57. /// <summary>
  58. /// Contains the local axes of the limb bones that they should bend towards.
  59. /// </summary>
  60. [System.Serializable]
  61. public class Limb {
  62. public Vector3 upper = Vector3.forward, lower = Vector3.forward, last = Vector3.right;
  63. public Limb (Vector3 common) {
  64. this.upper = common;
  65. this.lower = common;
  66. this.last = common;
  67. }
  68. public Limb (Vector3 upper, Vector3 lower, Vector3 last) {
  69. this.upper = upper;
  70. this.lower = lower;
  71. this.last = last;
  72. }
  73. }
  74. public Limb leftArm, rightArm, leftLeg, rightLeg;
  75. /// <summary>
  76. /// Initializes a new instance of the <see cref="RootMotion.FinalIK.FullBodyBipedBendDirections"/> class.
  77. /// </summary>
  78. public FullBodyBipedBendDirections(Vector3 upper, Vector3 lower, Vector3 last) {
  79. this.leftArm = new Limb(upper, lower, last);
  80. this.rightArm = new Limb(upper, lower, last);
  81. this.leftLeg = new Limb(upper, lower, last);
  82. this.rightLeg = new Limb(upper, lower, last);
  83. }
  84. /// <summary>
  85. /// Initializes a new instance of the <see cref="RootMotion.FinalIK.FullBodyBipedBendAxes"/> struct.
  86. /// </summary>
  87. public FullBodyBipedBendDirections(Limb leftArm, Limb rightArm, Limb leftLeg, Limb rightLeg) {
  88. this.leftArm = leftArm;
  89. this.rightArm = rightArm;
  90. this.leftLeg = leftLeg;
  91. this.rightLeg = rightLeg;
  92. }
  93. /// <summary>
  94. /// Gets the local bend directions of the standard UMA skeleton.
  95. /// </summary>
  96. public static FullBodyBipedBendDirections UMA {
  97. get {
  98. return new FullBodyBipedBendDirections(
  99. new Limb(Vector3.back, Vector3.back, Vector3.back),
  100. new Limb(Vector3.back, Vector3.back, Vector3.forward),
  101. new Limb(Vector3.forward, Vector3.forward, Vector3.down),
  102. new Limb(Vector3.forward, Vector3.forward, Vector3.down)
  103. );
  104. }
  105. }
  106. /// <summary>
  107. /// Gets the local bend directions of the standard 3ds Max Biped skeleton.
  108. /// </summary>
  109. public static FullBodyBipedBendDirections MaxBiped {
  110. get {
  111. return new FullBodyBipedBendDirections(
  112. new Limb(Vector3.up, Vector3.up, Vector3.up),
  113. new Limb(Vector3.up, Vector3.up, Vector3.down),
  114. new Limb(Vector3.up, Vector3.up, Vector3.back),
  115. new Limb(Vector3.up, Vector3.up, Vector3.back)
  116. );
  117. }
  118. }
  119. */
  120. }
  121. }