material_editor_plugin.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**************************************************************************/
  2. /* material_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 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. Vector2 rot = Vector2();
  44. ViewportContainer *vc;
  45. Viewport *viewport;
  46. Spatial *rotation;
  47. MeshInstance *sphere_instance;
  48. MeshInstance *box_instance;
  49. DirectionalLight *light1;
  50. DirectionalLight *light2;
  51. Camera *camera;
  52. Ref<SphereMesh> sphere_mesh;
  53. Ref<CubeMesh> box_mesh;
  54. TextureButton *sphere_switch;
  55. TextureButton *box_switch;
  56. TextureButton *light_1_switch;
  57. TextureButton *light_2_switch;
  58. Ref<Material> material;
  59. void _button_pressed(Node *p_button);
  60. bool first_enter;
  61. protected:
  62. void _notification(int p_what);
  63. void _gui_input(const Ref<InputEvent> &p_event);
  64. void _update_rotation();
  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);
  75. virtual void parse_begin(Object *p_object);
  76. EditorInspectorPluginMaterial();
  77. };
  78. class MaterialEditorPlugin : public EditorPlugin {
  79. GDCLASS(MaterialEditorPlugin, EditorPlugin);
  80. public:
  81. virtual String get_name() const { return "Material"; }
  82. MaterialEditorPlugin(EditorNode *p_node);
  83. };
  84. class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin {
  85. GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin);
  86. public:
  87. virtual String converts_to() const;
  88. virtual bool handles(const Ref<Resource> &p_resource) const;
  89. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
  90. };
  91. class ParticlesMaterialConversionPlugin : public EditorResourceConversionPlugin {
  92. GDCLASS(ParticlesMaterialConversionPlugin, EditorResourceConversionPlugin);
  93. public:
  94. virtual String converts_to() const;
  95. virtual bool handles(const Ref<Resource> &p_resource) const;
  96. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
  97. };
  98. class CanvasItemMaterialConversionPlugin : public EditorResourceConversionPlugin {
  99. GDCLASS(CanvasItemMaterialConversionPlugin, EditorResourceConversionPlugin);
  100. public:
  101. virtual String converts_to() const;
  102. virtual bool handles(const Ref<Resource> &p_resource) const;
  103. virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
  104. };
  105. #endif // MATERIAL_EDITOR_PLUGIN_H