public bool Equals(UnifiedPositionVertex v) { if ((object)v == null) { return(false); } return(this.position == v.position); }
public override bool Equals(object obj) { if (obj == null) { return(false); } UnifiedPositionVertex v = obj as UnifiedPositionVertex; if ((object)v == null) { return(false); } return(this.position == v.position); }
public void SaveToMqo(TextWriter tw, TSOFile tso) { tw.WriteLine("Metasequoia Document"); tw.WriteLine("Format Text Ver 1.0"); tw.WriteLine(""); tw.WriteLine("Scene {"); tw.WriteLine("\tpos -7.0446 4.1793 1541.1764"); tw.WriteLine("\tlookat 11.8726 193.8590 0.4676"); tw.WriteLine("\thead 0.8564"); tw.WriteLine("\tpich 0.1708"); tw.WriteLine("\tortho 0"); tw.WriteLine("\tzoom2 31.8925"); tw.WriteLine("\tamb 0.250 0.250 0.250"); tw.WriteLine("}"); tw.WriteLine("Material {0} {{", tso.sub_scripts.Length); Dictionary <string, TSOTex> texmap = new Dictionary <string, TSOTex>(); foreach (TSOTex tex in tso.textures) { texmap[tex.Name] = tex; } foreach (TSOSubScript sub in tso.sub_scripts) { TSOTex tex = texmap[sub.shader.ColorTexName]; string tex_file = tex.FileName.Trim('"'); tex_file = Path.GetFileNameWithoutExtension(tex_file) + ".bmp"; tw.WriteLine( "\t\"{0}\" shader(3) col(1.00 1.00 1.00 1.00) dif(0.800) amb(0.600) emi(0.000) spc(0.000) power(5.00) tex(\"{1}\")", sub.Name, tex_file); } tw.WriteLine("}"); foreach (TSOMesh mesh in tso.meshes) { tw.WriteLine("Object \"{0}\" {{", mesh.Name); tw.WriteLine("\tvisible {0}", 15); tw.WriteLine("\tlocking {0}", 0); tw.WriteLine("\tshading {0}", 1); tw.WriteLine("\tfacet {0}", 59.5); tw.WriteLine("\tcolor {0} {1} {2}", 0.898f, 0.498f, 0.698f); tw.WriteLine("\tcolor_type {0}", 0); Heap <UnifiedPositionVertex> vh = new Heap <UnifiedPositionVertex>(); List <MqoFace> faces = new List <MqoFace>(); foreach (TSOSubMesh sub in mesh.sub_meshes) { UnifiedPositionVertex[] vertices = new UnifiedPositionVertex[sub.vertices.Length]; for (int i = 0; i < vertices.Length; i++) { vertices[i] = new UnifiedPositionVertex(sub.vertices[i]); } for (int i = 2; i < vertices.Length; i++) { UnifiedPositionVertex va, vb, vc; if (i % 2 == 0) { va = vertices[i - 2]; vb = vertices[i - 0]; vc = vertices[i - 1]; } else { va = vertices[i - 2]; vb = vertices[i - 1]; vc = vertices[i - 0]; } ushort a, b, c; a = vh.Add(va); b = vh.Add(vb); c = vh.Add(vc); if (a != b && b != c && c != a) { MqoFace f = new MqoFace(); f.a = a; f.b = b; f.c = c; f.ta = new Vector2(va.u, 1 - va.v); f.tb = new Vector2(vb.u, 1 - vb.v); f.tc = new Vector2(vc.u, 1 - vc.v); f.mtl = (ushort)sub.spec; faces.Add(f); } } } tw.WriteLine("\tvertex {0} {{", vh.Count); foreach (UnifiedPositionVertex v in vh.ary) { tw.WriteLine("\t\t{0:F6} {1:F6} {2:F6}", v.position.X, v.position.Y, v.position.Z); } tw.WriteLine("\t}"); tw.WriteLine("\tface {0} {{", faces.Count); foreach (MqoFace f in faces) { tw.WriteLine("\t\t{0} V({1} {2} {3}) M({10}) UV({4} {5} {6} {7} {8} {9})", 3, f.a, f.b, f.c, f.ta.X, f.ta.Y, f.tb.X, f.tb.Y, f.tc.X, f.tc.Y, f.mtl); } tw.WriteLine("\t}"); tw.WriteLine("}"); } }