Esempio n. 1
0
        private void ModifyParents(int parent)
        {
            FrameObjectBase obj    = treeView1.SelectedNode.Tag as FrameObjectBase;
            ListWindow      window = new ListWindow();

            window.PopulateForm(parent);

            if (window.ShowDialog() == DialogResult.OK)
            {
                int refID = (window.chosenObject as FrameEntry).RefID;
                obj.IsOnFrameTable = true;

                if (parent == 0)
                {
                    obj.ParentIndex1.Name  = window.chosenObject.ToString();
                    obj.ParentIndex1.Index = SceneData.FrameResource.GetIndexOfObject(refID);
                    obj.ParentIndex1.RefID = refID;
                    obj.SubRef(FrameEntryRefTypes.Parent1);
                    obj.AddRef(FrameEntryRefTypes.Parent1, refID);
                }
                else if (parent == 1)
                {
                    obj.ParentIndex2.Name  = window.chosenObject.ToString();
                    obj.ParentIndex2.Index = SceneData.FrameResource.GetIndexOfObject(refID) + SceneData.FrameResource.FrameScenes.Count;
                    obj.ParentIndex2.RefID = refID;
                    obj.SubRef(FrameEntryRefTypes.Parent2);
                    obj.AddRef(FrameEntryRefTypes.Parent2, refID);
                }

                treeView1.Nodes.Remove(treeView1.SelectedNode);
                TreeNode newNode = new TreeNode();
                newNode.Tag  = obj;
                newNode.Name = obj.RefID.ToString();
                newNode.Text = obj.ToString();

                if (obj.ParentIndex1.Index != -1)
                {
                    TreeNode[] nodes = treeView1.Nodes.Find(obj.ParentIndex1.RefID.ToString(), true);

                    if (nodes.Length > 0)
                    {
                        AddToTree(newNode, nodes[0]);
                    }
                }
                else if (obj.ParentIndex2.Index != -1)
                {
                    TreeNode[] nodes = treeView1.Nodes.Find(obj.ParentIndex2.RefID.ToString(), true);

                    if (nodes.Length > 0)
                    {
                        AddToTree(newNode, nodes[0]);
                    }
                }
                else
                {
                }
            }
        }
        private void OnPropertyChanged(object s, PropertyValueChangedEventArgs e)
        {
            if (e.ChangedItem.Label == "RefID")
            {
                TreeNode[] nodes = treeView1.Nodes.Find(e.ChangedItem.Value.ToString(), true);

                if (nodes.Length > 0)
                {
                    int             newValue = (int)e.ChangedItem.Value;
                    FrameObjectBase obj      = (treeView1.SelectedNode.Tag as FrameObjectBase);
                    int             newIndex = SceneData.FrameResource.FrameObjects.IndexOfValue(newValue);

                    if (newIndex == -1)
                    {
                        //check if user didn't try setting it as a scene:
                        newIndex = SceneData.FrameResource.FrameScenes.IndexOfValue(newValue);
                    }

                    string name = (SceneData.FrameResource.FrameObjects.ElementAt(newIndex).Value as FrameObjectBase).Name.String;

                    //because C# doesn't allow me to get this data for some odd reason, im going to check for it in obj. Why does C# not allow me to see FullLabel in the e var?
                    if (obj.ParentIndex1.RefID == newValue)
                    {
                        obj.ParentIndex1.Index = newIndex;
                        obj.ParentIndex1.Name  = name;
                        obj.SubRef(FrameEntryRefTypes.Parent1);
                        obj.AddRef(FrameEntryRefTypes.Parent1, newValue);
                    }
                    else if (obj.ParentIndex2.RefID == newValue)
                    {
                        obj.ParentIndex2.Index = newIndex;
                        obj.ParentIndex2.Name  = name;
                        obj.SubRef(FrameEntryRefTypes.Parent2);
                        obj.AddRef(FrameEntryRefTypes.Parent2, newValue);
                    }
                    obj.UpdateNode();
                    treeView1.Nodes.Remove(treeView1.SelectedNode);
                    TreeNode newNode = CreateTreeNode(obj);
                    nodes[0].Nodes.Add(newNode);
                }
            }
        }
        private void ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                return;
            }

            if (e.ClickedItem.Name == "contextExtract3D")
            {
                FrameObjectSingleMesh mesh = treeView1.SelectedNode.Tag as FrameObjectSingleMesh;

                FrameGeometry  geom          = SceneData.FrameResource.FrameGeometries[mesh.Refs["Mesh"]];
                FrameMaterial  mat           = SceneData.FrameResource.FrameMaterials[mesh.Refs["Material"]];
                IndexBuffer[]  indexBuffers  = new IndexBuffer[geom.LOD.Length];
                VertexBuffer[] vertexBuffers = new VertexBuffer[geom.LOD.Length];

                //we need to retrieve buffers first.
                for (int c = 0; c != geom.LOD.Length; c++)
                {
                    indexBuffers[c]  = SceneData.IndexBufferPool.GetBuffer(geom.LOD[c].IndexBufferRef.uHash);
                    vertexBuffers[c] = SceneData.VertexBufferPool.GetBuffer(geom.LOD[c].VertexBufferRef.uHash);
                }

                Model newModel = new Model(mesh, indexBuffers, vertexBuffers, geom, mat);
                newModel.ModelStructure.ExportToM2T(ToolkitSettings.ExportPath + "\\");
                switch (ToolkitSettings.Format)
                {
                case 0:
                    newModel.ModelStructure.ExportToFbx(ToolkitSettings.ExportPath + "\\", false);
                    break;

                case 1:
                    newModel.ModelStructure.ExportToFbx(ToolkitSettings.ExportPath + "\\", true);
                    break;

                case 2:
                    newModel.ModelStructure.ExportToM2T(ToolkitSettings.ExportPath + "\\");
                    break;

                default:
                    Log.WriteLine("Error! Unknown value set for ToolkitSettings.Format!", LoggingTypes.ERROR);
                    break;
                }
            }
            else if (e.ClickedItem.Name == "contextUpdateParents")
            {
                FrameObjectBase obj    = treeView1.SelectedNode.Tag as FrameObjectBase;
                ListWindow      window = new ListWindow();
                window.PopulateForm(true);
                window.ShowDialog();
                if (window.type == -1)
                {
                    return;
                }

                int refID = (window.chosenObject as FrameEntry).RefID;
                obj.IsOnFrameTable     = true;
                obj.ParentIndex2.Index = window.chosenObjectIndex;
                obj.ParentIndex2.RefID = refID;
                obj.SubRef(FrameEntryRefTypes.Parent2);
                obj.AddRef(FrameEntryRefTypes.Parent2, refID);
                obj.UpdateNode();

                treeView1.Nodes.Remove(treeView1.SelectedNode);
                TreeNode newNode = CreateTreeNode(obj);
                treeView1.Nodes[window.chosenObjectIndex].Nodes.Add(newNode);
            }
        }