void MaterialItem::slot_export() { const char* project_path = m_editor_context.m_project.get_path(); const filesystem::path project_root_path = filesystem::path(project_path).parent_path(); const filesystem::path file_path = absolute("material.dmt", project_root_path); const filesystem::path file_root_path = file_path.parent_path(); QString filepath = get_save_filename( 0, "Export...", "Disney Materials (*.dmt)", m_editor_context.m_settings, SETTINGS_FILE_DIALOG_PROJECTS); if (!filepath.isEmpty()) { if (QFileInfo(filepath).suffix().isEmpty()) filepath += ".dmt"; filepath = QDir::toNativeSeparators(filepath); ParamArray parameters = m_entity->get_parameters(); parameters.insert("__name", m_entity->get_name()); parameters.insert("__model", m_entity->get_model()); SettingsFileWriter writer; if (!writer.write(filepath.toStdString().c_str(), parameters)) { show_error_message_box( "Exporting Error", "Failed to export the Disney Material file " + filepath.toStdString() + "."); } } }
void TestFixtureBase::create_color_entity(const char* name, const Spectrum& spectrum) { ParamArray params; params.insert("color_space", "spectral"); params.insert("wavelength_range", "400.0 700.0"); const ColorValueArray values(spectrum.Samples, &spectrum[0]); m_scene.colors().insert( ColorEntityFactory::create(name, params, values)); }
void TestFixtureBase::create_texture_instance(const char* name, const char* texture_name) { ParamArray params; params.insert("addressing_mode", "clamp"); params.insert("filtering_mode", "bilinear"); m_scene.texture_instances().insert( TextureInstanceFactory::create( name, params, texture_name, Transformf::identity())); }
void TestFixtureBase::create_color_entity(const char* name, const Color3f& linear_rgb) { ParamArray params; params.insert("color_space", "linear_rgb"); const ColorValueArray values(3, &linear_rgb[0]); m_scene.colors().insert( ColorEntityFactory::create(name, params, values)); }
void ObjectCollectionItem::insert_objects(const string& path) const { const string base_object_name = bf::path(path).replace_extension().filename().string(); ParamArray params; params.insert("filename", path); SearchPaths search_paths; MeshObjectArray mesh_objects; if (!MeshObjectReader().read( search_paths, base_object_name.c_str(), params, mesh_objects)) return; for (size_t i = 0; i < mesh_objects.size(); ++i) { MeshObject* object = mesh_objects[i]; m_parent_item->add_item(object); m_parent.objects().insert(auto_release_ptr<Object>(object)); const string object_instance_name = string(object->get_name()) + "_inst"; auto_release_ptr<ObjectInstance> object_instance( ObjectInstanceFactory::create( object_instance_name.c_str(), ParamArray(), object->get_name(), Transformd::identity(), StringDictionary())); m_parent_item->add_item(object_instance.get()); m_parent.object_instances().insert(object_instance); } if (!mesh_objects.empty()) { m_parent.bump_version_id(); m_editor_context.m_project_builder.slot_notify_project_modification(); } }
// Create a new instance of the default project. auto_release_ptr<Project> DefaultProjectFactory::create() { // Create a project. auto_release_ptr<Project> project(ProjectFactory::create("default")); // Add default configurations to the project. project->add_default_configurations(); // Create a scene. auto_release_ptr<Scene> scene(SceneFactory::create()); // Create an assembly. auto_release_ptr<Assembly> assembly( AssemblyFactory::create("assembly", ParamArray())); // Create an instance of the assembly and insert it into the scene. scene->assembly_instances().insert( AssemblyInstanceFactory::create( "assembly_inst", ParamArray(), *assembly, Transformd(Matrix4d::identity()))); // Insert the assembly into the scene. scene->assemblies().insert(assembly); // // Camera. // { // Create a pinhole camera. // Film dimensions are 0.980 in × 0.735 in (24.892 mm x 18.669 mm). // Reference: http://en.wikipedia.org/wiki/Aspect_ratio_(image). ParamArray params; params.insert("film_dimensions", "0.024892 0.018669"); params.insert("focal_length", "0.035"); auto_release_ptr<Camera> camera( PinholeCameraFactory().create("camera", params)); // Attach the camera to the scene. scene->set_camera(camera); } // // Frame. // { // Create a frame. ParamArray params; params.insert("camera", scene->get_camera()->get_name()); params.insert("resolution", "640 480"); params.insert("color_space", "srgb"); auto_release_ptr<Frame> frame(FrameFactory::create("beauty", params)); // Attach the frame to the project. project->set_frame(frame); } // Attach the scene to the project. project->set_scene(scene); // Return the newly created project. return project; }