Exemplo n.º 1
0
        private void SetVisibleModelMeshes(bool showLayer1, bool showLayer2)
        {
            foreach (TreeNode modelItem in treeModel.Nodes)
            {
                if (modelItem.Nodes.Count > 0)
                {
                    // Set model meshes check state
                    foreach (TreeNode meshItem in modelItem.Nodes)
                    {
                        ModelMeshReference meshData = (ModelMeshReference)meshItem.Tag;
                        GcmfMesh           mesh     = gma[meshData.ModelIdx].ModelObject.Meshes[meshData.MeshIdx];
                        if (mesh.Layer == GcmfMesh.MeshLayer.Layer1)
                        {
                            treeModel.SetCheckState(meshItem, showLayer1 ? CheckState.Checked : CheckState.Unchecked);
                        }
                        else if (mesh.Layer == GcmfMesh.MeshLayer.Layer2)
                        {
                            treeModel.SetCheckState(meshItem, showLayer2 ? CheckState.Checked : CheckState.Unchecked);
                        }
                    }
                }
                else
                {
                    // For the orphan nodes (models with no meshes, mostly GMA null entries),
                    // unselect them unless we're choosing to show both types of layers
                    treeModel.SetCheckState(modelItem, (showLayer1 && showLayer2) ? CheckState.Checked : CheckState.Unchecked);
                }
            }

            // The model will be updated due to the AfterCheckState event on treeModel
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 3
0
        private int GetSelectedModelIdx()
        {
            // If no item is selected in the list, return -1
            if (treeModel.SelectedNode == null)
            {
                return(-1);
            }

            // Otherwise, extract the model/mesh reference structure and get the model index from there
            ModelMeshReference itemData = (ModelMeshReference)treeModel.SelectedNode.Tag;

            return(((ModelMeshReference)treeModel.SelectedNode.Tag).ModelIdx);
        }
Exemplo n.º 4
0
        private void glControlModel_Paint(object sender, PaintEventArgs e)
        {
            // Reload the model if necessary
            if (reloadOnNextRedraw)
            {
                LoadModel();
                reloadOnNextRedraw = false;
            }

            // Set up OpenGL context
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.Translate(0.0f, 0.0f, -6.0f);
            GL.Rotate(angleY, 1.0f, 0.0f, 0.0f);
            GL.Rotate(angleX, 0.0f, 1.0f, 0.0f);
            GL.Scale(zoomFactor, zoomFactor, zoomFactor);

            // Draw the models/meshes
            foreach (TreeNode modelItem in treeModel.Nodes)
            {
                ModelMeshReference modelRef = (ModelMeshReference)modelItem.Tag;
                if (gma[modelRef.ModelIdx] != null)
                {
                    if (treeModel.GetCheckState(modelItem) == CheckState.Checked)
                    {
                        // Whole item is checked -> Call the display list corresponding to the entire model
                        ctx.CallDisplayList(modelObjects[modelRef.ModelIdx].Value);
                    }
                    else if (treeModel.GetCheckState(modelItem) == CheckState.Indeterminate)
                    {
                        // Only some meshes of the item are checked -> Call the display list corresponding to each mesh
                        foreach (TreeNode meshItem in modelItem.Nodes)
                        {
                            if (treeModel.GetCheckState(meshItem) == CheckState.Checked)
                            {
                                ModelMeshReference meshRef = (ModelMeshReference)meshItem.Tag;
                                ctx.CallDisplayList(modelObjects[meshRef.ModelIdx][meshRef.MeshIdx].Value);
                            }
                        }
                    }
                }
            }

            glControlModel.SwapBuffers();
        }
Exemplo n.º 5
0
        private void glControl_Paint(object sender, PaintEventArgs e)
        {
            // Reload the model if necessary
            if (ReloadOnNextRedraw)
            {
                LoadModel();
                ReloadOnNextRedraw = false;
            }

            // Set up OpenGL context
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.Translate(0.0f, 0.0f, -6.0f);
            GL.Rotate(angleY, 1.0f, 0.0f, 0.0f);
            GL.Rotate(angleX, 0.0f, 1.0f, 0.0f);
            GL.Scale(zoomFactor, zoomFactor, zoomFactor);

            // Draw the models/meshes
            foreach (TreeNode modelItem in mainWindow.paneModels.TreeModel.Nodes)
            {
                ModelMeshReference modelRef = (ModelMeshReference)modelItem.Tag;
                if (mainWindow.Gma[modelRef.ModelIdx] != null)
                {
                    if (mainWindow.paneModels.TreeModel.GetCheckState(modelItem) == CheckState.Checked)
                    {
                        // Whole item is checked -> Call the display list corresponding to the entire model
                        ctx.CallDisplayList(modelObjects[modelRef.ModelIdx].Value);
                    }
                    else if (mainWindow.paneModels.TreeModel.GetCheckState(modelItem) == CheckState.Indeterminate)
                    {
                        // Only some meshes of the item are checked -> Call the display list corresponding to each mesh
                        foreach (TreeNode meshItem in modelItem.Nodes)
                        {
                            if (mainWindow.paneModels.TreeModel.GetCheckState(meshItem) == CheckState.Checked)
                            {
                                ModelMeshReference meshRef = (ModelMeshReference)meshItem.Tag;
                                ctx.CallDisplayList(modelObjects[meshRef.ModelIdx][meshRef.MeshIdx].Value);
                            }
                        }
                    }
                }
            }

            if (mainWindow.Gma == null)
            {
                DrawUnitCube(Vector3.Zero, new Vector3(0.75f, 0.75f, 0.75f), 1);
            }

            if (mainWindow.StageLayout != null)
            {
                foreach (var b in mainWindow.StageLayout.Bananas)
                {
                    DrawUnitCube(b.Position, new Vector3(1, 1, 0), 1);
                }
                foreach (var g in mainWindow.StageLayout.Goals)
                {
                    switch (g.Color)
                    {
                    case StageLayoutGoal.GoalColor.Blue:
                        DrawUnitCube(g.Position, new Vector3(0, 0, 1), 2);
                        break;

                    case StageLayoutGoal.GoalColor.Green:
                        DrawUnitCube(g.Position, new Vector3(0, 1, 0), 2);
                        break;

                    case StageLayoutGoal.GoalColor.Red:
                        DrawUnitCube(g.Position, new Vector3(1, 0, 0), 2);
                        break;
                    }
                }
            }

            glControl.SwapBuffers();
        }