Axiom.Components.Paging.Grid2PageStrategy.UpdateDebugDisplay C# (CSharp) Метод

UpdateDebugDisplay() публичный Метод

public UpdateDebugDisplay ( Page p, SceneNode sn ) : void
p Page
sn Axiom.Core.SceneNode
Результат void
        public override void UpdateDebugDisplay(Page p, SceneNode sn)
        {
            uint dbglvl = mManager.DebugDisplayLevel;
            if (dbglvl != 0)
            {
                // we could try to avoid updating the geometry every time here, but this 
                // wouldn't easily deal with paging parameter changes. There shouldn't 
                // be that many pages anyway, and this is debug after all, so update every time
                int row = 0, col = 0;
                Grid2DPageStrategyData stratData = (Grid2DPageStrategyData)p.ParentSection.StrategyData;
                stratData.CalculateRowCol(p.PageID, ref row, ref col);
#warning data is created twice here, should be useless.
                Grid2DPageStrategyData data = (Grid2DPageStrategyData)p.ParentSection.StrategyData;
                // Determine our centre point, we'll anchor here
                // Note that world points are initialised to ZERO since only 2 dimensions
                // are updated by the grid data (we could display this grid anywhere)
                Vector2 gridMidPoint = Vector2.Zero;
                Vector3 worldMidPoint = Vector3.Zero;
                data.GetMidPointGridSpace(row, col, ref gridMidPoint);
                data.ConvertGridToWorldSpace(gridMidPoint, ref worldMidPoint);

                sn.Position = worldMidPoint;
                Vector2[] gridCorners = new Vector2[4];
                Vector3[] worldCorners = new Vector3[4];

                data.GetCornersGridSpace(row, col, ref gridCorners);
                for (int i = 0; i < 4; ++i)
                {
                    worldCorners[i] = Vector3.Zero;
                    data.ConvertGridToWorldSpace(gridCorners[i], ref worldCorners[i]);
                    //make relative to mid point
                    worldCorners[i] -= worldMidPoint;
                }
                
                string matName = "Ogre/G2D/Debug";
                Material mat = (Material)MaterialManager.Instance.GetByName(matName);
                if (mat == null)
                {
                    mat = (Material)MaterialManager.Instance.Create(matName, ResourceGroupManager.DefaultResourceGroupName);
                    Pass pass = mat.GetTechnique(0).GetPass(0);
                    pass.LightingEnabled = false;
                    pass.VertexColorTracking = TrackVertexColor.Ambient;
                    pass.DepthWrite = false;
                    mat.Load();
                }

                ManualObject mo = null;
                if (sn.ObjectCount == 0)
                {
                    mo = p.ParentSection.SceneManager.CreateManualObject("Grid2PageStrategyManualObject");
                    mo.Begin(matName, OperationType.LineStrip);
                }
                else
                {
					mo = (ManualObject)sn.GetObject( "Grid2PageStrategyManualObject" );
                    mo.BeginUpdate(0);
                }

                ColorEx vcol = p.Status == UnitStatus.Loaded ? ColorEx.Green : ColorEx.Red;

                for (int i = 0; i < 5; ++i)
                {
                    mo.Position(worldCorners[i % 4]);
                    mo.Color(vcol);
                }

                mo.End();
                if (sn.ObjectCount == 0)
                    sn.AttachObject(mo);
            }
        }
        /// <summary>