mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
New functions in scene editor
This commit is contained in:
@@ -206,7 +206,7 @@ editor_mode::on_key( int const Key, int const Scancode, int const Action, int co
|
|||||||
|
|
||||||
m_node = nullptr;
|
m_node = nullptr;
|
||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
Application.set_cursor( GLFW_CURSOR_NORMAL );
|
//Application.set_cursor( GLFW_CURSOR_NORMAL );
|
||||||
static_cast<editor_ui*>( m_userinterface.get() )->set_node(nullptr);
|
static_cast<editor_ui*>( m_userinterface.get() )->set_node(nullptr);
|
||||||
|
|
||||||
simulation::State.delete_model(model);
|
simulation::State.delete_model(model);
|
||||||
@@ -318,10 +318,14 @@ editor_mode::on_mouse_button( int const Button, int const Action, int const Mods
|
|||||||
if( Action == GLFW_PRESS ) {
|
if( Action == GLFW_PRESS ) {
|
||||||
// left button press
|
// left button press
|
||||||
auto const mode = static_cast<editor_ui*>( m_userinterface.get() )->mode();
|
auto const mode = static_cast<editor_ui*>( m_userinterface.get() )->mode();
|
||||||
|
auto const rotation_mode = static_cast<editor_ui*>( m_userinterface.get() )->rot_mode();
|
||||||
|
auto const fixed_rotation_value =
|
||||||
|
static_cast<editor_ui *>(m_userinterface.get())->rot_val();
|
||||||
|
|
||||||
m_node = nullptr;
|
m_node = nullptr;
|
||||||
|
|
||||||
GfxRenderer->Pick_Node_Callback([this, mode,Action,Button](scene::basic_node *node) {
|
GfxRenderer->Pick_Node_Callback([this, mode, rotation_mode, fixed_rotation_value,
|
||||||
|
Action, Button](scene::basic_node *node) {
|
||||||
editor_ui *ui = static_cast<editor_ui *>(m_userinterface.get());
|
editor_ui *ui = static_cast<editor_ui *>(m_userinterface.get());
|
||||||
|
|
||||||
if (mode == nodebank_panel::MODIFY) {
|
if (mode == nodebank_panel::MODIFY) {
|
||||||
@@ -329,10 +333,10 @@ editor_mode::on_mouse_button( int const Button, int const Action, int const Mods
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_node = node;
|
m_node = node;
|
||||||
if( m_node )
|
//if( m_node )
|
||||||
Application.set_cursor( GLFW_CURSOR_DISABLED );
|
//Application.set_cursor( GLFW_CURSOR_DISABLED );
|
||||||
else
|
//else
|
||||||
m_dragging = false;
|
//m_dragging = false;
|
||||||
ui->set_node(m_node);
|
ui->set_node(m_node);
|
||||||
}
|
}
|
||||||
else if (mode == nodebank_panel::COPY) {
|
else if (mode == nodebank_panel::COPY) {
|
||||||
@@ -360,8 +364,24 @@ editor_mode::on_mouse_button( int const Button, int const Action, int const Mods
|
|||||||
if (!m_dragging)
|
if (!m_dragging)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_node = cloned;
|
|
||||||
Application.set_cursor( GLFW_CURSOR_DISABLED );
|
m_node = cloned;
|
||||||
|
|
||||||
|
if (rotation_mode == functions_panel::RANDOM)
|
||||||
|
{
|
||||||
|
auto const rotation{glm::vec3{0, LocalRandom(0.0, 360.0), 0}};
|
||||||
|
|
||||||
|
m_editor.rotate(m_node, rotation, 1);
|
||||||
|
}
|
||||||
|
else if (rotation_mode == functions_panel::FIXED)
|
||||||
|
{
|
||||||
|
|
||||||
|
auto const rotation{glm::vec3{0, fixed_rotation_value, 0}};
|
||||||
|
|
||||||
|
m_editor.rotate(m_node, rotation, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
//Application.set_cursor( GLFW_CURSOR_DISABLED );
|
||||||
ui->set_node( m_node );
|
ui->set_node( m_node );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -370,8 +390,8 @@ editor_mode::on_mouse_button( int const Button, int const Action, int const Mods
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// left button release
|
// left button release
|
||||||
if( m_node )
|
//if( m_node )
|
||||||
Application.set_cursor( GLFW_CURSOR_NORMAL );
|
//Application.set_cursor( GLFW_CURSOR_NORMAL );
|
||||||
m_dragging = false;
|
m_dragging = false;
|
||||||
// prime history stack for another snapshot
|
// prime history stack for another snapshot
|
||||||
m_takesnapshot = true;
|
m_takesnapshot = true;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ editor_ui::editor_ui() {
|
|||||||
|
|
||||||
add_external_panel( &m_itempropertiespanel );
|
add_external_panel( &m_itempropertiespanel );
|
||||||
add_external_panel( &m_nodebankpanel );
|
add_external_panel( &m_nodebankpanel );
|
||||||
|
add_external_panel( &m_functionspanel );
|
||||||
}
|
}
|
||||||
|
|
||||||
// updates state of UI elements
|
// updates state of UI elements
|
||||||
@@ -41,6 +42,7 @@ editor_ui::update() {
|
|||||||
|
|
||||||
ui_layer::update();
|
ui_layer::update();
|
||||||
m_itempropertiespanel.update( m_node );
|
m_itempropertiespanel.update( m_node );
|
||||||
|
m_functionspanel.update( m_node );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -63,3 +65,17 @@ nodebank_panel::edit_mode
|
|||||||
editor_ui::mode() {
|
editor_ui::mode() {
|
||||||
return m_nodebankpanel.mode;
|
return m_nodebankpanel.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
functions_panel::rotation_mode
|
||||||
|
editor_ui::rot_mode() {
|
||||||
|
return m_functionspanel.rot_mode;
|
||||||
|
}
|
||||||
|
float
|
||||||
|
editor_ui::rot_val() {
|
||||||
|
return m_functionspanel.rot_value;
|
||||||
|
}
|
||||||
|
bool
|
||||||
|
editor_ui::rot_from_last()
|
||||||
|
{
|
||||||
|
return m_functionspanel.rot_from_last;
|
||||||
|
}
|
||||||
@@ -31,6 +31,12 @@ public:
|
|||||||
set_node( scene::basic_node * Node );
|
set_node( scene::basic_node * Node );
|
||||||
void
|
void
|
||||||
add_node_template(const std::string &desc);
|
add_node_template(const std::string &desc);
|
||||||
|
float
|
||||||
|
rot_val();
|
||||||
|
bool
|
||||||
|
rot_from_last();
|
||||||
|
functions_panel::rotation_mode
|
||||||
|
rot_mode();
|
||||||
const std::string *
|
const std::string *
|
||||||
get_active_node_template();
|
get_active_node_template();
|
||||||
nodebank_panel::edit_mode
|
nodebank_panel::edit_mode
|
||||||
@@ -39,6 +45,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
// members
|
// members
|
||||||
itemproperties_panel m_itempropertiespanel { "Node Properties", true };
|
itemproperties_panel m_itempropertiespanel { "Node Properties", true };
|
||||||
|
functions_panel m_functionspanel { "Functions", true };
|
||||||
nodebank_panel m_nodebankpanel{ "Node Bank", true };
|
nodebank_panel m_nodebankpanel{ "Node Bank", true };
|
||||||
scene::basic_node * m_node { nullptr }; // currently bound scene node, if any
|
scene::basic_node * m_node { nullptr }; // currently bound scene node, if any
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -420,8 +420,6 @@ nodebank_panel::render() {
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::RadioButton("Insert from bank", (int*)&mode, ADD);
|
ImGui::RadioButton("Insert from bank", (int*)&mode, ADD);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::RadioButton("Brush", (int*)&mode, BRUSH);
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::RadioButton( "Copy to bank", (int*)&mode, COPY );
|
ImGui::RadioButton( "Copy to bank", (int*)&mode, COPY );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Reload Nodebank"))
|
if (ImGui::Button("Reload Nodebank"))
|
||||||
@@ -493,3 +491,64 @@ nodebank_panel::generate_node_label( std::string Input ) const {
|
|||||||
model :
|
model :
|
||||||
model + " (" + texture + ")" );
|
model + " (" + texture + ")" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void functions_panel::update(scene::basic_node const *Node)
|
||||||
|
{
|
||||||
|
m_node = Node;
|
||||||
|
|
||||||
|
if (false == is_open)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
text_lines.clear();
|
||||||
|
m_grouplines.clear();
|
||||||
|
|
||||||
|
std::string textline;
|
||||||
|
|
||||||
|
// scenario inspector
|
||||||
|
auto const *node{Node};
|
||||||
|
auto const &camera{Global.pCamera};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
functions_panel::render() {
|
||||||
|
|
||||||
|
if( false == is_open ) { return; }
|
||||||
|
|
||||||
|
auto flags =
|
||||||
|
ImGuiWindowFlags_NoFocusOnAppearing
|
||||||
|
| ImGuiWindowFlags_NoCollapse
|
||||||
|
| ( size.x > 0 ? ImGuiWindowFlags_NoResize : 0 );
|
||||||
|
|
||||||
|
if( size.x > 0 ) {
|
||||||
|
ImGui::SetNextWindowSize( ImVec2S( size.x, size.y ) );
|
||||||
|
}
|
||||||
|
if( size_min.x > 0 ) {
|
||||||
|
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x, size_min.y ), ImVec2( size_max.x, size_max.y ) );
|
||||||
|
}
|
||||||
|
auto const panelname { (
|
||||||
|
title.empty() ?
|
||||||
|
m_name :
|
||||||
|
title )
|
||||||
|
+ "###" + m_name };
|
||||||
|
if( true == ImGui::Begin( panelname.c_str(), nullptr, flags ) ) {
|
||||||
|
// header section
|
||||||
|
|
||||||
|
ImGui::RadioButton("Random rotation", (int *)&rot_mode, RANDOM);
|
||||||
|
ImGui::RadioButton("Fixed rotation", (int *)&rot_mode, FIXED);
|
||||||
|
if(rot_mode == FIXED){
|
||||||
|
//ImGui::Checkbox("Get rotation from last object", &rot_from_last);
|
||||||
|
ImGui::SliderFloat("Rotation Value", &rot_value, 0.0f, 360.0f, "%.1f");
|
||||||
|
};
|
||||||
|
ImGui::RadioButton("Default rotation", (int *)&rot_mode, DEFAULT);
|
||||||
|
for( auto const &line : text_lines ) {
|
||||||
|
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
@@ -73,3 +73,35 @@ private:
|
|||||||
char m_nodesearch[ 128 ];
|
char m_nodesearch[ 128 ];
|
||||||
std::shared_ptr<std::string> m_selectedtemplate;
|
std::shared_ptr<std::string> m_selectedtemplate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class functions_panel : public ui_panel
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum rotation_mode
|
||||||
|
{
|
||||||
|
RANDOM,
|
||||||
|
FIXED,
|
||||||
|
DEFAULT
|
||||||
|
};
|
||||||
|
rotation_mode rot_mode = DEFAULT;
|
||||||
|
|
||||||
|
float rot_value = 0.0f;
|
||||||
|
bool rot_from_last = false;
|
||||||
|
|
||||||
|
functions_panel(std::string const &Name, bool const Isopen) : ui_panel(Name, Isopen) {}
|
||||||
|
|
||||||
|
void update(scene::basic_node const *Node);
|
||||||
|
void render() override;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
// methods
|
||||||
|
|
||||||
|
|
||||||
|
// members
|
||||||
|
scene::basic_node const *m_node{nullptr}; // scene node bound to the panel
|
||||||
|
scene::group_handle m_grouphandle{null_handle}; // scene group bound to the panel
|
||||||
|
std::string m_groupprefix;
|
||||||
|
std::vector<text_line> m_grouplines;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user