Beispiel #1
0
        private void ResetTriangles()
        {
            _tris.Clear();
            uint currentTriAddress = Config.Stream.GetUInt32(MarioConfig.StructAddress + MarioConfig.WallTriangleOffset);

            foreach (var tri in TriangleUtilities.GetLevelTriangles())
            {
                if (tri.IsWall() && !(_removeCurrentTri && tri.Address == currentTriAddress))
                {
                    _tris.Add(tri);
                }
            }

            _triangleListForm?.RefreshAndSort();
        }
        public override void Update()
        {
            int numAllTriangles   = Config.Stream.GetInt32(TriangleConfig.TotalTriangleCountAddress);
            int numLevelTriangles = Config.Stream.GetInt32(TriangleConfig.LevelTriangleCountAddress);
            int numObjTriangles   = numAllTriangles - numLevelTriangles;

            if (_levelTriAddressList.Count != numLevelTriangles)
            {
                _levelTriAddressList.Clear();
                _levelTriAddressList.AddRange(TriangleUtilities.GetLevelTriangles().ConvertAll(tri => tri.Address));
            }

            if (_objTriAddressList.Count != numObjTriangles)
            {
                _objTriAddressList.Clear();
                _objTriAddressList.AddRange(TriangleUtilities.GetObjectTriangles().ConvertAll(tri => tri.Address));
            }
        }
Beispiel #3
0
        private void SwitchLevelModel()
        {
            List <TriangleDataModel> triangleStructs = TriangleUtilities.GetLevelTriangles();

            // Build vertice and triangle list from triangle set
            List <int[]>   triangles    = new List <int[]>();
            List <short[]> vertices     = new List <short[]>();
            List <int>     surfaceTypes = new List <int>();

            triangleStructs.ForEach(t =>
            {
                var vIndex = vertices.Count;
                triangles.Add(new int[] { vIndex, vIndex + 1, vIndex + 2 });
                surfaceTypes.Add(t.SurfaceType);
                vertices.Add(new short[] { t.X1, t.Y1, t.Z1 });
                vertices.Add(new short[] { t.X2, t.Y2, t.Z2 });
                vertices.Add(new short[] { t.X3, t.Y3, t.Z3 });
            });

            _modelView?.ChangeModel(vertices, triangles);

            // Update tables
            dataGridViewVertices.Rows.Clear();
            for (int i = 0; i < vertices.Count; i++)
            {
                short[] v = vertices[i];
                dataGridViewVertices.Rows.Add(i, v[0], v[1], v[2]);
            }
            dataGridViewTriangles.Rows.Clear();
            for (int i = 0; i < triangles.Count; i++)
            {
                int[] t = triangles[i];
                dataGridViewTriangles.Rows.Add(0, surfaceTypes[i], t[0], t[1], t[2]);
            }
            dataGridViewTriangles.SelectAll();

            ModelObjectAddress = _previousModelPointer = 0;
        }
Beispiel #4
0
        public TriangleManager(Control tabControl, string varFilePath, WatchVariableFlowLayoutPanel watchVariablePanel)
            : base(varFilePath, watchVariablePanel, ALL_VAR_GROUPS, VISIBLE_VAR_GROUPS)
        {
            _recordedTriangleAddresses = new List <uint>();

            SplitContainer splitContainerTriangles = tabControl.Controls["splitContainerTriangles"] as SplitContainer;

            _addressBox = splitContainerTriangles.Panel1.Controls["textBoxCustomTriangle"] as BetterTextbox;
            _useMisalignmentOffsetCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxVertexMisalignment"] as CheckBox;

            _addressBox.AddEnterAction(() => AddressBoxEnter());

            _radioButtonTriFloor          = splitContainerTriangles.Panel1.Controls["radioButtonTriFloor"] as RadioButton;
            _radioButtonTriFloor.Click   += (sender, e) => Mode_Click(sender, e, TriangleMode.Floor);
            _radioButtonTriWall           = splitContainerTriangles.Panel1.Controls["radioButtonTriWall"] as RadioButton;
            _radioButtonTriWall.Click    += (sender, e) => Mode_Click(sender, e, TriangleMode.Wall);
            _radioButtonTriCeiling        = splitContainerTriangles.Panel1.Controls["radioButtonTriCeiling"] as RadioButton;
            _radioButtonTriCeiling.Click += (sender, e) => Mode_Click(sender, e, TriangleMode.Ceiling);
            _radioButtonTriCustom         = splitContainerTriangles.Panel1.Controls["radioButtonTriCustom"] as RadioButton;
            _radioButtonTriCustom.Click  += (sender, e) => Mode_Click(sender, e, TriangleMode.Custom);

            ControlUtilities.AddContextMenuStripFunctions(
                _radioButtonTriCustom,
                new List <string>()
            {
                "Paste Addresses",
            },
                new List <Action>()
            {
                () => EnterCustomText(Clipboard.GetText()),
            });

            Label labelTriangleSelection = splitContainerTriangles.Panel1.Controls["labelTriangleSelection"] as Label;

            ControlUtilities.AddContextMenuStripFunctions(
                labelTriangleSelection,
                new List <string>()
            {
                "Update Based on Coordinates",
                "Paste Triangles",
            },
                new List <Action>()
            {
                () => UpdateBasedOnCoordinates(),
                () => PasteTriangles(),
            });

            (splitContainerTriangles.Panel1.Controls["buttonGotoV1"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 1, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV2"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 2, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV3"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 3, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoVClosest"] as Button).Click += (sender, e) =>
                                                                                               ButtonUtilities.GotoTriangleVertexClosest(TriangleAddresses[0], _useMisalignmentOffsetCheckbox.Checked);

            (splitContainerTriangles.Panel1.Controls["buttonRetrieveTriangle"] as Button).Click
                += (sender, e) => ButtonUtilities.RetrieveTriangle(TriangleAddresses);

            Button buttonNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["buttonNeutralizeTriangle"] as Button;

            buttonNeutralizeTriangle.Click += (sender, e) => ButtonUtilities.NeutralizeTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonNeutralizeTriangle,
                new List <string>()
            {
                "Neutralize", "Neutralize with 0", "Neutralize with 0x15"
            },
                new List <Action>()
            {
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, false),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, true),
            });

            Button buttonAnnihilateTriangle = splitContainerTriangles.Panel1.Controls["buttonAnnihilateTriangle"] as Button;

            buttonAnnihilateTriangle.Click += (sender, e) => ButtonUtilities.AnnihilateTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonAnnihilateTriangle,
                new List <string>()
            {
                "Annihilate All Tri But Death Barriers",
                "Annihilate All Ceilings",
            },
                new List <Action>()
            {
                () => TriangleUtilities.AnnihilateAllTrianglesButDeathBarriers(),
                () => TriangleUtilities.AnnihilateAllCeilings(),
            });

            var trianglePosGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTrianglePos"] as GroupBox;

            ControlUtilities.InitializeThreeDimensionController(
                CoordinateSystem.Euler,
                true,
                trianglePosGroupBox,
                trianglePosGroupBox.Controls["buttonTrianglePosXn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYn"] as Button,
                trianglePosGroupBox.Controls["textBoxTrianglePosXZ"] as TextBox,
                trianglePosGroupBox.Controls["textBoxTrianglePosY"] as TextBox,
                trianglePosGroupBox.Controls["checkBoxTrianglePosRelative"] as CheckBox,
                (float hOffset, float vOffset, float nOffset, bool useRelative) =>
            {
                ButtonUtilities.MoveTriangle(
                    TriangleAddresses,
                    hOffset,
                    nOffset,
                    -1 * vOffset,
                    useRelative);
            });

            var triangleNormalGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTriangleNormal"] as GroupBox;

            ControlUtilities.InitializeScalarController(
                triangleNormalGroupBox.Controls["buttontriangleNormalN"] as Button,
                triangleNormalGroupBox.Controls["buttontriangleNormalP"] as Button,
                triangleNormalGroupBox.Controls["textBoxTriangleNormal"] as TextBox,
                (float normalValue) =>
            {
                ButtonUtilities.MoveTriangleNormal(TriangleAddresses, normalValue);
            });

            _checkBoxNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["checkBoxNeutralizeTriangle"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowCoords"] as Button).Click
                += (sender, e) => ShowTriangleCoordinates();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowEquation"] as Button).Click
                += (sender, e) => ShowTriangleEquation();

            _recordTriangleDataCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRecordTriangleData"] as CheckBox;
            _recordTriangleCountLabel   = splitContainerTriangles.Panel1.Controls["labelRecordTriangleCount"] as Label;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowData"] as Button).Click
                += (sender, e) => ShowTriangleData();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowVertices"] as Button).Click
                += (sender, e) => ShowTriangleVertices();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowAddresses"] as Button).Click
                += (sender, e) => ShowTriangleAddresses();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleClearData"] as Button).Click
                += (sender, e) => ClearTriangleData();

            _repeatFirstVertexCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRepeatFirstVertex"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowLevelTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetLevelTriangles());

            Button buttonTriangleShowObjTris = splitContainerTriangles.Panel1.Controls["buttonTriangleShowObjTris"] as Button;

            buttonTriangleShowObjTris.Click += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles());
            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleShowObjTris,
                new List <string>()
            {
                "Show All Object Tris", "Show Selected Object Tris"
            },
                new List <Action>()
            {
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles()),
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetSelectedObjectTriangles()),
            });

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowAllTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetAllTriangles());

            var buttonTriangleNeutralizeAllTriangles = splitContainerTriangles.Panel1.Controls["buttonTriangleNeutralizeAllTriangles"] as Button;

            buttonTriangleNeutralizeAllTriangles.Click += (sender, e) => TriangleUtilities.NeutralizeTriangles();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleNeutralizeAllTriangles,
                new List <string>()
            {
                "Neutralize All Triangles",
                "Neutralize Wall Triangles",
                "Neutralize Floor Triangles",
                "Neutralize Ceiling Triangles",
                "Neutralize Death Barriers",
                "Neutralize Lava",
                "Neutralize Sleeping",
                "Neutralize Loading Zones"
            },
                new List <Action>()
            {
                () => TriangleUtilities.NeutralizeTriangles(),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Wall),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Floor),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Ceiling),
                () => TriangleUtilities.NeutralizeTriangles(0x0A),
                () => TriangleUtilities.NeutralizeTriangles(0x01),
                () => TriangleUtilities.NeutralizeSleeping(),
                () => {
                    TriangleUtilities.NeutralizeTriangles(0x1B);
                    TriangleUtilities.NeutralizeTriangles(0x1C);
                    TriangleUtilities.NeutralizeTriangles(0x1D);
                    TriangleUtilities.NeutralizeTriangles(0x1E);
                },
            });

            var buttonTriangleDisableAllCamCollision = splitContainerTriangles.Panel1.Controls["buttonTriangleDisableAllCamCollision"] as Button;

            buttonTriangleDisableAllCamCollision.Click += (sender, e) => TriangleUtilities.DisableCamCollision();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleDisableAllCamCollision,
                new List <string>()
            {
                "Disable Cam Collision for All Triangles",
                "Disable Cam Collision for Wall Triangles",
                "Disable Cam Collision for Floor Triangles",
                "Disable Cam Collision for Ceiling Triangles",
            },
                new List <Action>()
            {
                () => TriangleUtilities.DisableCamCollision(),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Wall),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Floor),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Ceiling),
            });

            GroupBox groupBoxTriangleTypeConversion        = splitContainerTriangles.Panel1.Controls["groupBoxTriangleTypeConversion"] as GroupBox;
            ComboBox comboBoxTriangleTypeConversionConvert = groupBoxTriangleTypeConversion.Controls["comboBoxTriangleTypeConversionConvert"] as ComboBox;
            TextBox  textBoxTriangleTypeConversionFromType = groupBoxTriangleTypeConversion.Controls["textBoxTriangleTypeConversionFromType"] as TextBox;
            TextBox  textBoxTriangleTypeConversionToType   = groupBoxTriangleTypeConversion.Controls["textBoxTriangleTypeConversionToType"] as TextBox;
            Button   buttonTriangleTypeConversionConvert   = groupBoxTriangleTypeConversion.Controls["buttonTriangleTypeConversionConvert"] as Button;

            comboBoxTriangleTypeConversionConvert.DataSource = EnumUtilities.GetEnumValues <TriangleClassificationExtended>(typeof(TriangleClassificationExtended));

            buttonTriangleTypeConversionConvert.Click += (sender, e) =>
            {
                TriangleClassificationExtended classification = (TriangleClassificationExtended)comboBoxTriangleTypeConversionConvert.SelectedItem;
                short?fromType = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionFromType.Text);
                short?toType   = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionToType.Text);
                if (!fromType.HasValue || !toType.HasValue)
                {
                    return;
                }
                TriangleUtilities.ConvertSurfaceTypes(classification, fromType.Value, toType.Value);
            };
        }
Beispiel #5
0
        public TriangleManager(Control tabControl, List <WatchVariableControlPrecursor> variables, WatchVariablePanel watchVariablePanel)
            : base(variables, watchVariablePanel, ALL_VAR_GROUPS, VISIBLE_VAR_GROUPS)
        {
            _triangleCache = new Dictionary <uint, TriangleStruct>();

            _triangleData = new List <short[]>();

            SplitContainer splitContainerTriangles = tabControl.Controls["splitContainerTriangles"] as SplitContainer;

            _addressBox = splitContainerTriangles.Panel1.Controls["maskedTextBoxOtherTriangle"] as MaskedTextBox;
            _useMisalignmentOffsetCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxVertexMisalignment"] as CheckBox;

            _addressBox.KeyDown += AddressBox_KeyDown;
            (splitContainerTriangles.Panel1.Controls["radioButtonTriFloor"] as RadioButton).Click
                += (sender, e) => Mode_Click(sender, e, TriangleMode.Floor);
            (splitContainerTriangles.Panel1.Controls["radioButtonTriWall"] as RadioButton).Click
                += (sender, e) => Mode_Click(sender, e, TriangleMode.Wall);
            (splitContainerTriangles.Panel1.Controls["radioButtonTriCeiling"] as RadioButton).Click
                += (sender, e) => Mode_Click(sender, e, TriangleMode.Ceiling);
            (splitContainerTriangles.Panel1.Controls["radioButtonTriOther"] as RadioButton).Click
                += (sender, e) => Mode_Click(sender, e, TriangleMode.Other);

            (splitContainerTriangles.Panel1.Controls["labelTriangleSelection"] as Label).Click
                += (sender, e) => ShowTriangleCoordinates();

            (splitContainerTriangles.Panel1.Controls["buttonGotoV1"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangle(_triangleAddress, 1, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV2"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangle(_triangleAddress, 2, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV3"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangle(_triangleAddress, 3, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoVClosest"] as Button).Click += (sender, e) =>
            {
                int closestVertex = WatchVariableSpecialUtilities.GetClosestTriangleVertexIndex(_triangleAddress);
                ButtonUtilities.GotoTriangle(_triangleAddress, closestVertex, _useMisalignmentOffsetCheckbox.Checked);
            };

            (splitContainerTriangles.Panel1.Controls["buttonRetrieveTriangle"] as Button).Click
                += (sender, e) => ButtonUtilities.RetrieveTriangle(_triangleAddress);

            Button buttonNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["buttonNeutralizeTriangle"] as Button;

            buttonNeutralizeTriangle.Click += (sender, e) => ButtonUtilities.NeutralizeTriangle(_triangleAddress);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonNeutralizeTriangle,
                new List <string>()
            {
                "Neutralize", "Neutralize with 0", "Neutralize with 21"
            },
                new List <Action>()
            {
                () => ButtonUtilities.NeutralizeTriangle(_triangleAddress),
                () => ButtonUtilities.NeutralizeTriangle(_triangleAddress, false),
                () => ButtonUtilities.NeutralizeTriangle(_triangleAddress, true),
            });

            (splitContainerTriangles.Panel1.Controls["buttonAnnihilateTriangle"] as Button).Click
                += (sender, e) => ButtonUtilities.AnnihilateTriangle(_triangleAddress);

            var trianglePosGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTrianglePos"] as GroupBox;

            ControlUtilities.InitializeThreeDimensionController(
                CoordinateSystem.Euler,
                trianglePosGroupBox,
                trianglePosGroupBox.Controls["buttonTrianglePosXn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYn"] as Button,
                trianglePosGroupBox.Controls["textBoxTrianglePosXZ"] as TextBox,
                trianglePosGroupBox.Controls["textBoxTrianglePosY"] as TextBox,
                trianglePosGroupBox.Controls["checkBoxTrianglePosRelative"] as CheckBox,
                (float hOffset, float vOffset, float nOffset, bool useRelative) =>
            {
                ButtonUtilities.MoveTriangle(
                    _triangleAddress,
                    hOffset,
                    nOffset,
                    -1 * vOffset,
                    useRelative);
            });

            var triangleNormalGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTriangleNormal"] as GroupBox;

            ControlUtilities.InitializeScalarController(
                triangleNormalGroupBox.Controls["buttontriangleNormalN"] as Button,
                triangleNormalGroupBox.Controls["buttontriangleNormalP"] as Button,
                triangleNormalGroupBox.Controls["textBoxTriangleNormal"] as TextBox,
                (float normalValue) =>
            {
                ButtonUtilities.MoveTriangleNormal(_triangleAddress, normalValue);
            });

            _checkBoxNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["checkBoxNeutralizeTriangle"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowCoords"] as Button).Click
                += (sender, e) => ShowTriangleCoordinates();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowEquation"] as Button).Click
                += (sender, e) => ShowTriangleEquation();

            _recordTriangleDataCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRecordTriangleData"] as CheckBox;
            _recordTriangleCountLabel   = splitContainerTriangles.Panel1.Controls["labelRecordTriangleCount"] as Label;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowData"] as Button).Click
                += (sender, e) => ShowTriangleData();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowVertices"] as Button).Click
                += (sender, e) => ShowTriangleVertices();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleClearData"] as Button).Click
                += (sender, e) => ClearTriangleData();

            _repeatFirstVertexCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRepeatFirstVertex"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowLevelTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetLevelTriangles());
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowObjTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles());
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowAllTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetAllTriangles());

            var buttonTriangleNeutralizeAllTriangles = splitContainerTriangles.Panel1.Controls["buttonTriangleNeutralizeAllTriangles"] as Button;

            buttonTriangleNeutralizeAllTriangles.Click += (sender, e) => TriangleUtilities.NeutralizeTriangles();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleNeutralizeAllTriangles,
                new List <string>()
            {
                "Neutralize All Triangles",
                "Neutralize Wall Triangles",
                "Neutralize Floor Triangles",
                "Neutralize Ceiling Triangles",
            },
                new List <Action>()
            {
                () => TriangleUtilities.NeutralizeTriangles(),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Wall),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Floor),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Ceiling),
            });

            var buttonTriangleDisableAllCamCollision = splitContainerTriangles.Panel1.Controls["buttonTriangleDisableAllCamCollision"] as Button;

            buttonTriangleDisableAllCamCollision.Click += (sender, e) => TriangleUtilities.DisableCamCollision();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleDisableAllCamCollision,
                new List <string>()
            {
                "Disable Cam Collision for All Triangles",
                "Disable Cam Collision for Wall Triangles",
                "Disable Cam Collision for Floor Triangles",
                "Disable Cam Collision for Ceiling Triangles",
            },
                new List <Action>()
            {
                () => TriangleUtilities.DisableCamCollision(),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Wall),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Floor),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Ceiling),
            });
        }
Beispiel #6
0
        public override void InitializeTab()
        {
            base.InitializeTab();

            _recordedTriangleAddresses = new List <uint>();

            textBoxCustomTriangle.AddEnterAction(() => AddressBoxEnter());

            radioButtonTriFloor.Click   += (sender, e) => Mode_Click(sender, e, TriangleMode.Floor);
            radioButtonTriWall.Click    += (sender, e) => Mode_Click(sender, e, TriangleMode.Wall);
            radioButtonTriCeiling.Click += (sender, e) => Mode_Click(sender, e, TriangleMode.Ceiling);
            radioButtonTriCustom.Click  += (sender, e) => Mode_Click(sender, e, TriangleMode.Custom);

            ControlUtilities.AddContextMenuStripFunctions(
                radioButtonTriCustom,
                new List <string>()
            {
                "Paste Addresses",
            },
                new List <Action>()
            {
                () => EnterCustomText(Clipboard.GetText()),
            });

            Label labelTriangleSelection = splitContainerTriangles.Panel1.Controls["labelTriangleSelection"] as Label;

            ControlUtilities.AddContextMenuStripFunctions(
                labelTriangleSelection,
                new List <string>()
            {
                "Update Based on Coordinates",
                "Paste Triangles",
            },
                new List <Action>()
            {
                () => UpdateBasedOnCoordinates(),
                () => PasteTriangles(),
            });


            buttonGotoV1.Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 1, checkBoxVertexMisalignment.Checked);
            buttonGotoV2.Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 2, checkBoxVertexMisalignment.Checked);
            buttonGotoV3.Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 3, checkBoxVertexMisalignment.Checked);
            buttonGotoVClosest.Click += (sender, e) =>
                                        ButtonUtilities.GotoTriangleVertexClosest(TriangleAddresses[0], checkBoxVertexMisalignment.Checked);

            buttonRetrieveTriangle.Click
                += (sender, e) => ButtonUtilities.RetrieveTriangle(TriangleAddresses);

            buttonNeutralizeTriangle.Click += (sender, e) => ButtonUtilities.NeutralizeTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonNeutralizeTriangle,
                new List <string>()
            {
                "Neutralize", "Neutralize with 0", "Neutralize with 0x15"
            },
                new List <Action>()
            {
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, false),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, true),
            });

            buttonAnnihilateTriangle.Click += (sender, e) => ButtonUtilities.AnnihilateTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonAnnihilateTriangle,
                new List <string>()
            {
                "Annihilate All Tri But Death Barriers",
                "Annihilate All Ceilings",
            },
                new List <Action>()
            {
                () => TriangleUtilities.AnnihilateAllTrianglesButDeathBarriers(),
                () => TriangleUtilities.AnnihilateAllCeilings(),
            });

            ControlUtilities.InitializeThreeDimensionController(
                CoordinateSystem.Euler,
                true,
                groupBoxTrianglePos,
                buttonTrianglePosXn,
                buttonTrianglePosXp,
                buttonTrianglePosZn,
                buttonTrianglePosZp,
                buttonTrianglePosXnZn,
                buttonTrianglePosXnZp,
                buttonTrianglePosXpZn,
                buttonTrianglePosXpZp,
                buttonTrianglePosYp,
                buttonTrianglePosYn,
                textBoxTrianglePosXZ,
                textBoxTrianglePosY,
                checkBoxTrianglePosRelative,
                (float hOffset, float vOffset, float nOffset, bool useRelative) =>
            {
                ButtonUtilities.MoveTriangle(
                    TriangleAddresses,
                    hOffset,
                    nOffset,
                    -1 * vOffset,
                    useRelative,
                    true);
            });

            ControlUtilities.InitializeScalarController(
                buttonTriangleNormalN,
                buttonTriangleNormalP,
                textBoxTriangleNormal,
                (float normalValue) =>
            {
                ButtonUtilities.MoveTriangleNormal(TriangleAddresses, normalValue);
            });


            buttonTriangleShowCoords.Click
                += (sender, e) => ShowTriangleCoordinates();
            buttonTriangleShowEquation.Click
                += (sender, e) => ShowTriangleEquation();


            buttonTriangleShowData.Click
                += (sender, e) => ShowTriangleData();
            buttonTriangleShowVertices.Click
                += (sender, e) => ShowTriangleVertices();
            buttonTriangleShowAddresses.Click
                += (sender, e) => ShowTriangleAddresses();
            buttonTriangleClearData.Click
                += (sender, e) => ClearTriangleData();

            buttonTriangleShowLevelTris.Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetLevelTriangles());

            buttonTriangleShowObjTris.Click += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles());
            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleShowObjTris,
                new List <string>()
            {
                "Show All Object Tris", "Show Selected Object Tris"
            },
                new List <Action>()
            {
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles()),
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetSelectedObjectTriangles()),
            });

            buttonTriangleShowAllTris.Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetAllTriangles());

            buttonTriangleNeutralizeAllTriangles.Click += (sender, e) => TriangleUtilities.NeutralizeTriangles();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleNeutralizeAllTriangles,
                new List <string>()
            {
                "Neutralize All Triangles",
                "Neutralize Wall Triangles",
                "Neutralize Floor Triangles",
                "Neutralize Ceiling Triangles",
                "Neutralize Death Barriers",
                "Neutralize Lava",
                "Neutralize Sleeping",
                "Neutralize Loading Zones"
            },
                new List <Action>()
            {
                () => TriangleUtilities.NeutralizeTriangles(),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Wall),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Floor),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Ceiling),
                () => TriangleUtilities.NeutralizeTriangles(0x0A),
                () => TriangleUtilities.NeutralizeTriangles(0x01),
                () => TriangleUtilities.NeutralizeSleeping(),
                () => {
                    TriangleUtilities.NeutralizeTriangles(0x1B);
                    TriangleUtilities.NeutralizeTriangles(0x1C);
                    TriangleUtilities.NeutralizeTriangles(0x1D);
                    TriangleUtilities.NeutralizeTriangles(0x1E);
                },
            });

            var buttonTriangleDisableAllCamCollision = splitContainerTriangles.Panel1.Controls["buttonTriangleDisableAllCamCollision"] as Button;

            buttonTriangleDisableAllCamCollision.Click += (sender, e) => TriangleUtilities.DisableCamCollision();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleDisableAllCamCollision,
                new List <string>()
            {
                "Disable Cam Collision for All Triangles",
                "Disable Cam Collision for Wall Triangles",
                "Disable Cam Collision for Floor Triangles",
                "Disable Cam Collision for Ceiling Triangles",
            },
                new List <Action>()
            {
                () => TriangleUtilities.DisableCamCollision(),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Wall),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Floor),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Ceiling),
            });

            comboBoxTriangleTypeConversionConvert.DataSource = EnumUtilities.GetEnumValues <TriangleClassificationExtended>(typeof(TriangleClassificationExtended));

            buttonTriangleTypeConversionConvert.Click += (sender, e) =>
            {
                TriangleClassificationExtended classification = (TriangleClassificationExtended)comboBoxTriangleTypeConversionConvert.SelectedItem;
                short?fromType = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionFromType.Text);
                short?toType   = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionToType.Text);
                if (!fromType.HasValue || !toType.HasValue)
                {
                    return;
                }
                TriangleUtilities.ConvertSurfaceTypes(classification, fromType.Value, toType.Value);
            };
        }
        public static void Test()
        {
            double        startX         = -2838;
            double        startY         = 1610.8349609375;
            double        startZ         = -42.8171844482422;
            List <double> initialHSpeeds = new List <double>()
            {
                -427922.90625, -641883.5, -962824.375, -1444235.625, -2166352.75, -3249528.25,
            };
            double goalX = 2806.789063;
            double goalY = 1033;
            double goalZ = -130.9819946;

            flatFloorTris = TriangleUtilities.GetLevelTriangles()
                            .FindAll(tri => tri.IsFloor() && tri.NormY == 1 && tri.SurfaceType != 0x0A);
            possibleAngles = Enumerable.Range(0, 4096).ToList().ConvertAll(i => 16 * i);

            List <double> moreHSpeeds = initialHSpeeds.ConvertAll(
                hSpeed => GetSuccessiveHSpeeds(hSpeed)).SelectMany(list => list).ToList();

            initialHSpeeds.AddRange(moreHSpeeds);
            initialHSpeeds = ControlUtilities.Randomize(initialHSpeeds);

            Queue <MarioPuState> queue = new Queue <MarioPuState>();

            initialHSpeeds.ForEach(hSpeed => queue.Enqueue(
                                       new MarioPuState(startX, startY, startZ, hSpeed, 0, null, 0)));

            Config.Print("START");
            int lastIndex = -1;

            while (queue.Count > 0)
            {
                MarioPuState dequeue = queue.Dequeue();
                if (dequeue.Index > lastIndex)
                {
                    lastIndex = dequeue.Index;
                    Config.Print("Now on index " + lastIndex);
                }

                List <int> anglesToUse;
                if (dequeue.Index < 2)
                {
                    anglesToUse = possibleAngles;
                }
                else
                {
                    int angle = MoreMath.NormalizeAngleTruncated(MoreMath.AngleTo_AngleUnits(goalX, goalZ, dequeue.X, dequeue.Z));
                    anglesToUse = new List <int>()
                    {
                        angle - 16, angle, angle + 16
                    };
                }

                foreach (int angle in anglesToUse)
                {
                    MarioPuState state = TestOverflowJump(dequeue, angle);
                    if (state == null)
                    {
                        continue;
                    }

                    double dist = MoreMath.GetDistanceBetween(state.X, state.Z, goalX, goalZ);
                    if (state.Index >= 2 && dist > Math.Abs(state.HSpeed))
                    {
                        continue;
                    }
                    if (dist < 1000 && state.Y == goalY)
                    {
                        Config.Print(dist);
                        Config.Print(state.GetLineage());
                    }

                    if (state.Index >= 3)
                    {
                        continue;
                    }
                    List <MarioPuState> nextStates = GetSuccessiveStates(state);
                    nextStates.Insert(0, state);
                    nextStates = ControlUtilities.Randomize(nextStates);
                    nextStates.ForEach(s => queue.Enqueue(s));
                }
            }
            Config.Print("END");
        }