Example #1
0
        protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, SkyboxAsset asset, AssetCompilerResult result)
        {
            result.BuildSteps = new AssetBuildStep(AssetItem);
            result.ShouldWaitForPreviousBuilds = true;

            // build the textures for windows (needed for skybox compilation)
            foreach (var dependency in asset.Model.GetDependencies())
            {
                var assetItem = context.Package.Assets.Find(dependency.Id);
                if (assetItem != null && assetItem.Asset is TextureAsset)
                {
                    var textureAsset = (TextureAsset)assetItem.Asset;

                    // Get absolute path of asset source on disk
                    var assetSource = GetAbsolutePath(assetItem.Location.GetDirectoryAndFileName(), textureAsset.Source);

                    // Create a synthetic url
                    var textureUrl = SkyboxGenerator.BuildTextureForSkyboxGenerationLocation(assetItem.Location);

                    var gameSettingsAsset = context.GetGameSettingsAsset();

                    // Create and add the texture command.
                    var textureParameters = new TextureConvertParameters(assetSource, textureAsset, PlatformType.Windows, GraphicsPlatform.Direct3D11, GraphicsProfile.Level_10_0, gameSettingsAsset.TextureQuality);
                    result.BuildSteps.Add(new AssetBuildStep(AssetItem)
                    {
                        new TextureAssetCompiler.TextureConvertCommand(textureUrl, textureParameters)
                    });
                }
            }

            // add the skybox command itself.
            result.BuildSteps.Add(new WaitBuildStep());
            result.BuildSteps.Add(new SkyboxCompileCommand(urlInStorage, asset));
        }
Example #2
0
            /// <inheritdoc/>
            protected override Task <ResultStatus> DoCommandOverride(ICommandContext commandContext)
            {
                // TODO Convert SkyboxAsset to Skybox and save to Skybox object
                // TODO Add system to prefilter

                using (var context = new SkyboxGeneratorContext())
                {
                    var result = SkyboxGenerator.Compile(asset, context);

                    if (result.HasErrors)
                    {
                        result.CopyTo(commandContext.Logger);
                        return(Task.FromResult(ResultStatus.Failed));
                    }

                    context.Assets.Save(Url, result.Skybox);
                }

                return(Task.FromResult(ResultStatus.Successful));
            }