PageRenderTime 453ms CodeModel.GetById 141ms app.highlight 4ms RepoModel.GetById 197ms app.codeStats 0ms

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