mesh_editor_plugin.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**************************************************************************/
  2. /* mesh_editor_plugin.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 MESH_EDITOR_PLUGIN_H
  31. #define MESH_EDITOR_PLUGIN_H
  32. #include "editor/editor_inspector.h"
  33. #include "editor/plugins/editor_plugin.h"
  34. #include "scene/3d/camera_3d.h"
  35. #include "scene/3d/light_3d.h"
  36. #include "scene/3d/mesh_instance_3d.h"
  37. #include "scene/gui/subviewport_container.h"
  38. #include "scene/resources/camera_attributes.h"
  39. class SubViewport;
  40. class Button;
  41. class MeshEditor : public SubViewportContainer {
  42. GDCLASS(MeshEditor, SubViewportContainer);
  43. float rot_x;
  44. float rot_y;
  45. SubViewport *viewport = nullptr;
  46. MeshInstance3D *mesh_instance = nullptr;
  47. Node3D *rotation = nullptr;
  48. DirectionalLight3D *light1 = nullptr;
  49. DirectionalLight3D *light2 = nullptr;
  50. Camera3D *camera = nullptr;
  51. Ref<CameraAttributesPractical> camera_attributes;
  52. Ref<Mesh> mesh;
  53. Button *light_1_switch = nullptr;
  54. Button *light_2_switch = nullptr;
  55. struct ThemeCache {
  56. Ref<Texture2D> light_1_icon;
  57. Ref<Texture2D> light_2_icon;
  58. } theme_cache;
  59. void _on_light_1_switch_pressed();
  60. void _on_light_2_switch_pressed();
  61. void _update_rotation();
  62. protected:
  63. virtual void _update_theme_item_cache() override;
  64. void _notification(int p_what);
  65. void gui_input(const Ref<InputEvent> &p_event) override;
  66. public:
  67. void edit(Ref<Mesh> p_mesh);
  68. MeshEditor();
  69. };
  70. class EditorInspectorPluginMesh : public EditorInspectorPlugin {
  71. GDCLASS(EditorInspectorPluginMesh, EditorInspectorPlugin);
  72. public:
  73. virtual bool can_handle(Object *p_object) override;
  74. virtual void parse_begin(Object *p_object) override;
  75. };
  76. class MeshEditorPlugin : public EditorPlugin {
  77. GDCLASS(MeshEditorPlugin, EditorPlugin);
  78. public:
  79. virtual String get_plugin_name() const override { return "Mesh"; }
  80. MeshEditorPlugin();
  81. };
  82. #endif // MESH_EDITOR_PLUGIN_H