material_editor_plugin.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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/property_editor.h"
  33. #include "scene/resources/primitive_meshes.h"
  34. #include "editor/editor_node.h"
  35. #include "editor/editor_plugin.h"
  36. #include "scene/3d/camera.h"
  37. #include "scene/3d/light.h"
  38. #include "scene/3d/mesh_instance.h"
  39. #include "scene/resources/material.h"
  40. class ViewportContainer;
  41. class MaterialEditor : public Control {
  42. GDCLASS(MaterialEditor, Control);
  43. ViewportContainer *vc;
  44. Viewport *viewport;
  45. MeshInstance *sphere_instance;
  46. MeshInstance *box_instance;
  47. DirectionalLight *light1;
  48. DirectionalLight *light2;
  49. Camera *camera;
  50. Ref<SphereMesh> sphere_mesh;
  51. Ref<CubeMesh> box_mesh;
  52. TextureButton *sphere_switch;
  53. TextureButton *box_switch;
  54. TextureButton *light_1_switch;
  55. TextureButton *light_2_switch;
  56. Ref<Material> material;
  57. void _button_pressed(Node *p_button);
  58. bool first_enter;
  59. protected:
  60. void _notification(int p_what);
  61. static void _bind_methods();
  62. public:
  63. void edit(Ref<Material> p_material, const Ref<Environment> &p_env);
  64. MaterialEditor();
  65. };
  66. class EditorInspectorPluginMaterial : public EditorInspectorPlugin {
  67. GDCLASS(EditorInspectorPluginMaterial, EditorInspectorPlugin);
  68. Ref<Environment> env;
  69. public:
  70. virtual bool can_handle(Object *p_object);
  71. virtual void parse_begin(Object *p_object);
  72. EditorInspectorPluginMaterial();
  73. };
  74. class MaterialEditorPlugin : public EditorPlugin {
  75. GDCLASS(MaterialEditorPlugin, EditorPlugin);
  76. public:
  77. virtual String get_name() const { return "Material"; }
  78. MaterialEditorPlugin(EditorNode *p_node);
  79. };
  80. class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin {
  81. GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin);
  82. public:
  83. virtual String converts_to() const;
  84. virtual bool handles(const Ref<Resource> &p_resource) const;
  85. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
  86. };
  87. class ParticlesMaterialConversionPlugin : public EditorResourceConversionPlugin {
  88. GDCLASS(ParticlesMaterialConversionPlugin, EditorResourceConversionPlugin);
  89. public:
  90. virtual String converts_to() const;
  91. virtual bool handles(const Ref<Resource> &p_resource) const;
  92. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
  93. };
  94. class CanvasItemMaterialConversionPlugin : public EditorResourceConversionPlugin {
  95. GDCLASS(CanvasItemMaterialConversionPlugin, EditorResourceConversionPlugin);
  96. public:
  97. virtual String converts_to() const;
  98. virtual bool handles(const Ref<Resource> &p_resource) const;
  99. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
  100. };
  101. #endif // MATERIAL_EDITOR_PLUGIN_H