public override void Deploy() { var modelOutPath = new FileInfo(_outputFilePath); Directory.CreateDirectory(modelOutPath.DirectoryName); var assetFileModel = PrepareNewAssetFile(null); assetFileModel.FileType = FileType.Generic3dModel; assetFileModel.OutputFilePath = modelOutPath.FullName; DeployFile(assetFileModel); FilesDeployed.Add(assetFileModel); foreach (var tp in _texturePaths) { var actualTexPath = GetOutputPathForTexture(tp); var texOutPath = new FileInfo(actualTexPath); Directory.CreateDirectory(texOutPath.DirectoryName); var assetFileTex = PrepareNewAssetFile(assetFileModel); // Alter input path: assetFileTex.InputFilePath = GetInputPathForTexture(tp); assetFileTex.FileType = FileType.Generic; assetFileTex.OutputFilePath = texOutPath.FullName; DeployFile(assetFileTex); FilesDeployed.Add(assetFileTex); } assetFileModel.Messages.Add(Message.Create(MessageType.Success, $"Copied model '{assetFileModel.OutputFilePath}', and {_texturePaths.Count} dependent material textures.", null)); // TODO: open a window or so? }
public override void Deploy() { var outPath = new FileInfo(_outputFilePath); Directory.CreateDirectory(outPath.DirectoryName); var assetFileModel = PrepareNewAssetFile(null); assetFileModel.FileType = FileType.Generic; assetFileModel.OutputFilePath = outPath.FullName; // Now, are we going to copy or are we going to symlink? FilesDeployed.Add(assetFileModel); // store before deployment to keep the info - even if DeployFile() might fail DeployFile(assetFileModel); }
public override void Deploy() { var outPath = new FileInfo(_outputFilePath); Directory.CreateDirectory(outPath.DirectoryName); var assetFileModel = PrepareNewAssetFile(null); assetFileModel.FileType = FileType.Generic; assetFileModel.OutputFilePath = outPath.FullName; // Now, are we going to copy or are we going to symlink? DeployFile(assetFileModel); FilesDeployed.Add(assetFileModel); }
public override void Deploy() { var modelOutPath = new FileInfo(_outputFilePath); Directory.CreateDirectory(modelOutPath.DirectoryName); var assetFileModel = PrepareNewAssetFile(null); assetFileModel.FileType = FileType.Generic3dModel; assetFileModel.OutputFilePath = modelOutPath.FullName; DeployFile(assetFileModel); FilesDeployed.Add(assetFileModel); foreach (var tp in _texturePaths) { var texInPathStr = GetInputPathForTexture(tp); var texInPath = new FileInfo(texInPathStr); // Perform some checks before deploying it // -> A dependent resource must reside in the same folder or in a subfolder of the root resource. if (!texInPath.Directory.IsSameOrSubdirectoryOf(_inputFile.Directory)) { assetFileModel.Messages.Add(Message.Create(MessageType.Warning, $"The texture '{texInPath.FullName}' is not located in the same directory or a subdirectory of {_inputFile.FullName}. It will not be deployed.", null)); continue; } if (!texInPath.Exists) { assetFileModel.Messages.Add(Message.Create(MessageType.Warning, $"The texture '{texInPath.FullName}' (referenced in '{_inputFile.Name}') does not exist at that path.", null)); continue; } var texOutPathStr = GetOutputPathForTexture(tp); var texOutPath = new FileInfo(texOutPathStr); Directory.CreateDirectory(texOutPath.DirectoryName); var assetFileTex = PrepareNewAssetFile(assetFileModel); // Alter input path: assetFileTex.InputFilePath = texInPathStr; assetFileTex.FileType = FileType.Generic; assetFileTex.OutputFilePath = texOutPath.FullName; DeployFile(assetFileTex); FilesDeployed.Add(assetFileTex); } assetFileModel.Messages.Add(Message.Create(MessageType.Success, $"Copied model '{assetFileModel.OutputFilePath}', and {_texturePaths.Count} dependent material textures.", null)); // TODO: open a window or so? }
public override void Deploy() { var outFile = new FileInfo(_outputFilePath); Directory.CreateDirectory(outFile.DirectoryName); // Read in -> modify -> write out string glslCode = File.ReadAllText(_inputFile.FullName); File.WriteAllText(outFile.FullName, MorphVkGlslIntoGlGlsl(glslCode)); var assetFile = PrepareNewAssetFile(null); assetFile.FileType = FileType.GlslShaderForGl; assetFile.OutputFilePath = outFile.FullName; assetFile.DeploymentType = DeploymentType.MorphedCopy; assetFile.Messages.Add(Message.Create(MessageType.Success, $"Copied (Vk->Gl morphed) GLSL file to '{outFile.FullName}'", null)); // TODO: open a window or so? FilesDeployed.Add(assetFile); }
public override void Deploy() { base.Deploy(); string matFile = null; using (var sr = new StreamReader(_inputFile.FullName)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line.TrimStart().StartsWith("mtllib")) { // found a .mat-file! matFile = line.TrimStart().Substring("mtllib".Length).Trim(); } } } if (null != matFile) { var modelOutPath = new FileInfo(_outputFilePath); var actualMatPath = Path.Combine(modelOutPath.DirectoryName, matFile); var matOutPath = new FileInfo(actualMatPath); Directory.CreateDirectory(matOutPath.DirectoryName); Diag.Debug.Assert(FilesDeployed[0].FileType == FileType.Generic3dModel); Diag.Debug.Assert(FilesDeployed[0].Parent == null); var assetFileMat = PrepareNewAssetFile(FilesDeployed[0]); // Alter input path: assetFileMat.InputFilePath = Path.Combine(_inputFile.DirectoryName, matFile); assetFileMat.FileType = FileType.ObjMaterials; assetFileMat.OutputFilePath = matOutPath.FullName; DeployFile(assetFileMat); assetFileMat.Messages.Add(Message.Create(MessageType.Success, $"Added materials file '{assetFileMat.OutputFilePath}', of .obj model '{FilesDeployed[0].OutputFilePath}'", null)); // TODO: open a window or so? FilesDeployed.Add(assetFileMat); } }
public override void Deploy() { base.Deploy(); string matFile = null; using (var sr = new StreamReader(_inputFile.FullName)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line.TrimStart().StartsWith("mtllib")) { // found a .mat-file! matFile = line.TrimStart().Substring("mtllib".Length).Trim(); } } } if (null != matFile) { var matInPathStr = Path.Combine(_inputFile.DirectoryName, matFile); var matInPath = new FileInfo(matInPathStr); // Perform some checks before deploying it // -> A dependent resource must reside in the same folder or in a subfolder of the root resource. bool failed = false; if (!matInPath.Directory.IsSameOrSubdirectoryOf(_inputFile.Directory)) { // The first element of FilesDeployed will contain the 3D-model file FilesDeployed.First().Messages.Add(Message.Create(MessageType.Warning, $"The material file '{matInPath.FullName}' is not located in the same directory or a subdirectory of {_inputFile.FullName}. It will not be deployed.", null)); failed = true; } if (!matInPath.Exists) { // The first element of FilesDeployed will contain the 3D-model file FilesDeployed.First().Messages.Add(Message.Create(MessageType.Warning, $"The material file '{matInPath.FullName}' (referenced in '{_inputFile.Name}') does not exist at that path.", null)); failed = true; } if (!failed) { var modelOutPath = new FileInfo(_outputFilePath); var actualMatPath = Path.Combine(modelOutPath.DirectoryName, matFile); var matOutPath = new FileInfo(actualMatPath); Directory.CreateDirectory(matOutPath.DirectoryName); Diag.Debug.Assert(FilesDeployed[0].FileType == FileType.Generic3dModel); Diag.Debug.Assert(FilesDeployed[0].Parent == null); var assetFileMat = PrepareNewAssetFile(FilesDeployed[0]); // Alter input path: assetFileMat.InputFilePath = matInPathStr; assetFileMat.FileType = FileType.ObjMaterials; assetFileMat.OutputFilePath = matOutPath.FullName; DeployFile(assetFileMat); assetFileMat.Messages.Add(Message.Create(MessageType.Success, $"Added materials file '{assetFileMat.OutputFilePath}', of .obj model '{FilesDeployed[0].OutputFilePath}'", null)); // TODO: open a window or so? FilesDeployed.Add(assetFileMat); } } }
public override void Deploy() { var outFile = new FileInfo(_outputFilePath); Directory.CreateDirectory(outFile.DirectoryName); var cmdLineParams = string.Format(GlslangValidatorParams, _inputFile.FullName, outFile.FullName); var sb = new StringBuilder(); int numErrors = 0; int numWarnings = 0; var assetFile = PrepareNewAssetFile(null); assetFile.FileType = FileType.GlslShaderForVk; assetFile.OutputFilePath = outFile.FullName; assetFile.DeploymentType = DeploymentType.MorphedCopy; void processLine(string line) { sb.AppendLine(line); // check for error: if (line.TrimStart().StartsWith("error", StringComparison.InvariantCultureIgnoreCase)) { var m = LineNumberRegex.Match(line); assetFile.Messages.Add(Message.Create( MessageType.Error, line, null, _inputFile.FullName, true, m.Success ? int.Parse(m.Groups[1].Value) : (int?)null)); numErrors += 1; } // check for warning: else if (line.TrimStart().StartsWith("warn", StringComparison.InvariantCultureIgnoreCase)) { var m = LineNumberRegex.Match(line); assetFile.Messages.Add(Message.Create( MessageType.Warning, line, null, _inputFile.FullName, true, m.Success ? int.Parse(m.Groups[1].Value) : (int?)null)); numWarnings += 1; } } // Call the other process: using (Diag.Process proc = new Diag.Process() { StartInfo = new Diag.ProcessStartInfo(GlslangValidatorPath, cmdLineParams) { UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, WindowStyle = Diag.ProcessWindowStyle.Hidden, } }) { proc.Start(); while (!proc.StandardOutput.EndOfStream) { var line = proc.StandardOutput.ReadLine(); processLine(line); } while (!proc.StandardError.EndOfStream) { var line = proc.StandardOutput.ReadLine(); processLine(line); } } if (numErrors > 0 || numWarnings > 0) { if (numErrors > 0 && numWarnings > 0) { assetFile.Messages.Add(Message.Create(MessageType.Information, $"Compiling shader for Vulkan resulted in {numErrors} errors and {numWarnings} warnings:" + Environment.NewLine + Environment.NewLine + sb.ToString(), null, _inputFile.FullName, true)); } else if (numWarnings > 0) { assetFile.Messages.Add(Message.Create(MessageType.Information, $"Compiling shader for Vulkan resulted in {numWarnings} warnings:" + Environment.NewLine + Environment.NewLine + sb.ToString(), null, _inputFile.FullName, true)); } else { assetFile.Messages.Add(Message.Create(MessageType.Information, $"Compiling shader for Vulkan resulted in {numErrors} errors:" + Environment.NewLine + Environment.NewLine + sb.ToString(), null, _inputFile.FullName, true)); } } else { assetFile.Messages.Add(Message.Create(MessageType.Success, $"Compiling shader for Vulkan succeeded:" + Environment.NewLine + Environment.NewLine + sb.ToString(), null, _inputFile.FullName, true)); } FilesDeployed.Add(assetFile); }