Example #1
0
        private void UpdateModelTree()
        {
            treeMaterials.SelectedNode = null; // Workaround for bug 5661 in Mono
            treeModel.Nodes.Clear();

            if (gma != null)
            {
                for (int i = 0; i < gma.Count; i++)
                {
                    // Add entry corresponding to the whole model
                    TreeNode modelItem = new TreeNode((gma[i] != null) ? gma[i].Name : "Unnamed");
                    modelItem.Tag       = new ModelMeshReference(i, -1);
                    modelItem.ForeColor = (gma[i] != null) ? Color.DarkGreen : Color.Red;
                    treeModel.Nodes.Add(modelItem);

                    // Add display list entries for the meshes within the model
                    if (gma[i] != null)
                    {
                        Gcmf model = gma[i].ModelObject;
                        for (int j = 0; j < model.Meshes.Count; j++)
                        {
                            int      layerNo  = (model.Meshes[j].Layer == GcmfMesh.MeshLayer.Layer1) ? 1 : 2;
                            TreeNode meshItem = new TreeNode(string.Format("[Layer {0}] Mesh {1}", layerNo, j));
                            meshItem.Tag = new ModelMeshReference(i, j);
                            modelItem.Nodes.Add(meshItem);
                        }
                    }

                    treeModel.SetCheckState(modelItem, CheckState.Checked);
                }
            }
        }
Example #2
0
        private void treeModel_AfterSelect(object sender, TreeViewEventArgs e)
        {
            mainWindow.paneMaterials.UpdateTrees();

            // If no item is selected in the list, hide the display completely
            if (mainWindow.paneModels.SelectedNode == null)
            {
                modelTable.Visible = false;
                meshTable.Visible  = false;
                return;
            }

            // Otherwise, extract the ModelTreeItem structure to get the selected model/mesh
            ModelMeshReference modelMeshReference = (ModelMeshReference)mainWindow.paneModels.SelectedNode.Tag;

            if (mainWindow.Gma[modelMeshReference.ModelIdx] == null)
            {
                modelTable.Visible = false;
                meshTable.Visible  = false;
                return;
            }

            Gcmf model = mainWindow.Gma[modelMeshReference.ModelIdx].ModelObject;

            // Show information about the selected model / mesh
            if (modelMeshReference.MeshIdx == -1)
            {
                modelTable.Visible = true;
                meshTable.Visible  = false;

                lblModelSectionFlags.Text = string.Format("0x{0:X8}", model.SectionFlags);
                lblModelCenter.Text       = model.BoundingSphereCenter.ToString();
                lblModelRadius.Text       = model.BoundingSphereRadius.ToString();
                lblModelTransformMatrixDefaultReferences.Text = string.Join(",",
                                                                            Array.ConvertAll(model.TransformMatrixDefaultIdxs, b => string.Format("0x{0:X2}", b)));
                lblModelNumTransformMatrices.Text = model.TransformMatrices.Count.ToString();
            }
            else
            {
                GcmfMesh mesh = model.Meshes[modelMeshReference.MeshIdx];

                modelTable.Visible = true;
                meshTable.Visible  = true;

                lblMeshRenderFlags.Text          = string.Format("0x{0:X8} ({1})", (uint)mesh.RenderFlags, EnumUtils.GetEnumFlagsString(mesh.RenderFlags));
                lblMeshUnk4.Text                 = string.Format("0x{0:X8}", mesh.Unk4);
                lblMeshUnk8.Text                 = string.Format("0x{0:X8}", mesh.Unk8);
                lblMeshUnkC.Text                 = string.Format("0x{0:X8}", mesh.UnkC);
                lblMeshUnk10.Text                = string.Format("0x{0:X4}", mesh.Unk10);
                lblMeshUnk14.Text                = string.Format("0x{0:X4}", mesh.Unk14);
                lblMeshPrimaryMaterialIdx.Text   = mesh.PrimaryMaterialIdx.ToString();
                lblMeshSecondaryMaterialIdx.Text = mesh.SecondaryMaterialIdx.ToString();
                lblMeshTertiaryMaterialIdx.Text  = mesh.TertiaryMaterialIdx.ToString();
                lblMeshTransformMatrixSpecificReferences.Text = string.Join(",",
                                                                            Array.ConvertAll(mesh.TransformMatrixSpecificIdxsObj1, b => string.Format("0x{0:X2}", b)));
                lblMeshCenter.Text = mesh.BoundingSphereCenter.ToString();
                lblMeshUnk3C.Text  = mesh.Unk3C.ToString();
                lblMeshUnk40.Text  = string.Format("0x{0:X8}", mesh.Unk40);
            }
        }
Example #3
0
        public void UpdateTrees()
        {
            treeTextures.SelectedNode = null; // Workaround for bug 5661 in Mono
            treeTextures.Nodes.Clear();

            if (mainWindow.Tpl != null)
            {
                for (int i = 0; i < mainWindow.Tpl.Count; i++)
                {
                    TreeNode textureItem = new TreeNode(string.Format("Texture {0}", i));
                    textureItem.ForeColor = (!mainWindow.Tpl[i].IsEmpty) ? Color.DarkGreen : Color.Red;
                    textureItem.Tag       = new TextureReference(i, -1);
                    treeTextures.Nodes.Add(textureItem);

                    // Add subitems for the texture levels
                    if (!mainWindow.Tpl[i].IsEmpty)
                    {
                        for (int j = 0; j < mainWindow.Tpl[i].LevelCount; j++)
                        {
                            TreeNode levelItem = new TreeNode(string.Format("Level {0}", j));
                            levelItem.Tag = new TextureReference(i, j);
                            textureItem.Nodes.Add(levelItem);
                        }
                    }
                }
            }

            treeMaterials.SelectedNode = null; // Workaround for bug 5661 in Mono
            treeMaterials.Nodes.Clear();

            // Make sure that an item is selected in the model list and it corresponds to a non-null model
            int modelIdx = GetSelectedModelIdx();

            if (modelIdx == -1 || mainWindow.Gma[modelIdx] == null)
            {
                return;
            }

            // Populate the material list from the model
            Gcmf model = mainWindow.Gma[modelIdx].ModelObject;

            for (int i = 0; i < model.Materials.Count; i++)
            {
                TreeNode materialItem = new TreeNode(string.Format("Material {0}", i));
                materialItem.Tag = new ModelMaterialReference(modelIdx, i);
                treeMaterials.Nodes.Add(materialItem);
            }
        }
Example #4
0
        private void UpdateMaterialList()
        {
            treeMaterials.Nodes.Clear();

            // Make sure that an item is selected in the model list and it corresponds to a non-null model
            int modelIdx = GetSelectedModelIdx();

            if (modelIdx == -1 || gma[modelIdx] == null)
            {
                return;
            }

            // Populate the material list from the model
            Gcmf model = gma[modelIdx].ModelObject;

            for (int i = 0; i < model.Materials.Count; i++)
            {
                TreeNode materialItem = new TreeNode(string.Format("Material {0}", i));
                materialItem.Tag = new ModelMaterialReference(modelIdx, i);
                treeMaterials.Nodes.Add(materialItem);
            }
        }
Example #5
0
        public ModelFlagEditor(Gcmf model)
        {
            InitializeComponent();
            this.model = model;
            this.sectionFlagsTextBox.Text = String.Format("{0:X8}", model.SectionFlags);

            this.boundingSphereCenterX.Text = "" + model.BoundingSphereCenter.X;
            this.boundingSphereCenterY.Text = "" + model.BoundingSphereCenter.Y;
            this.boundingSphereCenterZ.Text = "" + model.BoundingSphereCenter.Z;
            this.boundingSphereRadius.Text  = "" + model.BoundingSphereRadius;

            this.transformationMatrixCount.Text = "" + model.TransformMatrices.Count;

            this.transformationMatrixDefaultIdOne.Text   = "" + model.TransformMatrixDefaultIdxs[0];
            this.transformationMatrixDefaultIdTwo.Text   = "" + model.TransformMatrixDefaultIdxs[1];
            this.transformationMatrixDefaultIdThree.Text = "" + model.TransformMatrixDefaultIdxs[2];
            this.transformationMatrixDefaultIdFour.Text  = "" + model.TransformMatrixDefaultIdxs[3];
            this.transformationMatrixDefaultIdFive.Text  = "" + model.TransformMatrixDefaultIdxs[4];
            this.transformationMatrixDefaultIdSix.Text   = "" + model.TransformMatrixDefaultIdxs[5];
            this.transformationMatrixDefaultIdSeven.Text = "" + model.TransformMatrixDefaultIdxs[6];
            this.transformationMatrixDefaultIdEight.Text = "" + model.TransformMatrixDefaultIdxs[7];
        }