material_editor_plugin.h 4.7 KB

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