/src/away3d/animators/skeleton/JointPose.as

http://github.com/away3d/away3d-core-fp11 · ActionScript · 63 lines · 31 code · 6 blank · 26 comment · 0 complexity · 93213342c290ca551d787c02a23becbd MD5 · raw file

  1. package away3d.animators.skeleton
  2. {
  3. import away3d.core.math.Quaternion;
  4. import flash.geom.Matrix3D;
  5. import flash.geom.Vector3D;
  6. /**
  7. * JointPose contains transformation data for a skeleton joint, used for skeleton animation.
  8. *
  9. * @see away3d.core.animation.skeleton.Skeleton
  10. * @see away3d.core.animation.skeleton.Joint
  11. *
  12. * todo: support (uniform) scale
  13. */
  14. public class JointPose
  15. {
  16. /**
  17. * The name of the joint this pose is for
  18. */
  19. public var name : String; // intention is that this should be used only at load time, not in the main loop
  20. /**
  21. * The rotation of the joint stored as a quaternion
  22. */
  23. public var orientation : Quaternion = new Quaternion();
  24. /**
  25. * The translation of the joint
  26. */
  27. public var translation : Vector3D = new Vector3D();
  28. /**
  29. * Converts the transformation to a Matrix3D representation.
  30. * @param target An optional target matrix to store the transformation. If not provided, it will create a new instance.
  31. * @return A Matrix3D object containing the transformation.
  32. */
  33. public function toMatrix3D(target : Matrix3D = null) : Matrix3D
  34. {
  35. target ||= new Matrix3D();
  36. orientation.toMatrix3D(target);
  37. target.appendTranslation(translation.x, translation.y, translation.z);
  38. return target;
  39. }
  40. /**
  41. * Copies the transformation data from a different JointPose object
  42. * @param pose the source JointPose object to copy from
  43. */
  44. public function copyFrom(pose : JointPose) : void
  45. {
  46. var or : Quaternion = pose.orientation;
  47. var tr : Vector3D = pose.translation;
  48. orientation.x = or.x;
  49. orientation.y = or.y;
  50. orientation.z = or.z;
  51. orientation.w = or.w;
  52. translation.x = tr.x;
  53. translation.y = tr.y;
  54. translation.z = tr.z;
  55. }
  56. }
  57. }