private void saveOutputBtn_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(outputPath.Text)) { // MessageBox.Show("Please specify output file path first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var exporter = new Exporter(); UpdateExporterSettings(exporter.Options); lastExporterSettings = exporter.Options; #if !DEBUG try { #endif exporter.Export(); MessageBox.Show("Export completed successfully."); #if !DEBUG } catch (Exception exc) { GR2ConversionError(exporter.Options.InputPath, exporter.Options.OutputPath, exc); } #endif } }
private void UpdateCommonExporterSettings(ExporterOptions settings) { Game game = _form.GetGame(); settings.FlipUVs = flipUVs.Checked; settings.BuildDummySkeleton = buildDummySkeleton.Checked; settings.DeduplicateUVs = filterUVs.Checked; settings.ApplyBasisTransforms = applyBasisTransforms.Checked; settings.FlipMesh = flipMeshes.Checked; settings.FlipSkeleton = flipSkeletons.Checked; settings.LoadGameSettings(game); settings.ModelType = 0; if (meshRigid.Checked) { settings.ModelType |= DivinityModelFlag.Rigid; } if (meshCloth.Checked) { settings.ModelType |= DivinityModelFlag.Cloth; } if (meshProxy.Checked) { settings.ModelType |= DivinityModelFlag.MeshProxy | DivinityModelFlag.HasProxyGeometry; } settings.ConformGR2Path = conformToOriginal.Checked && conformantGR2Path.Text.Length > 0 ? conformantGR2Path.Text : null; settings.ConformSkeletonsCopy = conformCopySkeletons.Checked; }
/// <summary> /// Exporta los archivos /// </summary> internal void Export(DeploymentModel deployment) { using (BlockLogModel block = Manager.Logger.Default.CreateBlock(LogModel.LogType.Info, $"Start deployment '{deployment.Name}'")) { (NormalizedDictionary <object> constants, string error) = GetParameters(deployment.JsonParameters); if (!string.IsNullOrWhiteSpace(error)) { block.Error(error); } else { ExporterOptions options = new ExporterOptions(deployment.SourcePath, deployment.TargetPath); // Asigna las propiedades options.WriteComments = deployment.WriteComments; options.LowcaseFileNames = deployment.LowcaseFileNames; options.ReplaceArguments = deployment.ReplaceArguments; // Añade los parámetros foreach ((string key, object value) in constants.Enumerate()) { options.AddParameter(key, value); } // Exporta los archivos new DatabrickExporter(Manager.Logger, options).Export(); } } }
/// <summary>Export the passed FHIR version into the specified directory.</summary> /// <param name="info"> The information.</param> /// <param name="serverInfo"> Information describing the server.</param> /// <param name="options"> Options for controlling the operation.</param> /// <param name="exportDirectory">Directory to write files.</param> void ILanguage.Export( FhirVersionInfo info, FhirServerInfo serverInfo, ExporterOptions options, string exportDirectory) { // set internal vars so we don't pass them to every function // this is ugly, but the interface patterns get bad quickly because we need the type map to copy the FHIR info _info = info; _options = options; // create a filename for writing (single file for now) string filename = Path.Combine(exportDirectory, $"R{info.MajorVersion}.txt"); using (FileStream stream = new FileStream(filename, FileMode.Create)) using (ExportStreamWriter writer = new ExportStreamWriter(stream)) { _writer = writer; WriteHeader(); WritePrimitiveTypes(_info.PrimitiveTypes.Values); WriteComplexes(_info.ComplexTypes.Values, "Complex Types"); WriteComplexes(_info.Resources.Values, "Resources"); WriteOperations(_info.SystemOperations.Values, true, "System Operations"); WriteSearchParameters(_info.AllResourceParameters.Values, "All Resource Parameters"); WriteSearchParameters(_info.SearchResultParameters.Values, "Search Result Parameters"); WriteSearchParameters(_info.AllInteractionParameters.Values, "All Interaction Parameters"); WriteValueSets(_info.ValueSetsByUrl.Values, "Value Sets"); WriteFooter(); } }
public static Root LoadModel(string inputPath, ExporterOptions options) { switch (options.InputFormat) { case ExportFormat.GR2: { using (var fs = File.Open(inputPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var root = new Root(); var gr2 = new GR2Reader(fs); gr2.Read(root); root.PostLoad(gr2.Tag); return(root); } } case ExportFormat.DAE: { var importer = new ColladaImporter { Options = options }; return(importer.Import(inputPath)); } default: throw new ArgumentException("Invalid model format"); } }
private void UpdateExporterSettings(ExporterOptions settings) { UpdateCommonExporterSettings(settings); settings.InputPath = inputPath.Text; var inputExtension = Path.GetExtension(settings.InputPath)?.ToLower(); bool inputIsGr2 = inputExtension == ".gr2" || inputExtension == ".lsm"; settings.InputFormat = inputIsGr2 ? ExportFormat.GR2 : ExportFormat.DAE; settings.OutputPath = outputPath.Text; var outputExtension = Path.GetExtension(settings.OutputPath)?.ToLower(); bool outputIsGr2 = outputExtension == ".gr2" || outputExtension == ".lsm"; settings.OutputFormat = outputIsGr2 ? ExportFormat.GR2 : ExportFormat.DAE; foreach (ListViewItem setting in from object item in resourceFormats.Items select item as ListViewItem) { string name = setting.SubItems[0].Text; string type = setting.SubItems[1].Text; string value = setting.SubItems[2].Text; if (type == "Mesh" && value != "Automatic") { // TODO - support for name -> format translation throw new NotImplementedException("Custom vertex formats not supported"); // settings.VertexFormats.Add(name, value); } } }
private void UpdateCommonExporterSettings(ExporterOptions settings) { Game game = _form.GetGame(); if (game == Game.DivinityOriginalSin) { settings.Is64Bit = false; settings.AlternateSignature = false; settings.VersionTag = Header.Tag_DOS; settings.ModelInfoFormat = DivinityModelInfoFormat.None; } else { settings.Is64Bit = true; settings.AlternateSignature = true; settings.VersionTag = Header.Tag_DOSEE; if (game == Game.DivinityOriginalSinEE) { settings.ModelInfoFormat = DivinityModelInfoFormat.UserDefinedProperties; } else { settings.ModelInfoFormat = DivinityModelInfoFormat.LSMv1; } } settings.ExportNormals = exportNormals.Checked; settings.ExportTangents = exportTangents.Checked; settings.ExportUVs = exportUVs.Checked; settings.ExportColors = exportColors.Checked; settings.FlipUVs = flipUVs.Checked; settings.RecalculateNormals = recalculateNormals.Checked; settings.RecalculateTangents = recalculateTangents.Checked; settings.RecalculateIWT = recalculateJointIWT.Checked; settings.BuildDummySkeleton = buildDummySkeleton.Checked; settings.CompactIndices = use16bitIndex.Checked; settings.DeduplicateVertices = deduplicateVertices.Checked; settings.DeduplicateUVs = filterUVs.Checked; settings.ApplyBasisTransforms = applyBasisTransforms.Checked; settings.UseObsoleteVersionTag = forceLegacyVersion.Checked; settings.FlipMesh = flipMeshes.Checked; settings.FlipSkeleton = flipSkeletons.Checked; switch (gr2ExtraProps.SelectedIndex) { case 0: settings.ModelType = DivinityModelType.Normal; break; case 1: settings.ModelType = DivinityModelType.Rigid; break; case 2: settings.ModelType = DivinityModelType.Cloth; break; case 3: settings.ModelType = DivinityModelType.MeshProxy; break; default: throw new Exception("Unknown model type selected"); } settings.ConformGR2Path = conformToOriginal.Checked && conformantGR2Path.Text.Length > 0 ? conformantGR2Path.Text : null; }
public static Root LoadModel(string inputPath) { var options = new ExporterOptions { InputFormat = ExtensionToModelFormat(inputPath) }; return(LoadModel(inputPath, options)); }
/// <summary> /// Genera las opciones /// </summary> private static ExporterOptions GetOptions(string[] args) { ExporterOptions options = new ExporterOptions(GetArgument(SourceParameter, args), GetArgument(TargetParameter, args)); // Añade los parámetros adicionales AssignParameters(options, args); // Devuelve los parámetros return(options); }
static void Main(string[] args) { ExporterOptions options = GetOptions(args); if (ValidateData(options)) { new DatabrickExporter(GetLogger(), options).Export(); } }
/// <summary> /// Asigna el resto de parámetros /// </summary> private static void AssignParameters(ExporterOptions options, string[] args) { for (int index = 0; index < args.Length; index++) { string name = GetParameterName(args[index]); if (!string.IsNullOrWhiteSpace(name) && !name.Equals(SourceParameter, StringComparison.CurrentCultureIgnoreCase) && !name.Equals(TargetParameter, StringComparison.CurrentCultureIgnoreCase) && index < args.Length - 1) { options.AddParameter(name, args[index + 1]); } } }
private void UpdateCommonExporterSettings(ExporterOptions settings) { Game game = _form.GetGame(); if (game == Game.DivinityOriginalSin) { settings.Is64Bit = false; settings.AlternateSignature = false; settings.VersionTag = Header.Tag_DOS; } else { settings.Is64Bit = true; settings.AlternateSignature = true; settings.VersionTag = Header.Tag_DOSEE; } settings.ExportNormals = exportNormals.Checked; settings.ExportTangents = exportTangents.Checked; settings.ExportUVs = exportUVs.Checked; settings.ExportColors = exportColors.Checked; settings.FlipUVs = flipUVs.Checked; settings.RecalculateNormals = recalculateNormals.Checked; settings.RecalculateTangents = recalculateTangents.Checked; settings.RecalculateIWT = recalculateJointIWT.Checked; settings.BuildDummySkeleton = buildDummySkeleton.Checked; settings.CompactIndices = use16bitIndex.Checked; settings.DeduplicateVertices = deduplicateVertices.Checked; settings.DeduplicateUVs = filterUVs.Checked; settings.ApplyBasisTransforms = applyBasisTransforms.Checked; settings.UseObsoleteVersionTag = forceLegacyVersion.Checked; if (rigid.Checked) { settings.ModelType = DivinityModelType.Rigid; } else { settings.ModelType = DivinityModelType.Normal; } settings.ConformGR2Path = conformToOriginal.Checked && conformantGR2Path.Text.Length > 0 ? conformantGR2Path.Text : null; }
/// <summary> /// Comprueba los datos /// </summary> private static bool ValidateData(ExporterOptions options) { if (string.IsNullOrWhiteSpace(options.SourcePath)) { throw new Exception("Source path undefined"); } else if (!System.IO.Directory.Exists(options.SourcePath)) { throw new Exception($"Cant find the path '{options.SourcePath}'"); } else if (string.IsNullOrWhiteSpace(options.TargetPath)) { throw new Exception("Target path undefined"); } else { return(true); } }
/// <summary>Export the passed FHIR version into the specified directory.</summary> /// <param name="info"> The information.</param> /// <param name="serverInfo"> Information describing the server.</param> /// <param name="options"> Options for controlling the operation.</param> /// <param name="exportDirectory">Directory to write files.</param> void ILanguage.Export( FhirVersionInfo info, FhirServerInfo serverInfo, ExporterOptions options, string exportDirectory) { // set internal vars so we don't pass them to every function // this is ugly, but the interface patterns get bad quickly because we need the type map to copy the FHIR info _info = info; _options = options; _exportedCodes = new HashSet <string>(); if (options.OptionalClassTypesToExport.Contains(ExporterOptions.FhirExportClassType.Enum)) { _exportEnums = true; } else { _exportEnums = false; } // create a filename for writing (single file for now) string filename = Path.Combine(exportDirectory, $"R{info.MajorVersion}.ts"); using (FileStream stream = new FileStream(filename, FileMode.Create)) using (ExportStreamWriter writer = new ExportStreamWriter(stream)) { _writer = writer; WriteHeader(); WriteComplexes(_info.ComplexTypes.Values, false); WriteComplexes(_info.Resources.Values, true); if (_exportEnums) { WriteValueSets(_info.ValueSetsByUrl.Values); } WriteFooter(); } }
public static ExporterOptions UpdateExporterSettings() { var exporterOptions = new ExporterOptions() { InputPath = CommandLineActions.SourcePath, OutputPath = CommandLineActions.DestinationPath, InputFormat = Program.argv.InputFormat != null?CommandLineArguments.GetModelFormatByString(Program.argv.InputFormat) : CommandLineArguments.GetModelFormatByPath(CommandLineActions.SourcePath), OutputFormat = Program.argv.OutputFormat != null?CommandLineArguments.GetModelFormatByString(Program.argv.OutputFormat) : CommandLineArguments.GetModelFormatByPath(CommandLineActions.DestinationPath), ExportNormals = GR2Options["export-normals"], ExportTangents = GR2Options["export-tangents"], ExportUVs = GR2Options["export-uvs"], ExportColors = GR2Options["export-colors"], FlipUVs = GR2Options["flip-uvs"], RecalculateNormals = GR2Options["recalculate-normals"], RecalculateTangents = GR2Options["recalculate-tangents"], RecalculateIWT = GR2Options["recalculate-iwt"], BuildDummySkeleton = GR2Options["build-dummy-skeleton"], CompactIndices = GR2Options["compact-tris"], DeduplicateVertices = GR2Options["deduplicate-vertices"], DeduplicateUVs = GR2Options["deduplicate-uvs"], ApplyBasisTransforms = GR2Options["apply-basis-transforms"], UseObsoleteVersionTag = GR2Options["force-legacy-version"], ConformGR2Path = GR2Options["conform"] && !string.IsNullOrEmpty(CommandLineActions.ConformPath) ? CommandLineActions.ConformPath : null, FlipSkeleton = GR2Options["x-flip-skeletons"], FlipMesh = GR2Options["x-flip-meshes"], TransformSkeletons = GR2Options["y-up-skeletons"], IgnoreUVNaN = GR2Options["ignore-uv-nan"] }; if (exporterOptions.ConformGR2Path != null) { if (GR2Options["conform-copy"]) { exporterOptions.ConformSkeletons = false; exporterOptions.ConformSkeletonsCopy = true; } } exporterOptions.LoadGameSettings(CommandLineActions.Game); return(exporterOptions); }
private void saveOutputBtn_Click(object sender, EventArgs e) { var exporter = new Exporter(); UpdateExporterSettings(exporter.Options); lastExporterSettings = exporter.Options; #if !DEBUG try { #endif exporter.Export(); MessageBox.Show("Export completed successfully."); #if !DEBUG } catch (Exception exc) { GR2ConversionError(exporter.Options.InputPath, exporter.Options.OutputPath, exc); } #endif }
private void UpdateExporterSettings(ExporterOptions settings) { UpdateCommonExporterSettings(settings); settings.InputPath = inputPath.Text; settings.InputFormat = Path.GetExtension(settings.InputPath)?.ToLower() == ".gr2" ? ExportFormat.GR2 : ExportFormat.DAE; settings.OutputPath = outputPath.Text; settings.OutputFormat = Path.GetExtension(settings.OutputPath)?.ToLower() == ".gr2" ? ExportFormat.GR2 : ExportFormat.DAE; foreach (ListViewItem setting in from object item in resourceFormats.Items select item as ListViewItem) { string name = setting.SubItems[0].Text; string type = setting.SubItems[1].Text; string value = setting.SubItems[2].Text; if (type == "Mesh" && value != "Automatic") { settings.VertexFormats.Add(name, value); } } }
public static ExporterOptions UpdateExporterSettings() { ExporterOptions exporterOptions = new ExporterOptions { InputPath = CommandLineActions.SourcePath, OutputPath = CommandLineActions.DestinationPath, InputFormat = CommandLineArguments.GetExportFormatByString(Program.argv.InputFormat), OutputFormat = CommandLineArguments.GetExportFormatByString(Program.argv.OutputFormat), ExportNormals = GR2Options["export-normals"], ExportTangents = GR2Options["export-tangents"], ExportUVs = GR2Options["export-uvs"], ExportColors = GR2Options["export-colors"], FlipUVs = GR2Options["flip-uvs"], RecalculateNormals = GR2Options["recalculate-normals"], RecalculateTangents = GR2Options["recalculate-tangents"], RecalculateIWT = GR2Options["recalculate-iwt"], BuildDummySkeleton = GR2Options["build-dummy-skeleton"], CompactIndices = GR2Options["compact-tris"], DeduplicateVertices = GR2Options["deduplicate-vertices"], DeduplicateUVs = GR2Options["deduplicate-uvs"], ApplyBasisTransforms = GR2Options["apply-basis-transforms"], UseObsoleteVersionTag = GR2Options["force-legacy-version"], ConformGR2Path = GR2Options["conform"] && !string.IsNullOrEmpty(CommandLineActions.ConformPath) ? CommandLineActions.ConformPath : null }; if (CommandLineActions.Game == Game.DivinityOriginalSin) { exporterOptions.Is64Bit = false; exporterOptions.AlternateSignature = false; exporterOptions.VersionTag = Header.Tag_DOS; } else { exporterOptions.Is64Bit = true; exporterOptions.AlternateSignature = true; exporterOptions.VersionTag = Header.Tag_DOSEE; } return(exporterOptions); }
/// <summary>Export the passed FHIR version into the specified directory.</summary> /// <param name="info"> The information.</param> /// <param name="serverInfo"> Information describing the server.</param> /// <param name="options"> Options for controlling the operation.</param> /// <param name="exportDirectory">Directory to write files.</param> void ILanguage.Export( FhirVersionInfo info, FhirServerInfo serverInfo, ExporterOptions options, string exportDirectory) { // set internal vars so we don't pass them to every function // this is ugly, but the interface patterns get bad quickly because we need the type map to copy the FHIR info _info = info; _options = options; Dictionary <string, CytoElement> elementDict = BuildNodes(); // create a filename for writing string filename = Path.Combine(exportDirectory, $"{_languageName}_R{info.MajorVersion}.json"); using (FileStream stream = new FileStream(filename, FileMode.Create)) using (StreamWriter writer = new StreamWriter(stream)) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(writer, elementDict.Values); } }
private void UpdateExporterSettings(ExporterOptions settings) { UpdateCommonExporterSettings(settings); settings.InputPath = inputPath.Text; if (settings.InputPath.Substring(settings.InputPath.Length - 4).ToLower() == ".gr2") { settings.InputFormat = ExportFormat.GR2; } else { settings.InputFormat = ExportFormat.DAE; } settings.OutputPath = outputPath.Text; if (settings.OutputPath.Substring(settings.OutputPath.Length - 4).ToLower() == ".gr2") { settings.OutputFormat = ExportFormat.GR2; } else { settings.OutputFormat = ExportFormat.DAE; } foreach (var item in resourceFormats.Items) { var setting = item as ListViewItem; var name = setting.SubItems[0].Text; var type = setting.SubItems[1].Text; var value = setting.SubItems[2].Text; if (type == "Mesh" && value != "Automatic") { settings.VertexFormats.Add(name, value); } } }
/// <summary>Export the passed FHIR version into the specified directory.</summary> /// <param name="info"> The information.</param> /// <param name="serverInfo"> Information describing the server.</param> /// <param name="options"> Options for controlling the operation.</param> /// <param name="exportDirectory">Directory to write files.</param> void ILanguage.Export( FhirVersionInfo info, FhirServerInfo serverInfo, ExporterOptions options, string exportDirectory) { // set internal vars so we don't pass them to every function // this is ugly, but the interface patterns get bad quickly because we need the type map to copy the FHIR info _info = info; _options = options; if (options.OptionalClassTypesToExport.Contains(ExporterOptions.FhirExportClassType.Enum)) { _exportEnums = true; } else { _exportEnums = false; } if ((options.LanguageOptions != null) && (options.LanguageOptions.Count > 0)) { foreach (KeyValuePair <string, string> kvp in options.LanguageOptions) { string key = kvp.Key.ToUpperInvariant(); switch (key) { case "NAMESPACE": _namespace = kvp.Value; break; } } } _exportedResourceNamesAndTypes = new Dictionary <string, string>(); _exportedCodes = new HashSet <string>(); // create a filename for writing (single file for now) string filename = Path.Combine(exportDirectory, $"R{info.MajorVersion}.cs"); using (FileStream stream = new FileStream(filename, FileMode.Create)) using (ExportStreamWriter writer = new ExportStreamWriter(stream)) { _writer = writer; WriteHeader(); // open namespace _writer.WriteLineIndented($"namespace {_namespace}"); _writer.WriteLineIndented("{"); _writer.IncreaseIndent(); WriteComplexes(_info.ComplexTypes.Values, false); WriteComplexes(_info.Resources.Values, true); if (_exportEnums) { WriteValueSets(_info.ValueSetsByUrl.Values); } WritePolymorphicHelpers(); // close namespace _writer.DecreaseIndent(); _writer.WriteLineIndented("}"); WriteFooter(); } }