コード例 #1
0
        /// <summary>
        /// 面リストを生成します。
        /// </summary>
        /// <returns>面リスト</returns>
        public static List <TSOFace> CreateFaces(TSOMesh mesh)
        {
            List <TSOFace> faces = new List <TSOFace>();

            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], sub.bone_indices, sub.spec);
                }
                for (int i = 2; i < vertices.Length; i++)
                {
                    UnifiedPositionVertex a, b, c;
                    if (i % 2 != 0)
                    {
                        a = vertices[i - 2];
                        b = vertices[i - 0];
                        c = vertices[i - 1];
                    }
                    else
                    {
                        a = vertices[i - 2];
                        b = vertices[i - 1];
                        c = vertices[i - 0];
                    }
                    if (!a.Equals(b) && !b.Equals(c) && !c.Equals(a))
                    {
                        faces.Add(new TSOFace(a, b, c));
                    }
                }
            }
            return(faces);
        }
コード例 #2
0
 /// <summary>
 /// 等値関数
 /// </summary>
 /// <param name="v">v</param>
 /// <returns></returns>
 public bool Equals(UnifiedPositionVertex v)
 {
     if ((object)v == null)
     {
         return(false);
     }
     return(this.position == v.position);
 }
コード例 #3
0
ファイル: TSOFace.cs プロジェクト: xvok16/TDCGExplorer
 /// <summary>
 /// 面を生成します。
 /// </summary>
 /// <param name="a">頂点a</param>
 /// <param name="b">頂点b</param>
 /// <param name="c">頂点c</param>
 public TSOFace(UnifiedPositionVertex a, UnifiedPositionVertex b, UnifiedPositionVertex c)
 {
     this.a      = a;
     this.b      = b;
     this.c      = c;
     this.spec   = a.spec;
     vertices    = new UnifiedPositionVertex[3];
     vertices[0] = a;
     vertices[1] = b;
     vertices[2] = c;
 }
コード例 #4
0
        /// <summary>
        /// 等値関数
        /// </summary>
        /// <param name="obj">object</param>
        /// <returns></returns>
        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);
        }
コード例 #5
0
        /// <summary>
        /// 比較関数
        /// </summary>
        /// <param name="obj">object</param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            UnifiedPositionVertex v = obj as UnifiedPositionVertex;

            if ((object)v == null)
            {
                throw new ArgumentException("not a UnifiedPositionVertex");
            }
            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);
            }
            return(cmp);
        }
コード例 #6
0
 public UnifiedPositionTexcoordVertex(UnifiedPositionVertex v, Dictionary <int, ushort> bone_idmap)
 {
     this.position     = v.position;
     this.normal       = v.normal;
     this.u            = v.u;
     this.v            = v.v;
     this.skin_weights = new SkinWeight[4];
     for (int i = 0; i < 4; i++)
     {
         if (v.skin_weights[i].weight < WeightEpsilon)
         {
             this.skin_weights[i] = new SkinWeight(0, 0.0f);
         }
         else
         {
             this.skin_weights[i] = new SkinWeight(bone_idmap[v.skin_weights[i].bone_index], v.skin_weights[i].weight);
         }
     }
     GenerateBoneIndices();
 }
コード例 #7
0
        public static UnifiedPositionTexcoordVertex CreateVertex(UnifiedPositionVertex v, Dictionary <int, ushort> bone_idmap)
        {
            UnifiedPositionTexcoordVertex a = new UnifiedPositionTexcoordVertex(v, bone_idmap);

            return(a);
        }