OSDN Git Service

refactored. GetHashCode
[tdcgexplorer/tso2mqo.git] / TSOWriter.cs
index d392946..33acba4 100644 (file)
@@ -2,11 +2,8 @@
 using System.Collections.Generic;\r
 using System.IO;\r
 using System.Text;\r
-using Microsoft.DirectX;\r
-using Microsoft.DirectX.Direct3D;\r
-using tso2mqo.Extensions;\r
 \r
-namespace tso2mqo\r
+namespace Tso2MqoGui\r
 {\r
     public class TSOWriter\r
     {\r
@@ -42,11 +39,8 @@ namespace tso2mqo
 \r
             bw.Write(items.Length);\r
 \r
-            foreach (var i in items)\r
-            {\r
-                Matrix m = i.Matrix;\r
-                bw.Write(ref m);\r
-            }\r
+            foreach(var i in items)\r
+                Write(bw, i.Matrix);\r
         }\r
 \r
         public static void Write(BinaryWriter bw, TSONode item)\r
@@ -54,6 +48,14 @@ namespace tso2mqo
             Write(bw, item.Name);\r
         }\r
 \r
+        public static void Write(BinaryWriter bw, Matrix44 item)\r
+        {\r
+            bw.Write(item.M11); bw.Write(item.M12); bw.Write(item.M13); bw.Write(item.M14);\r
+            bw.Write(item.M21); bw.Write(item.M22); bw.Write(item.M23); bw.Write(item.M24);\r
+            bw.Write(item.M31); bw.Write(item.M32); bw.Write(item.M33); bw.Write(item.M34);\r
+            bw.Write(item.M41); bw.Write(item.M42); bw.Write(item.M43); bw.Write(item.M44);\r
+        }\r
+\r
         public static void Write(BinaryWriter bw, TSOTex[] items)\r
         {\r
             bw.Write(items.Length);\r
@@ -112,8 +114,7 @@ namespace tso2mqo
         public static void Write(BinaryWriter bw, TSOMesh item)\r
         {\r
             Write(bw, item.Name);\r
-            Matrix m = item.Matrix;\r
-            bw.Write(ref m);\r
+            Write(bw, item.Matrix);\r
             bw.Write(1);\r
             Write(bw, item.sub);\r
         }\r
@@ -147,13 +148,13 @@ namespace tso2mqo
             List<int>   idxs    = new List<int>(4);\r
             List<float> wgts    = new List<float>(4);\r
 \r
-            if(v.Wgt.X > 0) { idxs.Add(idx[0]); wgts.Add(v.Wgt.X); }\r
-            if(v.Wgt.Y > 0) { idxs.Add(idx[1]); wgts.Add(v.Wgt.Y); }\r
-            if(v.Wgt.Z > 0) { idxs.Add(idx[2]); wgts.Add(v.Wgt.Z); }\r
-            if(v.Wgt.W > 0) { idxs.Add(idx[3]); wgts.Add(v.Wgt.W); }\r
+            if(v.Wgt.x > 0) { idxs.Add(idx[0]); wgts.Add(v.Wgt.x); }\r
+            if(v.Wgt.y > 0) { idxs.Add(idx[1]); wgts.Add(v.Wgt.y); }\r
+            if(v.Wgt.z > 0) { idxs.Add(idx[2]); wgts.Add(v.Wgt.z); }\r
+            if(v.Wgt.w > 0) { idxs.Add(idx[3]); wgts.Add(v.Wgt.w); }\r
 \r
-            bw.Write(ref v.Pos);\r
-            bw.Write(ref v.Nrm);\r
+            bw.Write(v.Pos.X); bw.Write(v.Pos.Y); bw.Write(v.Pos.Z);\r
+            bw.Write(v.Nrm.X); bw.Write(v.Nrm.Y); bw.Write(v.Nrm.Z);\r
             bw.Write(v.Tex.X); bw.Write(v.Tex.Y);\r
 \r
             bw.Write(wgts.Count);\r