Exemplo n.º 1
0
void TextureCollectionItem::slot_import_textures()
{
    const QStringList filepaths =
        get_open_filenames(
            treeWidget(),
            "Import Textures...",
            g_bitmap_files_filter,
            m_editor_context.m_settings,
            SETTINGS_FILE_DIALOG_PROJECTS);

    if (filepaths.empty())
        return;

    const filesystem::path path(
        QDir::toNativeSeparators(filepaths.first()).toStdString());

    // todo: schedule creation of texture and texture instances when rendering.
    for (int i = 0; i < filepaths.size(); ++i)
    {
        const string filepath = QDir::toNativeSeparators(filepaths[i]).toStdString();

        auto_release_ptr<Texture> texture = create_texture(filepath);
        auto_release_ptr<TextureInstance> texture_instance = create_texture_instance(texture->get_name());

        m_parent_item->add_item(texture.get());
        m_parent_item->add_item(texture_instance.get());

        m_parent.textures().insert(texture);
        m_parent.texture_instances().insert(texture_instance);

    }

    m_editor_context.m_project_builder.notify_project_modification();
}
void ObjectCollectionItem::slot_import_objects()
{
    const QStringList filepaths =
        get_open_filenames(
            treeWidget(),
            "Import Objects...",
            "Geometry Files (*.binarymesh *.obj);;All Files (*.*)",
            m_editor_context.m_settings,
            SETTINGS_FILE_DIALOG_PROJECTS);

    if (filepaths.empty())
        return;

    m_editor_context.m_rendering_manager.schedule_or_execute(
        unique_ptr<RenderingManager::IScheduledAction>(
            new ImportObjectsAction(this, filepaths)));
}