ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/OniSplit/Physics/ObjectDatWriter.cs
Revision: 1114
Committed: Wed Jan 22 14:08:57 2020 UTC (5 years, 8 months ago) by iritscen
File size: 1312 byte(s)
Log Message:
Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File Contents

# Content
1 using System;
2
3 namespace 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 }