1 /*************************************************************************/
2 /*  path_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 PATH_EDITOR_PLUGIN_H
31 #define PATH_EDITOR_PLUGIN_H
32 
33 #include "editor/spatial_editor_gizmos.h"
34 #include "scene/3d/path.h"
35 class PathSpatialGizmo : public EditorSpatialGizmo {
36 
37 	OBJ_TYPE(PathSpatialGizmo, EditorSpatialGizmo);
38 
39 	Path *path;
40 	mutable Vector3 original;
41 
42 public:
43 	virtual String get_handle_name(int p_idx) const;
44 	virtual Variant get_handle_value(int p_idx) const;
45 	virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
46 	virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
47 
48 	void redraw();
49 	PathSpatialGizmo(Path *p_path = NULL);
50 };
51 
52 class PathEditorPlugin : public EditorPlugin {
53 
54 	OBJ_TYPE(PathEditorPlugin, EditorPlugin);
55 
56 	Separator *sep;
57 	ToolButton *curve_create;
58 	ToolButton *curve_edit;
59 	ToolButton *curve_del;
60 	ToolButton *curve_close;
61 
62 	EditorNode *editor;
63 
64 	Path *path;
65 
66 	void _mode_changed(int p_idx);
67 	void _close_curve();
68 
69 protected:
70 	void _notification(int p_what);
71 	static void _bind_methods();
72 
73 public:
get_edited_path()74 	Path *get_edited_path() { return path; }
75 
76 	static PathEditorPlugin *singleton;
77 	Ref<FixedMaterial> path_material;
78 	Ref<FixedMaterial> path_thin_material;
79 	virtual bool forward_spatial_input_event(Camera *p_camera, const InputEvent &p_event);
80 
81 	//	virtual bool forward_input_event(const InputEvent& p_event) { return collision_polygon_editor->forward_input_event(p_event); }
82 	virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial);
get_name()83 	virtual String get_name() const { return "Path"; }
has_main_screen()84 	bool has_main_screen() const { return false; }
85 	virtual void edit(Object *p_node);
86 	virtual bool handles(Object *p_node) const;
87 	virtual void make_visible(bool p_visible);
88 
89 	PathEditorPlugin(EditorNode *p_node);
90 	~PathEditorPlugin();
91 };
92 
93 #endif // PATH_EDITOR_PLUGIN_H
94