OSDN Git Service

uses Direct3D.Vector3
authornomeu <nomeu@72ae2088-5f33-de11-a17b-0000e250a282>
Wed, 7 Jul 2010 08:26:24 +0000 (08:26 +0000)
committernomeu <nomeu@72ae2088-5f33-de11-a17b-0000e250a282>
Wed, 7 Jul 2010 08:26:24 +0000 (08:26 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/tdcgexplorer/trunk/tso2mqo@1314 72ae2088-5f33-de11-a17b-0000e250a282

General.cs
MqoFile.cs
MqoWriter.cs
TSOFile.cs
Tso2MqoGui.csproj
TsoGenerator.cs

index 9c18a85..b685ff1 100644 (file)
@@ -1,6 +1,8 @@
 using System;\r
 using System.Collections.Generic;\r
 using System.Text;\r
+using Microsoft.DirectX;\r
+using Microsoft.DirectX.Direct3D;\r
 \r
 namespace Tso2MqoGui\r
 {\r
@@ -140,9 +142,9 @@ namespace Tso2MqoGui
 \r
     public partial struct Point3\r
     {\r
-        public static Point3    Parse(string[] t, int  begin)\r
+        public static Vector3 Parse(string[] t, int begin)\r
         {\r
-            return new Point3(\r
+            return new Vector3(\r
                 float.Parse(t[begin+0]),\r
                 float.Parse(t[begin+1]),\r
                 float.Parse(t[begin+2]));\r
index a93eeec..b9d8e40 100644 (file)
@@ -3,6 +3,8 @@ using System.Collections.Generic;
 using System.IO;\r
 using System.Text;\r
 using System.Text.RegularExpressions;\r
+using Microsoft.DirectX;\r
+using Microsoft.DirectX.Direct3D;\r
 \r
 namespace Tso2MqoGui\r
 {\r
@@ -262,7 +264,7 @@ namespace Tso2MqoGui
         {\r
             if(tokens[2].ToLower() != "{")          Error(tokens);\r
 \r
-            current.vertices    = new List<Point3>(int.Parse(tokens[1]));\r
+            current.vertices = new List<Vector3>(int.Parse(tokens[1]));\r
             DoRead(SectionVertex);\r
         }\r
 \r
@@ -277,8 +279,8 @@ namespace Tso2MqoGui
 \r
     public class MqoScene\r
     {\r
-        public Point3           pos;\r
-        public Point3           lookat;\r
+        public Vector3 pos;\r
+        public Vector3 lookat;\r
         public float            head;\r
         public float            pich;\r
         public float            ortho;\r
@@ -339,7 +341,7 @@ namespace Tso2MqoGui
            public float            facet;\r
            public Color3           color;\r
            public int              color_type;\r
-        public List<Point3>     vertices;\r
+        public List<Vector3> vertices;\r
         public List<MqoFace>    faces;\r
 \r
         public MqoObject()              {           }\r
index 1d49546..719a713 100644 (file)
@@ -173,7 +173,7 @@ namespace Tso2MqoGui
                         ++cnt;\r
                         va= vb; a= b;\r
                         vb= vc; b= c;\r
-                        vc= k;  c= vh.Add(new UVertex(k.Pos.x, k.Pos.y, k.Pos.z, k.Nrm.x, k.Nrm.y, k.Nrm.z, k.Tex.x, k.Tex.y, j.spec));\r
+                        vc= k;  c= vh.Add(new UVertex(k.Pos.X, k.Pos.Y, k.Pos.Z, k.Nrm.X, k.Nrm.Y, k.Nrm.Z, k.Tex.x, k.Tex.y, j.spec));\r
 \r
                         if(cnt < 3)                     continue;\r
                         if(a == b || b == c || c == a)  continue;\r
index 9618322..ef9432c 100644 (file)
@@ -3,6 +3,8 @@ using System.Collections.Generic;
 using System.IO;\r
 using System.Text;\r
 using System.ComponentModel;\r
+using Microsoft.DirectX;\r
+using Microsoft.DirectX.Direct3D;\r
 \r
 namespace Tso2MqoGui\r
 {\r
@@ -632,15 +634,15 @@ namespace Tso2MqoGui
 \r
     public partial struct Vertex : IComparable<Vertex>\r
     {\r
-        public Point3       Pos;\r
+        public Vector3 Pos;\r
         public Point4       Wgt;\r
         public UInt32       Idx;\r
-        public Point3       Nrm;\r
+        public Vector3 Nrm;\r
         public Point2       Tex;\r
       //public int          Count;\r
       //public Weights[]    Weights;\r
 \r
-        public Vertex(Point3 pos, Point4 wgt, UInt32 idx, Point3 nrm, Point2 tex)\r
+        public Vertex(Vector3 pos, Point4 wgt, UInt32 idx, Vector3 nrm, Point2 tex)\r
         {\r
             Pos = pos;\r
             Wgt = wgt;\r
@@ -651,12 +653,12 @@ namespace Tso2MqoGui
 \r
         public int CompareTo(Vertex o)\r
         {\r
-            if(Pos.x < o.Pos.x) return -1; if(Pos.x > o.Pos.x) return 1;\r
-            if(Pos.y < o.Pos.y) return -1; if(Pos.y > o.Pos.y) return 1;\r
-            if(Pos.z < o.Pos.z) return -1; if(Pos.z > o.Pos.z) return 1;\r
-            if(Nrm.x < o.Nrm.x) return -1; if(Nrm.x > o.Nrm.x) return 1;\r
-            if(Nrm.y < o.Nrm.y) return -1; if(Nrm.y > o.Nrm.y) return 1;\r
-            if(Nrm.z < o.Nrm.z) return -1; if(Nrm.z > o.Nrm.z) return 1;\r
+            if(Pos.X < o.Pos.X) return -1; if(Pos.X > o.Pos.X) return 1;\r
+            if(Pos.Y < o.Pos.Y) return -1; if(Pos.Y > o.Pos.Y) return 1;\r
+            if(Pos.Z < o.Pos.Z) return -1; if(Pos.Z > o.Pos.Z) return 1;\r
+            if(Nrm.X < o.Nrm.X) return -1; if(Nrm.X > o.Nrm.X) return 1;\r
+            if(Nrm.Y < o.Nrm.Y) return -1; if(Nrm.Y > o.Nrm.Y) return 1;\r
+            if(Nrm.Z < o.Nrm.Z) return -1; if(Nrm.Z > o.Nrm.Z) return 1;\r
             if(Tex.x < o.Tex.x) return -1; if(Tex.x > o.Tex.x) return 1;\r
             if(Tex.y < o.Tex.y) return -1; if(Tex.y > o.Tex.y) return 1;\r
             if(Wgt.x < o.Wgt.x) return -1; if(Wgt.x > o.Wgt.x) return 1;\r
@@ -669,8 +671,8 @@ namespace Tso2MqoGui
 \r
         public override int GetHashCode()\r
         {\r
-            return Pos.x.GetHashCode() ^ Pos.y.GetHashCode() ^ Pos.z.GetHashCode()\r
-                 ^ Nrm.x.GetHashCode() ^ Nrm.y.GetHashCode() ^ Nrm.z.GetHashCode()\r
+            return Pos.X.GetHashCode() ^ Pos.Y.GetHashCode() ^ Pos.Z.GetHashCode()\r
+                 ^ Nrm.X.GetHashCode() ^ Nrm.Y.GetHashCode() ^ Nrm.Z.GetHashCode()\r
                  ^ Tex.x.GetHashCode() ^ Tex.y.GetHashCode() ^ Wgt.w.GetHashCode()\r
                  ^ Wgt.x.GetHashCode() ^ Wgt.y.GetHashCode() ^ Wgt.z.GetHashCode()\r
                  - Idx.GetHashCode();\r
@@ -680,8 +682,8 @@ namespace Tso2MqoGui
         {\r
             Vertex  o   = (Vertex)obj;\r
 \r
-            return Pos.x==o.Pos.x && Pos.y==o.Pos.y && Pos.z==o.Pos.z\r
-                && Nrm.x==o.Nrm.x && Nrm.y==o.Nrm.y && Nrm.z==o.Nrm.z\r
+            return Pos.X==o.Pos.X && Pos.Y==o.Pos.Y && Pos.Z==o.Pos.Z\r
+                && Nrm.X==o.Nrm.X && Nrm.Y==o.Nrm.Y && Nrm.Z==o.Nrm.Z\r
                 && Tex.x==o.Tex.x && Tex.y==o.Tex.y && Wgt.w==o.Wgt.w\r
                 && Wgt.x==o.Wgt.x && Wgt.y==o.Wgt.y && Wgt.z==o.Wgt.z\r
                 && Idx  ==o.Idx;\r
index 97b1f72..8df8985 100644 (file)
@@ -2,7 +2,7 @@
   <PropertyGroup>\r
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
-    <ProductVersion>9.0.21022</ProductVersion>\r
+    <ProductVersion>9.0.30729</ProductVersion>\r
     <SchemaVersion>2.0</SchemaVersion>\r
     <ProjectGuid>{C0DE49DD-78AB-4517-8234-7331DEF93472}</ProjectGuid>\r
     <OutputType>WinExe</OutputType>\r
@@ -55,6 +55,9 @@
     <ErrorReport>prompt</ErrorReport>\r
   </PropertyGroup>\r
   <ItemGroup>\r
+    <Reference Include="Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
+    <Reference Include="Microsoft.DirectX.Direct3D, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
+    <Reference Include="Microsoft.DirectX.Direct3DX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />\r
     <Reference Include="System" />\r
     <Reference Include="System.Data" />\r
     <Reference Include="System.Deployment" />\r
index b8b0ad5..5ffe1e7 100644 (file)
@@ -7,6 +7,8 @@ using System.Runtime.InteropServices;
 using System.ComponentModel;\r
 using System.Windows.Forms;\r
 using System.Windows.Forms.Design;\r
+using Microsoft.DirectX;\r
+using Microsoft.DirectX.Direct3D;\r
 \r
 namespace Tso2MqoGui\r
 {\r
@@ -46,7 +48,7 @@ namespace Tso2MqoGui
             pc  = new PointCluster(vlst.Count);\r
 \r
             foreach(Vertex i in vlst)\r
-                pc.Add(i.Pos.x, i.Pos.y, i.Pos.z);\r
+                pc.Add(i.Pos.X, i.Pos.Y, i.Pos.Z);\r
 \r
             pc.Clustering();\r
         }\r
@@ -273,17 +275,17 @@ namespace Tso2MqoGui
                 // \88ê\94Ô\8bß\82¢\92¸\93_\82Ö\82Ì\8eQ\8fÆ\r
                 List<int>       vref= new List<int>(i.vertices.Count);\r
 \r
-                foreach(Point3 j in i.vertices)\r
-                    vref.Add(pc.NearestIndex(j.x, j.y, j.z));\r
+                foreach (Vector3 j in i.vertices)\r
+                    vref.Add(pc.NearestIndex(j.X, j.Y, j.Z));\r
 \r
                 // \96@\90ü\90\90¬\r
-                Point3[]        nrm = new Point3[i.vertices.Count];\r
+                Vector3[] nrm = new Vector3[i.vertices.Count];\r
                 \r
                 foreach(MqoFace j in i.faces)\r
                 {\r
-                    Point3  v1  = Point3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
-                    Point3  v2  = Point3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
-                    Point3  n   = Point3.Normalize(Point3.Cross(v1, v2));\r
+                    Vector3 v1 = Vector3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
+                    Vector3 v2 = Vector3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
+                    Vector3 n = Vector3.Normalize(Vector3.Cross(v1, v2));\r
 #if false\r
                     nrm[j.a]    +=n;\r
                     nrm[j.b]    +=n;\r
@@ -296,7 +298,7 @@ namespace Tso2MqoGui
                 }\r
 \r
                 for(int j= 0; j < nrm.Length; ++j)\r
-                    nrm[j]      = Point3.Normalize(nrm[j]);\r
+                    nrm[j] = Vector3.Normalize(nrm[j]);\r
 \r
                 // \83t\83F\83C\83X\82Ì\91g\90¬\r
                 List<int>               faces1  = new List<int>();\r
@@ -469,20 +471,20 @@ namespace Tso2MqoGui
                 System.Diagnostics.Debug.WriteLine("object:" + i.name);            \r
 #endif\r
                 // \96@\90ü\90\90¬\r
-                Point3[]        nrm = new Point3[i.vertices.Count];\r
+                Vector3[] nrm = new Vector3[i.vertices.Count];\r
                 \r
                 foreach(MqoFace j in i.faces)\r
                 {\r
-                    Point3  v1  = Point3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
-                    Point3  v2  = Point3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
-                    Point3  n   = Point3.Normalize(Point3.Cross(v1, v2));\r
+                    Vector3 v1 = Vector3.Normalize(i.vertices[j.b] - i.vertices[j.a]);\r
+                    Vector3 v2 = Vector3.Normalize(i.vertices[j.c] - i.vertices[j.b]);\r
+                    Vector3 n = Vector3.Normalize(Vector3.Cross(v1, v2));\r
                     nrm[j.a]    -=n;\r
                     nrm[j.b]    -=n;\r
                     nrm[j.c]    -=n;\r
                 }\r
 \r
                 for(int j= 0; j < nrm.Length; ++j)\r
-                    nrm[j]      = Point3.Normalize(nrm[j]);\r
+                    nrm[j] = Vector3.Normalize(nrm[j]);\r
 \r
                 // \83{\81[\83\93\8fî\95ñ\8dì\90¬\r
                 uint                idx     = 0x00000000;\r