当前位置: 首页>>代码示例>>C#>>正文


C# Parameter.GetTexmap方法代码示例

本文整理汇总了C#中Parameter.GetTexmap方法的典型用法代码示例。如果您正苦于以下问题:C# Parameter.GetTexmap方法的具体用法?C# Parameter.GetTexmap怎么用?C# Parameter.GetTexmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parameter的用法示例。


在下文中一共展示了Parameter.GetTexmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTexmap

        protected const int MAP_HAS_ALPHA = (1 << 1);//!< The bitmap has an alpha channel.


        MessageMapContent GetTexmap(Parameter mapParam, MessageMapRequest request)
        {
            /* Get the map and render it into a new bitmap */

            var texmap = mapParam.GetTexmap();

            //http://docs.autodesk.com/3DSMAX/16/ENU/3ds-Max-SDK-Programmer-Guide/index.html?url=files/GUID-FD9764C9-EE84-4A1A-BC62-87AE6AF86CC1.htm,topicNumber=d30e31073
            //http://docs.autodesk.com/3DSMAX/16/ENU/3ds-Max-SDK-Programmer-Guide/index.html?url=files/GUID-FD9764C9-EE84-4A1A-BC62-87AE6AF86CC1.htm,topicNumber=d30e31073

            IBitmapInfo bmpInfo = _gi.BitmapInfo.Create();

            bmpInfo.SetType(BMM_TRUE_32);
            bmpInfo.SetWidth(request.m_width);
            bmpInfo.SetHeight(request.m_height);
            bmpInfo.SetFlags(MAP_HAS_ALPHA);
            bmpInfo.SetCustomFlag(0);
            bmpInfo.SetFirstFrame(0);
            bmpInfo.SetLastFrame(0);

            IBitmap bmp = _gi.CreateBitmapFromBitmapInfo(bmpInfo);

            texmap.RenderBitmap(0, bmp, 1.0f, request.m_filter);

            /* If the user is not requesting a filename, create a temp one to write to */

            if (!request.m_writeToFile)
            {
                request.m_filename = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName() + ".png");
            }

            /* Write the bitmap to file */

            Directory.CreateDirectory(Path.GetDirectoryName(request.m_filename));

            //The bmpInfo contains the filename - note it doesnt have to be the same bmpInfo as created above thats just the easiest way to do it here
            bmpInfo.SetName(request.m_filename);
            bmp.OpenOutput(bmpInfo);
            bmp.Write(bmpInfo, 0);
            bmp.Close(bmpInfo, 0);

            //Max prepends the filename with the sequence number, so rename afterwards
            string extension = System.IO.Path.GetExtension(request.m_filename);
            string maxfilename = request.m_filename.Substring(0, request.m_filename.Length - extension.Length) + "0000" + extension;

            /* If the user has requested a file, then rename and return this, otherwise get the data from it and delete it */

            if (request.m_writeToFile)
            {
                if (File.Exists(request.m_filename))
                {
                    File.Delete(request.m_filename);
                }
                System.IO.File.Move(maxfilename, request.m_filename);
                
                return new MessageMapFilename(request.m_filename);
            }
            else
            {
                MessageMapContent response = new MessageMapData(File.ReadAllBytes(maxfilename));
                File.Delete(maxfilename);
                return response;
            }
        }
开发者ID:sebjf,项目名称:maxbridge,代码行数:66,代码来源:Materials.cs


注:本文中的Parameter.GetTexmap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。