コード例 #1
0
        protected string MakeScript(MaterialWrapper m, IMtlBase referenceMtl)
        {
            List<String> Commands = new List<string>();

            Commands.Add(string.Format("mtl = copy (getAnimByHandle {0})", Convert(referenceMtl)));

            Commands.Add(string.Format("mtl.name = \"{0}\"", m.MaterialName));

            /*Build diffuse map*/

            Commands.Add(string.Format("diffuse_map = CompositeTextureMap()"));
            Commands.Add(string.Format("diffuse_map.add()"));
            Commands.Add(string.Format("diffuse_map.blendMode[2] = 2"));

            string addDiffuseMapCommand = "";
            if (m.diffuseMap != null)
            {
                addDiffuseMapCommand = string.Format("map1:(bitmapTexture filename:\"{0}\")", m.diffuseMap);
            }

            Commands.Add(string.Format("diffuse_map.mapList[1] = RGB_Multiply {0} color2:(color {1} {2} {3})", addDiffuseMapCommand, m.diffuse.R, m.diffuse.G, m.diffuse.B));

            if (m.diffuseMap != null)
            {
                Commands.Add(string.Format("diffuse_map.mapList[1].map1.coords.u_tiling = {0}; diffuse_map.mapList[1].map1.coords.v_tiling = {1};", m.u_tiling, m.v_tiling));

                if (MapFilteringDisable)
                {
                    Commands.Add(string.Format("diffuse_map.mapList[1].map1.coords.blur = 0.01;"));
                    Commands.Add(string.Format("diffuse_map.mapList[1].map1.filtering = 2;"));
                }
            }

            string addAmbientMapCommand = "";
            if (m.ambientMap != null)
            {
                addAmbientMapCommand = string.Format("map1:(bitmapTexture filename:\"{0}\")", m.ambientMap);
            }

            Commands.Add(string.Format("diffuse_map.mapList[2] = RGB_Multiply {0} color2:(color {1} {2} {3})", addAmbientMapCommand, m.ambient.R * m.ambientMapAmount, m.ambient.G * m.ambientMapAmount, m.ambient.B * m.ambientMapAmount));

            if (m.ambientMap != null)
            {
                Commands.Add(string.Format("diffuse_map.mapList[2].map1.coords.u_tiling = {0}; diffuse_map.mapList[2].map1.coords.v_tiling = {1};", m.u_tiling, m.v_tiling));

                if (MapFilteringDisable)
                {
                    Commands.Add(string.Format("diffuse_map.mapList[2].map1.coords.blur = 0.01;"));
                    Commands.Add(string.Format("diffuse_map.mapList[2].map1.filtering = 2;"));
                }
            }

            Commands.Add(string.Format("diffuse_map.mask[2] = diffuse_map.mapList[1]"));

            /*Apply diffuse map - if there is an RGB_Multiply called Diffuse, find it and set the map, otherwise leave it*/

            Commands.Add(RGBMultiplyMapAssignment("Diffuse", "diffuse_map"));

            if (m.diffuseMap != null)
            {
                Commands.Add("(if (diffuse_map.mapList[1].map1 != undefined) then (showTextureMap mtl diffuse_map.mapList[1].map1 on))"); //show the diffuse map in the viewport
            }

            /* Add the other maps if they are present */

            if (m.bumpMap != null)
            {
                Commands.AddRange(LoadMap("bump_map", m.bumpMap, m));
                Commands.Add(RGBMultiplyMapAssignment("Bump", "bump_map"));
            }

            if (m.opacityMap != null)
            {
                Commands.AddRange(LoadMap("opacity_map", m.opacityMap, m));
                Commands.Add(RGBMultiplyMapAssignment("Opacity", "opacity_map"));
            }

            if (m.specularMap != null)
            {
                Commands.AddRange(LoadMap("specular_map", m.specularMap, m));
                Commands.Add(RGBMultiplyMapAssignment("Specular", "specular_map"));
            }

            Commands.Add("(getHandleByAnim mtl) as String");

            string script = "";
            foreach (var c in Commands)
            {
                script += (c + "; ");
            }
            return "(" + script + ")"; //Note, remove these brackets to have max print the results of each command in the set when debugging.
        }
コード例 #2
0
ファイル: Material.cs プロジェクト: Sugz/ReleaseMaxSharp2013
 internal ShadingObject(IMtlBase x) : base(x) { }
コード例 #3
0
        protected IMtl CreateSkinMaterial(MaterialWrapper m, IMtlBase referenceMtl)
        {
            if (referenceMtl == null)
            {
                referenceMtl = intrface.CreateInstance(SClass_ID.Material, gi.Class_ID.Create(2004030991, 2251076473)) as IMtlBase;
            }

            var script = MakeScript(m, referenceMtl);
            Log.Add(string.Format("Running script: {0}", script), LogLevel.Debug);
            return GetFromScript(script);
        }
コード例 #4
0
ファイル: Material.cs プロジェクト: Sugz/ReleaseMaxSharp2013
 internal ShadingObject(IMtlBase x) : base(x)
 {
 }