AnimationsProcessor.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. #region License
  2. // Copyright 2011-2016 Kastellanos Nikolaos
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #endregion
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using Microsoft.Xna.Framework;
  20. using Microsoft.Xna.Framework.Content.Pipeline;
  21. using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
  22. using Microsoft.Xna.Framework.Graphics;
  23. using nkast.Aether.Content.Pipeline.Animation;
  24. namespace nkast.Aether.Content.Pipeline.Processors
  25. {
  26. [ContentProcessor(DisplayName = "Animation - Aether")]
  27. class AnimationsProcessor : ContentProcessor<NodeContent, AnimationsContent>
  28. {
  29. private int _maxBones = SkinnedEffect.MaxBones;
  30. private int _generateKeyframesFrequency = 0;
  31. private bool _fixRealBoneRoot = false;
  32. [DisplayName("MaxBones")]
  33. [DefaultValue(SkinnedEffect.MaxBones)]
  34. public virtual int MaxBones
  35. {
  36. get { return _maxBones; }
  37. set { _maxBones = value; }
  38. }
  39. [DisplayName("Generate Keyframes Frequency")]
  40. [DefaultValue(0)] // (0=no, 30=30fps, 60=60fps)
  41. public virtual int GenerateKeyframesFrequency
  42. {
  43. get { return _generateKeyframesFrequency; }
  44. set { _generateKeyframesFrequency = value; }
  45. }
  46. [DisplayName("Fix BoneRoot from MG importer")]
  47. [DefaultValue(false)]
  48. public virtual bool FixRealBoneRoot
  49. {
  50. get { return _fixRealBoneRoot; }
  51. set { _fixRealBoneRoot = value; }
  52. }
  53. public override AnimationsContent Process(NodeContent input, ContentProcessorContext context)
  54. {
  55. if(_fixRealBoneRoot)
  56. MGFixRealBoneRoot(input, context);
  57. ValidateMesh(input, context, null);
  58. // Find the skeleton.
  59. BoneContent skeleton = MeshHelper.FindSkeleton(input);
  60. if (skeleton == null)
  61. throw new InvalidContentException("Input skeleton not found.");
  62. // We don't want to have to worry about different parts of the model being
  63. // in different local coordinate systems, so let's just bake everything.
  64. FlattenTransforms(input, skeleton);
  65. // Read the bind pose and skeleton hierarchy data.
  66. IList<BoneContent> bones = MeshHelper.FlattenSkeleton(skeleton);
  67. if (bones.Count > MaxBones)
  68. {
  69. throw new InvalidContentException(string.Format("Skeleton has {0} bones, but the maximum supported is {1}.", bones.Count, MaxBones));
  70. }
  71. List<Matrix> bindPose = new List<Matrix>();
  72. List<Matrix> invBindPose = new List<Matrix>();
  73. List<int> skeletonHierarchy = new List<int>();
  74. List<string> boneNames = new List<string>();
  75. foreach(var bone in bones)
  76. {
  77. bindPose.Add(bone.Transform);
  78. invBindPose.Add(Matrix.Invert(bone.AbsoluteTransform));
  79. skeletonHierarchy.Add(bones.IndexOf(bone.Parent as BoneContent));
  80. boneNames.Add(bone.Name);
  81. }
  82. // Convert animation data to our runtime format.
  83. Dictionary<string, ClipContent> clips;
  84. clips = ProcessAnimations(input, context, skeleton.Animations, bones, GenerateKeyframesFrequency);
  85. return new AnimationsContent(bindPose, invBindPose, skeletonHierarchy, boneNames, clips);
  86. }
  87. /// <summary>
  88. /// MonoGame converts some NodeContent into BoneContent.
  89. /// Here we revert that to get the original Skeleton and
  90. /// add the real boneroot to the root node.
  91. /// </summary>
  92. private void MGFixRealBoneRoot(NodeContent input, ContentProcessorContext context)
  93. {
  94. for (int i = input.Children.Count - 1; i >= 0; i--)
  95. {
  96. var node = input.Children[i];
  97. if (node is BoneContent &&
  98. node.AbsoluteTransform == Matrix.Identity &&
  99. node.Children.Count ==1 &&
  100. node.Children[0] is BoneContent &&
  101. node.Children[0].AbsoluteTransform == Matrix.Identity
  102. )
  103. {
  104. //dettach real boneRoot
  105. var realBoneRoot = node.Children[0];
  106. node.Children.RemoveAt(0);
  107. //copy animation from node to boneRoot
  108. foreach (var animation in node.Animations)
  109. realBoneRoot.Animations.Add(animation.Key, animation.Value);
  110. // convert fake BoneContent back to NodeContent
  111. input.Children[i] = new NodeContent()
  112. {
  113. Name = node.Name,
  114. Identity = node.Identity,
  115. Transform = node.Transform,
  116. };
  117. foreach (var animation in node.Animations)
  118. input.Children[i].Animations.Add(animation.Key, animation.Value);
  119. foreach (var opaqueData in node.OpaqueData)
  120. input.Children[i].OpaqueData.Add(opaqueData.Key, opaqueData.Value);
  121. //attach real boneRoot to the root node
  122. input.Children.Add(realBoneRoot);
  123. break;
  124. }
  125. }
  126. }
  127. /// <summary>
  128. /// Makes sure this mesh contains the kind of data we know how to animate.
  129. /// </summary>
  130. void ValidateMesh(NodeContent node, ContentProcessorContext context, string parentBoneName)
  131. {
  132. MeshContent mesh = node as MeshContent;
  133. if (mesh != null)
  134. {
  135. // Validate the mesh.
  136. if (parentBoneName != null)
  137. {
  138. context.Logger.LogWarning(null, null,
  139. "Mesh {0} is a child of bone {1}. AnimatedModelProcessor " +
  140. "does not correctly handle meshes that are children of bones.",
  141. mesh.Name, parentBoneName);
  142. }
  143. if (!MeshHasSkinning(mesh))
  144. {
  145. context.Logger.LogWarning(null, null,
  146. "Mesh {0} has no skinning information, so it has been deleted.",
  147. mesh.Name);
  148. mesh.Parent.Children.Remove(mesh);
  149. return;
  150. }
  151. }
  152. else if (node is BoneContent)
  153. {
  154. // If this is a bone, remember that we are now looking inside it.
  155. parentBoneName = node.Name;
  156. }
  157. // Recurse (iterating over a copy of the child collection,
  158. // because validating children may delete some of them).
  159. foreach (NodeContent child in new List<NodeContent>(node.Children))
  160. ValidateMesh(child, context, parentBoneName);
  161. }
  162. /// <summary>
  163. /// Checks whether a mesh contains skininng information.
  164. /// </summary>
  165. bool MeshHasSkinning(MeshContent mesh)
  166. {
  167. foreach (GeometryContent geometry in mesh.Geometry)
  168. {
  169. if (!geometry.Vertices.Channels.Contains(VertexChannelNames.Weights()) &&
  170. !geometry.Vertices.Channels.Contains("BlendWeight0"))
  171. return false;
  172. }
  173. return true;
  174. }
  175. /// <summary>
  176. /// Bakes unwanted transforms into the model geometry,
  177. /// so everything ends up in the same coordinate system.
  178. /// </summary>
  179. void FlattenTransforms(NodeContent node, BoneContent skeleton)
  180. {
  181. foreach (NodeContent child in node.Children)
  182. {
  183. // Don't process the skeleton, because that is special.
  184. if (child == skeleton)
  185. continue;
  186. // Bake the local transform into the actual geometry.
  187. MeshHelper.TransformScene(child, child.Transform);
  188. // Having baked it, we can now set the local
  189. // coordinate system back to identity.
  190. child.Transform = Matrix.Identity;
  191. // Recurse.
  192. FlattenTransforms(child, skeleton);
  193. }
  194. }
  195. /// <summary>
  196. /// Converts an intermediate format content pipeline AnimationContentDictionary
  197. /// object to our runtime AnimationClip format.
  198. /// </summary>
  199. Dictionary<string, ClipContent> ProcessAnimations(NodeContent input, ContentProcessorContext context, AnimationContentDictionary animations, IList<BoneContent> bones, int generateKeyframesFrequency)
  200. {
  201. // Build up a table mapping bone names to indices.
  202. Dictionary<string, int> boneMap = new Dictionary<string, int>();
  203. for (int i = 0; i < bones.Count; i++)
  204. {
  205. string boneName = bones[i].Name;
  206. if (!string.IsNullOrEmpty(boneName))
  207. boneMap.Add(boneName, i);
  208. }
  209. // Convert each animation in turn.
  210. Dictionary<string, ClipContent> animationClips;
  211. animationClips = new Dictionary<string, ClipContent>();
  212. foreach (KeyValuePair<string, AnimationContent> animation in animations)
  213. {
  214. ClipContent clip = ProcessAnimation(input, context, animation.Value, boneMap, generateKeyframesFrequency);
  215. animationClips.Add(animation.Key, clip);
  216. }
  217. if (animationClips.Count == 0)
  218. {
  219. //throw new InvalidContentException("Input file does not contain any animations.");
  220. context.Logger.LogWarning(null, null, "Input file does not contain any animations.");
  221. }
  222. return animationClips;
  223. }
  224. /// <summary>
  225. /// Converts an intermediate format content pipeline AnimationContent
  226. /// object to our runtime AnimationClip format.
  227. /// </summary>
  228. ClipContent ProcessAnimation(NodeContent input, ContentProcessorContext context, AnimationContent animation, Dictionary<string, int> boneMap, int generateKeyframesFrequency)
  229. {
  230. List<KeyframeContent> keyframes = new List<KeyframeContent>();
  231. // For each input animation channel.
  232. foreach (KeyValuePair<string, AnimationChannel> channel in
  233. animation.Channels)
  234. {
  235. // Look up what bone this channel is controlling.
  236. int boneIndex;
  237. if (!boneMap.TryGetValue(channel.Key, out boneIndex))
  238. {
  239. //throw new InvalidContentException(string.Format("Found animation for bone '{0}', which is not part of the skeleton.", channel.Key));
  240. context.Logger.LogWarning(null, null, "Found animation for bone '{0}', which is not part of the skeleton.", channel.Key);
  241. continue;
  242. }
  243. foreach (AnimationKeyframe keyframe in channel.Value)
  244. keyframes.Add(new KeyframeContent(boneIndex, keyframe.Time, keyframe.Transform));
  245. }
  246. // Sort the merged keyframes by time.
  247. keyframes.Sort(CompareKeyframeTimes);
  248. //System.Diagnostics.Debugger.Launch();
  249. if (generateKeyframesFrequency > 0)
  250. keyframes = InterpolateKeyframes(animation.Duration, keyframes, generateKeyframesFrequency);
  251. keyframes = EnsureFirstKeyframeExists(animation.Duration, keyframes);
  252. if (keyframes.Count == 0)
  253. throw new InvalidContentException("Animation has no keyframes.");
  254. if (animation.Duration <= TimeSpan.Zero)
  255. throw new InvalidContentException("Animation has a zero duration.");
  256. return new ClipContent(animation.Duration, keyframes.ToArray());
  257. }
  258. static int CompareKeyframeTimes(KeyframeContent a, KeyframeContent b)
  259. {
  260. int cmpTime = a.Time.CompareTo(b.Time);
  261. if (cmpTime == 0)
  262. return a.Bone.CompareTo(b.Bone);
  263. return cmpTime;
  264. }
  265. private List<KeyframeContent> InterpolateKeyframes(TimeSpan duration, List<KeyframeContent> keyframes, int generateKeyframesFrequency)
  266. {
  267. if (generateKeyframesFrequency <= 0)
  268. return keyframes;
  269. int keyframeCount = keyframes.Count;
  270. //
  271. System.Diagnostics.Debug.WriteLine("Duration: " + duration);
  272. System.Diagnostics.Debug.WriteLine("keyframeCount: " + keyframeCount);
  273. // find bones
  274. HashSet<int> bonesSet = new HashSet<int>();
  275. int maxBone = 0;
  276. double maxTime = 0;
  277. for (int i = 0; i < keyframeCount; i++)
  278. {
  279. int bone = keyframes[i].Bone;
  280. maxBone = Math.Max(maxBone, bone);
  281. maxTime = Math.Max(maxTime, keyframes[i].Time.TotalSeconds);
  282. bonesSet.Add(bone);
  283. }
  284. int boneCount = bonesSet.Count;
  285. // check if keyframes are allready fully interpolated
  286. int frames = keyframeCount / boneCount;
  287. TimeSpan checkDuration = TimeSpan.FromSeconds((frames - 1) / generateKeyframesFrequency);
  288. if (duration == checkDuration)
  289. return keyframes;
  290. // split bones
  291. List<KeyframeContent>[] boneFrames = new List<KeyframeContent>[maxBone + 1];
  292. for (int i = 0; i < keyframeCount; i++)
  293. {
  294. int bone = keyframes[i].Bone;
  295. if (boneFrames[bone] == null) boneFrames[bone] = new List<KeyframeContent>();
  296. boneFrames[bone].Add(keyframes[i]);
  297. }
  298. // Interpolate Frames for each bone
  299. for (int b = 0; b < boneFrames.Length; b++)
  300. {
  301. boneFrames[b] = InterpolateFramesBone(b, boneFrames[b], duration, generateKeyframesFrequency);
  302. }
  303. // copy keyframes from boneFrames back to a flat list and order them by time
  304. List<KeyframeContent> newKeyframes = new List<KeyframeContent>();
  305. for (int b = 0; b < boneFrames.Length; b++)
  306. {
  307. if (boneFrames[b] != null)
  308. {
  309. for (int k = 0; k < boneFrames[b].Count; ++k)
  310. {
  311. newKeyframes.Add(boneFrames[b][k]);
  312. }
  313. }
  314. }
  315. newKeyframes.Sort(CompareKeyframeTimes);
  316. return newKeyframes;
  317. }
  318. // the player currently requires all bones to have a keyframe at time zero
  319. private List<KeyframeContent> EnsureFirstKeyframeExists(TimeSpan duration, List<KeyframeContent> keyframes)
  320. {
  321. int keyframeCount = keyframes.Count;
  322. // find bones
  323. HashSet<int> bonesSet = new HashSet<int>();
  324. int maxBone = 0;
  325. for (int i = 0; i < keyframeCount; i++)
  326. {
  327. int bone = keyframes[i].Bone;
  328. maxBone = Math.Max(maxBone, bone);
  329. bonesSet.Add(bone);
  330. }
  331. int boneCount = bonesSet.Count;
  332. // split bones
  333. List<KeyframeContent>[] boneFrames = new List<KeyframeContent>[maxBone + 1];
  334. for (int i = 0; i < keyframeCount; i++)
  335. {
  336. int bone = keyframes[i].Bone;
  337. if (boneFrames[bone] == null) boneFrames[bone] = new List<KeyframeContent>();
  338. boneFrames[bone].Add(keyframes[i]);
  339. }
  340. //
  341. System.Diagnostics.Debug.WriteLine("Duration: " + duration);
  342. System.Diagnostics.Debug.WriteLine("keyframeCount: " + keyframeCount);
  343. for (int b = 0; b < boneFrames.Length; b++)
  344. {
  345. if (boneFrames[b] == null)
  346. continue;
  347. if (boneFrames[b][0].Time != TimeSpan.Zero)
  348. {
  349. var keyframe0 = new KeyframeContent(boneFrames[b][0].Bone, TimeSpan.Zero, boneFrames[b][0].Transform);
  350. boneFrames[b].Insert(0, keyframe0);
  351. }
  352. }
  353. List<KeyframeContent> newKeyframes = new List<KeyframeContent>();
  354. for (int b = 0; b < boneFrames.Length; b++)
  355. {
  356. if (boneFrames[b] != null)
  357. {
  358. for (int k = 0; k < boneFrames[b].Count; ++k)
  359. {
  360. newKeyframes.Add(boneFrames[b][k]);
  361. }
  362. }
  363. }
  364. newKeyframes.Sort(CompareKeyframeTimes);
  365. return newKeyframes;
  366. }
  367. private static List<KeyframeContent> InterpolateFramesBone(int bone, List<KeyframeContent> frames, TimeSpan duration, int generateKeyframesFrequency)
  368. {
  369. System.Diagnostics.Debug.WriteLine("");
  370. System.Diagnostics.Debug.WriteLine("Bone: " + bone);
  371. if (frames == null)
  372. {
  373. System.Diagnostics.Debug.WriteLine("Frames: " + "null");
  374. return frames;
  375. }
  376. System.Diagnostics.Debug.WriteLine("Frames: " + frames.Count);
  377. System.Diagnostics.Debug.WriteLine("MinTime: " + frames[0].Time);
  378. System.Diagnostics.Debug.WriteLine("MaxTime: " + frames[frames.Count - 1].Time);
  379. List<KeyframeContent> newFrames = new List<KeyframeContent>();
  380. if (frames.Count == 1)
  381. {
  382. TimeSpan time = TimeSpan.Zero;
  383. int frame = 0;
  384. for (; time < duration; frame++)
  385. {
  386. long timeTicks = (frame * TimeSpan.TicksPerSecond) / generateKeyframesFrequency;
  387. time = TimeSpan.FromTicks(timeTicks);
  388. newFrames.Add(new KeyframeContent(bone, time, frames[0].Transform));
  389. }
  390. }
  391. else
  392. {
  393. generateKeyframesFrequency = 60;
  394. int lastKeyFrame = (frames.Count - 1);
  395. int keyFrameA = lastKeyFrame;
  396. int keyFrameB = 0;
  397. TimeSpan timeA = frames[keyFrameA].Time - duration; // timeA is initially lower than TimeSpan.Zero
  398. TimeSpan timeB = frames[keyFrameB].Time;
  399. TimeSpan diffAB = timeB - timeA;
  400. Matrix mA = frames[keyFrameA].Transform;
  401. Matrix mB = frames[keyFrameB].Transform;
  402. Matrix mBlend = Matrix.Identity;
  403. TimeSpan time = TimeSpan.Zero;
  404. int frame = 0;
  405. for (; time < duration; frame++)
  406. {
  407. long timeTicks = (frame * TimeSpan.TicksPerSecond) / generateKeyframesFrequency;
  408. time = TimeSpan.FromTicks(timeTicks);
  409. while (time > timeB)
  410. {
  411. keyFrameA = keyFrameB;
  412. timeA = timeB;
  413. mA = mB;
  414. keyFrameB = (keyFrameB + 1) % frames.Count;
  415. timeB = frames[keyFrameB].Time;
  416. if (timeB < timeA)
  417. timeB += duration; // timeB is now greater than duration
  418. mB = frames[keyFrameB].Transform;
  419. diffAB = timeB - timeA;
  420. }
  421. // if the first keyFrame is at time zero, we skip interpolation with the prev/last keyframe.
  422. if (keyFrameB == 0 && timeB == TimeSpan.Zero)
  423. {
  424. mBlend = mB;
  425. }
  426. else
  427. {
  428. TimeSpan diffB = timeB - time;
  429. float amount = 1f - (float)((double)diffB.Ticks / (double)diffAB.Ticks);
  430. MatrixLerpDecomposition(ref mA, ref mB, amount, ref mBlend);
  431. }
  432. newFrames.Add(new KeyframeContent(bone, time, mBlend));
  433. System.Diagnostics.Debug.WriteLine("{Time:" + time);
  434. }
  435. }
  436. //newFrames.AddRange(frames);
  437. newFrames.Sort(CompareKeyframeTimes);
  438. //TimeSpan keySpan = TimeSpan.FromTicks((long)((1f / generateKeyframesFrequency) * TimeSpan.TicksPerSecond));
  439. //for (int i = 0; i < frames.Count - 1; ++i)
  440. //{
  441. // InterpolateFrames(bone, frames, keySpan, i);
  442. //}
  443. return newFrames;
  444. }
  445. private static void InterpolateFrames(int bone, List<KeyframeContent> frames, TimeSpan keySpan, int i)
  446. {
  447. int a = i;
  448. int b = i + 1;
  449. var diff = frames[b].Time - frames[a].Time;
  450. Matrix mBlend = Matrix.Identity;
  451. if (diff > keySpan)
  452. {
  453. TimeSpan newTime = frames[a].Time + keySpan;
  454. float amount = (float)(keySpan.TotalSeconds / diff.TotalSeconds);
  455. Matrix m1 = frames[a].Transform;
  456. Matrix m2 = frames[b].Transform;
  457. MatrixLerpDecomposition(ref m1, ref m2, amount, ref mBlend);
  458. frames.Insert(b, new KeyframeContent(bone, newTime, mBlend));
  459. }
  460. return;
  461. }
  462. private static void MatrixLerpPrecise(ref Matrix m1, ref Matrix m2, float amount, ref Matrix result)
  463. {
  464. float w1 = 1f - amount;
  465. float w2 = amount;
  466. result.M11 = (m1.M11 * w1) + (m2.M11 * w2);
  467. result.M12 = (m1.M12 * w1) + (m2.M12 * w2);
  468. result.M13 = (m1.M13 * w1) + (m2.M13 * w2);
  469. result.M21 = (m1.M21 * w1) + (m2.M21 * w2);
  470. result.M22 = (m1.M22 * w1) + (m2.M22 * w2);
  471. result.M23 = (m1.M23 * w1) + (m2.M23 * w2);
  472. result.M31 = (m1.M31 * w1) + (m2.M31 * w2);
  473. result.M32 = (m1.M32 * w1) + (m2.M32 * w2);
  474. result.M33 = (m1.M33 * w1) + (m2.M33 * w2);
  475. result.M41 = (m1.M41 * w1) + (m2.M41 * w2);
  476. result.M42 = (m1.M42 * w1) + (m2.M42 * w2);
  477. result.M43 = (m1.M43 * w1) + (m2.M43 * w2);
  478. }
  479. private static void MatrixLerpDecomposition(ref Matrix m1, ref Matrix m2, float amount, ref Matrix mBlend)
  480. {
  481. Vector3 pScale; Quaternion pRotation; Vector3 pTranslation;
  482. m1.Decompose(out pScale, out pRotation, out pTranslation);
  483. Vector3 iScale; Quaternion iRotation; Vector3 iTranslation;
  484. m2.Decompose(out iScale, out iRotation, out iTranslation);
  485. Vector3 Scale; Quaternion Rotation; Vector3 Translation;
  486. //lerp
  487. Vector3.Lerp(ref pScale, ref iScale, amount, out Scale);
  488. Quaternion.Slerp(ref pRotation, ref iRotation, amount, out Rotation);
  489. Vector3.Lerp(ref pTranslation, ref iTranslation, amount, out Translation);
  490. Matrix rotation;
  491. Matrix.CreateFromQuaternion(ref Rotation, out rotation);
  492. mBlend.M11 = Scale.X * rotation.M11;
  493. mBlend.M12 = Scale.X * rotation.M12;
  494. mBlend.M13 = Scale.X * rotation.M13;
  495. mBlend.M21 = Scale.Y * rotation.M21;
  496. mBlend.M22 = Scale.Y * rotation.M22;
  497. mBlend.M23 = Scale.Y * rotation.M23;
  498. mBlend.M31 = Scale.Z * rotation.M31;
  499. mBlend.M32 = Scale.Z * rotation.M32;
  500. mBlend.M33 = Scale.Z * rotation.M33;
  501. mBlend.M41 = Translation.X;
  502. mBlend.M42 = Translation.Y;
  503. mBlend.M43 = Translation.Z;
  504. }
  505. }
  506. }