Ejemplo n.º 1
0
        private void _addTextureDebugOverlay(TrayLocation loc, string texname, int i)
        {
            // Create material
            var matName  = "Axiom/DebugTexture" + i;
            var debugMat = (Material)MaterialManager.Instance.GetByName(matName);

            if (debugMat == null)
            {
                debugMat = (Material)MaterialManager.Instance.Create(matName, ResourceGroupManager.DefaultResourceGroupName);
            }

            var p = debugMat.GetTechnique(0).GetPass(0);

            p.RemoveAllTextureUnitStates();
            p.LightingEnabled = false;
            var t = p.CreateTextureUnitState(texname);

            t.SetTextureAddressingMode(TextureAddressing.Clamp);

            // create template
            if (OverlayManager.Instance.Elements.GetElement("Axiom/DebugTexOverlay", true) == null)
            {
                var e = OverlayManager.Instance.Elements.CreateElement("Panel", "Axiom/DebugTexOverlay", true);
                e.MetricsMode = MetricsMode.Pixels;
                e.Width       = 128;
                e.Height      = 128;
            }

            // add widget
            var widgetName = "DebugTex" + i;
            var w          = TrayManager.GetWidget(widgetName);

            if (w == null)
            {
                w = TrayManager.CreateDecorWidget(loc, widgetName, "", "Axiom/DebugTexOverlay");
            }

            w.OverlayElement.MaterialName = matName;
        }