private void ReloadBoneList()
        {
            if (!IsLoaded)
            {
                return;
            }

            if (!IsBoneListLoaded)
            {
                bonesCB.Items.Clear();
                foreach (var bn in activeShape.GetParentModel().Skeleton.bones)
                {
                    bonesCB.Items.Add(bn.Text);
                }

                bonesCB.SelectedIndex = activeShape.BoneIndex;
                IsBoneListLoaded      = true;
            }
        }
示例#2
0
        private void stbtnView_Click(object sender, EventArgs e)
        {
            if (attributeListView.SelectedItems.Count <= 0)
            {
                return;
            }

            var attribute = attributeListView.SelectedItems[0];

            uint VertexID = 0;

            VertexAttributeDataList list = new VertexAttributeDataList();

            foreach (Vertex vtx in activeShape.vertices)
            {
                switch (attribute.Text)
                {
                case "_p0":
                    list.AddVector3(vtx.pos, VertexID);
                    break;

                case "_n0":
                    list.AddVector3(vtx.nrm, VertexID);
                    break;

                case "_u0":
                    list.AddVector2(vtx.uv0, VertexID);
                    break;

                case "_u1":
                    list.AddVector2(vtx.uv1, VertexID);
                    break;

                case "_u2":
                    list.AddVector2(vtx.uv2, VertexID);
                    break;

                case "_c0":
                    list.AddColor(vtx.col, VertexID);
                    break;

                case "_t0":
                    list.AddVector4(vtx.tan, VertexID);
                    break;

                case "_b0":
                    list.AddVector4(vtx.bitan, VertexID);
                    break;

                case "_w0":
                    list.AddWeights(vtx.boneWeights, VertexID);
                    break;

                case "_i0":
                    List <string> boneNames = new List <string>();
                    foreach (int id in vtx.boneIds)
                    {
                        boneNames.Add(activeShape.GetBoneNameFromIndex(activeShape.GetParentModel(), id));
                    }
                    list.AddBoneName(boneNames, vtx.boneIds, VertexID);
                    boneNames = null;
                    break;

                case "_w1":
                    list.AddWeights(vtx.boneWeights, VertexID);
                    break;

                case "_i1":
                    List <string> boneNames2 = new List <string>();
                    foreach (int id in vtx.boneIds)
                    {
                        boneNames2.Add(activeShape.GetBoneNameFromIndex(activeShape.GetParentModel(), id));
                    }
                    list.AddBoneName(boneNames2, vtx.boneIds, VertexID);
                    boneNames2 = null;
                    break;
                }
                VertexID++;
            }

            list.Show();
        }
        public void LoadShape(FSHP fshp)
        {
            InitializeControls();

            activeShape = fshp;

            shapeVertexSkinCountUD.Value = (decimal)fshp.VertexSkinCount;

            FMDL fmdl = fshp.GetParentModel();

            //Load info
            nameTB.Bind(fshp, "Text");
            shapeIndexUD.Value = fmdl.shapes.IndexOf(fshp);

            //Load meshes to toggle LOD display
            for (int i = 0; i < fshp.lodMeshes.Count; i++)
            {
                lodDisplayCB.Items.Add($"mesh {i}");
            }
            lodDisplayCB.SelectedIndex = activeShape.DisplayLODIndex;

            //Load material (all materials will load when activated)
            materialComboBox1.Items.Add(fshp.GetMaterial().Text);
            materialComboBox1.SelectedIndex = 0;

            //Load bone binded (all bones will load when activated)
            bonesCB.Items.Add(fmdl.Skeleton.bones[fshp.BoneIndex].Text);
            bonesCB.SelectedIndex = 0;

            //Load transform
            GetShapeTransform();

            if (fshp.VertexBufferU != null)
            {
                vertexBufferSkinCountUD.Maximum = (decimal)fshp.VertexBufferU.VertexSkinCount;
                vertexBufferSkinCountUD.Value   = (decimal)fshp.VertexBufferU.VertexSkinCount;
                vertexBufferList1.LoadVertexBuffers(fshp, fshp.VertexBufferU);
            }
            else
            {
                vertexBufferSkinCountUD.Maximum = (decimal)fshp.VertexBuffer.VertexSkinCount;
                vertexBufferSkinCountUD.Value   = (decimal)fshp.VertexBuffer.VertexSkinCount;
                vertexBufferList1.LoadVertexBuffers(fshp, fshp.VertexBuffer);
            }

            vtxCountUD.Maximum = fshp.vertices.Count;
            vtxCountUD.Value   = fshp.vertices.Count;


            if (fshp.ShapeU != null)
            {
                keyShapeList1.LoadKeyShapes(fshp.ShapeU.KeyShapes);
            }
            else
            {
                keyShapeList1.LoadKeyShapes(fshp.Shape.KeyShapes, fshp.Shape.KeyShapeDict);
            }

            int lodIndx = 0;

            foreach (var mesh in fshp.lodMeshes)
            {
                lodListView.Items.Add($"Detail Level {lodIndx++}");
            }

            IsLoaded = true;
        }