\r
private void OpenMQOFile(string f)\r
{\r
- TSOGenerator gen = new TSOGenerator();\r
- TSOGenerateConfig config = new TSOGenerateConfig();\r
- config.materialconfig = cbShowMaterials.Checked;\r
+ TSOGenerator gen = new TSOGenerator();\r
+ TSOGenerateConfig config = new TSOGenerateConfig();\r
+ config.materialconfig = cbShowMaterials.Checked;\r
\r
- if(rbAutoBone.Checked)\r
+ if (rbAutoBone.Checked)\r
{\r
gen.GenerateAutoBone(f, tbTso.Text, tbTsoEx.Text, config);\r
- } else\r
- if(rb1Bone.Checked)\r
+ }\r
+ else\r
+ if (rb1Bone.Checked)\r
{\r
- foreach(ListViewItem i in lvObject.Items)\r
+ foreach (ListViewItem i in lvObject.Items)\r
{\r
- if(i.SubItems[1].Text == "")\r
+ if (i.SubItems[1].Text == "")\r
{\r
MessageBox.Show("すべてのオブジェクトにボーンを設定してください");\r
return;\r
}\r
\r
gen.GenerateOneBone(f, tbTso.Text, tbTsoEx.Text, config);\r
- } else\r
+ }\r
+ else\r
{\r
}\r
}\r
\r
private void bOk_Click(object sender, EventArgs e)\r
{\r
- Color c = tabPage2.BackColor;\r
+ Color c = tabPage2.BackColor;\r
\r
try\r
{\r
- tabPage2.BackColor = Color.Tomato;\r
+ tabPage2.BackColor = Color.Tomato;\r
tabPage2.Update();\r
- string file= tbMqoIn.Text;\r
+ string file = tbMqoIn.Text;\r
OpenMQOFile(file);\r
- } catch(Exception ex)\r
+ }\r
+ catch (Exception ex)\r
{\r
Util.ProcessError(ex);\r
- } finally\r
+ }\r
+ finally\r
{\r
- tabPage2.BackColor = c;\r
+ tabPage2.BackColor = c;\r
}\r
}\r
#endregion\r
tw = null;\r
}\r
\r
+ string GetTexturePath(TSOTex tex)\r
+ {\r
+ string filename = Path.GetFileName(tex.File.Trim('"'));\r
+ if (filename == "")\r
+ filename = "none";\r
+ return Path.Combine(OutPath, filename);\r
+ }\r
+\r
public void CreateTextureFile(TSOTex tex)\r
{\r
- string file= Path.Combine(OutPath, Path.GetFileName(tex.file.Trim('"')));\r
+ string file = GetTexturePath(tex);\r
byte[] data= tex.data;\r
\r
+\r
using(FileStream fs= File.OpenWrite(file))\r
{\r
BinaryWriter bw = new BinaryWriter(fs);\r
List<float> uv = new List<float>(2048*3 * 2);\r
List<int> mtl = new List<int>(2048);\r
\r
- foreach(TSOTex i in file.textures)\r
- CreateTextureFile(i);\r
+ foreach(TSOTex tex in file.textures)\r
+ CreateTextureFile(tex);\r
\r
tw.WriteLine("Material {0} {{", file.materials.Length);\r
\r
- foreach(TSOMaterial i in file.materials)\r
+ foreach(TSOMaterial mat in file.materials)\r
{\r
- if(i.ColorTex != null)\r
+ if(mat.ColorTex != null)\r
{\r
- TSOTex tex = file.texturemap[i.ColorTex];\r
+ TSOTex tex = file.texturemap[mat.ColorTex];\r
tw.WriteLine(\r
" \"{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}\")",\r
- i.name, Path.Combine(OutPath, tex.File.Trim('"')));\r
+ mat.name, GetTexturePath(tex));\r
} else\r
{\r
tw.WriteLine(\r
" \"{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))",\r
- i.name);\r
+ mat.name);\r
}\r
}\r
\r
private List<Vertex> vlst;\r
private Dictionary<string, TSONode> nodes;\r
private List<TSOMesh> meshes;\r
- private string mqoin;\r
- private string tsoref;\r
- private string tsoex;\r
private ImportInfo ii;\r
private BinaryWriter bw;\r
private Dictionary<string, MaterialInfo> materials;\r
pc.Clustering();\r
}\r
\r
- private bool Common_DoSetupDir()\r
+ private bool Common_DoSetupDir(string mqoin)\r
{\r
Environment.CurrentDirectory= dir= Path.GetDirectoryName(mqoin);\r
return true;\r
}\r
\r
- private bool Common_DoLoadMQO()\r
+ private bool Common_DoLoadMQO(string mqoin)\r
{\r
// MQO読み込み\r
mqo = new MqoFile();\r
return true;\r
}\r
\r
- private bool AutoBone_DoLoadRefTSO()\r
+ private bool AutoBone_DoLoadRefTSO(string tsoref)\r
{\r
// 参照TSOロード\r
tsor = LoadTSO(tsoref);\r
return true;\r
}\r
\r
- private bool OneBone_DoLoadRefTSO()\r
+ private bool OneBone_DoLoadRefTSO(string tsoref)\r
{\r
// 参照TSOロード\r
tsor = LoadTSO(tsoref);\r
return true;\r
}\r
\r
- private bool Common_DoLoadXml()\r
+ private bool Common_DoLoadXml(string mqoin)\r
{\r
// XML読み込み\r
ii = ImportInfo.Load(Path.ChangeExtension(mqoin, ".xml"));\r
return true;\r
}\r
\r
- private bool AutoBone_DoOutput()\r
+ private bool AutoBone_DoOutput(string tsoex)\r
{\r
//----- 出力処理 -----------------------------------------------\r
ii.materials.Clear();\r
ii.textures.Clear();\r
\r
- using(FileStream fs= File.OpenWrite(tsoex))\r
+ using (FileStream fs = File.OpenWrite(tsoex))\r
{\r
fs.SetLength(0);\r
- bw = new BinaryWriter(fs);\r
+ bw = new BinaryWriter(fs);\r
\r
Common_DoWriteHeader();\r
Common_DoWriteNodeNames();\r
return true;\r
}\r
\r
- private bool OneBone_DoOutput()\r
+ private bool OneBone_DoOutput(string tsoex)\r
{\r
//----- 出力処理 -----------------------------------------------\r
ii.materials.Clear();\r
ii.textures.Clear();\r
\r
- using(FileStream fs= File.OpenWrite(tsoex))\r
+ using (FileStream fs = File.OpenWrite(tsoex))\r
{\r
fs.SetLength(0);\r
- bw = new BinaryWriter(fs);\r
+ bw = new BinaryWriter(fs);\r
\r
Common_DoWriteHeader();\r
Common_DoWriteNodeNames();\r
return true;\r
}\r
\r
- private bool Common_DoSaveXml()\r
+ private bool Common_DoSaveXml(string mqoin)\r
{\r
// 結果を保存しておく\r
ImportInfo.Save(Path.ChangeExtension(mqoin, ".xml"), ii);\r
vlst = null;\r
nodes = null;\r
meshes = null;\r
- mqoin = null;\r
- tsoref = null;\r
- tsoex = null;\r
config = null;\r
mqo = null;\r
ii = null;\r
return true;\r
}\r
\r
- public unsafe void GenerateOneBone(string mqoin, string tsoref, string tsoex, TSOGenerateConfig config)\r
+ public void GenerateOneBone(string mqoin, string tsoref, string tsoex, TSOGenerateConfig config)\r
{\r
- this.mqoin = mqoin;\r
- this.tsoref = tsoref;\r
- this.tsoex = tsoex;\r
this.config = config;\r
\r
try\r
{\r
- if(!Common_DoSetupDir()) return;\r
- if(!Common_DoLoadMQO()) return;\r
- if(!OneBone_DoLoadRefTSO()) return;\r
- if(!Common_DoLoadXml()) return;\r
- if(!OneBone_DoOutput()) return;\r
- if(!Common_DoSaveXml()) return;\r
- } finally\r
+ if (!Common_DoSetupDir(mqoin)) return;\r
+ if (!Common_DoLoadMQO(mqoin)) return;\r
+ if (!OneBone_DoLoadRefTSO(tsoref)) return;\r
+ if (!Common_DoLoadXml(mqoin)) return;\r
+ if (!OneBone_DoOutput(tsoex)) return;\r
+ if (!Common_DoSaveXml(mqoin)) return;\r
+ }\r
+ finally\r
{\r
Common_DoCleanup();\r
}\r
}\r
\r
- public unsafe void GenerateAutoBone(string mqoin, string tsoref, string tsoex, TSOGenerateConfig config)\r
+ public void GenerateAutoBone(string mqoin, string tsoref, string tsoex, TSOGenerateConfig config)\r
{\r
- this.mqoin = mqoin;\r
- this.tsoref = tsoref;\r
- this.tsoex = tsoex;\r
this.config = config;\r
\r
try\r
{\r
- if(!Common_DoSetupDir()) return;\r
- if(!Common_DoLoadMQO()) return;\r
- if(!AutoBone_DoLoadRefTSO()) return;\r
- if(!Common_DoLoadXml()) return;\r
- if(!AutoBone_DoOutput()) return;\r
- if(!Common_DoSaveXml()) return;\r
- } finally\r
+ if (!Common_DoSetupDir(mqoin)) return;\r
+ if (!Common_DoLoadMQO(mqoin)) return;\r
+ if (!AutoBone_DoLoadRefTSO(tsoref)) return;\r
+ if (!Common_DoLoadXml(mqoin)) return;\r
+ if (!AutoBone_DoOutput(tsoex)) return;\r
+ if (!Common_DoSaveXml(mqoin)) return;\r
+ }\r
+ finally\r
{\r
Common_DoCleanup();\r
}\r
tex.depth = header.depth / 8;\r
tex.width = header.width;\r
tex.height = header.height;\r
- tex.file = file;\r
+ tex.File = file;\r
tex.data = br.ReadBytes(tex.width * tex.height * tex.depth);\r
\r
return tex;\r
tex.depth = bih.biBitCount / 8;\r
tex.width = bih.biWidth;\r
tex.height = bih.biHeight;\r
- tex.file = file;\r
+ tex.File = file;\r
tex.data = br.ReadBytes(tex.width * tex.height * tex.depth);\r
\r
return tex;\r