Poser.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace RootMotion.FinalIK {
  4. /// <summary>
  5. /// The base abstract class for all class that are translating a hierarchy of bones to match the translation of bones in another hierarchy.
  6. /// </summary>
  7. public abstract class Poser: SolverManager {
  8. /// <summary>
  9. /// Reference to the other Transform (should be identical to this one)
  10. /// </summary>
  11. public Transform poseRoot;
  12. /// <summary>
  13. /// The master weight.
  14. /// </summary>
  15. [Range(0f, 1f)] public float weight = 1f;
  16. /// <summary>
  17. /// Weight of localRotation matching
  18. /// </summary>
  19. [Range(0f, 1f)] public float localRotationWeight = 1f;
  20. /// <summary>
  21. /// Weight of localPosition matching
  22. /// </summary>
  23. [Range(0f, 1f)] public float localPositionWeight;
  24. /// <summary>
  25. /// Map this instance to the poseRoot.
  26. /// </summary>
  27. public abstract void AutoMapping();
  28. /// <summary>
  29. /// For manual update of the poser.
  30. /// </summary>
  31. public void UpdateManual() {
  32. UpdatePoser();
  33. }
  34. private bool initiated;
  35. protected abstract void InitiatePoser();
  36. protected abstract void UpdatePoser();
  37. protected abstract void FixPoserTransforms();
  38. /*
  39. * Updates the solver. If you need full control of the execution order of your IK solvers, disable this script and call UpdateSolver() instead.
  40. * */
  41. protected override void UpdateSolver() {
  42. if (!initiated) InitiateSolver();
  43. if (!initiated) return;
  44. UpdatePoser();
  45. }
  46. /*
  47. * Initiates the %IK solver
  48. * */
  49. protected override void InitiateSolver() {
  50. if (initiated) return;
  51. InitiatePoser();
  52. initiated = true;
  53. }
  54. protected override void FixTransforms() {
  55. if (!initiated) return;
  56. FixPoserTransforms();
  57. }
  58. }
  59. }