auto_release_ptr<MeshObject> create_primitive_mesh(const char* name, const ParamArray& params) { const char* primitive_type = params.get("primitive"); // Parametric surfaces. if (strcmp(primitive_type, "grid") == 0) return create_parametric_surface<ParametricGrid>(name, params); if (strcmp(primitive_type, "disk") == 0) return create_parametric_surface<ParametricDisk>(name, params); if (strcmp(primitive_type, "sphere") == 0) return create_parametric_surface<ParametricSphere>(name, params); if (strcmp(primitive_type, "torus") == 0) return create_parametric_surface<ParametricTorus>(name, params); // Other, non-parametric primitives. if (strcmp(primitive_type, "cube") == 0) return create_cube(name, params); RENDERER_LOG_ERROR("unknown primitive type: %s", primitive_type); return auto_release_ptr<MeshObject>(); }
void MaterialCollectionItem::slot_import_disney() { #ifdef APPLESEED_WITH_DISNEY_MATERIAL QString filepath = get_open_filename( 0, "Import...", "Disney Material (*.dmt);;All Files (*.*)", m_editor_context.m_settings, SETTINGS_FILE_DIALOG_PROJECTS); if (!filepath.isEmpty()) { filepath = QDir::toNativeSeparators(filepath); const bf::path root_path(Application::get_root_path()); const bf::path schema_file_path = root_path / "schemas" / "settings.xsd"; SettingsFileReader reader(global_logger()); ParamArray parameters; const bool success = reader.read( filepath.toStdString().c_str(), schema_file_path.string().c_str(), parameters); if (!success) { show_error_message_box( "Importing Error", "Failed to import the Disney Material file " + filepath.toStdString()); return; } string name = parameters.get("__name"); const string model = parameters.get("__model"); parameters.strings().remove("__name"); parameters.strings().remove("__model"); if (model != "disney_material") { show_error_message_box( "Importing Error", "Material model " + model + " is not supported."); return; } // If there is already a material with the same name, rename the imported material. for (const_each<MaterialContainer> i = m_parent.materials(); i; ++i) { if (strcmp(i->get_name(), name.c_str()) == 0) { name = make_unique_name(name, m_parent.materials()); break; } } auto_release_ptr<Material> material = DisneyMaterialFactory().create(name.c_str(), parameters); Material* material_ptr = material.get(); add_item(material_ptr); EntityTraits<Material>::insert_entity(material, m_parent); m_editor_context.m_project_builder.notify_project_modification(); m_editor_context.m_project_explorer.select_entity(material_ptr->get_uid()); } #endif }