本文整理汇总了C#中ContentProcessorContext类的典型用法代码示例。如果您正苦于以下问题:C# ContentProcessorContext类的具体用法?C# ContentProcessorContext怎么用?C# ContentProcessorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentProcessorContext类属于命名空间,在下文中一共展示了ContentProcessorContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Process
/// <summary>
/// The main Process method converts an intermediate format content pipeline
/// NodeContent tree to a ModelContent object with embedded animation data.
/// </summary>
public override ModelContent Process(NodeContent input, ContentProcessorContext context)
{
contentPath = Environment.CurrentDirectory;
using (XmlReader reader = XmlReader.Create(MaterialDataFilePath))
{
incomingMaterials = IntermediateSerializer.Deserialize<List<MaterialData>>(reader, null);
}
context.AddDependency(Path.Combine(Environment.CurrentDirectory, MaterialDataFilePath));
// Chain to the base ModelProcessor class so it can convert the model data.
ModelContent model = base.Process(input, context);
// Put the material's flags into the ModelMeshPartContent's Tag property.
foreach (ModelMeshContent mmc in model.Meshes)
{
foreach (ModelMeshPartContent mmpc in mmc.MeshParts)
{
MaterialData mat = incomingMaterials.Single(m => m.Name == mmpc.Material.Name);
MaterialInfo extraInfo = new MaterialInfo();
extraInfo.HandlingFlags = mat.HandlingFlags;
extraInfo.RenderState = mat.RenderState;
mmpc.Tag = extraInfo;
}
}
return model;
}
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:32,代码来源:SimpleModelProcessor.cs
示例2: Process
/// <summary>
/// The main method in charge of processing the content.
/// </summary>
public override ModelContent Process(NodeContent input,
ContentProcessorContext context)
{
// Chain to the base ModelProcessor class.
ModelContent model = base.Process(input, context);
// Look up the input vertex positions.
FindVertices(input);
// You can store any type of object in the model Tag property. This
// sample only uses built-in types such as string, Vector3, BoundingSphere,
// dictionaries, and arrays, which the content pipeline knows how to
// serialize by default. We could also attach custom data types here, but
// then we would have to provide a ContentTypeWriter and ContentTypeReader
// implementation to tell the pipeline how to serialize our custom type.
//
// We are setting our model Tag to a dictionary that maps strings to
// objects, and then storing two different kinds of custom data into that
// dictionary. This is a useful pattern because it allows processors to
// combine many different kinds of information inside the single Tag value.
Dictionary<string, object> tagData = new Dictionary<string, object>();
model.Tag = tagData;
// Store vertex information in the tag data, as an array of Vector3.
tagData.Add("Vertices", vertices.ToArray());
// Also store a custom bounding sphere.
tagData.Add("BoundingSphere", BoundingSphere.CreateFromPoints(vertices));
return model;
}
开发者ID:nguoihocnghe,项目名称:chessbreaklaw,代码行数:36,代码来源:ChessBreakLawProcessor.cs
示例3: Process
/// <summary>
/// The main Process method converts an intermediate format content pipeline
/// NodeContent tree to a ModelContent object with embedded animation data.
/// </summary>
public override ModelContent Process(NodeContent input, ContentProcessorContext context)
{
SkinningData skinningData = SkinningHelpers.GetSkinningData(input, context, SkinnedEffect.MaxBones);
ModelContent model = base.Process(input, context);
model.Tag = skinningData;
return model;
}
开发者ID:tykz,项目名称:xna-morijobi-win,代码行数:11,代码来源:GpuSkinnedModelProcessor.cs
示例4: Build
public TerrainModelContent Build(ContentProcessorContext context)
{
// TODO: i think numlevels is log2, or something like that
// calculate number of levels, based on patch size
int nCurrent = (_patchSize - 1) * 2;
int numLevels = 0;
while (nCurrent != 1)
{
nCurrent /= 2;
numLevels++;
}
int numPatchesX = (_heightMap.Width - 1) / (_patchSize - 1);
int numPatchesY = (_heightMap.Height - 1) / (_patchSize - 1);
// create patches
PatchContent[,] patches = new PatchContent[numPatchesX, numPatchesY];
for (int y = 0; y < numPatchesY; y++)
for (int x = 0; x < numPatchesX; x++)
{
PatchContentBuilder patchContentBuilder = new PatchContentBuilder(_patchSize, x, y, _heightMap, numLevels, _detailTextureTiling, _horizontalScale);
patches[x, y] = patchContentBuilder.Build();
}
return new TerrainModelContent
{
NumPatchesX = numPatchesX,
NumPatchesY = numPatchesY,
Patches = patches,
HeightMap = _heightMap,
Material = _material
};
}
开发者ID:amezin,项目名称:osiris,代码行数:34,代码来源:TerrainModelContentBuilder.cs
示例5: Process
public override TextureContent Process( TextureContent input, ContentProcessorContext context )
{
logger = context.Logger;
logger.LogMessage( "sending texture to base TextureProcessor for initial processing" );
var textureContent = base.Process( input, context );
var bmp = (PixelBitmapContent<Color>)textureContent.Faces[0][0];
var destData = bmp.getData();
// process the data
if( flattenImage )
{
logger.LogMessage( "flattening image" );
destData = TextureUtils.createFlatHeightmap( destData, opaqueColor, transparentColor );
}
if( blurType != BlurType.None )
{
logger.LogMessage( "blurring image width blurDeviation: {0}", blurDeviation );
if( blurType == BlurType.Color )
destData = TextureUtils.createBlurredTexture( destData, bmp.Width, bmp.Height, (double)blurDeviation );
else
destData = TextureUtils.createBlurredGrayscaleTexture( destData, bmp.Width, bmp.Height, (double)blurDeviation );
}
logger.LogMessage( "generating normal map with {0}", edgeDetectionFilter );
destData = TextureUtils.createNormalMap( destData, edgeDetectionFilter, bmp.Width, bmp.Height, normalStrength, invertX, invertY );
bmp.setData( destData );
return textureContent;
}
开发者ID:RastaCow,项目名称:Nez,代码行数:32,代码来源:NormalMapProcessor.cs
示例6: Import
/// <summary>
/// Imports the asset.
/// </summary>
/// <param name="context">Contains any required custom process parameters.</param>
public void Import(ContentProcessorContext context)
{
if (context == null)
throw new ArgumentNullException("context");
if (string.IsNullOrWhiteSpace(ModelDescription.FileName))
throw new InvalidContentException("The attribute 'File' is not set in the model description (.drmdl file).", Identity);
var fileName = ContentHelper.FindFile(ModelDescription.FileName, Identity);
var asset = new ExternalReference<NodeContent>(fileName);
var node = context.BuildAndLoadAsset<NodeContent, NodeContent>(asset, null, null, ModelDescription.Importer);
// BuildAndLoadAsset does not return root node in MonoGame.
while (node.Parent != null)
node = node.Parent;
if (node.GetType() == typeof(NodeContent))
{
// Root node is of type NodeContent.
// --> Copy root node content and children.
Name = node.Name;
Transform = node.Transform;
Animations.AddRange(node.Animations);
OpaqueData.AddRange(node.OpaqueData);
var children = node.Children.ToArray();
node.Children.Clear(); // Clear parents.
Children.AddRange(children);
}
else
{
// Root node is a derived type.
// --> Add node as child.
Children.Add(node);
}
}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:39,代码来源:DeferredNodeContent.cs
示例7: ConvertMaterial
/// <summary>
/// Changes all the materials to use our skinned model effect.
/// </summary>
protected override MaterialContent ConvertMaterial(MaterialContent material,
ContentProcessorContext context)
{
BasicMaterialContent basicMaterial = material as BasicMaterialContent;
if (basicMaterial == null)
{
throw new InvalidContentException(string.Format(
"InstancedSkinnedModelProcessor only supports BasicMaterialContent, " +
"but input mesh uses {0}.", material.GetType()));
}
EffectMaterialContent effectMaterial = new EffectMaterialContent();
// Store a reference to our skinned mesh effect.
string effectPath = Path.GetFullPath("SkinnedModelInstancing.fx");
effectMaterial.Effect = new ExternalReference<EffectContent>(effectPath);
// Copy texture settings from the input
// BasicMaterialContent over to our new material.
if (basicMaterial.Texture != null)
effectMaterial.Textures.Add("Texture", basicMaterial.Texture);
// Chain to the base ModelProcessor converter.
return base.ConvertMaterial(effectMaterial, context);
}
开发者ID:extr0py,项目名称:xna-skinned-model-instancing,代码行数:30,代码来源:ModifiedModelProcessor.cs
示例8: ProcessTextures
private void ProcessTextures(MaterialContent input, SkinnedModelMaterialContent skinnedModelMaterial,
ContentProcessorContext context)
{
foreach (string key in input.Textures.Keys)
{
ExternalReference<TextureContent> texture = input.Textures[key];
if (!String.IsNullOrEmpty(texturePath))
{
string fullFilePath;
if (texturePathType == PathType.Relative)
{
// If relative path
string sourceAssetPath = Path.GetDirectoryName(input.Identity.SourceFilename);
fullFilePath = Path.GetFullPath(
Path.Combine(sourceAssetPath, texturePath));
}
else
{
fullFilePath = texturePath;
}
texture.Filename = Path.Combine(fullFilePath,
Path.GetFileName(texture.Filename));
}
ProcessTexture(key, texture, skinnedModelMaterial, context);
}
}
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:30,代码来源:SkinnedModelMaterialProcessor.cs
示例9: StoreEffectTechniqueInMeshName
/// <summary>
/// Stores the current selected technique and if the texture uses alpha
/// into the mesh name for each mesh part.
/// </summary>
private void StoreEffectTechniqueInMeshName(
NodeContent input, ContentProcessorContext context)
{
MeshContent mesh = input as MeshContent;
if (mesh != null)
{
foreach (GeometryContent geom in mesh.Geometry)
{
EffectMaterialContent effectMaterial = geom.Material as EffectMaterialContent;
if (effectMaterial != null)
{
if (effectMaterial.OpaqueData.ContainsKey("technique"))
{
// Store technique here! (OpaqueData["technique"] is an int32)
input.Name = input.Name + effectMaterial.OpaqueData["technique"];
} // if
} // if
} // foreach
} // if
// Go through all childs
foreach (NodeContent child in input.Children)
{
StoreEffectTechniqueInMeshName(child, context);
} // foreach
}
开发者ID:kiichi7,项目名称:SpeedyRacerContentAndSourceCode,代码行数:30,代码来源:XnaGraphicEngineModelProcessor.cs
示例10: 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
示例11: Process
public override CompiledEffectContent Process(EffectContent input, ContentProcessorContext context)
{
//System.Diagnostics.Debugger.Launch();
// If this isn't a MonoGame platform then do the default processing.
var platform = ContentHelper.GetMonoGamePlatform();
if (platform == MonoGamePlatform.None)
return base.Process(input, context);
var options = new Options();
options.SourceFile = input.Identity.SourceFilename;
options.Profile = platform == MonoGamePlatform.Windows8 ? ShaderProfile.DirectX_11 : ShaderProfile.OpenGL;
options.Debug = DebugMode == EffectProcessorDebugMode.Debug;
options.OutputFile = context.OutputFilename;
// Parse the MGFX file expanding includes, macros, and returning the techniques.
ShaderInfo shaderInfo;
try
{
shaderInfo = ShaderInfo.FromFile(options.SourceFile, options);
foreach (var dep in shaderInfo.Dependencies)
context.AddDependency(dep);
}
catch (Exception ex)
{
// TODO: Extract good line numbers from mgfx parser!
throw new InvalidContentException(ex.Message, input.Identity, ex);
}
// Create the effect object.
EffectObject effect = null;
var shaderErrorsAndWarnings = string.Empty;
try
{
effect = EffectObject.CompileEffect(shaderInfo, out shaderErrorsAndWarnings);
}
catch (ShaderCompilerException)
{
throw ProcessErrorsAndWarnings(shaderErrorsAndWarnings, input, context);
}
// Write out the effect to a runtime format.
CompiledEffectContent result;
try
{
using (var stream = new MemoryStream())
{
using (var writer = new BinaryWriter(stream))
effect.Write(writer, options);
result = new CompiledEffectContent(stream.GetBuffer());
}
}
catch (Exception ex)
{
throw new InvalidContentException("Failed to serialize the effect!", input.Identity, ex);
}
return result;
}
开发者ID:BrainSlugs83,项目名称:MonoGame,代码行数:60,代码来源:MGEffectProcessor.cs
示例12: Process
/// <summary>
/// Converts a material.
/// </summary>
public override MaterialContent Process(MaterialContent input,
ContentProcessorContext context)
{
// Create a new effect material.
EffectMaterialContent customMaterial = new EffectMaterialContent();
// Point the new material at our custom effect file.
string effectFile = Path.GetFullPath("Effects\\PreEffects\\TexturingEffect.fx");
customMaterial.Effect = new ExternalReference<EffectContent>(effectFile);
// Copy texture data across from the original material.
BasicMaterialContent basicMaterial = (BasicMaterialContent)input;
if (basicMaterial.Texture != null)
{
customMaterial.Textures.Add("DefaultTexture", basicMaterial.Texture);
customMaterial.OpaqueData.Add("TextureEnabled", true);
}
// Add the reflection texture.
//string envmap = Path.GetFullPath(EnvironmentMap);
//customMaterial.Textures.Add("EnvironmentMap",
//new ExternalReference<TextureContent>(envmap));
// Chain to the base material processor.
return base.Process(customMaterial, context);
}
开发者ID:JMarple,项目名称:MicrosoftImagineCup2013,代码行数:32,代码来源:EnvironmentMappedMaterialProcessor.cs
示例13: Process
public override ModelContent Process(NodeContent input, ContentProcessorContext context)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
//we always want to generate tangent frames, as we use tangent space normal mapping
GenerateTangentFrames = true;
//merge transforms
MeshHelper.TransformScene(input, input.Transform);
input.Transform = Matrix.Identity;
if (!_isSkinned)
MergeTransforms(input);
ModelContent model = base.Process(input, context);
//gather some information that will be useful in run time
MeshMetadata metadata = new MeshMetadata();
BoundingBox aabb = new BoundingBox();
metadata.BoundingBox = ComputeBoundingBox(input, ref aabb, metadata);
//assign it to our Tag
model.Tag = metadata;
return model;
}
开发者ID:justshiv,项目名称:LightSavers,代码行数:26,代码来源:LightPrePassProcessor.cs
示例14: ConvertMaterial
protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
{
MaterialData mat = incomingMaterials.Single(m => m.Name == material.Name);
EffectMaterialContent emc = new EffectMaterialContent();
emc.Effect = new ExternalReference<EffectContent>(Path.Combine(contentPath, mat.CustomEffect));
emc.Name = material.Name;
emc.Identity = material.Identity;
foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture in material.Textures)
{
if (texture.Key == "Texture")
{
emc.Textures.Add(texture.Key, texture.Value);
}
else
{
context.Logger.LogWarning(null, material.Identity, "There were some other textures referenced by the model, but we can't properly assign them to the correct effect parameter.");
}
}
foreach (EffectParam ep in mat.EffectParams)
{
if (ep.Category == EffectParamCategory.OpaqueData)
{
emc.OpaqueData.Add(ep.Name, ep.Value);
}
else if (ep.Category == EffectParamCategory.Texture)
{
emc.Textures.Add(ep.Name, new ExternalReference<TextureContent>((string)(ep.Value)));
}
}
return base.ConvertMaterial(emc, context);
}
开发者ID:Tengato,项目名称:Mechadrone1,代码行数:35,代码来源:SimpleModelProcessor.cs
示例15: Process
public override ModelContent Process(NodeContent input, ContentProcessorContext context)
{
ValidateMesh(input, context, null);
BoneContent skeleton = MeshHelper.FindSkeleton(input);
if (skeleton == null)
throw new InvalidContentException("Input skeleton not found.");
//Bakes everything
FlattenTransforms(input, skeleton);
//Read bind pse and skeleton hierarchy data.
IList<BoneContent> bones = MeshHelper.FlattenSkeleton(skeleton);
if (bones.Count > SkinnedEffect.MaxBones)
{
throw new InvalidContentException(string.Format("Skeleton has {0} bones, but the max is {1}.", bones.Count, SkinnedEffect.MaxBones));
}
List<Matrix> bindPose = new List<Matrix>();
List<Matrix> inverseBindPose = new List<Matrix>();
List<int> skeletonHierarchy = new List<int>();
Dictionary<string, int> boneIndices = new Dictionary<string, int>();
foreach (BoneContent bone in bones)
{
bindPose.Add(bone.Transform);
inverseBindPose.Add(Matrix.Invert(bone.AbsoluteTransform));
skeletonHierarchy.Add(bones.IndexOf(bone.Parent as BoneContent));
boneIndices.Add(bone.Name, boneIndices.Count);
}
ModelContent model = base.Process(input, context);
model.Tag = new SkinningDataStorage(bindPose, inverseBindPose, skeletonHierarchy, boneIndices);
return model;
}
开发者ID:DuxClarus,项目名称:Uat-Portfolio,代码行数:31,代码来源:SkinnedModelProcessor.cs
示例16: Process
public override TextureContent Process(TextureContent input, ContentProcessorContext context)
{
input.ConvertBitmapType(typeof(PixelBitmapContent<Color>));
foreach (MipmapChain mipChain in input.Faces)
{
foreach (PixelBitmapContent<Color> bitmap in mipChain)
{
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width; x++)
{
Color c = bitmap.GetPixel(x, y);
c.R = (byte)(c.R * c.A / 255);
c.G = (byte)(c.G * c.A / 255);
c.B = (byte)(c.B * c.A / 255);
bitmap.SetPixel(x, y, c);
}
}
}
}
return base.Process(input, context);
}
开发者ID:struckAnerve,项目名称:vikingvalg,代码行数:26,代码来源:PremultipliedAlphaTextureProcessor.cs
示例17: Process
public override ModelContent Process(NodeContent input, ContentProcessorContext context)
{
model = base.Process(input, context);
AnimationClips clips = ProcessAnimations(model, input, context);
model.Tag = clips;
return model;
}
开发者ID:Kingofhearts102,项目名称:PrisonSteps,代码行数:7,代码来源:AnimationProcessor.cs
示例18: Process
public override CompiledEffectContent Process(Microsoft.Xna.Framework.Content.Pipeline.Graphics.EffectContent input, ContentProcessorContext context)
{
this.DebugMode = EffectProcessorDebugMode.Optimize;
if (context.Parameters.ContainsKey("Defines"))
this.Defines = context.Parameters["Defines"].ToString();
return base.Process(input, context);
}
开发者ID:justshiv,项目名称:LightSavers,代码行数:7,代码来源:LightPrePassFXProcessor.cs
示例19: LoadFragmentContent
protected FragmentContent LoadFragmentContent(ContentProcessorContext context, string fileName, ContentIdentity relativeToContent = null)
{
ExternalReference<FragmentContent> externalReference = (relativeToContent != null)
? new ExternalReference<FragmentContent>(fileName, relativeToContent)
: new ExternalReference<FragmentContent>(fileName);
return context.BuildAndLoadAsset<FragmentContent, FragmentContent>(externalReference, null);
}
开发者ID:modulexcite,项目名称:stitchup,代码行数:7,代码来源:FragmentSource.cs
示例20: Process
public override SpriteFontContent Process(Texture2DContent input, ContentProcessorContext context)
{
if(context.TargetPlatform == TargetPlatform.Windows)
CreateExEnOutput(input, context);
return base.Process(input, context);
}
开发者ID:meds,项目名称:ChicksnVixens,代码行数:7,代码来源:FontShim.cs
注:本文中的ContentProcessorContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论