Ejemplo n.º 1
0
        private static TriangleDataModel FindCeilingFromList(short shortX, short shortY, short shortZ, int cellX, int cellZ, bool isStaticParition)
        {
            uint partitionAddress = isStaticParition ? TriangleConfig.StaticTrianglePartitionAddress : TriangleConfig.DynamicTrianglePartitionAddress;
            int  type             = 1; // ceiling

            int  typeSize = 2 * 4;
            int  xSize    = 3 * typeSize;
            int  zSize    = 16 * xSize;
            uint address  = (uint)(partitionAddress + cellZ * zSize + cellX * xSize + type * typeSize);

            address = Config.Stream.GetUInt32(address);

            while (address != 0)
            {
                uint triAddress           = Config.Stream.GetUInt32(address + 4);
                TriangleDataModel tri     = TriangleDataModel.Create(triAddress);
                bool isLegitimateTriangle = tri.NormX != 0 || tri.NormY != 0 || tri.NormZ != 0;
                if (isLegitimateTriangle && tri.IsPointInsideAndBelowTriangle(shortX, shortY, shortZ))
                {
                    return(tri);
                }
                address = Config.Stream.GetUInt32(address);
            }

            return(null);
        }
Ejemplo n.º 2
0
 private void UpdateBasedOnCoordinates()
 {
     foreach (uint triangleAddress in TriangleAddresses)
     {
         TriangleDataModel tri = TriangleDataModel.Create(triangleAddress);
         UpdateBasedOnCoordinates(triangleAddress, tri.X1, tri.Y1, tri.Z1, tri.X2, tri.Y2, tri.Z2, tri.X3, tri.Y3, tri.Z3);
     }
 }
Ejemplo n.º 3
0
        public void RefreshAndSort()
        {
            dataGridView.Rows.Clear();
            List <(uint address, double dist)> dataList = _triAddressList.ConvertAll(address =>
            {
                TriangleDataModel tri = TriangleDataModel.Create(address);
                double dist           = tri.GetDistToMidpoint();
                return(address, dist);
            });

            dataList = Enumerable.OrderBy(dataList, data => data.dist).ToList();
            dataList.ForEach(data =>
            {
                dataGridView.Rows.Add(HexUtilities.FormatValue(data.address), Math.Round(data.dist, 3));
            });
            labelNumTriangles.Text = _triAddressList.Count + " Triangles";
        }
Ejemplo n.º 4
0
 public static List <TriangleDataModel> GetTrianglesInRange(uint startAddress, int numTriangles)
 {
     return(GetTriangleAddressesInRange(startAddress, numTriangles)
            .ConvertAll(triAddress => TriangleDataModel.Create(triAddress)));
 }
Ejemplo n.º 5
0
        public override ContextMenuStrip GetContextMenuStrip()
        {
            if (_contextMenuStrip == null)
            {
                ToolStripMenuItem itemAutoUpdate = new ToolStripMenuItem("Auto Update");
                itemAutoUpdate.Click += (sender, e) =>
                {
                    _autoUpdate            = !_autoUpdate;
                    itemAutoUpdate.Checked = _autoUpdate;
                };
                itemAutoUpdate.Checked = _autoUpdate;

                ToolStripMenuItem itemReset = new ToolStripMenuItem("Reset");
                itemReset.Click += (sender, e) => ResetTriangles();

                ToolStripMenuItem itemRemoveCurrentTri = new ToolStripMenuItem("Remove Current Tri");
                itemRemoveCurrentTri.Click += (sender, e) =>
                {
                    _removeCurrentTri            = !_removeCurrentTri;
                    itemRemoveCurrentTri.Checked = _removeCurrentTri;
                };

                ToolStripMenuItem itemShowTriData = new ToolStripMenuItem("Show Tri Data");
                itemShowTriData.Click += (sender, e) =>
                {
                    List <TriangleDataModel> tris = _triAddressList.ConvertAll(address => TriangleDataModel.Create(address));
                    TriangleUtilities.ShowTriangles(tris);
                };

                ToolStripMenuItem itemOpenForm = new ToolStripMenuItem("Open Form");
                itemOpenForm.Click += (sender, e) =>
                {
                    if (_triangleListForm != null)
                    {
                        return;
                    }
                    _triangleListForm = new TriangleListForm(
                        this, TriangleClassification.Floor, _triAddressList);
                    _triangleListForm.Show();
                };

                _contextMenuStrip = new ContextMenuStrip();
                _contextMenuStrip.Items.Add(itemAutoUpdate);
                _contextMenuStrip.Items.Add(itemReset);
                _contextMenuStrip.Items.Add(itemRemoveCurrentTri);
                _contextMenuStrip.Items.Add(itemShowTriData);
                _contextMenuStrip.Items.Add(itemOpenForm);
                _contextMenuStrip.Items.Add(new ToolStripSeparator());
                GetFloorToolStripMenuItems().ForEach(item => _contextMenuStrip.Items.Add(item));
                _contextMenuStrip.Items.Add(new ToolStripSeparator());
                GetHorizontalTriangleToolStripMenuItems().ForEach(item => _contextMenuStrip.Items.Add(item));
                _contextMenuStrip.Items.Add(new ToolStripSeparator());
                GetTriangleToolStripMenuItems().ForEach(item => _contextMenuStrip.Items.Add(item));
            }

            return(_contextMenuStrip);
        }
Ejemplo n.º 6
0
 public static List <TriangleDataModel> GetTriangles(List <uint> triAddresses)
 {
     return(triAddresses.FindAll(triAddress => triAddress != 0)
            .ConvertAll(triAddress => TriangleDataModel.Create(triAddress)));
 }