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


C# ContentProcessorContext.BuildAsset方法代码示例

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


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

示例1: BuildTileSetTextures

        /// <summary>
        /// Iterates all of the tile sets and builds external references to the textures. Useful if you want to just
        /// load the resulting map and not have to also load up textures. The external reference is stored on the
        /// TileSet's Texture field so make sure you serialize that if you call this method.
        /// </summary>
        public static void BuildTileSetTextures(MapContent input, ContentProcessorContext context, string textureRoot = "")
        {
            foreach (var tileSet in input.TileSets)
            {
                // get the real path to the image
                string path = Path.Combine(textureRoot, tileSet.Image);

                // the asset name is the entire path, minus extension, after the content directory
                string asset = string.Empty;
                if (path.StartsWith(Directory.GetCurrentDirectory()))
                    asset = path.Remove(tileSet.Image.LastIndexOf('.')).Substring(Directory.GetCurrentDirectory().Length + 1);
                else
                    asset = Path.GetFileNameWithoutExtension(path);

                // build the asset as an external reference
                OpaqueDataDictionary data = new OpaqueDataDictionary();
                data.Add("GenerateMipmaps", false);
                data.Add("ResizeToPowerOfTwo", false);
                data.Add("TextureFormat", TextureProcessorOutputFormat.Color);
                data.Add("ColorKeyEnabled", tileSet.ColorKey.HasValue);
                data.Add("ColorKeyColor", tileSet.ColorKey.HasValue ? tileSet.ColorKey.Value : Microsoft.Xna.Framework.Color.Magenta);
                tileSet.Texture = context.BuildAsset<Texture2DContent, Texture2DContent>(
                    new ExternalReference<Texture2DContent>(path), null, data, null, asset);
            }
        }
开发者ID:sippeangelo,项目名称:DepthsBelow,代码行数:30,代码来源:TiledHelpers.cs

示例2: BuildEffect

        protected override ExternalReference<CompiledEffectContent> BuildEffect(ExternalReference<EffectContent> effect, ContentProcessorContext context)
        {
            OpaqueDataDictionary processorParameters = new OpaqueDataDictionary();

            if (context.Parameters.ContainsKey("Defines"))
                processorParameters.Add("Defines", context.Parameters["Defines"]);

            return context.BuildAsset<EffectContent, CompiledEffectContent>(effect, "DeferredRendererFXProcessor", processorParameters, "EffectImporter", effect.Name);
        }
开发者ID:Imortilize,项目名称:Psynergy-Engine,代码行数:9,代码来源:DeferredRendererMaterialProcessor.cs

示例3: BuildTexture

        protected override ExternalReference<TextureContent> BuildTexture(string textureName, ExternalReference<TextureContent> texture, ContentProcessorContext context)
        {
            // Named textures will each have their own custom processor
            switch (textureName) {
                case HMModelProcessor.SPECULAR_MAP_KEY:
                    return context.BuildAsset<TextureContent, TextureContent>(texture, typeof (HMSpecularProcessor).Name);

                default:
                    // Default processing for all others
                    return base.BuildTexture(textureName, texture, context);
            }
        }
开发者ID:mikeschuld,项目名称:HMEngineXNA,代码行数:12,代码来源:HMMaterialProcessor.cs

示例4: buildTextures

        private int torso_frames; //animation offset, for legs

        #endregion Fields

        #region Methods

        public void buildTextures(ContentProcessorContext context)
        {
            Dictionary<string, ExternalReference<TextureContent>>.Enumerator e = materials_list.GetEnumerator();
              built_textures = new List<ExternalReference<TextureContent>>();
              while (e.MoveNext())
              {
            ExternalReference<TextureContent> t = e.Current.Value;
            ExternalReference<TextureContent> builtTexture = context.BuildAsset<TextureContent, TextureContent>(t, "TextureProcessor");
            builtTexture.Name = e.Current.Key;
            built_textures.Add(builtTexture);
              }
        }
开发者ID:obyrnemj,项目名称:computational-geometry-3d-vision,代码行数:18,代码来源:PK3Loader.cs

示例5: BuildTexture

        protected override ExternalReference<TextureContent> BuildTexture(string textureName, ExternalReference<TextureContent> texture,
            ContentProcessorContext context)
        {
            if (textureName == NormalMappingModelProcessor.NormalMapKey)
            {
                // put the normal map through the special NormalMapTextureProcessor,
                // which will convert it to a signed format.
                return context.BuildAsset<TextureContent, TextureContent>(texture,
                    typeof(NormalMapTextureProcessor).Name);
            }

            // Apply default processing to all other textures.
            return base.BuildTexture(textureName, texture, context);
        }
开发者ID:OctopussyGame,项目名称:Octopussy,代码行数:14,代码来源:NormalMappingMaterialProcessor.cs

示例6: ConvertMaterial

		protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
		{
			if (string.IsNullOrEmpty(StitchedEffect))
				throw new Exception("Stitched Effect property must be set for StitchUp Model Processor.");

			string fullPath = Path.GetFullPath(Path.Combine(new FileInfo(material.Identity.SourceFilename).DirectoryName, StitchedEffect));
			context.AddDependency(fullPath);

			EffectMaterialContent effectMaterial = new EffectMaterialContent
			{
				CompiledEffect = context.BuildAsset<StitchedEffectContent, CompiledEffectContent>(new ExternalReference<StitchedEffectContent>(fullPath), typeof(StitchedEffectProcessor).Name),
				Identity = material.Identity,
				Name = material.Name
			};

			return effectMaterial;
		}
开发者ID:modulexcite,项目名称:stitchup,代码行数:17,代码来源:StitchedEffectModelProcessor.cs

示例7: 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

示例8: BuildTexture

        protected override ExternalReference<TextureContent>  BuildTexture(string textureName, ExternalReference<TextureContent> texture, ContentProcessorContext context)
        {
            // Fallback if we aren't buiding for iOS.
            var platform = ContentHelper.GetMonoGamePlatform();
            if (platform != MonoGamePlatform.iOS)
                return base.BuildTexture(textureName, texture, context);
        
            var processorParameters = new OpaqueDataDictionary();
            processorParameters.Add("ColorKeyColor", this.ColorKeyColor);
            processorParameters.Add("ColorKeyEnabled", this.ColorKeyEnabled);
            processorParameters.Add("TextureFormat", this.TextureFormat);
            processorParameters.Add("GenerateMipmaps", this.GenerateMipmaps);
            processorParameters.Add("ResizeToPowerOfTwo", this.ResizeTexturesToPowerOfTwo);
            processorParameters.Add("PremultiplyAlpha", this.PremultiplyTextureAlpha);

            return context.BuildAsset<TextureContent, TextureContent>(texture, typeof(MGTextureProcessor).Name, processorParameters, null, null);
        }
开发者ID:Boerlam001,项目名称:MonoGame,代码行数:17,代码来源:MGMaterialProcessor.cs

示例9: LoadTexture

        public static ExternalReference<Texture2DContent> LoadTexture(string imagePath, Color? color_key, ContentProcessorContext context, string textureRoot = "")
        {
            string path = Path.Combine(textureRoot, imagePath);

                // the asset name is the entire path, minus extension, after the content directory
                string asset = string.Empty;
                if (path.StartsWith(Directory.GetCurrentDirectory()))
                    asset = path.Remove(imagePath.LastIndexOf('.')).Substring(Directory.GetCurrentDirectory().Length + 1);
                else
                    asset = Path.GetFileNameWithoutExtension(path);

                // build the asset as an external reference
                OpaqueDataDictionary data = new OpaqueDataDictionary();
                data.Add("GenerateMipmaps", false);
                data.Add("ResizeToPowerOfTwo", false);
                data.Add("TextureFormat", TextureProcessorOutputFormat.Color);
                data.Add("ColorKeyEnabled", color_key.HasValue);
                data.Add("ColorKeyColor", color_key.HasValue ? color_key.Value : Microsoft.Xna.Framework.Color.Magenta);

                return context.BuildAsset<Texture2DContent, Texture2DContent>(
                    new ExternalReference<Texture2DContent>(path), null, data, null, asset);
        }
开发者ID:ndssia,项目名称:Project-Corsair---Platformer,代码行数:22,代码来源:ContentHelper.cs

示例10: OnBuildMaterial

 protected virtual ExternalReference<DRMaterialContent> OnBuildMaterial(ExternalReference<DRMaterialContent> material, ContentProcessorContext context)
 {
     return context.BuildAsset<DRMaterialContent, DRMaterialContent>(material, typeof(DRMaterialProcessor).Name, null, typeof(DRMaterialImporter).Name, null);
 }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:4,代码来源:DRModelProcessor_Materials.cs

示例11: BuildFontExternal

 public static string BuildFontExternal(ContentProcessorContext context, string fontPath)
 {
     var dir = Path.GetDirectoryName(fontPath);
     return Path.Combine(dir, Path.GetFileNameWithoutExtension(context.BuildAsset<FontDescription, SpriteFontContent>(new ExternalReference<FontDescription>(fontPath), "FontDescriptionProcessor").Filename));
 }
开发者ID:quandtm,项目名称:XNInterface,代码行数:5,代码来源:Loaders.cs

示例12: ConvertMaterial

        protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
        {
            EffectMaterialContent deferredShadingMaterial = new EffectMaterialContent();
            deferredShadingMaterial.Effect = new ExternalReference<EffectContent>("../../GraphicsLibrary/GraphicsContent/Shaders/Deferred Rendering/RenderGBuffer.fx");
            deferredShadingMaterial.CompiledEffect = context.BuildAsset<EffectContent, CompiledEffectContent>(deferredShadingMaterial.Effect, "EffectProcessor");

            // copy the textures in the original material to the new normal mapping
            // material, if they are relevant to our renderer. The
            // LookUpTextures function has added the normal map and specular map
            // textures to the Textures collection, so that will be copied as well.
            foreach (KeyValuePair<String, ExternalReference<TextureContent>> texture in material.Textures)
            {
                if (texture.Key.Contains("DiffuseMap") || texture.Key.Contains("Texture"))
                    deferredShadingMaterial.Textures.Add(texture.Key, texture.Value);

                if (texture.Key.Contains("NormalMap"))
                    deferredShadingMaterial.Textures.Add(texture.Key, texture.Value);

                if (texture.Key.Contains("SpecularMap"))
                    deferredShadingMaterial.Textures.Add(texture.Key, texture.Value);

                if (texture.Key.Contains("EmissiveMap"))
                    deferredShadingMaterial.Textures.Add(texture.Key, texture.Value);
            }

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

            // Return material
            return context.Convert<MaterialContent, MaterialContent>(deferredShadingMaterial, typeof(DeferredRendererMaterialProcessor).Name);
        }
开发者ID:Imortilize,项目名称:Psynergy-Engine,代码行数:31,代码来源:DeferredRendererModel.cs

示例13: BuildTexture

        /// <summary>
        /// Builds a texture for use by this material.
        /// </summary>
        protected override ExternalReference<TextureContent> BuildTexture(
                                            string textureName,
                                            ExternalReference<TextureContent> texture,
                                            ContentProcessorContext context)
        {
            // Use our custom CubemapProcessor for the environment map texture.
            if (textureName == "EnvironmentMap")
            {
                return context.BuildAsset<TextureContent,
                                          TextureContent>(texture, "CubemapProcessor");
            }

            // Apply default processing to all other textures.
            return base.BuildTexture(textureName, texture, context);
        }
开发者ID:JMarple,项目名称:MicrosoftImagineCup2013,代码行数:18,代码来源:EnvironmentMappedMaterialProcessor.cs

示例14: ConvertMaterial

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

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

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

            // copy the textures in the original material to the new lpp
            // material
            ExtractTextures(lppMaterial, material);
            //extract the extra parameters
            ExtractDefines(lppMaterial, material, context);

            // 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:justshiv,项目名称:LightSavers,代码行数:28,代码来源:LightPrePassProcessor.cs

示例15: BuildTextureExternal

 public static string BuildTextureExternal(ContentProcessorContext context, string texPath)
 {
     var dir = Path.GetDirectoryName(texPath);
     return Path.Combine(dir, Path.GetFileNameWithoutExtension(context.BuildAsset<TextureContent, TextureContent>(new ExternalReference<TextureContent>(texPath), "TextureProcessor").Filename));
 }
开发者ID:quandtm,项目名称:XNInterface,代码行数:5,代码来源:Loaders.cs


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