Exemple #1
0
int main(int argc, const char* argv[])
{
    SuperLogger logger;
    Application::check_installation(logger);

    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    // Initialize the renderer's logger.
    global_logger().add_target(&logger.get_log_target());

    // Retrieve the input file path.
    const string& input_filepath = cl.m_filename.value();

    // Construct the schema file path.
    const filesystem::path schema_filepath =
          filesystem::path(Application::get_root_path())
        / "schemas"
        / "project.xsd";

    // Read the input project from disk.
    // Note: it is crucial that we read mesh files as well, so that we can collect
    // material slots declared by objects. Material slots are required by the project
    // file updater, for instance when migrating projects from rev. 7 to rev. 8.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            input_filepath.c_str(),
            schema_filepath.string().c_str(),
            ProjectFileReader::OmitProjectFileUpdate));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Update the project file to the desired revision.
    ProjectFileUpdater updater;
    if (cl.m_to_revision.is_set())
        updater.update(project.ref(), cl.m_to_revision.value());
    else updater.update(project.ref());

    // Write the project back to disk.
    const bool success =
        ProjectFileWriter::write(
            project.ref(),
            project->get_path(),
            ProjectFileWriter::OmitWritingGeometryFiles | ProjectFileWriter::OmitBringingAssets);

    return success ? 0 : 1;
}
int main(int argc, const char* argv[])
{
    SuperLogger logger;

    Application::check_installation(logger);

    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    global_logger().add_target(&logger.get_log_target());

    // Retrieve the input file path.
    const string& input_filepath = cl.m_filename.values()[0];

    // Construct the schema file path.
    const string schema_filepath =
        (filesystem::path(Application::get_root_path())
        / "schemas" / "project.xsd").string();

    // Load the input project from disk.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            input_filepath.c_str(),
            schema_filepath.c_str(),
            ProjectFileReader::OmitReadingMeshFiles | ProjectFileReader::OmitProjectFileUpdate));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Update the project file to the desired revision.
    ProjectFileUpdater updater;
    if (cl.m_to_revision.is_set())
        updater.update(project.ref(), cl.m_to_revision.values()[0]);
    else updater.update(project.ref());

    // Write the project back to disk.
    const bool success =
        ProjectFileWriter::write(
            project.ref(),
            project->get_path(),
            ProjectFileWriter::OmitWritingMeshFiles | ProjectFileWriter::OmitCopyingAssets);

    return success ? 0 : 1;
}
Exemple #3
0
int main(int argc, const char* argv[])
{
    // Initialize the logger that will be used throughout the program.
    SuperLogger logger;

    // Make sure appleseed is correctly installed.
    Application::check_installation(logger);

    // Parse the command line.
    CommandLineHandler cl;
    cl.parse(argc, argv, logger);

    // Load an apply settings from the settings file.
    Dictionary settings;
    Application::load_settings("appleseed.tools.xml", settings, logger);
    logger.configure_from_settings(settings);

    // Apply command line arguments.
    cl.apply(logger);

    // Configure the renderer's global logger.
    // Must be done after settings have been loaded and the command line
    // has been parsed, because these two operations may replace the log
    // target of the global logger.
    global_logger().initialize_from(logger);

    // Retrieve the input file path.
    const string& input_filepath = cl.m_filename.value();

    // Construct the schema file path.
    const bf::path schema_filepath =
          bf::path(Application::get_root_path())
        / "schemas"
        / "project.xsd";

    // Read the input project from disk.
    // Note: it is crucial that we read mesh files as well, so that we can collect
    // material slots declared by objects. Material slots are required by the project
    // file updater, for instance when migrating projects from rev. 7 to rev. 8.
    ProjectFileReader reader;
    auto_release_ptr<Project> project(
        reader.read(
            input_filepath.c_str(),
            schema_filepath.string().c_str(),
            ProjectFileReader::OmitProjectFileUpdate));

    // Bail out if the project couldn't be loaded.
    if (project.get() == 0)
        return 1;

    // Update the project file to the desired revision.
    ProjectFileUpdater updater;
    if (cl.m_to_revision.is_set())
        updater.update(project.ref(), cl.m_to_revision.value());
    else updater.update(project.ref());

    // Write the project back to disk.
    const bool success =
        ProjectFileWriter::write(
            project.ref(),
            project->get_path(),
            ProjectFileWriter::OmitWritingGeometryFiles | ProjectFileWriter::OmitHandlingAssetFiles);

    return success ? 0 : 1;
}