private void SaveFigure() { if (lvTSOFiles.SelectedIndices.Count == 0) { return; } Figure fig; if (viewer.TryGetFigure(out fig)) { SaveFileDialog dialog = new SaveFileDialog(); int index = lvTSOFiles.SelectedIndices[0]; TSOFile tso = fig.TSOList[index]; dialog.FileName = tso.FileName; dialog.Filter = "tso files|*.tso|tmo files|*.tmo"; dialog.FilterIndex = 0; if (dialog.ShowDialog() == DialogResult.OK) { string dest_file = dialog.FileName; string extension = Path.GetExtension(dest_file); if (extension == ".tso") { tso.Save(dest_file); } if (extension == ".tmo") { TMOFile tmo = fig.Tmo; tmo.SaveTransformationMatrixToFrame(0); tmo.Save(dest_file); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (tso == null) { return; } if (sub_script != null) { sub_script.SaveShader(); } SaveFileDialog dialog = new SaveFileDialog(); dialog.FileName = tso.FileName; dialog.Filter = "tso files|*.tso"; dialog.FilterIndex = 0; if (dialog.ShowDialog() == DialogResult.OK) { string dest_file = dialog.FileName; string extension = Path.GetExtension(dest_file); if (extension == ".tso") { tso.Save(dest_file); } } }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("TSOHair.exe <tso file> <basename>"); return; } string source_file = args[0]; string basename = "N000BHEA_C00"; if (args.Length > 1) { basename = args[1]; } string col = basename.Substring(10, 2); TSOFile tso = new TSOFile(); tso.Load(source_file); TDCG.TSOHair.TSOHairProcessor processor = TDCG.TSOHair.TSOHairProcessor.Load(Path.Combine(Application.StartupPath, @"TSOHairProcessor.xml")); processor.Process(tso, col); tso.Save(string.Format("{0}.tso", basename)); }
public void ProcessTSOFile(Stream tso_stream, Stream ret_stream, string col) { TSOFile tso = new TSOFile(); tso.Load(tso_stream); tsohair_processor.Process(tso, col); tso.Save(ret_stream); }
private void btnTSOSave_Click(object sender, EventArgs e) { TSOFile tso = GetSelectedTSOFile(); if (tso == null) { return; } saveFileDialog1.FileName = "out.tso"; saveFileDialog1.Filter = "TSO files (*.tso)|*.tso|All files (*.*)|*.*"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { tso.Save(saveFileDialog1.OpenFile()); } }
public static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("TSOMeshOptimize.exe <tso file>"); return; } string source_file = args[0]; TSOFile tso = new TSOFile(); tso.Load(source_file); Console.WriteLine("メッシュ:"); int i = 0; foreach (TSOMesh mesh in tso.meshes) { Console.WriteLine("{0} {1}", i, mesh.Name); i++; } Console.Write("メッシュを選択 (0-{0}): ", tso.meshes.Length - 1); int mesh_idx = 0; { string line = Console.ReadLine(); if (line.Length != 0) { try { mesh_idx = int.Parse(line); } catch (System.FormatException e) { Console.WriteLine(e); return; } } } TSOMesh selected_mesh = null; try { selected_mesh = tso.meshes[mesh_idx]; } catch (IndexOutOfRangeException e) { Console.WriteLine(e); return; } Console.WriteLine("サブメッシュ:"); Console.WriteLine(" vertices bone_indices"); Console.WriteLine(" -------- ------------"); foreach (TSOSubMesh sub in selected_mesh.sub_meshes) { Console.WriteLine(" {0,8} {1,12}", sub.vertices.Length, sub.bone_indices.Length); } Console.Write("最大パレット長: "); int max_palettes = 16; { string line = Console.ReadLine(); if (line.Length != 0) { try { max_palettes = int.Parse(line); } catch (System.FormatException e) { Console.WriteLine(e); return; } } } RebuildMesh(selected_mesh, max_palettes); string dest_path = Path.GetDirectoryName(source_file); string dest_file = Path.GetFileNameWithoutExtension(source_file) + @".new.tso"; dest_path = Path.Combine(dest_path, dest_file); Console.WriteLine("Save File: " + dest_path); tso.Save(dest_path); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("TSOWeightCopy.exe <tso file>"); return; } string source_file = args[0]; TSOFile tso = new TSOFile(); tso.Load(source_file); UniqueVertex.nodes = tso.nodes; UniqueVertex.oppnode_idmap = create_oppnode_idmap(tso); Console.WriteLine("メッシュ:"); int i = 0; foreach (TSOMesh mesh in tso.meshes) { Console.WriteLine("{0} {1}", i, mesh.Name); i++; } Console.Write("メッシュを選択 (0-{0}): ", tso.meshes.Length - 1); int mesh_idx = 0; try { mesh_idx = int.Parse(Console.ReadLine()); } catch (System.FormatException e) { Console.WriteLine(e); return; } TSOMesh selected_mesh = null; try { selected_mesh = tso.meshes[mesh_idx]; } catch (IndexOutOfRangeException e) { Console.WriteLine(e); return; } Vector3 min = Vector3.Empty; Vector3 max = Vector3.Empty; int nvertices = 0; foreach (TSOSubMesh sub in selected_mesh.sub_meshes) { foreach (Vertex v in sub.vertices) { float x = v.position.X; float y = v.position.Y; float z = v.position.Z; if (min.X > x) { min.X = x; } if (min.Y > y) { min.Y = y; } if (min.Z > z) { min.Z = z; } if (max.X < x) { max.X = x; } if (max.Y < y) { max.Y = y; } if (max.Z < z) { max.Z = z; } nvertices++; } } Console.WriteLine("頂点数:{0}", nvertices); Console.WriteLine("min:{0}", UniqueVertex.ToString(min)); Console.WriteLine("max:{0}", UniqueVertex.ToString(max)); Cluster cluster = new Cluster(min, max); foreach (TSOSubMesh sub in selected_mesh.sub_meshes) { foreach (Vertex v in sub.vertices) { cluster.Push(v, sub); } } Console.WriteLine("同一視頂点数:{0}", cluster.vertices.Count); Console.WriteLine(); Console.WriteLine("方向:"); Console.WriteLine("0 左から右"); Console.WriteLine("1 右から左"); Console.Write("方向を選択 (0-1): "); int copy_dir = 0; try { copy_dir = int.Parse(Console.ReadLine()); } catch (System.FormatException e) { Console.WriteLine(e); return; } switch (copy_dir) { case 0: cluster.dir = CopyDirection.LtoR; break; case 1: cluster.dir = CopyDirection.RtoL; break; } cluster.AssignOppositeCells(); cluster.AssignOppositeVertices(); //cluster.Dump(); cluster.CopyOppositeWeights(); string dest_path = Path.GetDirectoryName(source_file); string dest_file = Path.GetFileNameWithoutExtension(source_file) + @".new.tso"; dest_path = Path.Combine(dest_path, dest_file); Console.WriteLine("Save File: " + dest_path); tso.Save(dest_path); }
public static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("TSODeform.exe <tso file> <tmo file> [fig file]"); return; } string tso_file = args[0]; string tmo_file = args[1]; string fig_file = null; if (args.Length > 2) { fig_file = args[2]; } TSOFile tso = new TSOFile(); tso.Load(tso_file); TMOFile tmo = new TMOFile(); tmo.Load(tmo_file); Figure fig = new Figure(); fig.TSOList.Add(tso); fig.Tmo = tmo; if (fig_file != null) { List <float> ratios = ReadFloats(fig_file); /* * ◆FIGU * スライダの位置。値は float型で 0.0 .. 1.0 * 0: 姉妹 * 1: うで * 2: あし * 3: 胴まわり * 4: おっぱい * 5: つり目たれ目 * 6: やわらか */ fig.slider_matrix.TallRatio = ratios[0]; fig.slider_matrix.ArmRatio = ratios[1]; fig.slider_matrix.LegRatio = ratios[2]; fig.slider_matrix.WaistRatio = ratios[3]; fig.slider_matrix.BustRatio = ratios[4]; fig.slider_matrix.EyeRatio = ratios[5]; } fig.UpdateNodeMap(); if (fig_file != null) { fig.UpdateBoneMatrices(true); } else { fig.UpdateBoneMatricesWithoutSlider(true); } foreach (TSOMesh mesh in tso.meshes) { foreach (TSOSubMesh sub in mesh.sub_meshes) { Matrix[] clipped_boneMatrices = fig.ClipBoneMatrices(sub); for (int i = 0; i < sub.vertices.Length; i++) { CalcSkindeform(ref sub.vertices[i], clipped_boneMatrices); } } } foreach (TSONode tso_node in tso.nodes) { TMONode tmo_node; if (fig.nodemap.TryGetValue(tso_node, out tmo_node)) { tso_node.TransformationMatrix = tmo_node.matrices[0].m; } } tso.Save(@"out.tso"); }
public int Compose(string dest_path) { string source_file = dest_path + @".tso"; if (!File.Exists(source_file)) { Console.WriteLine("File not found: " + source_file); return(-1); } TSOFile tso = new TSOFile(); tso.Load(source_file); foreach (TSOTex tex in tso.textures) { string name = tex.Name; string file = tex.FileName.Trim('"'); string path = Path.Combine(dest_path, file); path = Path.ChangeExtension(path, ".png"); if (!File.Exists(path)) { path = Path.ChangeExtension(path, ".bmp"); } if (!File.Exists(path)) { path = Path.ChangeExtension(path, ".tga"); } if (!File.Exists(path)) { Console.WriteLine("File not found: " + path); continue; } Console.WriteLine(file); tex.Load(path); } foreach (TSOScript scr in tso.scripts) { string name = scr.Name; string path = Path.Combine(dest_path, name); if (!File.Exists(path)) { Console.WriteLine("File not found: " + path); continue; } Console.WriteLine(name); scr.Load(path); } foreach (TSOSubScript scr in tso.sub_scripts) { string name = scr.Name; string file = scr.FileName.Trim('"'); string path = Path.Combine(dest_path, name); if (!File.Exists(path)) { Console.WriteLine("File not found: " + path); continue; } Console.WriteLine(name); scr.Load(path); } string dest_file = Path.ChangeExtension(dest_path, @".new" + Path.GetExtension(dest_path) + @".tso"); Console.WriteLine("Save File: " + dest_file); tso.Save(dest_file); return(0); }
public int Compose(string dest_path) { string source_file = dest_path + @".tso"; if (!File.Exists(source_file)) { Console.WriteLine("File not found: " + source_file); return(-1); } TSOFile tso = new TSOFile(); tso.Load(source_file); foreach (TSOTex tex in tso.textures) { string name = tex.Name; string file = tex.FileName.Trim('"'); string path = Path.Combine(dest_path, file); path = Path.ChangeExtension(path, ".bmp"); if (!File.Exists(path)) { path = Path.ChangeExtension(path, ".tga"); } if (!File.Exists(path)) { Console.WriteLine("File not found: " + path); continue; } Console.WriteLine(file); using (BinaryReader br = new BinaryReader(File.OpenRead(path))) { switch (Path.GetExtension(path).ToLower()) { case ".bmp": tex.LoadBMP(br); break; case ".tga": tex.LoadTGA(br); break; } } } foreach (TSOScript scr in tso.scripts) { string name = scr.Name; string path = Path.Combine(dest_path, name); if (!File.Exists(path)) { Console.WriteLine("File not found: " + path); continue; } Console.WriteLine(name); scr.Load(path); } foreach (TSOSubScript scr in tso.sub_scripts) { string name = scr.Name; string file = scr.FileName.Trim('"'); string path = Path.Combine(dest_path, name); if (!File.Exists(path)) { Console.WriteLine("File not found: " + path); continue; } Console.WriteLine(name); scr.Load(path); } string dest_file = Path.ChangeExtension(dest_path, @".new" + Path.GetExtension(dest_path) + @".tso"); Console.WriteLine("Save File: " + dest_file); tso.Save(dest_file); return(0); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("TSOSmooth.exe <tso file>"); return; } string source_file = args[0]; TSOFile tso = new TSOFile(); tso.Load(source_file); Dictionary <string, TSONode> nodemap = new Dictionary <string, TSONode>(); foreach (TSONode node in tso.nodes) { nodemap.Add(node.Name, node); } string[] nodesets = GetSetsNames().ToArray(); Console.WriteLine("nodesets:"); { int i = 0; foreach (string name in nodesets) { Console.WriteLine("{0} {1}", i, name); i++; } } Console.Write("nodesetsを選択 (0-{0}): ", nodesets.Length - 1); int sets_idx = 0; { string line = Console.ReadLine(); if (line.Length != 0) { try { sets_idx = int.Parse(line); } catch (System.FormatException e) { Console.WriteLine(e); return; } } } setsname = nodesets[sets_idx]; char[] delim = { ' ' }; using (StreamReader source = new StreamReader(File.OpenRead(GetSetsPath()))) { string line; while ((line = source.ReadLine()) != null) { string[] tokens = line.Split(delim); string op = tokens[0]; if (op == "node") { Debug.Assert(tokens.Length == 2, "tokens length should be 2: " + line); string cnode_name = tokens[1]; TSONode cnode = nodemap[cnode_name]; use_nodes.Add(cnode); } } } Console.WriteLine("メッシュ:"); { int i = 0; foreach (TSOMesh mesh in tso.meshes) { Console.WriteLine("{0} {1}", i, mesh.Name); i++; } } Console.Write("メッシュを選択 (0-{0}): ", tso.meshes.Length - 1); int mesh_idx = 0; { string line = Console.ReadLine(); if (line.Length != 0) { try { mesh_idx = int.Parse(line); } catch (System.FormatException e) { Console.WriteLine(e); return; } } } TSOMesh selected_mesh = null; try { selected_mesh = tso.meshes[mesh_idx]; } catch (IndexOutOfRangeException e) { Console.WriteLine(e); return; } Console.WriteLine("サブメッシュ:"); Console.WriteLine(" vertices bone_indices"); Console.WriteLine(" -------- ------------"); foreach (TSOSubMesh sub in selected_mesh.sub_meshes) { Console.WriteLine(" {0,8} {1,12}", sub.vertices.Length, sub.bone_indices.Length); } int max_palettes = 16; RebuildMesh(selected_mesh, max_palettes); string dest_path = Path.GetDirectoryName(source_file); string dest_file = Path.GetFileNameWithoutExtension(source_file) + @".new.tso"; dest_path = Path.Combine(dest_path, dest_file); Console.WriteLine("Save File: " + dest_path); tso.Save(dest_path); }