Example #1
0
        public void LoadMaterialUI()
        {
            this.Plugin.brgObjectListView.Columns.Clear();
            OLVColumn idCol = new OLVColumn("ID", "Id");

            idCol.Width      = 35;
            idCol.IsEditable = false;
            this.Plugin.brgObjectListView.Columns.Add(idCol);

            OLVColumn flagsCol = new OLVColumn("Flags", "Flags");

            flagsCol.Width = 200;
            this.Plugin.brgObjectListView.Columns.Add(flagsCol);

            OLVColumn diffColorCol = new OLVColumn("Diffuse Color", "DiffuseColor");

            this.Plugin.brgObjectListView.Columns.Add(diffColorCol);
            OLVColumn ambColorCol = new OLVColumn("Ambient Color", "AmbientColor");

            this.Plugin.brgObjectListView.Columns.Add(ambColorCol);
            OLVColumn specColorCol = new OLVColumn("Specular Color", "SpecularColor");

            this.Plugin.brgObjectListView.Columns.Add(specColorCol);
            OLVColumn emisColorCol = new OLVColumn("Emissive Color", "EmissiveColor");

            this.Plugin.brgObjectListView.Columns.Add(emisColorCol);

            OLVColumn specLevelCol = new OLVColumn("Specular Level", "SpecularExponent");

            this.Plugin.brgObjectListView.Columns.Add(specLevelCol);

            OLVColumn opacityCol = new OLVColumn("Opacity", "Opacity");

            this.Plugin.brgObjectListView.Columns.Add(opacityCol);

            OLVColumn diffMapCol = new OLVColumn("Diffuse Map", "DiffuseMap");

            this.Plugin.brgObjectListView.Columns.Add(diffMapCol);

            OLVColumn bumpMapCol = new OLVColumn("Bump Map", "BumpMap");

            this.Plugin.brgObjectListView.Columns.Add(bumpMapCol);

            OLVColumn reflMapCol = new OLVColumn("Reflection Map", string.Empty);

            reflMapCol.AspectGetter = delegate(object rowObject)
            {
                BrgMaterial mat = (BrgMaterial)rowObject;
                if (mat.sfx.Count > 0)
                {
                    return(mat.sfx[0].Name);
                }
                else
                {
                    return(string.Empty);
                }
            };
            reflMapCol.AspectPutter = delegate(object rowObject, object newValue)
            {
                BrgMaterial mat    = (BrgMaterial)rowObject;
                BrgMatSFX   sfxMap = new BrgMatSFX();
                sfxMap.Id   = 30;
                sfxMap.Name = (string)newValue;

                if (mat.sfx.Count > 0)
                {
                    mat.sfx[0] = sfxMap;
                }
                else
                {
                    mat.sfx.Add(sfxMap);
                }
            };
            this.Plugin.brgObjectListView.Columns.Add(reflMapCol);
        }
Example #2
0
        private void ExportBrgMaterial(string mainObject, BrgMaterial mat)
        {
            //mat.id = Maxscript.QueryInteger("{0}.material.materialIDList[{1}]", mainObject, materialIndex + 1);
            //Maxscript.Command("mat = {0}.material[{1}]", mainObject, mat.id);

            mat.DiffuseColor = new Color3D(Maxscript.QueryFloat("mat.diffuse.r") / 255f,
                                           Maxscript.QueryFloat("mat.diffuse.g") / 255f,
                                           Maxscript.QueryFloat("mat.diffuse.b") / 255f);
            mat.AmbientColor = new Color3D(Maxscript.QueryFloat("mat.ambient.r") / 255f,
                                           Maxscript.QueryFloat("mat.ambient.g") / 255f,
                                           Maxscript.QueryFloat("mat.ambient.b") / 255f);
            mat.SpecularColor = new Color3D(Maxscript.QueryFloat("mat.specular.r") / 255f,
                                            Maxscript.QueryFloat("mat.specular.g") / 255f,
                                            Maxscript.QueryFloat("mat.specular.b") / 255f);
            mat.EmissiveColor = new Color3D(Maxscript.QueryFloat("mat.selfIllumColor.r") / 255f,
                                            Maxscript.QueryFloat("mat.selfIllumColor.g") / 255f,
                                            Maxscript.QueryFloat("mat.selfIllumColor.b") / 255f);

            mat.SpecularExponent = Maxscript.QueryFloat("mat.specularLevel");
            if (mat.SpecularExponent > 0)
            {
                mat.Flags |= BrgMatFlag.SpecularExponent;
            }

            mat.Opacity = Maxscript.QueryFloat("mat.opacity") / 100f;
            if (mat.Opacity < 1f)
            {
                mat.Flags |= BrgMatFlag.Alpha;
            }

            int opacityType = Maxscript.QueryInteger("mat.opacityType");

            if (opacityType == 1)
            {
                mat.Flags |= BrgMatFlag.SubtractiveBlend;
            }
            else if (opacityType == 2)
            {
                mat.Flags |= BrgMatFlag.AdditiveBlend;
            }

            if (Maxscript.QueryBoolean("mat.twoSided"))
            {
                mat.Flags |= BrgMatFlag.TwoSided;
            }

            if (Maxscript.QueryBoolean("mat.faceMap"))
            {
                mat.Flags |= BrgMatFlag.FaceMap;
            }

            if (Maxscript.QueryBoolean("(classof mat.reflectionMap) == BitmapTexture"))
            {
                mat.Flags |= BrgMatFlag.WrapUTx1 | BrgMatFlag.WrapVTx1 | BrgMatFlag.REFLECTIONTEXTURE;
                BrgMatSFX sfxMap = new BrgMatSFX();
                sfxMap.Id   = 30;
                sfxMap.Name = Maxscript.QueryString("getFilenameFile(mat.reflectionMap.filename)") + ".cub";
                mat.sfx.Add(sfxMap);
            }
            if (Maxscript.QueryBoolean("(classof mat.bumpMap) == BitmapTexture"))
            {
                mat.BumpMap = Maxscript.QueryString("getFilenameFile(mat.bumpMap.filename)");
                if (mat.BumpMap.Length > 0)
                {
                    mat.Flags |= BrgMatFlag.WrapUTx3 | BrgMatFlag.WrapVTx3 | BrgMatFlag.BumpMap;
                }
            }
            if (Maxscript.QueryBoolean("(classof mat.diffusemap) == BitmapTexture"))
            {
                mat.DiffuseMap = Maxscript.QueryString("getFilenameFile(mat.diffusemap.filename)");
                int parenthIndex = mat.DiffuseMap.IndexOf('(');
                if (parenthIndex > 0)
                {
                    mat.DiffuseMap = mat.DiffuseMap.Remove(parenthIndex);
                }

                if (mat.DiffuseMap.Length > 0)
                {
                    mat.Flags |= BrgMatFlag.WrapUTx1 | BrgMatFlag.WrapVTx1;
                    if (Maxscript.QueryBoolean("mat.diffusemap.filename == mat.filtermap.filename"))
                    {
                        mat.Flags |= BrgMatFlag.PixelXForm1;
                    }
                }
            }
            else if (Maxscript.QueryBoolean("(classof mat.diffusemap) == CompositeTextureMap") && Maxscript.QueryBoolean("(classof mat.diffusemap.mapList[1]) == BitmapTexture"))
            {
                mat.Flags     |= BrgMatFlag.WrapUTx1 | BrgMatFlag.WrapVTx1 | BrgMatFlag.PixelXForm1;
                mat.DiffuseMap = Maxscript.QueryString("getFilenameFile(mat.diffusemap.mapList[1].filename)");
                int parenthIndex = mat.DiffuseMap.IndexOf('(');
                if (parenthIndex > 0)
                {
                    mat.DiffuseMap = mat.DiffuseMap.Remove(parenthIndex);
                }
            }

            this.ExportMaterialFlagsFromName(mat);
        }