本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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*/);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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
}