Path: blob/master/editor/scene/3d/mesh_library_editor_plugin.h
9903 views
/**************************************************************************/1/* mesh_library_editor_plugin.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/plugins/editor_plugin.h"33#include "scene/resources/3d/mesh_library.h"3435class EditorFileDialog;36class ConfirmationDialog;37class MenuButton;38class MeshInstance3D;3940class MeshLibraryEditor : public Control {41GDCLASS(MeshLibraryEditor, Control);4243Ref<MeshLibrary> mesh_library;4445MenuButton *menu = nullptr;46ConfirmationDialog *cd_remove = nullptr;47ConfirmationDialog *cd_update = nullptr;48EditorFileDialog *file = nullptr;49bool apply_xforms = false;50int to_erase = 0;5152enum {53MENU_OPTION_ADD_ITEM,54MENU_OPTION_REMOVE_ITEM,55MENU_OPTION_UPDATE_FROM_SCENE,56MENU_OPTION_IMPORT_FROM_SCENE,57MENU_OPTION_IMPORT_FROM_SCENE_APPLY_XFORMS58};5960int option = 0;61void _import_scene_cbk(const String &p_str);62void _menu_cbk(int p_option);63void _menu_remove_confirm();64void _menu_update_confirm(bool p_apply_xforms);6566static void _import_scene(Node *p_scene, Ref<MeshLibrary> p_library, bool p_merge, bool p_apply_xforms);67static void _import_scene_parse_node(Ref<MeshLibrary> p_library, HashMap<int, MeshInstance3D *> &p_mesh_instances, Node *p_node, bool p_merge, bool p_apply_xforms);6869public:70MenuButton *get_menu_button() const { return menu; }7172void edit(const Ref<MeshLibrary> &p_mesh_library);73static Error update_library_file(Node *p_base_scene, Ref<MeshLibrary> ml, bool p_merge = true, bool p_apply_xforms = false);7475MeshLibraryEditor();76};7778class MeshLibraryEditorPlugin : public EditorPlugin {79GDCLASS(MeshLibraryEditorPlugin, EditorPlugin);8081MeshLibraryEditor *mesh_library_editor = nullptr;8283public:84virtual String get_plugin_name() const override { return "MeshLibrary"; }85bool has_main_screen() const override { return false; }86virtual void edit(Object *p_node) override;87virtual bool handles(Object *p_node) const override;88virtual void make_visible(bool p_visible) override;8990MeshLibraryEditorPlugin();91};929394