summaryrefslogtreecommitdiff
path: root/NW4RTools/Models/VertexData.cs
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-03-05 05:25:14 +0100
committerTreeki <treeki@gmail.com>2011-03-05 05:25:14 +0100
commite962fd89af865d6e01522e9752f5fbd855ce128a (patch)
tree0fb19e74a2d87b2ece48152fee2b2f4ed963828c /NW4RTools/Models/VertexData.cs
parenta5b6dc1789f2e06a26fe6a0510aee04aeccdc70b (diff)
downloadnw4rtools-e962fd89af865d6e01522e9752f5fbd855ce128a.tar.gz
nw4rtools-e962fd89af865d6e01522e9752f5fbd855ce128a.zip
partially working obj importer. still untested in-game
Diffstat (limited to 'NW4RTools/Models/VertexData.cs')
-rw-r--r--NW4RTools/Models/VertexData.cs52
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();
+ }
}