diff options
Diffstat (limited to '')
-rw-r--r-- | NW4RTools/Models/VertexData.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/NW4RTools/Models/VertexData.cs b/NW4RTools/Models/VertexData.cs index 187b9aa..feb8eb6 100644 --- a/NW4RTools/Models/VertexData.cs +++ b/NW4RTools/Models/VertexData.cs @@ -60,6 +60,54 @@ namespace NW4RTools.Models { } } + public virtual void Save() { + int elementCount = Data[0].Length; + float scale = 1.0f / (1 << Fraction); + var output = new OutputStream(); + + switch (ComponentType) { + case VertexSettings.CompType.UInt8: + foreach (var array in Data) { + for (int i = 0; i < elementCount; i++) { + output.WriteByte((byte)(array[i] / scale)); + } + } + break; + case VertexSettings.CompType.Int8: + foreach (var array in Data) { + for (int i = 0; i < elementCount; i++) { + output.WriteSByte((sbyte)(array[i] / scale)); + } + } + break; + case VertexSettings.CompType.UInt16: + foreach (var array in Data) { + for (int i = 0; i < elementCount; i++) { + output.WriteUInt16((ushort)(array[i] / scale)); + } + } + break; + case VertexSettings.CompType.Int16: + foreach (var array in Data) { + for (int i = 0; i < elementCount; i++) { + output.WriteInt16((short)(array[i] / scale)); + } + } + break; + case VertexSettings.CompType.Float32: + foreach (var array in Data) { + for (int i = 0; i < elementCount; i++) { + output.WriteFloat(array[i]); + } + } + break; + default: + throw new NotImplementedException(String.Format("unimplemented type {0}", (int)ComponentType)); + } + + RawData = output.GetBuffer(); + } + public abstract int GetRealCount(); } @@ -186,6 +234,10 @@ namespace NW4RTools.Models { return ret; } + + public override void Save() { + throw new NotImplementedException(); + } } |