2014-02-10 09:10:30 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* spatial_editor_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-02 05:01:57 +08:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 06:11:42 +08:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2014-02-10 09:10:30 +08:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#ifndef SPATIAL_EDITOR_PLUGIN_H
|
|
|
|
#define SPATIAL_EDITOR_PLUGIN_H
|
|
|
|
|
2017-03-05 21:21:25 +08:00
|
|
|
#include "editor/editor_node.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "editor/editor_plugin.h"
|
2014-10-12 13:13:22 +08:00
|
|
|
#include "scene/3d/immediate_geometry.h"
|
|
|
|
#include "scene/3d/light.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "scene/3d/visual_instance.h"
|
2014-02-10 09:10:30 +08:00
|
|
|
#include "scene/gui/panel_container.h"
|
|
|
|
/**
|
|
|
|
@author Juan Linietsky <reduzio@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
class Camera;
|
|
|
|
class SpatialEditor;
|
|
|
|
class SpatialEditorGizmos;
|
|
|
|
|
|
|
|
class SpatialEditorGizmo : public SpatialGizmo {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(SpatialEditorGizmo, SpatialGizmo);
|
2014-05-05 09:50:23 +08:00
|
|
|
|
|
|
|
bool selected;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
|
|
|
void set_selected(bool p_selected) { selected = p_selected; }
|
2014-05-05 09:50:23 +08:00
|
|
|
bool is_selected() const { return selected; }
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
virtual String get_handle_name(int p_idx) const;
|
|
|
|
virtual Variant get_handle_value(int p_idx) const;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
|
|
|
|
virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum);
|
|
|
|
virtual bool intersect_ray(const Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false);
|
2014-02-10 09:10:30 +08:00
|
|
|
SpatialEditorGizmo();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SpatialEditorViewport : public Control {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(SpatialEditorViewport, Control);
|
|
|
|
friend class SpatialEditor;
|
2014-02-10 09:10:30 +08:00
|
|
|
enum {
|
|
|
|
|
|
|
|
VIEW_TOP,
|
|
|
|
VIEW_BOTTOM,
|
|
|
|
VIEW_LEFT,
|
|
|
|
VIEW_RIGHT,
|
|
|
|
VIEW_FRONT,
|
|
|
|
VIEW_REAR,
|
2016-10-05 02:39:38 +08:00
|
|
|
VIEW_CENTER_TO_ORIGIN,
|
2014-02-10 09:10:30 +08:00
|
|
|
VIEW_CENTER_TO_SELECTION,
|
2014-03-31 23:06:36 +08:00
|
|
|
VIEW_ALIGN_SELECTION_WITH_VIEW,
|
2014-02-10 09:10:30 +08:00
|
|
|
VIEW_PERSPECTIVE,
|
|
|
|
VIEW_ENVIRONMENT,
|
2014-10-03 11:10:51 +08:00
|
|
|
VIEW_ORTHOGONAL,
|
|
|
|
VIEW_AUDIO_LISTENER,
|
2014-10-12 13:13:22 +08:00
|
|
|
VIEW_GIZMOS,
|
2014-02-10 09:10:30 +08:00
|
|
|
};
|
2017-03-05 23:44:50 +08:00
|
|
|
|
2014-10-12 13:13:22 +08:00
|
|
|
public:
|
2014-05-05 09:50:23 +08:00
|
|
|
enum {
|
2017-03-05 23:44:50 +08:00
|
|
|
GIZMO_BASE_LAYER = 27,
|
|
|
|
GIZMO_EDIT_LAYER = 26,
|
|
|
|
GIZMO_GRID_LAYER = 25
|
2014-05-05 09:50:23 +08:00
|
|
|
};
|
2017-03-05 23:44:50 +08:00
|
|
|
|
2014-10-12 13:13:22 +08:00
|
|
|
private:
|
2014-05-05 09:50:23 +08:00
|
|
|
int index;
|
2015-03-22 04:47:21 +08:00
|
|
|
String name;
|
2014-02-10 09:10:30 +08:00
|
|
|
void _menu_option(int p_option);
|
2014-05-05 09:50:23 +08:00
|
|
|
Size2 prev_size;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
EditorNode *editor;
|
|
|
|
EditorSelection *editor_selection;
|
|
|
|
UndoRedo *undo_redo;
|
|
|
|
|
|
|
|
Button *preview_camera;
|
|
|
|
|
|
|
|
MenuButton *view_menu;
|
|
|
|
|
|
|
|
Control *surface;
|
|
|
|
Viewport *viewport;
|
|
|
|
Camera *camera;
|
|
|
|
bool transforming;
|
|
|
|
bool orthogonal;
|
2014-05-05 09:50:23 +08:00
|
|
|
float gizmo_scale;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2015-11-05 05:39:07 +08:00
|
|
|
struct _RayResult {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Spatial *item;
|
2015-11-05 05:39:07 +08:00
|
|
|
float depth;
|
|
|
|
int handle;
|
2017-03-05 23:44:50 +08:00
|
|
|
_FORCE_INLINE_ bool operator<(const _RayResult &p_rr) const { return depth < p_rr.depth; }
|
2015-11-05 05:39:07 +08:00
|
|
|
};
|
|
|
|
|
2015-03-22 04:47:21 +08:00
|
|
|
void _update_name();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _compute_edit(const Point2 &p_point);
|
2014-02-10 09:10:30 +08:00
|
|
|
void _clear_selected();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _select_clicked(bool p_append, bool p_single);
|
|
|
|
void _select(Spatial *p_node, bool p_append, bool p_single);
|
|
|
|
ObjectID _select_ray(const Point2 &p_pos, bool p_append, bool &r_includes_current, int *r_gizmo_handle = NULL, bool p_alt_select = false);
|
|
|
|
void _find_items_at_pos(const Point2 &p_pos, bool &r_includes_current, Vector<_RayResult> &results, bool p_alt_select = false);
|
|
|
|
Vector3 _get_ray_pos(const Vector2 &p_pos) const;
|
|
|
|
Vector3 _get_ray(const Vector2 &p_pos);
|
|
|
|
Point2 _point_to_screen(const Vector3 &p_point);
|
2014-02-10 09:10:30 +08:00
|
|
|
Transform _get_camera_transform() const;
|
|
|
|
int get_selected_count() const;
|
|
|
|
|
|
|
|
Vector3 _get_camera_pos() const;
|
|
|
|
Vector3 _get_camera_normal() const;
|
2017-03-05 23:44:50 +08:00
|
|
|
Vector3 _get_screen_to_space(const Vector3 &p_vector3);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
void _select_region();
|
2017-03-05 23:44:50 +08:00
|
|
|
bool _gizmo_select(const Vector2 &p_screenpos, bool p_hilite_only = false);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
float get_znear() const;
|
|
|
|
float get_zfar() const;
|
|
|
|
float get_fov() const;
|
|
|
|
|
|
|
|
ObjectID clicked;
|
2015-11-05 05:39:07 +08:00
|
|
|
Vector<_RayResult> selection_results;
|
2014-02-10 09:10:30 +08:00
|
|
|
bool clicked_includes_current;
|
|
|
|
bool clicked_wants_append;
|
|
|
|
|
2015-11-05 05:39:07 +08:00
|
|
|
PopupMenu *selection_menu;
|
|
|
|
|
2014-03-31 11:07:21 +08:00
|
|
|
enum NavigationScheme {
|
|
|
|
NAVIGATION_GODOT,
|
2014-03-31 15:52:27 +08:00
|
|
|
NAVIGATION_MAYA,
|
|
|
|
NAVIGATION_MODO,
|
2014-03-31 11:07:21 +08:00
|
|
|
};
|
|
|
|
|
2014-12-28 21:01:08 +08:00
|
|
|
enum NavigationZoomStyle {
|
|
|
|
NAVIGATION_ZOOM_VERTICAL,
|
|
|
|
NAVIGATION_ZOOM_HORIZONTAL
|
|
|
|
};
|
|
|
|
|
2014-03-31 11:07:21 +08:00
|
|
|
enum NavigationMode {
|
|
|
|
NAVIGATION_NONE,
|
|
|
|
NAVIGATION_PAN,
|
|
|
|
NAVIGATION_ZOOM,
|
|
|
|
NAVIGATION_ORBIT
|
|
|
|
};
|
2014-02-10 09:10:30 +08:00
|
|
|
enum TransformMode {
|
|
|
|
TRANSFORM_NONE,
|
|
|
|
TRANSFORM_ROTATE,
|
|
|
|
TRANSFORM_TRANSLATE,
|
|
|
|
TRANSFORM_SCALE
|
|
|
|
|
|
|
|
};
|
|
|
|
enum TransformPlane {
|
|
|
|
TRANSFORM_VIEW,
|
|
|
|
TRANSFORM_X_AXIS,
|
|
|
|
TRANSFORM_Y_AXIS,
|
|
|
|
TRANSFORM_Z_AXIS,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EditData {
|
|
|
|
TransformMode mode;
|
|
|
|
TransformPlane plane;
|
|
|
|
Transform original;
|
|
|
|
Vector3 click_ray;
|
|
|
|
Vector3 click_ray_pos;
|
|
|
|
Vector3 center;
|
|
|
|
Vector3 orig_gizmo_pos;
|
|
|
|
int edited_gizmo;
|
|
|
|
Point2 mouse_pos;
|
|
|
|
bool snap;
|
|
|
|
Ref<SpatialEditorGizmo> gizmo;
|
|
|
|
int gizmo_handle;
|
|
|
|
Variant gizmo_initial_value;
|
|
|
|
Vector3 gizmo_initial_pos;
|
|
|
|
} _edit;
|
|
|
|
|
|
|
|
struct Cursor {
|
|
|
|
|
|
|
|
Vector3 cursor_pos;
|
|
|
|
|
|
|
|
Vector3 pos;
|
2017-03-05 23:44:50 +08:00
|
|
|
float x_rot, y_rot, distance;
|
2014-02-10 09:10:30 +08:00
|
|
|
bool region_select;
|
2017-03-05 23:44:50 +08:00
|
|
|
Point2 region_begin, region_end;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Cursor() {
|
|
|
|
x_rot = y_rot = 0.5;
|
|
|
|
distance = 4;
|
|
|
|
region_select = false;
|
|
|
|
}
|
2014-02-10 09:10:30 +08:00
|
|
|
} cursor;
|
|
|
|
|
2014-05-05 09:50:23 +08:00
|
|
|
RID move_gizmo_instance[3], rotate_gizmo_instance[3];
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
String last_message;
|
|
|
|
String message;
|
|
|
|
float message_time;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_message(String p_message, float p_time = 5);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
void _update_camera();
|
|
|
|
void _draw();
|
|
|
|
|
|
|
|
void _smouseenter();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _sinput(const InputEvent &p_ie);
|
2014-02-10 09:10:30 +08:00
|
|
|
SpatialEditor *spatial_editor;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Camera *previewing;
|
|
|
|
Camera *preview;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
void _preview_exited_scene();
|
|
|
|
void _toggle_camera_preview(bool);
|
2014-05-05 09:50:23 +08:00
|
|
|
void _init_gizmo_instance(int p_idx);
|
2015-04-21 06:38:02 +08:00
|
|
|
void _finish_gizmo_instances();
|
2015-11-05 05:39:07 +08:00
|
|
|
void _selection_result_pressed(int);
|
|
|
|
void _selection_menu_hide();
|
2015-12-14 04:16:13 +08:00
|
|
|
void _list_select(InputEventMouseButton b);
|
2014-05-05 09:50:23 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2014-05-05 09:50:23 +08:00
|
|
|
void update_transform_gizmo_view();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_can_preview(Camera *p_preview);
|
|
|
|
void set_state(const Dictionary &p_state);
|
2014-02-10 09:10:30 +08:00
|
|
|
Dictionary get_state() const;
|
2014-09-20 05:39:50 +08:00
|
|
|
void reset();
|
2016-07-29 03:37:52 +08:00
|
|
|
|
|
|
|
void focus_selection();
|
|
|
|
|
2015-05-31 12:59:42 +08:00
|
|
|
Viewport *get_viewport_node() { return viewport; }
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index);
|
2014-02-10 09:10:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpatialEditorSelectedItem : public Object {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(SpatialEditorSelectedItem, Object);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
public:
|
2017-01-11 11:52:51 +08:00
|
|
|
Rect3 aabb;
|
2014-02-10 09:10:30 +08:00
|
|
|
Transform original; // original location when moving
|
|
|
|
Transform last_xform; // last transform
|
|
|
|
Spatial *sp;
|
|
|
|
RID sbox_instance;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
SpatialEditorSelectedItem() { sp = NULL; }
|
2014-02-10 09:10:30 +08:00
|
|
|
~SpatialEditorSelectedItem();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SpatialEditor : public VBoxContainer {
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(SpatialEditor, VBoxContainer);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2014-02-10 09:10:30 +08:00
|
|
|
enum ToolMode {
|
|
|
|
|
|
|
|
TOOL_MODE_SELECT,
|
|
|
|
TOOL_MODE_MOVE,
|
|
|
|
TOOL_MODE_ROTATE,
|
2015-12-14 04:16:13 +08:00
|
|
|
TOOL_MODE_SCALE,
|
|
|
|
TOOL_MODE_LIST_SELECT,
|
|
|
|
TOOL_MAX
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
EditorNode *editor;
|
|
|
|
EditorSelection *editor_selection;
|
|
|
|
|
|
|
|
Control *viewport_base;
|
|
|
|
SpatialEditorViewport *viewports[4];
|
|
|
|
VSplitContainer *shader_split;
|
|
|
|
HSplitContainer *palette_split;
|
|
|
|
|
|
|
|
/////
|
|
|
|
|
|
|
|
ToolMode tool_mode;
|
|
|
|
bool orthogonal;
|
|
|
|
|
|
|
|
VisualServer::ScenarioDebugMode scenario_debug;
|
|
|
|
|
|
|
|
RID light;
|
|
|
|
RID light_instance;
|
|
|
|
Transform light_transform;
|
|
|
|
|
|
|
|
RID origin;
|
|
|
|
RID origin_instance;
|
|
|
|
RID grid[3];
|
|
|
|
RID grid_instance[3];
|
|
|
|
bool grid_visible[3]; //currently visible
|
|
|
|
float last_grid_snap;
|
|
|
|
bool grid_enable[3]; //should be always visible if true
|
|
|
|
bool grid_enabled;
|
|
|
|
|
|
|
|
Ref<Mesh> move_gizmo[3], rotate_gizmo[3];
|
2017-04-07 10:36:37 +08:00
|
|
|
Ref<SpatialMaterial> gizmo_color[3];
|
|
|
|
Ref<SpatialMaterial> gizmo_hl;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2014-05-05 09:50:23 +08:00
|
|
|
int over_gizmo_handle;
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
Ref<Mesh> selection_box;
|
|
|
|
RID indicators;
|
2016-03-09 07:00:52 +08:00
|
|
|
RID indicators_instance;
|
2014-02-10 09:10:30 +08:00
|
|
|
RID cursor_mesh;
|
|
|
|
RID cursor_instance;
|
2017-04-07 10:36:37 +08:00
|
|
|
Ref<SpatialMaterial> indicator_mat;
|
|
|
|
Ref<SpatialMaterial> cursor_material;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
/*
|
2014-02-10 09:10:30 +08:00
|
|
|
struct Selected {
|
|
|
|
AABB aabb;
|
|
|
|
Transform original; // original location when moving
|
|
|
|
Transform last_xform; // last transform
|
|
|
|
Spatial *sp;
|
|
|
|
RID poly_instance;
|
|
|
|
};
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
Map<uint32_t,Selected> selected;
|
|
|
|
*/
|
|
|
|
struct Gizmo {
|
|
|
|
|
|
|
|
bool visible;
|
|
|
|
float scale;
|
|
|
|
Transform transform;
|
|
|
|
} gizmo;
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
enum MenuOption {
|
|
|
|
|
|
|
|
MENU_TOOL_SELECT,
|
|
|
|
MENU_TOOL_MOVE,
|
|
|
|
MENU_TOOL_ROTATE,
|
|
|
|
MENU_TOOL_SCALE,
|
2015-12-14 04:16:13 +08:00
|
|
|
MENU_TOOL_LIST_SELECT,
|
2014-02-10 09:10:30 +08:00
|
|
|
MENU_TRANSFORM_USE_SNAP,
|
|
|
|
MENU_TRANSFORM_CONFIGURE_SNAP,
|
|
|
|
MENU_TRANSFORM_LOCAL_COORDS,
|
|
|
|
MENU_TRANSFORM_DIALOG,
|
|
|
|
MENU_VIEW_USE_1_VIEWPORT,
|
|
|
|
MENU_VIEW_USE_2_VIEWPORTS,
|
2014-10-09 11:06:51 +08:00
|
|
|
MENU_VIEW_USE_2_VIEWPORTS_ALT,
|
2014-02-10 09:10:30 +08:00
|
|
|
MENU_VIEW_USE_3_VIEWPORTS,
|
2014-10-09 11:06:51 +08:00
|
|
|
MENU_VIEW_USE_3_VIEWPORTS_ALT,
|
2014-02-10 09:10:30 +08:00
|
|
|
MENU_VIEW_USE_4_VIEWPORTS,
|
|
|
|
MENU_VIEW_USE_DEFAULT_LIGHT,
|
2014-10-12 13:13:22 +08:00
|
|
|
MENU_VIEW_USE_DEFAULT_SRGB,
|
2014-02-10 09:10:30 +08:00
|
|
|
MENU_VIEW_DISPLAY_NORMAL,
|
|
|
|
MENU_VIEW_DISPLAY_WIREFRAME,
|
|
|
|
MENU_VIEW_DISPLAY_OVERDRAW,
|
2014-09-18 11:18:57 +08:00
|
|
|
MENU_VIEW_DISPLAY_SHADELESS,
|
2014-02-10 09:10:30 +08:00
|
|
|
MENU_VIEW_ORIGIN,
|
|
|
|
MENU_VIEW_GRID,
|
|
|
|
MENU_VIEW_CAMERA_SETTINGS,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-12-14 04:16:13 +08:00
|
|
|
Button *tool_button[TOOL_MAX];
|
2014-02-10 09:10:30 +08:00
|
|
|
Button *instance_button;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
MenuButton *transform_menu;
|
|
|
|
MenuButton *view_menu;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
ConfirmationDialog *snap_dialog;
|
|
|
|
ConfirmationDialog *xform_dialog;
|
|
|
|
ConfirmationDialog *settings_dialog;
|
|
|
|
|
|
|
|
bool snap_enabled;
|
|
|
|
LineEdit *snap_translate;
|
|
|
|
LineEdit *snap_rotate;
|
|
|
|
LineEdit *snap_scale;
|
2017-03-05 23:44:50 +08:00
|
|
|
PanelContainer *menu_panel;
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
LineEdit *xform_translate[3];
|
|
|
|
LineEdit *xform_rotate[3];
|
|
|
|
LineEdit *xform_scale[3];
|
|
|
|
OptionButton *xform_type;
|
|
|
|
|
2014-10-12 13:13:22 +08:00
|
|
|
VBoxContainer *settings_vbc;
|
|
|
|
SpinBox *settings_fov;
|
|
|
|
SpinBox *settings_znear;
|
|
|
|
SpinBox *settings_zfar;
|
|
|
|
DirectionalLight *settings_dlight;
|
|
|
|
ImmediateGeometry *settings_sphere;
|
|
|
|
Camera *settings_camera;
|
|
|
|
float settings_default_light_rot_x;
|
|
|
|
float settings_default_light_rot_y;
|
|
|
|
|
2016-10-05 12:26:35 +08:00
|
|
|
ViewportContainer *settings_light_base;
|
2014-10-12 13:13:22 +08:00
|
|
|
Viewport *settings_light_vp;
|
|
|
|
ColorPickerButton *settings_ambient_color;
|
|
|
|
Image settings_light_dir_image;
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void _xform_dialog_action();
|
|
|
|
void _menu_item_pressed(int p_option);
|
|
|
|
|
|
|
|
HBoxContainer *hbc_menu;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
//
|
|
|
|
//
|
2014-02-10 09:10:30 +08:00
|
|
|
void _generate_selection_box();
|
|
|
|
UndoRedo *undo_redo;
|
|
|
|
|
|
|
|
void _instance_scene();
|
|
|
|
void _init_indicators();
|
|
|
|
void _finish_indicators();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _toggle_maximize_view(Object *p_viewport);
|
2014-04-01 18:45:48 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
Node *custom_camera;
|
|
|
|
|
|
|
|
Object *_get_editor_data(Object *p_what);
|
|
|
|
|
|
|
|
Ref<Environment> viewport_environment;
|
|
|
|
|
2014-05-05 09:50:23 +08:00
|
|
|
Spatial *selected;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _request_gizmo(Object *p_obj);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
static SpatialEditor *singleton;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _node_removed(Node *p_node);
|
2014-02-10 09:10:30 +08:00
|
|
|
SpatialEditorGizmos *gizmos;
|
|
|
|
SpatialEditor();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _update_ambient_light_color(const Color &p_color);
|
2014-10-12 13:13:22 +08:00
|
|
|
void _update_default_light_angle();
|
2017-03-05 23:44:50 +08:00
|
|
|
void _default_light_angle_input(const InputEvent &p_event);
|
2014-10-12 13:13:22 +08:00
|
|
|
|
2016-03-09 07:00:52 +08:00
|
|
|
protected:
|
2014-02-10 09:10:30 +08:00
|
|
|
void _notification(int p_what);
|
2017-01-09 03:28:12 +08:00
|
|
|
//void _gui_input(InputEvent p_event);
|
2014-02-10 09:10:30 +08:00
|
|
|
void _unhandled_key_input(InputEvent p_event);
|
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2014-02-10 09:10:30 +08:00
|
|
|
static SpatialEditor *get_singleton() { return singleton; }
|
2017-03-05 23:44:50 +08:00
|
|
|
void snap_cursor_to_plane(const Plane &p_plane);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-01-04 12:16:14 +08:00
|
|
|
float get_znear() const { return settings_znear->get_value(); }
|
|
|
|
float get_zfar() const { return settings_zfar->get_value(); }
|
|
|
|
float get_fov() const { return settings_fov->get_value(); }
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
Transform get_gizmo_transform() const { return gizmo.transform; }
|
|
|
|
bool is_gizmo_visible() const { return gizmo.visible; }
|
|
|
|
|
|
|
|
ToolMode get_tool_mode() const { return tool_mode; }
|
|
|
|
bool is_snap_enabled() const { return snap_enabled; }
|
|
|
|
float get_translate_snap() const { return snap_translate->get_text().to_double(); }
|
|
|
|
float get_rotate_snap() const { return snap_rotate->get_text().to_double(); }
|
|
|
|
float get_scale_snap() const { return snap_scale->get_text().to_double(); }
|
|
|
|
|
2014-05-05 09:50:23 +08:00
|
|
|
Ref<Mesh> get_move_gizmo(int idx) const { return move_gizmo[idx]; }
|
|
|
|
Ref<Mesh> get_rotate_gizmo(int idx) const { return rotate_gizmo[idx]; }
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
void update_transform_gizmo();
|
|
|
|
|
2017-04-06 23:35:08 +08:00
|
|
|
void select_gizmo_highlight_axis(int p_axis);
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_custom_camera(Node *p_camera) { custom_camera = p_camera; }
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
|
2014-02-10 09:10:30 +08:00
|
|
|
Dictionary get_state() const;
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_state(const Dictionary &p_state);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
Ref<Environment> get_viewport_environment() { return viewport_environment; }
|
|
|
|
|
|
|
|
UndoRedo *get_undo_redo() { return undo_redo; }
|
|
|
|
|
|
|
|
void add_control_to_menu_panel(Control *p_control);
|
|
|
|
|
|
|
|
VSplitContainer *get_shader_split();
|
|
|
|
HSplitContainer *get_palette_split();
|
|
|
|
|
2014-05-05 09:50:23 +08:00
|
|
|
Spatial *get_selected() { return selected; }
|
|
|
|
|
|
|
|
int get_over_gizmo_handle() const { return over_gizmo_handle; }
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_over_gizmo_handle(int idx) { over_gizmo_handle = idx; }
|
2014-05-05 09:50:23 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void set_can_preview(Camera *p_preview);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
2015-05-31 12:59:42 +08:00
|
|
|
SpatialEditorViewport *get_editor_viewport(int p_idx) {
|
2017-03-05 23:44:50 +08:00
|
|
|
ERR_FAIL_INDEX_V(p_idx, 4, NULL);
|
2015-05-31 12:59:42 +08:00
|
|
|
return viewports[p_idx];
|
|
|
|
}
|
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
Camera *get_camera() { return NULL; }
|
|
|
|
void edit(Spatial *p_spatial);
|
2014-09-20 05:39:50 +08:00
|
|
|
void clear();
|
2014-02-10 09:10:30 +08:00
|
|
|
SpatialEditor(EditorNode *p_editor);
|
|
|
|
~SpatialEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SpatialEditorPlugin : public EditorPlugin {
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(SpatialEditorPlugin, EditorPlugin);
|
2016-03-09 07:00:52 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
SpatialEditor *spatial_editor;
|
|
|
|
EditorNode *editor;
|
2017-03-05 23:44:50 +08:00
|
|
|
|
2014-02-10 09:10:30 +08:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
|
|
|
void snap_cursor_to_plane(const Plane &p_plane);
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
SpatialEditor *get_spatial_editor() { return spatial_editor; }
|
|
|
|
virtual String get_name() const { return "3D"; }
|
|
|
|
bool has_main_screen() const { return true; }
|
2016-03-09 07:00:52 +08:00
|
|
|
virtual void make_visible(bool p_visible);
|
2014-02-10 09:10:30 +08:00
|
|
|
virtual void edit(Object *p_object);
|
|
|
|
virtual bool handles(Object *p_object) const;
|
|
|
|
|
|
|
|
virtual Dictionary get_state() const;
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void set_state(const Dictionary &p_state);
|
2014-09-20 05:39:50 +08:00
|
|
|
virtual void clear() { spatial_editor->clear(); }
|
2014-02-10 09:10:30 +08:00
|
|
|
|
|
|
|
SpatialEditorPlugin(EditorNode *p_node);
|
|
|
|
~SpatialEditorPlugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|