Exemple #1
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Removing a vertex buffer could potentially break the object. This cannot be undone. Are you sure you want to remove this?",
                                         "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                var attriubte = attributeListView.SelectedItems[0];
                if (attriubte.Text == "_p0")
                {
                    MessageBox.Show("Cannot remove position attribute! You should remove a mesh instead or hide by materials.");
                    return;
                }

                for (int att = 0; att < activeShape.vertexAttributes.Count; att++)
                {
                    var CurrentAttribute = activeShape.vertexAttributes[att];

                    if (CurrentAttribute.Name == attriubte.Text)
                    {
                        var buffer = CurrentAttribute.BufferIndex;
                        activeShape.vertexAttributes.Remove(CurrentAttribute);

                        //Check if the index is no longer used for any attribute
                        if (!activeShape.vertexAttributes.Any(x => x.BufferIndex == buffer))
                        {
                            foreach (var attr in activeShape.vertexAttributes)
                            {
                                if (attr.BufferIndex > buffer)
                                {
                                    attr.BufferIndex -= 1;
                                }
                            }
                        }

                        attributeListView.Items.Remove(attriubte);
                    }
                }

                activeShape.SaveVertexBuffer(activeShape.GetResFileU() != null);
                activeShape.UpdateVertexData();
            }
        }
Exemple #2
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Removing a vertex buffer could potentially break the object. This cannot be undone. Are you sure you want to remove this?",
                                         "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                var attriubte = attributeListView.SelectedItems[0];

                for (int att = 0; att < activeShape.vertexAttributes.Count; att++)
                {
                    var CurrentAttribute = activeShape.vertexAttributes[att];

                    if (CurrentAttribute.Name == attriubte.Text)
                    {
                        activeShape.vertexAttributes.Remove(CurrentAttribute);
                        attributeListView.Items.Remove(attriubte);
                    }
                }

                activeShape.SaveVertexBuffer(activeShape.GetResFileU() != null);
                activeShape.UpdateVertexData();
            }
        }
        public void LoadObject(FMDL mdl, FSHP shape)
        {
            InitializeControls();

            activeShape = shape;
            activeModel = mdl;



            //Load all the material names unless there's alot
            if (mdl.materials.Count < 1)
            {
                ReloadMaterialList();
            }
            else
            {
                materialComboBox1.Items.Add(shape.GetMaterial().Text);
                materialComboBox1.SelectedIndex = 0;
            }
            for (int i = 0; i < shape.lodMeshes.Count; i++)
            {
                LODMeshCB.Items.Add($"mesh {i}");
            }
            LODMeshCB.SelectedIndex = activeShape.DisplayLODIndex;

            textBoxName.Text      = shape.Text;
            textBoxBoneIndex.Text = shape.BoneIndex.ToString();
            textBoxMatIndex.Text  = shape.MaterialIndex.ToString();


            bonesCB.Items.Add(mdl.Skeleton.bones[shape.boneIndx].Text);
            bonesCB.SelectedIndex       = 0;
            textBoxVertexSkinCount.Text = shape.VertexSkinCount.ToString();

            if (shape.GetResFileU() != null)
            {
            }
            else
            {
                if (shape.Shape.Flags == ShapeFlags.SubMeshBoundaryConsistent)
                {
                    checkBoxUseSubMeshBoundryConsistent.Checked = true;
                }
                if (shape.Shape.Flags == ShapeFlags.HasVertexBuffer)
                {
                    checkBoxUseVertexBuffer.Checked = true;
                }
            }


            shaderAttCB.Items.Add("NONE");
            foreach (FSHP.VertexAttribute att in shape.vertexAttributes)
            {
                vtxAttributesCB.Items.Add(att.Name);
                vtxFormatCB.Items.Add(att.Format);

                if (activeShape.GetMaterial().shaderassign.attributes.ContainsValue(att.Name))
                {
                    var VertexShaderAttributre = activeShape.GetMaterial().shaderassign.attributes.FirstOrDefault(x => x.Value == att.Name).Key;

                    shaderAttCB.Items.Add(VertexShaderAttributre);
                }
            }

            if (vtxAttributesCB.Items.Count > 0)
            {
                vtxAttributesCB.SelectedIndex = 0;
            }
            if (vtxFormatCB.Items.Count > 0)
            {
                vtxFormatCB.SelectedIndex = 0;
            }


            Vector3 translate = new Vector3(0);
            Vector3 scale     = new Vector3(1);
            Vector4 rotate    = new Vector4(0);

            translate = activeShape.boundingBoxes[0].Center;

            transXUD.Value = (decimal)translate.X;
            transYUD.Value = (decimal)translate.Y;
            transZUD.Value = (decimal)translate.Z;
            rotUDX.Value   = (decimal)rotate.X;
            rotUDY.Value   = (decimal)rotate.Y;
            rotUDZ.Value   = (decimal)rotate.Z;
            scaleUDX.Value = (decimal)scale.X;
            scaleUDY.Value = (decimal)scale.Y;
            scaleUDZ.Value = (decimal)scale.Z;

            RenderTools.DrawCube(translate, 2);
        }