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


C# ContentProcessorContext.Convert方法代码示例

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


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

示例1: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
        {
            var customMaterial = new EffectMaterialContent();
            customMaterial.Effect = new ExternalReference<EffectContent>(effectPath);

            //var basicMaterial = (BasicMaterialContent) material;
            //if (basicMaterial.Texture != null)
            //{
            //    customMaterial.Textures.Add(skyMapKey, basicMaterial.Texture);
            //}

            foreach (var texture in material.Textures)
            {
                customMaterial.Textures.Add(texture.Key, texture.Value);
            }

            var parameters = new OpaqueDataDictionary();
            parameters["ColorKeyColor"] = ColorKeyColor;
            parameters["ColorKeyEnabled"] = ColorKeyEnabled;
            parameters["TextureFormat"] = TextureFormat;
            parameters["GenerateMipmaps"] = GenerateMipmaps;
            parameters["ResizeTexturesToPowerOfTwo"] = ResizeTexturesToPowerOfTwo;

            return context.Convert<MaterialContent, MaterialContent>(
                customMaterial, typeof(MaterialProcessor).Name, parameters);
        }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:26,代码来源:SkyDomeModelProcessor.cs

示例2: ConvertMaterial

        /// <summary>
        /// Use our custom EnvironmentMappedMaterialProcessor
        /// to convert all the materials on this model.
        /// </summary>
        protected override MaterialContent ConvertMaterial(MaterialContent material,
                                                         ContentProcessorContext context)
        {
            OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();
            processorParameters["ColorKeyColor"] = ColorKeyColor;
            processorParameters["ColorKeyEnabled"] = ColorKeyEnabled;
            processorParameters["TextureFormat"] = TextureFormat;
            processorParameters["GenerateMipmaps"] = GenerateMipmaps;
            processorParameters["ResizeTexturesToPowerOfTwo"] =
                ResizeTexturesToPowerOfTwo;

            return context.Convert<MaterialContent, MaterialContent>(material,
                "TankModelMaterialProcessor", processorParameters);
        }
开发者ID:poppuyo,项目名称:eecs395-proj2,代码行数:18,代码来源:TankModelProcessor.cs

示例3: ConvertMaterial

        /// <summary>
        /// Use the CustomEffectMaterialProcessor for all of the materials in the model.
        /// We pass the processor parameter along to the material processor for the 
        /// effect file name.
        /// </summary>
        protected override MaterialContent ConvertMaterial(MaterialContent material, 
                                                        ContentProcessorContext context)
        {
            OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();
            processorParameters.Add("CustomEffect", customEffect);
            processorParameters["ColorKeyColor"] = this.ColorKeyColor;
            processorParameters["ColorKeyEnabled"] = this.ColorKeyEnabled;
            processorParameters["TextureFormat"] = this.TextureFormat;
            processorParameters["GenerateMipmaps"] = this.GenerateMipmaps;
            processorParameters["ResizeTexturesToPowerOfTwo"] = 
                                                        this.ResizeTexturesToPowerOfTwo;

            return context.Convert<MaterialContent, MaterialContent>(material, 
                                  "CustomEffectMaterialProcessor", processorParameters);
        }
开发者ID:modulexcite,项目名称:xna-tutorials,代码行数:20,代码来源:CustomEffectModelProcessor.cs

示例4: OnConvertMaterial

 protected virtual DRMaterialContent OnConvertMaterial(MaterialContent material, ContentProcessorContext context)
 {
     //var processorParameters = new OpaqueDataDictionary
       //{
       //  { "ColorKeyColor", ColorKeyColor },
       //  { "ColorKeyEnabled", ColorKeyEnabled },
       //  { "GenerateMipmaps", GenerateMipmaps },
       //  { "PremultiplyTextureAlpha", PremultiplyTextureAlpha },
       //  { "ResizeTexturesToPowerOfTwo", ResizeTexturesToPowerOfTwo },
       //  { "TextureFormat", TextureFormat },
       //  { "DefaultEffectType", DefaultEffectType },
       //  { "DefaultEffectFile", DefaultEffectFile },
       //};
       return context.Convert<MaterialContent, DRMaterialContent>(material, typeof(DRMaterialProcessor).Name/*, processorParameters*/);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:15,代码来源:DRModelProcessor_Materials.cs

示例5: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
        {
            var customMaterial = new EffectMaterialContent();
            var effectPath = Path.GetFullPath(effectFilename);
            customMaterial.Effect = new ExternalReference<EffectContent>(effectPath);

            var parameters = new OpaqueDataDictionary();
            parameters["ColorKeyColor"] = ColorKeyColor;
            parameters["ColorKeyEnabled"] = ColorKeyEnabled;
            parameters["TextureFormat"] = TextureFormat;
            parameters["GenerateMipmaps"] = GenerateMipmaps;
            parameters["ResizeTexturesToPowerOfTwo"] = ResizeTexturesToPowerOfTwo;

            return context.Convert<MaterialContent, MaterialContent>(
                customMaterial, typeof(MaterialProcessor).Name, parameters);
        }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:16,代码来源:CloudLayerModelProcessor.cs

示例6: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
        {
            var basicMaterial = new EffectMaterialContent {
                Effect = new ExternalReference<EffectContent>("../HMEngineContent/Shaders/BasicShader.fx")
            };

            var processorParameters = new OpaqueDataDictionary();
            processorParameters["ColorKeyColor"] = ColorKeyColor;
            processorParameters["ColorKeyEnabled"] = ColorKeyEnabled;
            processorParameters["TextureFormat"] = TextureFormat;
            processorParameters["GenerateMipmaps"] = GenerateMipmaps;
            processorParameters["ResizeTexturesToPowerOfTwo"] = ResizeTexturesToPowerOfTwo;

            // Copy any textures already added to the built in material to our custom basicMaterial
            foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture in material.Textures) {
                basicMaterial.Textures.Add(texture.Key, texture.Value);
            }

            // Convert the material using the HMMaterialProcessor. This will perform any special texture processing we need
            return context.Convert<MaterialContent, MaterialContent>(basicMaterial, typeof (HMMaterialProcessor).Name, processorParameters);
        }
开发者ID:mikeschuld,项目名称:HMEngineXNA,代码行数:21,代码来源:HMModelProcessor.cs

示例7: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material,
            ContentProcessorContext context)
        {
            EffectMaterialContent normalMappingMaterial = new EffectMaterialContent();
            normalMappingMaterial.Effect = new ExternalReference<EffectContent>
                ("shaders/NormalMapping.fx");

            // copy the textures in the original material to the new normal mapping
            // material. this way the diffuse texture is preserved. The
            // PreprocessSceneHierarchy function has already added the normal map
            // texture to the Textures collection, so that will be copied as well.
            foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture
                in material.Textures)
            {
                normalMappingMaterial.Textures.Add(texture.Key, texture.Value);
            }

            return context.Convert<MaterialContent, MaterialContent>
                (normalMappingMaterial, typeof(MaterialProcessor).Name);
        }
开发者ID:CS583,项目名称:The3dgamesample,代码行数:20,代码来源:NormalMappingModelProcessor.cs

示例8: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material,
           ContentProcessorContext context)
        {
            EffectMaterialContent lppMaterial = new EffectMaterialContent();

            OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();
            processorParameters["ColorKeyColor"] = this.ColorKeyColor;
            processorParameters["ColorKeyEnabled"] = this.ColorKeyEnabled;
            processorParameters["TextureFormat"] = this.TextureFormat;
            processorParameters["GenerateMipmaps"] = this.GenerateMipmaps;
            processorParameters["ResizeTexturesToPowerOfTwo"] = this.ResizeTexturesToPowerOfTwo;
            processorParameters["PremultiplyTextureAlpha"] = false;
            processorParameters["ColorKeyEnabled"] = false;

            lppMaterial.Effect = new ExternalReference<EffectContent>("shaders/LPPMainEffect.fx");
            lppMaterial.CompiledEffect = context.BuildAsset<EffectContent, CompiledEffectContent>(lppMaterial.Effect, "EffectProcessor");

            //extract the extra parameters
            ExtractDefines(lppMaterial, material, context);

            // copy the textures in the original material to the new normal mapping
            // material. this way the diffuse texture is preserved. The
            // PreprocessSceneHierarchy function has already added the normal map
            // texture to the Textures collection, so that will be copied as well.
            foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture
                in material.Textures)
            {
                lppMaterial.Textures.Add(texture.Key, texture.Value);
            }

            try
            {
                lppMaterial.OpaqueData.Add("DiffuseColor", new Vector4((Vector3)material.OpaqueData["DiffuseColor"], (float)material.OpaqueData["Alpha"]));
                lppMaterial.OpaqueData.Add("SpecularColor", material.OpaqueData["SpecularColor"]);
                lppMaterial.OpaqueData.Add("SpecularPower", material.OpaqueData["SpecularPower"]);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            // and convert the material using the NormalMappingMaterialProcessor,
            // who has something special in store for the normal map.
            return context.Convert<MaterialContent, MaterialContent>
                (lppMaterial, typeof(LightPrePassMaterialProcessor).Name, processorParameters);
        }
开发者ID:razvanalex,项目名称:XNAEnvironment,代码行数:46,代码来源:LightPrePassProcessor.cs

示例9: ConvertMaterial

        /// <summary>
        /// Use our custom material processor
        /// to convert selected materials in this model.
        /// </summary>
        protected override MaterialContent ConvertMaterial(MaterialContent material,
                                                         ContentProcessorContext context)
        {
            if (CustomMaterialProcessor == "")
                return base.ConvertMaterial(material, context);

            OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();
            processorParameters.Add("Section", section);
            processorParameters.Add("Skinned", skinned);

            return context.Convert<MaterialContent, MaterialContent>(material,
                                                CustomMaterialProcessor,
                                                processorParameters);
        }
开发者ID:Kingofhearts102,项目名称:Step7,代码行数:18,代码来源:AnimationProcessor.cs

示例10: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material,
                                                          ContentProcessorContext context)
        {
            EffectMaterialContent Material = new EffectMaterialContent();
            Material.Effect = new ExternalReference<EffectContent>(effect);

            foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture
            in material.Textures)
            {
                if ((texture.Key == "Texture"))
                {
                    Material.Textures.Add(diffuseMapKey, texture.Value);
                    Material.Textures.Add(normalMapKey, 
                        new ExternalReference<TextureContent>(texture.Value.Filename.Substring(0, texture.Value.Filename.Length - 4) + "_N.jpg"));
                    Material.Textures.Add(heightMapKey, 
                        new ExternalReference<TextureContent>(texture.Value.Filename.Substring(0, texture.Value.Filename.Length - 4) + "_H.jpg"));
                }
            }
            return context.Convert<MaterialContent, MaterialContent>(Material, typeof(MaterialProcessor).Name);
        }
开发者ID:CC-Ricers,项目名称:XNA-4.0-parallax-occlusion-mapping,代码行数:20,代码来源:CustomModel.cs

示例11: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
        {
            EffectMaterialContent deferredShadingMaterial = new EffectMaterialContent();
            
            deferredShadingMaterial.Effect = new ExternalReference<EffectContent>("System/Effects/GBuffer.fx");

            foreach (KeyValuePair<string, ExternalReference<TextureContent>> texture in material.Textures)
            {
                // MonoGame has a bug where texture names must be named after the texture sampler in the shader
                // 
                // Example:
                //   texture Texture; 
                //   sampler AlbedoSampler = sampler_state 
                //   { 
                //       texture = <Texture>; 
                //       MINFILTER = LINEAR; 
                //       MAGFILTER = LINEAR; 
                //       MIPFILTER = LINEAR; 
                //       ADDRESSU = WRAP; 
                //       ADDRESSV = WRAP; 
                //   }; 

                if (texture.Key == "Texture")
                {
                    deferredShadingMaterial.Textures.Add("Texture", texture.Value);
                }

                if (texture.Key == "NormalMap")
                {
                    deferredShadingMaterial.Textures.Add("NormalMap", texture.Value);
                }

                if (texture.Key == "SpecularMap")
                {
                    deferredShadingMaterial.Textures.Add("SpecularMap", texture.Value);
                }
            }

            return context.Convert<MaterialContent, MaterialContent>(deferredShadingMaterial, "MGMaterialProcessor");
        }
开发者ID:kkestell,项目名称:nyx-1.0,代码行数:40,代码来源:DeferredRendererModel.cs

示例12: ConvertMaterial

        /// <summary>
        /// Loads the specified effect into the material.
        /// </summary>
        protected override MaterialContent ConvertMaterial(MaterialContent material,
                                                           ContentProcessorContext context)
        {
            EffectMaterialContent newMaterial = new EffectMaterialContent();

            if (string.IsNullOrWhiteSpace(mEffectName))
            {
                throw new ArgumentNullException("Effect asset undefined.");
            }

            newMaterial.Effect = new ExternalReference<EffectContent>(mEffectName);

            foreach (KeyValuePair<string,
                     ExternalReference<TextureContent>> pair in material.Textures)
            {
                newMaterial.Textures.Add(pair.Key, pair.Value);
            }

            return context.Convert<MaterialContent,
                                   MaterialContent>(newMaterial,
                                   typeof(MaterialProcessor).Name);
        }
开发者ID:BaronVonTeapot,项目名称:Basic,代码行数:25,代码来源:CustomModelProcessor.cs

示例13: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material,
            ContentProcessorContext context)
        {
            EffectMaterialContent shaderMaterial = new EffectMaterialContent();
            shaderMaterial.Effect = new ExternalReference<EffectContent>
                ("Effects/ShaderModelEffect.fx");

            // copy the textures in the original material to the new normal mapping
            // material. this way the diffuse texture is preserved. The
            // PreprocessSceneHierarchy function has already added the normal map
            // texture to the Textures collection, so that will be copied as well.
            foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture
                in material.Textures)
            {
                shaderMaterial.Textures.Add(texture.Key, texture.Value);
            }

            // and convert the material using the ShaderMaterialProcessor,
            // who has something special in store for the normal map.
            return context.Convert<MaterialContent, MaterialContent>
                (shaderMaterial, typeof(ShaderMaterialProcessor).Name);
        }
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:22,代码来源:ShaderModelProcessor.cs

示例14: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
        {
            EffectMaterialContent deferredShadingMaterial = new EffectMaterialContent();
            deferredShadingMaterial.Effect = new ExternalReference<EffectContent>("System/Effects/GBuffer.fx");

            foreach (KeyValuePair<string, ExternalReference<TextureContent>> texture in material.Textures)
            {
                if (texture.Key == "Texture" || texture.Key == "NormalMap" || texture.Key == "SpecularMap")
                {
                    deferredShadingMaterial.Textures.Add(texture.Key, texture.Value);
                }
            }

            return context.Convert<MaterialContent, MaterialContent>(deferredShadingMaterial, typeof(MaterialProcessor).Name);
        }
开发者ID:DavidMann10k,项目名称:nyx,代码行数:15,代码来源:DeferredRendererModel.cs

示例15: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
        {
            string effectFile = this.effectFileName;
            if (string.IsNullOrEmpty(effectFile))
            {
                if (string.IsNullOrEmpty(this.normalMapTexture))
                {
                    if (string.IsNullOrEmpty(this.diffuseTexture))
                        effectFile = "Effects\\DefaultSolidColor.fx";
                    else
                        effectFile = "Effects\\Default.fx";
                }
                else
                    effectFile = "Effects\\DefaultNormalMap.fx";
            }

            EffectMaterialContent normalMappingMaterial = new EffectMaterialContent();
            normalMappingMaterial.Effect = new ExternalReference<EffectContent>(Path.Combine(directory, effectFile));

            OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();
            processorParameters["ColorKeyColor"] = this.ColorKeyColor;
            processorParameters["ColorKeyEnabled"] = this.ColorKeyEnabled;
            processorParameters["TextureFormat"] = this.TextureFormat;
            processorParameters["PremultiplyTextureAlpha"] = this.PremultiplyTextureAlpha;
            processorParameters["PremultiplyVertexColors"] = this.PremultiplyVertexColors;
            processorParameters["GenerateMipmaps"] = this.GenerateMipmaps;
            processorParameters["ResizeTexturesToPowerOfTwo"] = this.ResizeTexturesToPowerOfTwo;

            // copy the textures in the original material to the new normal mapping
            // material. this way the diffuse texture is preserved. The
            // PreprocessSceneHierarchy function has already added the normal map
            // texture to the Textures collection, so that will be copied as well.
            foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture in material.Textures)
                normalMappingMaterial.Textures.Add(texture.Key, texture.Value);

            if (!string.IsNullOrEmpty(diffuseTexture))
                normalMappingMaterial.Textures.Add("DiffuseTexture", new ExternalReference<TextureContent>(Path.Combine(directory, diffuseTexture)));

            // and convert the material using the NormalMappingMaterialProcessor,
            // who has something special in store for the normal map.
            #if MONOGAME
            return context.Convert<MaterialContent, MaterialContent>(normalMappingMaterial, typeof(MGMaterialProcessor).Name, processorParameters);
            #else
            return context.Convert<MaterialContent, MaterialContent>(normalMappingMaterial, typeof(MaterialProcessor).Name, processorParameters);
            #endif
        }
开发者ID:dsmo7206,项目名称:Lemma,代码行数:46,代码来源:CustomModelProcessor.cs


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