Exemple #1
0
        void Populate()
        {
            NeedPopulate = false;

            // clear the current thumbnails.
            thumbnailSelector.Clear();

            // populate the thumbnail control.
            string[] materialNames = Bootstrap.Material.GetLoadedMaterialNames();

            // iterate through each material and create an icon.
            foreach (string materialName in materialNames)
            {
                // create a new material for the item.
                Bootstrap.Material material = new Bootstrap.Material(materialName);

                // try to get a decent thumbnail for the material.
                Bitmap bitmap = null;
                if (material.PassCount > 0)
                {
                    Bootstrap.MaterialPass pass = material.GetPass(0);
                    string textureName          = pass.DiffuseStage.Texture;
                    if (textureName != null && textureName != "")
                    {
                        bitmap = Program.ThumbnailMgr.GetThumbnail(textureName);
                    }
                    else
                    {
                        string uberTextureName = pass.UberTexture;
                        if (uberTextureName != null && uberTextureName != "")
                        {
                            using (Bootstrap.UberTexture uberTexture = new Bootstrap.UberTexture(uberTextureName))
                            {
                                bitmap = uberTexture.MakeThumbnail();
                            }
                        }
                    }
                }

                // set the bitmap to the error bitmap if no usable preview could
                // be found.
                if (bitmap == null)
                {
                    bitmap = Program.ThumbnailMgr.GetErrorThumbnail();
                }

                // add a new thumbnail and dispose the material.
                thumbnailSelector.Add(material.ShortName, bitmap, materialName);
                material.Dispose();
            }
        }
        private void UpdatePanel()
        {
            // protect against unintentional changes to settings.
            _populating = true;

            // make sure there are no group-bar items.
            this.gbPasses.GroupBarItems.Clear();

            // set all of the controls.
            if (_material == null)
            {
                // simply clear all of the controls.
                lbName.Text = "No material selected...";

                // return.
                _populating = false;
                return;
            }

            // assign values to all of the controls.
            lbName.Text = _material.Name;

            // get the error image.
            Bitmap errorImage = Program.ThumbnailMgr.GetErrorThumbnail();

            // make sure the material can be presented.
            int passCount = _material.PassCount;

            if (passCount == 0)
            {
                this.pbPreview.Image = errorImage;
                _populating          = false;
                return;
            }

            // if there isn't a diffuse texture, set the error texture.
            Bootstrap.MaterialPass pass = _material.GetPass(0);
            string diffuseTex           = "";

            if (pass.DiffuseStage != null)
            {
                diffuseTex = pass.DiffuseStage.Texture;
            }
            if (diffuseTex == null || diffuseTex == "")
            {
                this.pbPreview.Image = errorImage;
            }
            else
            {
                // try to create the thumbnail.
                Bootstrap.Image image   = new Bootstrap.Image(diffuseTex);
                Bitmap          preview = image.ToBitmap(this.pbPreview.Size.Width, this.pbPreview.Size.Height);
                if (preview != null)
                {
                    this.pbPreview.Image = preview;
                }
                else
                {
                    this.pbPreview.Image = errorImage;
                }
            }

            // setup material states.
            this.cbStipple.Checked = _material.Stipple;

            // populate pass controls.
            for (int i = 0; i < passCount; ++i)
            {
                Bootstrap.MaterialPass curPass = _material.GetPass(i);

                // create the material pass control group.
                Controls.MaterialPassControlGroup materialPassControlGroup = new Controls.MaterialPassControlGroup();
                materialPassControlGroup.SetPass(curPass);

                // create the pass item and add it to the group bar.
                GroupBarItem passItem = new GroupBarItem();
                gbPasses.GroupBarItems.Add(passItem);

                // configure the current group bar item.
                passItem.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(73)))), ((int)(((byte)(73)))), ((int)(((byte)(73)))));
                passItem.Client    = materialPassControlGroup;
                passItem.Text      = "Pass " + (i + 1).ToString();
            }

            // resize the gbPasses
            this.pnGroupBarPanel.AutoScroll = true;
            this.gbPasses.Size = new Size(this.gbPasses.Size.Width, 1100);

            _populating = false;
        }
Exemple #3
0
 public void SetPass(Bootstrap.MaterialPass pass)
 {
     _materialPass = pass;
     UpdateControls();
 }