コード例 #1
0
 /// 警告 'ボーン参照が見つかりませんでした' を出力します。
 public void WarnBoneIndexNotFound(Vertex a, TSOSubMesh sub)
 {
     Console.WriteLine("### 警告: ボーン参照が見つかりませんでした。修正は諦めます。");
     Dump();
     for (int i = 0; i < 4; i++)
     {
         SkinWeight sw   = skin_weights[i];
         SkinWeight a_sw = a.skin_weights[i];
         Console.WriteLine("{0} sw({1} {2}) a sw({3} {4})", i, sw.bone_index, sw.weight, sub.bone_indices[a_sw.bone_index], a_sw.weight);
     }
     Console.WriteLine();
 }
コード例 #2
0
 /// 警告 'ウェイト値がずれています' を出力します。
 public void WarnOppositeWeights()
 {
     Console.WriteLine("### 情報: ウェイト値がずれています。修正します。");
     Dump();
     for (int i = 0; i < 4; i++)
     {
         SkinWeight sw     = skin_weights[i];
         SkinWeight opp_sw = opposite_vertex.skin_weights[i];
         Console.WriteLine("{0} sw({1} {2}) opp sw({3} {4})", i, sw.bone_index, sw.weight, opp_sw.bone_index, opp_sw.weight);
     }
     Console.WriteLine();
 }
コード例 #3
0
 /// <summary>
 /// 位置が一意な頂点を生成します。
 /// </summary>
 /// <param name="a">頂点</param>
 /// <param name="sub">頂点を含むサブメッシュ</param>
 public UnifiedPositionVertex(Vertex a, int[] bone_indices, int spec)
 {
     this.position     = a.position;
     this.normal       = a.normal;
     this.u            = a.u;
     this.v            = a.v;
     this.skin_weights = new SkinWeight[4];
     for (int i = 0; i < 4; i++)
     {
         skin_weights[i] = new SkinWeight(bone_indices[a.skin_weights[i].bone_index], a.skin_weights[i].weight);
     }
     this.spec = spec;
 }
コード例 #4
0
 /// <summary>
 /// 同一視頂点を生成します。
 /// </summary>
 /// <param name="a">頂点</param>
 /// <param name="sub">頂点を含むサブメッシュ</param>
 public UniqueVertex(Vertex a, TSOSubMesh sub)
 {
     this.vertices     = new Dictionary <Vertex, TSOSubMesh>();
     vertices[a]       = sub;
     this.position     = a.position;
     this.skin_weights = new SkinWeight[4];
     for (int i = 0; i < 4; i++)
     {
         SkinWeight sw = a.skin_weights[i];
         skin_weights[i] = new SkinWeight(sub.bone_indices[sw.bone_index], sw.weight);
     }
     opposite_vertex = null;
 }
コード例 #5
0
        /// 対称位置にある同一視頂点のスキンウェイトを複写します。
        public void CopyOppositeWeights()
        {
            if (opposite_vertex == null)
            {
                return;
            }

            if (opposite_vertex == this)
            {
                return;
            }

            //ウェイト値がずれている場合は警告する。
            bool weights_gap_found = false;

            for (int i = 0; i < 4; i++)
            {
                SkinWeight sw     = skin_weights[i];
                SkinWeight opp_sw = opposite_vertex.skin_weights[i];
                if (Math.Abs(sw.weight - opp_sw.weight) >= 1.0e-2f)
                {
                    weights_gap_found = true;
                    break;
                }
            }
            if (weights_gap_found)
            {
                WarnOppositeWeights();
            }

            for (int i = 0; i < 4; i++)
            {
                SkinWeight sw     = skin_weights[i];
                SkinWeight opp_sw = opposite_vertex.skin_weights[i];
                sw.bone_index = GetOppositeBoneIndex(opp_sw.bone_index);
                sw.weight     = opp_sw.weight;
            }

            foreach (KeyValuePair <Vertex, TSOSubMesh> pair in vertices)
            {
                Vertex     a   = pair.Key;
                TSOSubMesh sub = pair.Value;
                CopyWeights(a, sub);
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: xvok16/TDCGExplorer
        private void lvSkinWeights_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvSkinWeights.SelectedItems.Count == 0)
            {
                return;
            }

            if (viewer.SelectedSubMesh == null)
            {
                return;
            }

            ListViewItem li          = lvSkinWeights.SelectedItems[0];
            SkinWeight   skin_weight = li.Tag as SkinWeight;

            viewer.SelectedNode = viewer.SelectedSubMesh.GetBone(skin_weight.bone_index);
            Invalidate(false);
        }
コード例 #7
0
            public SkinData(System.IO.BinaryReader reader)
            {
                var rotation = reader.ReadRotation();
                var position = reader.ReadVector3();
                var scale    = reader.ReadSingle();

                Matrix = Matrix4x4.TRS(position, rotation, new Vector3(scale, scale, scale));

                boundingSphereOffset = reader.ReadVector3();
                boundingSphereRadius = reader.ReadSingle();

                var vertexCount = reader.ReadInt16();

                vertexWeights = new SkinWeight[vertexCount];
                for (var i = 0; i < vertexWeights.Length; i++)
                {
                    vertexWeights[i] = new SkinWeight(reader);
                }
            }
コード例 #8
0
        /// 同じ位置にある頂点を追加します。
        public void Push(Vertex a, TSOSubMesh sub)
        {
            vertices[a] = sub;

            //頂点のボーン参照が最初の頂点と異なる場合は警告する。
            for (int i = 0; i < 4; i++)
            {
                SkinWeight sw   = skin_weights[i];
                SkinWeight a_sw = a.skin_weights[i];
                if (sw.weight != 0.0f)
                {
                    if (sw.bone_index != sub.bone_indices[a_sw.bone_index])
                    {
                        Console.WriteLine("### 警告: ボーン参照が最初の頂点と異なります。");
                        Dump();
                        Console.WriteLine("{0} sw({1} {2}) a sw({3} {4})", i, sw.bone_index, sw.weight, sub.bone_indices[a_sw.bone_index], a_sw.weight);
                    }
                }
            }
        }
コード例 #9
0
        void CopyWeights(Vertex a, TSOSubMesh sub)
        {
            //ボーン参照が見つからない場合は警告する。
            bool bone_index_not_found = false;

            for (int i = 0; i < 4; i++)
            {
                SkinWeight sw         = skin_weights[i];
                SkinWeight a_sw       = a.skin_weights[i];
                int        a_bone_idx = Array.IndexOf(sub.bone_indices, sw.bone_index);
                if (a_bone_idx == -1)
                {
                    a_bone_idx = sub.AddBone(GetBone(sw.bone_index));
                }
                if (a_bone_idx == -1)
                {
                    if (sw.weight == 0.0f)
                    {
                        a_sw.bone_index = 0;
                        a_sw.weight     = 0.0f;
                    }
                    else
                    {
                        bone_index_not_found = true;
                    }
                }
                else
                {
                    a_sw.bone_index = a_bone_idx;
                    a_sw.weight     = sw.weight;
                }
            }
            if (bone_index_not_found)
            {
                WarnBoneIndexNotFound(a, sub);
            }
        }