Exemplo n.º 1
0
        public void ProcessTree(Model m, int index, bool bReset = false)
        {
            TreeNode ParentNode;

            if (bReset || tvNodes.Nodes.Count == 0)
            {
                Reset();
            }

            ParentNode = tvNodes.Nodes[0].Nodes[0];

            for (int i = 0; i < m.Bones.Count; i++)
            {
                var bone = m.Bones[i];
                var key  = ModelBone.GetModelBoneKey(index, i);

                while (ParentNode != null && ParentNode.Tag != null && (int)ParentNode.Tag != ModelBone.GetModelBoneKey(index, bone.Parent.Index))
                {
                    ParentNode = ParentNode.Parent;
                }
                ParentNode = ParentNode.Nodes[ParentNode.Nodes.Add(CreateNode(bone, key))];
            }

            tvNodes.Nodes[0].Expand();
            if (tvNodes.Nodes[0].Nodes.Count > 0)
            {
                tvNodes.Nodes[0].Nodes[0].Expand();
            }
        }
Exemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var model = (SceneManager.Current.Models.Count > 0 ? SceneManager.Current.Models[modelIndex] : (Model)SceneManager.Current.Add(new Model()));

            newBoneKey = model.AddMesh(null, boneIndex);
            model.SetName(txtName.Text, newBoneKey);
            newBoneKey = ModelBone.GetModelBoneKey(modelIndex, newBoneKey);
            this.Close();
        }
Exemplo n.º 3
0
        protected int ReindexHierarchy(int modelIndex, int boneIndex, TreeNode root)
        {
            root.Tag = ModelBone.GetModelBoneKey(modelIndex, boneIndex++);

            foreach (TreeNode child in root.Nodes)
            {
                boneIndex = ReindexHierarchy(modelIndex, boneIndex, child);
            }

            return(boneIndex);
        }
Exemplo n.º 4
0
        private void menuObjectClick(object sender, EventArgs e)
        {
            ToolStripMenuItem mi = (ToolStripMenuItem)sender;

            int boneIndex    = SceneManager.Current.SelectedBoneIndex;
            int modelIndex   = SceneManager.Current.SelectedModelIndex;
            int modelBoneKey = ModelBone.GetModelBoneKey(modelIndex, boneIndex);

            switch (mi.Text)
            {
            case "New...":
                var addNew = new frmNewObject();
                addNew.SetParentNode(modelIndex, boneIndex);

                if (addNew.ShowDialog(this) == DialogResult.OK)
                {
                    SceneManager.Current.Change(ChangeType.Add, addNew.NewBoneKey, modelBoneKey);
                }
                break;

            case "Remove...":
                var removeObject = new frmRemoveObject();
                removeObject.SetParentNode(modelIndex, boneIndex);

                if (removeObject.ShowDialog(this) == DialogResult.OK)
                {
                    SceneManager.Current.Change(ChangeType.Delete, modelBoneKey, removeObject.RemovedBone);
                }
                break;

            case "Modify geometry...":
                var geometry = new frmModifyModel();
                geometry.SetParentNode(modelIndex, boneIndex);

                if (geometry.ShowDialog(this) == DialogResult.OK)
                {
                    SceneManager.Current.Change(ChangeType.Transform, modelBoneKey);
                }
                break;

            case "Modify actor...":
                var transform = new frmModifyActor();
                transform.SetParentNode(modelIndex, boneIndex);

                if (transform.ShowDialog(this) == DialogResult.OK)
                {
                    SceneManager.Current.Change(ChangeType.Transform, modelBoneKey);
                }
                break;

            case "Rename":
                var rename = new frmRename();
                rename.SetParentNode(modelIndex, boneIndex);

                if (rename.ShowDialog(this) == DialogResult.OK)
                {
                    SceneManager.Current.Change(ChangeType.Rename, modelBoneKey, rename.NewName);
                }
                break;

            case "Add/Change Type...":
                var changeType = new frmChangeNodeType();
                changeType.SetParentNode(modelIndex, boneIndex);

                if (changeType.ShowDialog(this) == DialogResult.OK)
                {
                    SceneManager.Current.Change(ChangeType.ChangeType, modelBoneKey);
                }
                break;

            case "Remove":
                break;

            case "Optimise":
                foreach (ModelMesh mesh in SceneManager.Current.SelectedModel.Meshes)
                {
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        part.Optimise();
                    }
                }
                break;

            case "Flatten hierarchy...":
                SceneManager.Current.UpdateProgress("TODO: Code \"Flatten hierarchy...\"");
                break;

            case "Invert texture 'v' coordinates":
                ModelManipulator.FlipUVs(SceneManager.Current.SelectedModel.Bones[SceneManager.Current.SelectedBoneIndex].Mesh);
                break;
            }
        }