1 #ifndef MATERIAL_EDITOR_PLUGIN_H
2 #define MATERIAL_EDITOR_PLUGIN_H
3 
4 #include "editor/editor_node.h"
5 #include "editor/editor_plugin.h"
6 #include "scene/3d/camera.h"
7 #include "scene/3d/light.h"
8 #include "scene/3d/mesh_instance.h"
9 #include "scene/resources/material.h"
10 
11 class MaterialEditor : public Control {
12 
13 	OBJ_TYPE(MaterialEditor, Control);
14 
15 	Viewport *viewport;
16 	MeshInstance *sphere_instance;
17 	MeshInstance *box_instance;
18 	DirectionalLight *light1;
19 	DirectionalLight *light2;
20 	Camera *camera;
21 
22 	Ref<Mesh> sphere_mesh;
23 	Ref<Mesh> box_mesh;
24 
25 	TextureButton *sphere_switch;
26 	TextureButton *box_switch;
27 
28 	TextureButton *light_1_switch;
29 	TextureButton *light_2_switch;
30 
31 	Ref<Material> material;
32 
33 	void _button_pressed(Node *p_button);
34 	bool first_enter;
35 
36 protected:
37 	void _notification(int p_what);
38 	void _input_event(InputEvent p_event);
39 	static void _bind_methods();
40 
41 public:
42 	void edit(Ref<Material> p_material);
43 	MaterialEditor();
44 };
45 
46 class MaterialEditorPlugin : public EditorPlugin {
47 
48 	OBJ_TYPE(MaterialEditorPlugin, EditorPlugin);
49 
50 	MaterialEditor *material_editor;
51 	EditorNode *editor;
52 
53 public:
get_name()54 	virtual String get_name() const { return "Material"; }
has_main_screen()55 	bool has_main_screen() const { return false; }
56 	virtual void edit(Object *p_node);
57 	virtual bool handles(Object *p_node) const;
58 	virtual void make_visible(bool p_visible);
59 
60 	MaterialEditorPlugin(EditorNode *p_node);
61 	~MaterialEditorPlugin();
62 };
63 
64 #endif // MATERIAL_EDITOR_PLUGIN_H
65