Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/scene/3d/mesh_editor_plugin.h
9906 views
1
/**************************************************************************/
2
/* mesh_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
31
#pragma once
32
33
#include "editor/inspector/editor_inspector.h"
34
#include "editor/plugins/editor_plugin.h"
35
#include "scene/3d/camera_3d.h"
36
#include "scene/3d/light_3d.h"
37
#include "scene/3d/mesh_instance_3d.h"
38
#include "scene/gui/subviewport_container.h"
39
#include "scene/resources/camera_attributes.h"
40
41
class SubViewport;
42
class Button;
43
44
class MeshEditor : public SubViewportContainer {
45
GDCLASS(MeshEditor, SubViewportContainer);
46
47
float rot_x;
48
float rot_y;
49
50
SubViewport *viewport = nullptr;
51
MeshInstance3D *mesh_instance = nullptr;
52
Node3D *rotation = nullptr;
53
DirectionalLight3D *light1 = nullptr;
54
DirectionalLight3D *light2 = nullptr;
55
Camera3D *camera = nullptr;
56
Ref<CameraAttributesPractical> camera_attributes;
57
58
Ref<Mesh> mesh;
59
60
Button *light_1_switch = nullptr;
61
Button *light_2_switch = nullptr;
62
63
struct ThemeCache {
64
Ref<Texture2D> light_1_icon;
65
Ref<Texture2D> light_2_icon;
66
} theme_cache;
67
68
void _on_light_1_switch_pressed();
69
void _on_light_2_switch_pressed();
70
void _update_rotation();
71
72
protected:
73
virtual void _update_theme_item_cache() override;
74
void _notification(int p_what);
75
void gui_input(const Ref<InputEvent> &p_event) override;
76
77
public:
78
void edit(Ref<Mesh> p_mesh);
79
MeshEditor();
80
};
81
82
class EditorInspectorPluginMesh : public EditorInspectorPlugin {
83
GDCLASS(EditorInspectorPluginMesh, EditorInspectorPlugin);
84
85
public:
86
virtual bool can_handle(Object *p_object) override;
87
virtual void parse_begin(Object *p_object) override;
88
};
89
90
class MeshEditorPlugin : public EditorPlugin {
91
GDCLASS(MeshEditorPlugin, EditorPlugin);
92
93
public:
94
virtual String get_plugin_name() const override { return "Mesh"; }
95
96
MeshEditorPlugin();
97
};
98
99