Exemplo 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;
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pageNum"></param>
        protected void ChangePage(int pageNum)
        {
            if (this.materialControlsContainer.Count == 0)
            {
                return;
            }

            this.currentPage = (pageNum == -1) ? (this.currentPage + 1) % this.numPages : pageNum;

            string pageText = string.Format("Parameters {0} / {1}", this.currentPage + 1, this.numPages);

            ((Button)TrayManager.GetWidget("PageButtonControl")).Caption = pageText;

            if (this.activeMaterial != null && this.activeMaterial.SupportedTechniques.Count > 0)
            {
                Technique currentTechnique = this.activeMaterial.SupportedTechniques[0];
                if (currentTechnique != null)
                {
                    this.activePass = currentTechnique.GetPass(0);
                    if (this.activePass != null)
                    {
                        if (this.activePass.HasFragmentProgram)
                        {
                            this.activeFragmentProgram    = this.activePass.FragmentProgram;
                            this.activeFragmentParameters = this.activePass.FragmentProgramParameters;
                        }
                        if (this.activePass.HasVertexProgram)
                        {
                            this.activeVertexProgram    = this.activePass.VertexProgram;
                            this.activeVertexParameters = this.activePass.VertexProgramParameters;
                        }

                        int activeControlCount = this.materialControlsContainer[this.currentMaterial].ShaderControlsCount;

                        int startControlIndex = this.currentPage * ControlsPerPage;
                        int numControls       = activeControlCount - startControlIndex;
                        if (numControls <= 0)
                        {
                            this.currentPage  = 0;
                            startControlIndex = 0;
                            numControls       = activeControlCount;
                        }

                        for (int i = 0; i < ControlsPerPage; i++)
                        {
                            Slider shaderControlSlider = this.shaderControls[i];
                            if (i < numControls)
                            {
                                shaderControlSlider.Show();

                                int           controlIndex    = startControlIndex + i;
                                ShaderControl activeShaderDef =
                                    this.materialControlsContainer[this.currentMaterial].GetShaderControl(controlIndex);
                                shaderControlSlider.SetRange(activeShaderDef.MinVal, activeShaderDef.MaxVal, 50, false);
                                shaderControlSlider.Caption      = activeShaderDef.Name;
                                shaderControlSlider.SliderMoved += new SliderMovedHandler(shaderControlSlider_SliderMoved);
                                float uniformVal = 0.0f;
                                switch (activeShaderDef.Type)
                                {
                                case ShaderType.GpuVertex:
                                case ShaderType.GpuFragment:
                                {
                                    GpuProgramParameters activeParameters = (activeShaderDef.Type == ShaderType.GpuVertex)
                                                                                                                                ? this.activeVertexParameters
                                                                                                                                : this.activeFragmentParameters;

                                    if (activeParameters != null)
                                    {
                                        throw new NotImplementedException("Fix this");
                                        //int idx = activeParameters.GetParamIndex( activeShaderDef.ParamName );
                                        //activeShaderDef.PhysicalIndex = idx;

                                        //uniformVal = activeParameters.GetNamedFloatConstant( activeShaderDef.ParamName ).val[ activeShaderDef.ElementIndex ];
                                    }
                                }
                                break;

                                case ShaderType.MatSpecular:
                                {
                                    // get the specular values from the material pass
                                    ColorEx oldSpec = this.activePass.Specular;
                                    int     x       = activeShaderDef.ElementIndex;
                                    uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
                                }
                                break;

                                case ShaderType.MatDiffuse:
                                {
                                    // get the specular values from the material pass
                                    ColorEx oldSpec = this.activePass.Diffuse;
                                    int     x       = activeShaderDef.ElementIndex;
                                    uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
                                }
                                break;

                                case ShaderType.MatAmbient:
                                {
                                    // get the specular values from the material pass
                                    ColorEx oldSpec = this.activePass.Ambient;
                                    int     x       = activeShaderDef.ElementIndex;
                                    uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
                                }
                                break;

                                case ShaderType.MatShininess:
                                {
                                    // get the specular values from the material pass
                                    uniformVal = this.activePass.Shininess;
                                }
                                break;
                                }
                                shaderControlSlider.Value = uniformVal;
                            }
                        }
                    }
                }
            }
        }