source: OniSplit/Physics/ObjectDatWriter.cs@ 1131

Last change on this file since 1131 was 1114, checked in by iritscen, 5 years ago

Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File size: 1.3 KB
RevLine 
[1114]1using System;
2
3namespace Oni.Physics
4{
5 internal class ObjectDatWriter
6 {
7 internal static ImporterDescriptor WriteAnimation(ObjectAnimation animation, Importer importer)
8 {
9 var frame0 = animation.Keys[0];
10 var scaleMatrix = Matrix.CreateScale(frame0.Scale);
11
12 var startMatrix = scaleMatrix
13 * Matrix.CreateFromQuaternion(frame0.Rotation)
14 * Matrix.CreateTranslation(frame0.Translation);
15
16 var oban = importer.CreateInstance(TemplateTag.OBAN, animation.Name);
17
18 using (var writer = oban.OpenWrite(12))
19 {
20 writer.Write((int)animation.Flags);
21 writer.WriteMatrix4x3(startMatrix);
22 writer.WriteMatrix4x3(scaleMatrix);
23 writer.WriteInt16(1);
24 writer.WriteUInt16(animation.Length);
25 writer.WriteInt16(animation.Stop);
26 writer.WriteUInt16(animation.Keys.Length);
27
28 foreach (var key in animation.Keys)
29 {
30 writer.Write(key.Rotation);
31 writer.Write(key.Translation);
32 writer.Write(key.Time);
33 }
34 }
35
36 return oban;
37 }
38 }
39}
Note: See TracBrowser for help on using the repository browser.