public int CompareTo(object obj) { UnifiedPositionTexcoordVertex v = obj as UnifiedPositionTexcoordVertex; if ((object)v == null) { throw new ArgumentException("not a UnifiedPositionTexcoordVertex"); } int cmp = this.position.X.CompareTo(v.position.X); if (cmp == 0) { cmp = this.position.Y.CompareTo(v.position.Y); } if (cmp == 0) { cmp = this.position.Z.CompareTo(v.position.Z); } if (cmp == 0) { cmp = this.u.CompareTo(v.u); } if (cmp == 0) { cmp = this.v.CompareTo(v.v); } return(cmp); }
public bool Equals(UnifiedPositionTexcoordVertex v) { if ((object)v == null) { return(false); } return(this.position == v.position && this.u == v.u && this.v == v.v); }
public override bool Equals(object obj) { if (obj == null) { return(false); } UnifiedPositionTexcoordVertex v = obj as UnifiedPositionTexcoordVertex; if ((object)v == null) { return(false); } return(this.position == v.position && this.u == v.u && this.v == v.v); }
public static List <TSOSubMesh> CreateSubMeshes(List <TSOFace> faces, int max_palettes) { List <TSOFace> faces_1 = faces; List <TSOFace> faces_2 = new List <TSOFace>(); Heap <int> bh = new Heap <int>(); Heap <UnifiedPositionTexcoordVertex> vh = new Heap <UnifiedPositionTexcoordVertex>(); List <ushort> vert_indices = new List <ushort>(); Dictionary <int, bool> adding_bone_indices = new Dictionary <int, bool>(); List <TSOSubMesh> sub_meshes = new List <TSOSubMesh>(); Console.WriteLine(" vertices bone_indices"); Console.WriteLine(" -------- ------------"); while (faces_1.Count != 0) { int spec = faces_1[0].spec; bh.Clear(); vh.Clear(); vert_indices.Clear(); foreach (TSOFace f in faces_1) { if (f.spec != spec) { faces_2.Add(f); continue; } adding_bone_indices.Clear(); foreach (UnifiedPositionVertex v in f.vertices) { foreach (SkinWeight sw in v.skin_weights) { if (sw.weight < WeightEpsilon) { continue; } if (bh.ContainsKey(sw.bone_index)) { continue; } adding_bone_indices[sw.bone_index] = true; } } if (bh.Count + adding_bone_indices.Count > max_palettes) { faces_2.Add(f); continue; } foreach (int bone_index in adding_bone_indices.Keys) { bh.Add(bone_index); } foreach (UnifiedPositionVertex v in f.vertices) { UnifiedPositionTexcoordVertex a = new UnifiedPositionTexcoordVertex(v, bh.map); if (!vh.ContainsKey(a)) { vh.Add(a); } vert_indices.Add(vh[a]); } } //Console.WriteLine("#vert_indices:{0}", vert_indices.Count); ushort[] optimized_indices = NvTriStrip.Optimize(vert_indices.ToArray()); //Console.WriteLine("#optimized_indices:{0}", optimized_indices.Length); TSOSubMesh sub = new TSOSubMesh(); sub.spec = spec; //Console.WriteLine("#bone_indices:{0}", bh.Count); sub.bone_indices = bh.ary.ToArray(); UnifiedPositionTexcoordVertex[] vertices = new UnifiedPositionTexcoordVertex[optimized_indices.Length]; for (int i = 0; i < optimized_indices.Length; i++) { vertices[i] = vh.ary[optimized_indices[i]]; } sub.vertices = vertices; Console.WriteLine(" {0,8} {1,12}", sub.vertices.Length, sub.bone_indices.Length); sub_meshes.Add(sub); List <TSOFace> faces_tmp = faces_1; faces_1 = faces_2; faces_2 = faces_tmp; faces_tmp.Clear(); } return(sub_meshes); }
public static UnifiedPositionTexcoordVertex CreateVertex(UnifiedPositionVertex v, Dictionary <int, ushort> bone_idmap) { UnifiedPositionTexcoordVertex a = new UnifiedPositionTexcoordVertex(v, bone_idmap); return(a); }