示例#1
0
 private bool BfresModelHasBones(TreeNode Anim, BFRES.FMDL_Model fmdl)
 {
     foreach (var b in ((Animation)Anim).Bones)
     {
         //Search for bones in VBN and bone anim. If it does't have one from the anim return false
         if (!fmdl.skeleton.bones.Any(s => s.Text == b.Text))
         {
             return(false);
         }
     }
     return(true);
 }
示例#2
0
        public void SetMeshBoneList(BFRES.FMDL_Model mdl, BFRES.Mesh m, bool sb = false)
        {
            listView1.Items.Clear();

            //This list is used for both viewing and also single binding for certain instances
            isSingleBinding = sb;
            msh             = m;
            fmdl            = mdl;

            foreach (var bn in m.BoneIndexList)
            {
                listView1.Items.Add(bn.Value.ToString()).SubItems.Add(bn.Key);
            }
        }
        public BfresMeshEditor(BFRES.Mesh p, BFRES.FMDL_Model mdl, BFRES b)
        {
            InitializeComponent();

            button1.Enabled      = false;
            textBox1.Text        = p.Text;
            VertCountlabel1.Text = VertCountlabel1.Text + " " + p.vertices.Count.ToString();
            PolyCountlabel3.Text = PolyCountlabel3.Text + " " + p.lodMeshes[p.DisplayLODIndex].displayFaceSize.ToString();
            skinCountLabel.Text  = skinCountLabel.Text + " " + p.VertexSkinCount.ToString();
            label3.Text          = label3.Text + " " + mdl.skeleton.bones[p.boneIndx].ToString();

            Mesh  = p;
            Model = mdl;
            bfres = b;


            foreach (var lod in p.lodMeshes)
            {
                LODcomboBox3.Items.Add(lod);
            }
            LODcomboBox3.SelectedIndex = p.DisplayLODIndex;

            List <string> attributes = new List <string>();

            foreach (Syroot.NintenTools.NSW.Bfres.GFX.AttribFormat attr in Enum.GetValues(typeof(Syroot.NintenTools.NSW.Bfres.GFX.AttribFormat)))
            {
                attributes.Add(attr.ToString());
            }
            attributes.Sort();
            foreach (string att in attributes)
            {
                comboBox2.Items.Add(att);
            }


            int Height = 2;

            foreach (BFRES.Mesh.VertexAttribute att in p.vertexAttributes)
            {
                comboBox1.Items.Add(att);
            }
        }
示例#4
0
        public void SetVertexBufferList(BFRES.Mesh m, string attName, BFRES.FMDL_Model mdl)
        {
            listView1.Items.Clear();

            //Set public variables so i can use it for other things
            AttName = attName;
            model   = mdl; //For updating meshes
            msh     = m;   //For updating meshes

            foreach (BFRES.Vertex v in msh.vertices)
            {
                if (attName == "_p0")
                {
                    var item = new ListViewItem(v.pos.X.ToString());
                    item.SubItems.Add(v.pos.Y.ToString());
                    item.SubItems.Add(v.pos.Z.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_p1")
                {
                    var item = new ListViewItem(v.pos1.X.ToString());
                    item.SubItems.Add(v.pos1.Y.ToString());
                    item.SubItems.Add(v.pos1.Z.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_p2")
                {
                    var item = new ListViewItem(v.pos2.X.ToString());
                    item.SubItems.Add(v.pos2.Y.ToString());
                    item.SubItems.Add(v.pos2.Z.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_n0")
                {
                    var item = new ListViewItem(v.nrm.X.ToString());
                    item.SubItems.Add(v.nrm.Y.ToString());
                    item.SubItems.Add(v.nrm.Z.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_u0")
                {
                    var item = new ListViewItem(v.uv0.X.ToString());
                    item.SubItems.Add(v.uv0.Y.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_u1")
                {
                    var item = new ListViewItem(v.uv1.X.ToString());
                    item.SubItems.Add(v.uv1.Y.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_u2")
                {
                    var item = new ListViewItem(v.uv2.X.ToString());
                    item.SubItems.Add(v.uv2.Y.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_w0")
                {
                    float X = v.boneWeights.Count > 0 ? v.boneWeights[0] : 0;
                    float Y = v.boneWeights.Count > 1 ? v.boneWeights[1] : 0;
                    float Z = v.boneWeights.Count > 2 ? v.boneWeights[2] : 0;
                    float W = v.boneWeights.Count > 3 ? v.boneWeights[3] : 0;

                    var item = new ListViewItem(X.ToString());
                    item.SubItems.Add(Y.ToString());
                    item.SubItems.Add(Z.ToString());
                    item.SubItems.Add(W.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_i0")
                {
                    string X = "";
                    string Y = "";
                    string Z = "";
                    string W = "";

                    float iX = v.boneIds.Count > 0 ? v.boneIds[0] : 0;
                    float iY = v.boneIds.Count > 1 ? v.boneIds[1] : 0;
                    float iZ = v.boneIds.Count > 2 ? v.boneIds[2] : 0;
                    float iW = v.boneIds.Count > 3 ? v.boneIds[3] : 0;

                    //Set the bone in the skeleton of it's fmdl.
                    try
                    {
                        if (iX != 0)
                        {
                            X = model.skeleton.bones[model.Node_Array[(int)iX]].Text;
                        }
                        if (iY != 0)
                        {
                            Y = model.skeleton.bones[model.Node_Array[(int)iY]].Text;
                        }
                        if (iZ != 0)
                        {
                            Z = model.skeleton.bones[model.Node_Array[(int)iZ]].Text;
                        }
                        if (iW != 0)
                        {
                            W = model.skeleton.bones[model.Node_Array[(int)iW]].Text;
                        }
                    }
                    catch
                    {
                        X = iX.ToString();
                        Y = iY.ToString();
                        Z = iZ.ToString();
                        W = iW.ToString();
                    }


                    var item = new ListViewItem(X);
                    item.SubItems.Add(Y);
                    item.SubItems.Add(Z);
                    item.SubItems.Add(W);
                    listView1.Items.Add(item);
                }
                if (attName == "_b0")
                {
                    var item = new ListViewItem(v.bitan.X.ToString());
                    item.SubItems.Add(v.bitan.Y.ToString());
                    item.SubItems.Add(v.bitan.Z.ToString());
                    item.SubItems.Add(v.bitan.W.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_t0")
                {
                    var item = new ListViewItem(v.tan.X.ToString());
                    item.SubItems.Add(v.tan.Y.ToString());
                    item.SubItems.Add(v.tan.Z.ToString());
                    item.SubItems.Add(v.tan.W.ToString());
                    listView1.Items.Add(item);
                }
                if (attName == "_c0")
                {
                    Color SetColor = Color.White;

                    int someIntX = (int)Math.Ceiling(v.col.X * 255);
                    int someIntY = (int)Math.Ceiling(v.col.Y * 255);
                    int someIntZ = (int)Math.Ceiling(v.col.Z * 255);
                    int someIntW = (int)Math.Ceiling(v.col.W * 255);

                    SetColor = Color.FromArgb(
                        255,
                        someIntX,
                        someIntY,
                        someIntZ
                        );


                    var item = new ListViewItem(v.col.X.ToString());
                    item.BackColor = SetColor;
                    item.SubItems.Add(v.col.Y.ToString());
                    item.SubItems.Add(v.col.Z.ToString());
                    item.SubItems.Add(v.col.W.ToString());
                    listView1.Items.Add(item);
                }
            }
        }