OSDN Git Service

textures may not be used. tdg-002
authornomeu <nomeu@nomeu.org>
Tue, 7 Oct 2014 16:31:43 +0000 (01:31 +0900)
committernomeu <nomeu@nomeu.org>
Tue, 7 Oct 2014 16:34:54 +0000 (01:34 +0900)
FormMaterial.cs
MqoWriter.cs
TSOFile.cs
TSOGenerator.cs

index 65e7b01..1f93809 100644 (file)
@@ -44,12 +44,12 @@ namespace Tso2MqoGui
                 {\r
                     string column_name = lvMaterials.Columns[i].Text;\r
                     string text = item.SubItems[i].Text;\r
-\r
+#if false\r
                     if (text == "")\r
                         error_message = string.Format("マテリアル名 {0} の {1} を設定する必要があります。", material_name, column_name);\r
                     else if (!File.Exists(text))\r
                         error_message = string.Format("マテリアル名 {0} の {1} は存在しません。", material_name, column_name);\r
-\r
+#endif\r
                     if (error_message != null)\r
                     {\r
                         MessageBox.Show(error_message);\r
index e39a9cb..618d6f8 100644 (file)
@@ -74,6 +74,7 @@ namespace Tso2MqoGui
             string file = GetTexturePath(tex);
             byte[] data = tex.data;
 
+            //TODO: .bmpのはずが.psdになってるものがある
 
             using (FileStream fs = File.OpenWrite(file))
             {
@@ -98,7 +99,7 @@ namespace Tso2MqoGui
                         bw.Write((byte)0);              // depth
                         break;
 
-                    case ".BMP":
+                    default:
                         bw.Write((byte)'B');
                         bw.Write((byte)'M');
                         bw.Write((int)(54 + data.Length));
@@ -150,9 +151,9 @@ namespace Tso2MqoGui
 
             foreach (TSOMaterial mat in file.materials)
             {
-                if (mat.ColorTex != null)
+                TSOTex tex = null;
+                if (file.texturemap.TryGetValue(mat.ColorTex, out tex))
                 {
-                    TSOTex tex = file.texturemap[mat.ColorTex];
                     tw.WriteLine(
                         "\t\"{0}\" col(1.000 1.000 1.000 1.000) dif(0.800) amb(0.600) emi(0.000) spc(0.000) power(5.00) tex(\"{1}\")",
                         mat.name, GetTextureFileName(tex));
index 0611250..6039730 100644 (file)
@@ -176,9 +176,6 @@ namespace Tso2MqoGui
                     meshes[i].sub_meshes[j].numbones = r.ReadInt32();
                     meshes[i].sub_meshes[j].bones = new int[meshes[i].sub_meshes[j].numbones];
 
-                    meshes[i].sub_meshes[j].ink = materials[meshes[i].sub_meshes[j].spec].technique.ToUpper().IndexOf("INKOFF") < 0;
-                    //meshes[i].sub[j].shadow     = specs[meshes[i].sub[j].spec].technique.ToUpper().IndexOf(Shadow
-
                     for (int k = 0; k < meshes[i].sub_meshes[j].numbones; ++k)
                         meshes[i].sub_meshes[j].bones[k] = r.ReadInt32();
 
@@ -552,8 +549,6 @@ namespace Tso2MqoGui
         internal int numvertices;
         internal Vertex[] vertices;
         internal TSOMesh owner;
-        //internal bool           shadow;
-        internal bool ink;
 
         [Category("Detail")]
         public int Spec { get { return spec; } set { spec = value; } }
@@ -703,4 +698,4 @@ namespace Tso2MqoGui
         public float        Weight;
     }
     */
-}
\ No newline at end of file
+}
index 9f5a218..4f510f0 100644 (file)
@@ -83,15 +83,15 @@ namespace Tso2MqoGui
 \r
             foreach (MaterialInfo i in materials.Values)\r
             {\r
-                string name = Path.GetFileNameWithoutExtension(i.ColorTexture);\r
+                string color_tex_name = Path.GetFileNameWithoutExtension(i.ColorTexture);\r
 \r
-                if (!textures.ContainsKey(name))\r
-                    textures.Add(name, new TextureInfo(name, i.ColorTexture));\r
+                if (color_tex_name != null && !textures.ContainsKey(color_tex_name))\r
+                        textures.Add(color_tex_name, new TextureInfo(color_tex_name, i.ColorTexture));\r
 \r
-                name = Path.GetFileNameWithoutExtension(i.ShadeTexture);\r
+                string shade_tex_name = Path.GetFileNameWithoutExtension(i.ShadeTexture);\r
 \r
-                if (!textures.ContainsKey(name))\r
-                    textures.Add(name, new TextureInfo(name, i.ShadeTexture));\r
+                if (shade_tex_name != null && !textures.ContainsKey(shade_tex_name))\r
+                        textures.Add(shade_tex_name, new TextureInfo(shade_tex_name, i.ShadeTexture));\r
             }\r
 \r
             return true;\r
@@ -829,20 +829,19 @@ namespace Tso2MqoGui
         {\r
             get\r
             {\r
-                return File.Exists(shader)\r
-                    && File.Exists(color_tex)\r
-                    && File.Exists(shade_tex);\r
+                return File.Exists(shader);\r
             }\r
         }\r
 \r
         public string[] GetCode()\r
         {\r
             TSOMaterialCode code = TSOMaterialCode.GenerateFromFile(shader);\r
-            List<string> line = new List<string>();\r
-\r
-            code.SetValue("ColorTex", Path.GetFileNameWithoutExtension(color_tex));\r
-            code.SetValue("ShadeTex", Path.GetFileNameWithoutExtension(shade_tex));\r
+            if (color_tex != null)\r
+                code.SetValue("ColorTex", Path.GetFileNameWithoutExtension(color_tex));\r
+            if (shade_tex != null)\r
+                code.SetValue("ShadeTex", Path.GetFileNameWithoutExtension(shade_tex));\r
 \r
+            List<string> line = new List<string>();\r
             foreach (KeyValuePair<string, TSOParameter> i in code)\r
                 line.Add(i.Value.ToString());\r
 \r