OSDN Git Service

change type MqoObject#vertices
authornomeu <nomeu@nomeu.org>
Sat, 24 Jan 2015 19:27:01 +0000 (04:27 +0900)
committernomeu <nomeu@nomeu.org>
Sat, 24 Jan 2015 19:27:01 +0000 (04:27 +0900)
change from List<Point3> to List<UVertex>.

MqoFile.cs
TSOGenerator.cs

index 80939ca..0ee3e1d 100644 (file)
@@ -323,7 +323,7 @@ namespace Tso2MqoGui
                         if (tokens[2] != "{")
                             Error(tokens);
 
-                        current.vertices = new List<Point3>(int.Parse(tokens[1]));
+                        current.vertices = new List<UVertex>(int.Parse(tokens[1]));
                         DoRead(SectionVertex);
                     }
                     break;
@@ -355,7 +355,9 @@ namespace Tso2MqoGui
             if (tokens[0] == "}")
                 return false;
 
-            current.vertices.Add(Point3.Parse(tokens, 0));
+            UVertex v = new UVertex();
+            v.Pos = Point3.Parse(tokens, 0);
+            current.vertices.Add(v);
 
             return true;
         }
@@ -520,7 +522,7 @@ namespace Tso2MqoGui
         public float facet;
         public Color3 color;
         public int color_type;
-        public List<Point3> vertices;
+        public List<UVertex> vertices;
         public List<MqoFace> faces;
 
         public MqoObject() { }
index 5f2bf47..d5da8e8 100644 (file)
@@ -459,8 +459,8 @@ namespace Tso2MqoGui
 \r
                 foreach (MqoFace face in obj.faces)\r
                 {\r
-                    Point3 v1 = Point3.Normalize(obj.vertices[face.b] - obj.vertices[face.a]);\r
-                    Point3 v2 = Point3.Normalize(obj.vertices[face.c] - obj.vertices[face.b]);\r
+                    Point3 v1 = Point3.Normalize(obj.vertices[face.b].Pos - obj.vertices[face.a].Pos);\r
+                    Point3 v2 = Point3.Normalize(obj.vertices[face.c].Pos - obj.vertices[face.b].Pos);\r
                     Point3 n = Point3.Normalize(Point3.Cross(v1, v2));\r
                     normal[face.a] -= n;\r
                     normal[face.b] -= n;\r
@@ -502,9 +502,9 @@ namespace Tso2MqoGui
                         if (face.mtl != mtl)\r
                             continue;\r
 \r
-                        Vertex va = new Vertex(obj.vertices[face.a], wgt, idx, normal[face.a], new Point2(face.ta.x, 1 - face.ta.y));\r
-                        Vertex vb = new Vertex(obj.vertices[face.b], wgt, idx, normal[face.b], new Point2(face.tb.x, 1 - face.tb.y));\r
-                        Vertex vc = new Vertex(obj.vertices[face.c], wgt, idx, normal[face.c], new Point2(face.tc.x, 1 - face.tc.y));\r
+                        Vertex va = new Vertex(obj.vertices[face.a].Pos, wgt, idx, normal[face.a], new Point2(face.ta.x, 1 - face.ta.y));\r
+                        Vertex vb = new Vertex(obj.vertices[face.b].Pos, wgt, idx, normal[face.b], new Point2(face.tb.x, 1 - face.tb.y));\r
+                        Vertex vc = new Vertex(obj.vertices[face.c].Pos, wgt, idx, normal[face.c], new Point2(face.tc.x, 1 - face.tc.y));\r
 \r
                         indices.Add(vh.Add(va));\r
                         indices.Add(vh.Add(vc));\r
@@ -598,16 +598,16 @@ namespace Tso2MqoGui
                 // 一番近い頂点への参照\r
                 List<int> vref = new List<int>(obj.vertices.Count);\r
 \r
-                foreach (Point3 j in obj.vertices)\r
-                    vref.Add(pc.NearestIndex(j.x, j.y, j.z));\r
+                foreach (UVertex j in obj.vertices)\r
+                    vref.Add(pc.NearestIndex(j.Pos.x, j.Pos.y, j.Pos.z));\r
 \r
                 // 法線生成\r
                 Point3[] normal = new Point3[obj.vertices.Count];\r
 \r
                 foreach (MqoFace face in obj.faces)\r
                 {\r
-                    Point3 v1 = Point3.Normalize(obj.vertices[face.b] - obj.vertices[face.a]);\r
-                    Point3 v2 = Point3.Normalize(obj.vertices[face.c] - obj.vertices[face.b]);\r
+                    Point3 v1 = Point3.Normalize(obj.vertices[face.b].Pos - obj.vertices[face.a].Pos);\r
+                    Point3 v2 = Point3.Normalize(obj.vertices[face.c].Pos - obj.vertices[face.b].Pos);\r
                     Point3 n = Point3.Normalize(Point3.Cross(v1, v2));\r
 \r
                     normal[face.a] -= n;\r
@@ -693,9 +693,9 @@ namespace Tso2MqoGui
                         }\r
 \r
                         // \todo 点の追加\r
-                        Vertex va = new Vertex(obj.vertices[f.a], v[0].Wgt, v[0].Idx, normal[f.a], new Point2(f.ta.x, 1 - f.ta.y));\r
-                        Vertex vb = new Vertex(obj.vertices[f.b], v[1].Wgt, v[1].Idx, normal[f.b], new Point2(f.tb.x, 1 - f.tb.y));\r
-                        Vertex vc = new Vertex(obj.vertices[f.c], v[2].Wgt, v[2].Idx, normal[f.c], new Point2(f.tc.x, 1 - f.tc.y));\r
+                        Vertex va = new Vertex(obj.vertices[f.a].Pos, v[0].Wgt, v[0].Idx, normal[f.a], new Point2(f.ta.x, 1 - f.ta.y));\r
+                        Vertex vb = new Vertex(obj.vertices[f.b].Pos, v[1].Wgt, v[1].Idx, normal[f.b], new Point2(f.tb.x, 1 - f.tb.y));\r
+                        Vertex vc = new Vertex(obj.vertices[f.c].Pos, v[2].Wgt, v[2].Idx, normal[f.c], new Point2(f.tc.x, 1 - f.tc.y));\r
 \r
                         indices.Add(vh.Add(va));\r
                         indices.Add(vh.Add(vc));\r