/// <summary>
 /// Initiates a nested build of the specified asset and then loads the result into memory.
 /// </summary>
 /// <typeparam name="TInput">Type of the input.</typeparam>
 /// <typeparam name="TOutput">Type of the converted output.</typeparam>
 /// <param name="sourceAsset">Reference to the source asset.</param>
 /// <param name="processorName">Optional processor for this content.</param>
 /// <returns>Copy of the final converted content.</returns>
 /// <remarks>An example of usage would be a mesh processor calling BuildAndLoadAsset to build any associated textures and replace the original .tga file references with an embedded copy of the converted texture.</remarks>
 public TOutput BuildAndLoadAsset <TInput, TOutput>(
     ExternalReference <TInput> sourceAsset,
     string processorName
     )
 {
     return(BuildAndLoadAsset <TInput, TOutput>(sourceAsset, processorName, null, null));
 }
 /// <summary>
 /// Initiates a nested build of an additional asset.
 /// </summary>
 /// <typeparam name="TInput">Type of the input.</typeparam>
 /// <typeparam name="TOutput">Type of the output.</typeparam>
 /// <param name="sourceAsset">Reference to the source asset.</param>
 /// <param name="processorName">Optional processor for this content.</param>
 /// <param name="processorParameters">Optional collection of named values available as input to the content processor.</param>
 /// <param name="importerName">Optional importer for this content.</param>
 /// <param name="assetName">Optional name of the final compiled content.</param>
 /// <returns>Reference to the final compiled content. The build work is not required to complete before returning. Therefore, this file may not be up to date when BuildAsset returns but it will be available for loading by the game at runtime.</returns>
 /// <remarks>An example of usage for BuildAsset is being called by a mesh processor to request that any related textures used are also built, replacing the original TGA file references with new references to the converted texture files.</remarks>
 public abstract ExternalReference <TOutput> BuildAsset <TInput, TOutput>(
     ExternalReference <TInput> sourceAsset,
     string processorName,
     OpaqueDataDictionary processorParameters,
     string importerName,
     string assetName
     );
Example #3
0
        private static List <MaterialContent> ImportMaterials(ContentIdentity identity, Scene scene)
        {
            var materials = new List <MaterialContent>();

            foreach (var sceneMaterial in scene.Materials)
            {
                var material = new BasicMaterialContent
                {
                    Name     = sceneMaterial.Name,
                    Identity = identity,
                };

                if (sceneMaterial.HasTextureDiffuse)
                {
                    var texture = new ExternalReference <TextureContent>(sceneMaterial.TextureDiffuse.FilePath, identity);
                    texture.OpaqueData.Add("TextureCoordinate", string.Format("TextureCoordinate{0}", sceneMaterial.TextureDiffuse.UVIndex));
                    material.Textures.Add("Texture", texture);
                }

                if (sceneMaterial.HasTextureOpacity)
                {
                    var texture = new ExternalReference <TextureContent>(sceneMaterial.TextureOpacity.FilePath, identity);
                    texture.OpaqueData.Add("TextureCoordinate", string.Format("TextureCoordinate{0}", sceneMaterial.TextureOpacity.UVIndex));
                    material.Textures.Add("Transparency", texture);
                }

                if (sceneMaterial.HasColorDiffuse)
                {
                    material.DiffuseColor = ToXna(sceneMaterial.ColorDiffuse);
                }

                if (sceneMaterial.HasColorEmissive)
                {
                    material.EmissiveColor = ToXna(sceneMaterial.ColorEmissive);
                }

                if (sceneMaterial.HasOpacity)
                {
                    material.Alpha = sceneMaterial.Opacity;
                }

                if (sceneMaterial.HasColorSpecular)
                {
                    material.SpecularColor = ToXna(sceneMaterial.ColorSpecular);
                }

                if (sceneMaterial.HasShininessStrength)
                {
                    material.SpecularPower = sceneMaterial.ShininessStrength;
                }

                materials.Add(material);
            }

            return(materials);
        }
 public ExternalReference <TOutput> BuildAsset <TInput, TOutput>(ExternalReference <TInput> sourceAsset, string processorName, OpaqueDataDictionary processorParameters, string importerName, string assetName)
 {
     throw new NotImplementedException();
 }
Example #5
0
        /// <summary>
        /// Converts all Assimp <see cref="Material"/>s to XNA <see cref="MaterialContent"/>s.
        /// </summary>
        private void ImportMaterials()
        {
            _materials = new List <MaterialContent>();
            foreach (var aiMaterial in _scene.Materials)
            {
                var material = new BasicMaterialContent
                {
                    Name     = aiMaterial.Name,
                    Identity = _identity,
                };

                if (aiMaterial.HasTextureDiffuse)
                {
                    var texture = new ExternalReference <TextureContent>(aiMaterial.TextureDiffuse.FilePath, _identity);
                    texture.OpaqueData.Add("TextureCoordinate", string.Format("TextureCoordinate{0}", aiMaterial.TextureDiffuse.UVIndex));
                    material.Texture = texture;
                }

                if (aiMaterial.HasTextureOpacity)
                {
                    var texture = new ExternalReference <TextureContent>(aiMaterial.TextureOpacity.FilePath, _identity);
                    texture.OpaqueData.Add("TextureCoordinate", string.Format("TextureCoordinate{0}", aiMaterial.TextureOpacity.UVIndex));
                    material.Textures.Add("Transparency", texture);
                }

                if (aiMaterial.HasTextureSpecular)
                {
                    var texture = new ExternalReference <TextureContent>(aiMaterial.TextureSpecular.FilePath, _identity);
                    texture.OpaqueData.Add("TextureCoordinate", string.Format("TextureCoordinate{0}", aiMaterial.TextureSpecular.UVIndex));
                    material.Textures.Add("Specular", texture);
                }

                if (aiMaterial.HasTextureHeight)
                {
                    var texture = new ExternalReference <TextureContent>(aiMaterial.TextureHeight.FilePath, _identity);
                    texture.OpaqueData.Add("TextureCoordinate", string.Format("TextureCoordinate{0}", aiMaterial.TextureHeight.UVIndex));
                    material.Textures.Add("Bump", texture);
                }

                if (aiMaterial.HasColorDiffuse)
                {
                    material.DiffuseColor = ToXna(aiMaterial.ColorDiffuse);
                }

                if (aiMaterial.HasColorEmissive)
                {
                    material.EmissiveColor = ToXna(aiMaterial.ColorEmissive);
                }

                if (aiMaterial.HasOpacity)
                {
                    material.Alpha = aiMaterial.Opacity;
                }

                if (aiMaterial.HasColorSpecular)
                {
                    material.SpecularColor = ToXna(aiMaterial.ColorSpecular);
                }

                if (aiMaterial.HasShininessStrength)
                {
                    material.SpecularPower = aiMaterial.ShininessStrength;
                }

                _materials.Add(material);
            }
        }