示例#1
0
        private IMaterial CopyMaterial(IMaterial source)
        {
            var materialManager = Global.gEnv.p3DEngine.GetMaterialManager();

            //Assign a material first, and use clone to get a new instance. Also set a new name to prevent problems in the lookup.
            var target = materialManager.CloneMaterial(source);

            target.SetName(string.Format("{0}_copy", source.GetName()));

            //Copy the values over to the destination material. This prevents the shader-resources error.
            materialManager.CopyMaterial(source, target, EMaterialCopyFlags.MTL_COPY_DEFAULT);

            target.AddRef();

            return(target);
        }