1 /*************************************************************************/ 2 /* baked_light_editor_plugin.h */ 3 /*************************************************************************/ 4 /* This file is part of: */ 5 /* GODOT ENGINE */ 6 /* https://godotengine.org */ 7 /*************************************************************************/ 8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ 9 /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ 10 /* */ 11 /* Permission is hereby granted, free of charge, to any person obtaining */ 12 /* a copy of this software and associated documentation files (the */ 13 /* "Software"), to deal in the Software without restriction, including */ 14 /* without limitation the rights to use, copy, modify, merge, publish, */ 15 /* distribute, sublicense, and/or sell copies of the Software, and to */ 16 /* permit persons to whom the Software is furnished to do so, subject to */ 17 /* the following conditions: */ 18 /* */ 19 /* The above copyright notice and this permission notice shall be */ 20 /* included in all copies or substantial portions of the Software. */ 21 /* */ 22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ 23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ 24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ 25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ 26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ 27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ 28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 29 /*************************************************************************/ 30 #ifndef BAKED_LIGHT_EDITOR_PLUGIN_H 31 #define BAKED_LIGHT_EDITOR_PLUGIN_H 32 33 #include "editor/editor_node.h" 34 #include "editor/editor_plugin.h" 35 #include "editor/plugins/baked_light_baker.h" 36 #include "scene/gui/spin_box.h" 37 38 /** 39 @author Juan Linietsky <reduzio@gmail.com> 40 */ 41 42 class MeshInstance; 43 44 class BakedLightEditor : public Control { 45 46 OBJ_TYPE(BakedLightEditor, Control); 47 48 float update_timeout; 49 DVector<uint8_t> octree_texture; 50 DVector<uint8_t> light_texture; 51 DVector<int> octree_sampler; 52 53 BakedLightBaker *baker; 54 AcceptDialog *err_dialog; 55 56 HBoxContainer *bake_hbox; 57 Button *button_bake; 58 Button *button_reset; 59 Button *button_make_lightmaps; 60 Label *bake_info; 61 62 uint64_t last_rays_time; 63 64 BakedLightInstance *node; 65 66 enum Menu { 67 68 MENU_OPTION_BAKE, 69 MENU_OPTION_CLEAR 70 }; 71 72 void _bake_lightmaps(); 73 74 void _bake_pressed(); 75 void _clear_pressed(); 76 77 void _end_baking(); 78 void _menu_option(int); 79 80 friend class BakedLightEditorPlugin; 81 82 protected: 83 void _node_removed(Node *p_node); 84 static void _bind_methods(); 85 void _notification(int p_what); 86 87 public: 88 void edit(BakedLightInstance *p_baked_light); 89 BakedLightEditor(); 90 ~BakedLightEditor(); 91 }; 92 93 class BakedLightEditorPlugin : public EditorPlugin { 94 95 OBJ_TYPE(BakedLightEditorPlugin, EditorPlugin); 96 97 BakedLightEditor *baked_light_editor; 98 EditorNode *editor; 99 100 public: get_name()101 virtual String get_name() const { return "BakedLight"; } has_main_screen()102 bool has_main_screen() const { return false; } 103 virtual void edit(Object *p_node); 104 virtual bool handles(Object *p_node) const; 105 virtual void make_visible(bool p_visible); 106 107 BakedLightEditorPlugin(EditorNode *p_node); 108 ~BakedLightEditorPlugin(); 109 }; 110 111 #endif // MULTIMESH_EDITOR_PLUGIN_H 112