material_editor_plugin.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*************************************************************************/
  2. /* material_editor_plugin.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 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 MATERIAL_EDITOR_PLUGIN_H
  31. #define MATERIAL_EDITOR_PLUGIN_H
  32. #include "editor/editor_plugin.h"
  33. #include "editor/plugins/editor_resource_conversion_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/color_rect.h"
  38. #include "scene/resources/material.h"
  39. #include "scene/resources/primitive_meshes.h"
  40. class SubViewportContainer;
  41. class MaterialEditor : public Control {
  42. GDCLASS(MaterialEditor, Control);
  43. HBoxContainer *layout_2d = nullptr;
  44. ColorRect *rect_instance = nullptr;
  45. SubViewportContainer *vc = nullptr;
  46. SubViewport *viewport = nullptr;
  47. MeshInstance3D *sphere_instance = nullptr;
  48. MeshInstance3D *box_instance = nullptr;
  49. DirectionalLight3D *light1 = nullptr;
  50. DirectionalLight3D *light2 = nullptr;
  51. Camera3D *camera = nullptr;
  52. Ref<CameraAttributesPractical> camera_attributes;
  53. Ref<SphereMesh> sphere_mesh;
  54. Ref<BoxMesh> box_mesh;
  55. HBoxContainer *layout_3d = nullptr;
  56. TextureButton *sphere_switch = nullptr;
  57. TextureButton *box_switch = nullptr;
  58. TextureButton *light_1_switch = nullptr;
  59. TextureButton *light_2_switch = nullptr;
  60. Ref<Material> material;
  61. void _button_pressed(Node *p_button);
  62. bool first_enter;
  63. protected:
  64. void _notification(int p_what);
  65. static void _bind_methods();
  66. public:
  67. void edit(Ref<Material> p_material, const Ref<Environment> &p_env);
  68. MaterialEditor();
  69. };
  70. class EditorInspectorPluginMaterial : public EditorInspectorPlugin {
  71. GDCLASS(EditorInspectorPluginMaterial, EditorInspectorPlugin);
  72. Ref<Environment> env;
  73. public:
  74. virtual bool can_handle(Object *p_object) override;
  75. virtual void parse_begin(Object *p_object) override;
  76. void _undo_redo_inspector_callback(Object *p_undo_redo, Object *p_edited, String p_property, Variant p_new_value);
  77. EditorInspectorPluginMaterial();
  78. };
  79. class MaterialEditorPlugin : public EditorPlugin {
  80. GDCLASS(MaterialEditorPlugin, EditorPlugin);
  81. public:
  82. virtual String get_name() const override { return "Material"; }
  83. MaterialEditorPlugin();
  84. };
  85. class StandardMaterial3DConversionPlugin : public EditorResourceConversionPlugin {
  86. GDCLASS(StandardMaterial3DConversionPlugin, EditorResourceConversionPlugin);
  87. public:
  88. virtual String converts_to() const override;
  89. virtual bool handles(const Ref<Resource> &p_resource) const override;
  90. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  91. };
  92. class ORMMaterial3DConversionPlugin : public EditorResourceConversionPlugin {
  93. GDCLASS(ORMMaterial3DConversionPlugin, EditorResourceConversionPlugin);
  94. public:
  95. virtual String converts_to() const override;
  96. virtual bool handles(const Ref<Resource> &p_resource) const override;
  97. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  98. };
  99. class ParticleProcessMaterialConversionPlugin : public EditorResourceConversionPlugin {
  100. GDCLASS(ParticleProcessMaterialConversionPlugin, EditorResourceConversionPlugin);
  101. public:
  102. virtual String converts_to() const override;
  103. virtual bool handles(const Ref<Resource> &p_resource) const override;
  104. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  105. };
  106. class CanvasItemMaterialConversionPlugin : public EditorResourceConversionPlugin {
  107. GDCLASS(CanvasItemMaterialConversionPlugin, EditorResourceConversionPlugin);
  108. public:
  109. virtual String converts_to() const override;
  110. virtual bool handles(const Ref<Resource> &p_resource) const override;
  111. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  112. };
  113. class ProceduralSkyMaterialConversionPlugin : public EditorResourceConversionPlugin {
  114. GDCLASS(ProceduralSkyMaterialConversionPlugin, EditorResourceConversionPlugin);
  115. public:
  116. virtual String converts_to() const override;
  117. virtual bool handles(const Ref<Resource> &p_resource) const override;
  118. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  119. };
  120. class PanoramaSkyMaterialConversionPlugin : public EditorResourceConversionPlugin {
  121. GDCLASS(PanoramaSkyMaterialConversionPlugin, EditorResourceConversionPlugin);
  122. public:
  123. virtual String converts_to() const override;
  124. virtual bool handles(const Ref<Resource> &p_resource) const override;
  125. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  126. };
  127. class PhysicalSkyMaterialConversionPlugin : public EditorResourceConversionPlugin {
  128. GDCLASS(PhysicalSkyMaterialConversionPlugin, EditorResourceConversionPlugin);
  129. public:
  130. virtual String converts_to() const override;
  131. virtual bool handles(const Ref<Resource> &p_resource) const override;
  132. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  133. };
  134. class FogMaterialConversionPlugin : public EditorResourceConversionPlugin {
  135. GDCLASS(FogMaterialConversionPlugin, EditorResourceConversionPlugin);
  136. public:
  137. virtual String converts_to() const override;
  138. virtual bool handles(const Ref<Resource> &p_resource) const override;
  139. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const override;
  140. };
  141. #endif // MATERIAL_EDITOR_PLUGIN_H