rename engine to src
This commit is contained in:
65
src/node_panel_grid.cpp
Normal file
65
src/node_panel_grid.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_panel_grid.h"
|
||||
#include "canvas.h"
|
||||
#include "app.h"
|
||||
#include "image.h"
|
||||
|
||||
Node* NodePanelGrid::clone_instantiate() const
|
||||
{
|
||||
return new NodePanelGrid();
|
||||
}
|
||||
|
||||
void NodePanelGrid::clone_finalize(Node* dest) const
|
||||
{
|
||||
NodePanelGrid* n = static_cast<NodePanelGrid*>(dest);
|
||||
n->init_controls();
|
||||
}
|
||||
|
||||
void NodePanelGrid::init()
|
||||
{
|
||||
init_template("tpl-panel-grid");
|
||||
init_controls();
|
||||
}
|
||||
|
||||
void NodePanelGrid::init_controls()
|
||||
{
|
||||
m_groud_opacity = find<NodeSliderH>("grid-ground-opacity");
|
||||
m_groud_scale = find<NodeSliderH>("grid-ground-scale");
|
||||
m_groud_value = find<NodeSliderH>("grid-ground-value");
|
||||
m_groud_height = find<NodeSliderH>("grid-ground-height");
|
||||
//m_box_opacity = find<NodeSliderH>("grid-box-opacity");
|
||||
//m_box_width = find<NodeSliderH>("grid-box-width");
|
||||
//m_box_height = find<NodeSliderH>("grid-box-height");
|
||||
//m_box_depth = find<NodeSliderH>("grid-box-depth");
|
||||
|
||||
auto update_hm = [this](Node* target, float v) {
|
||||
m_hm_plane.create(1, 1, m_hm_image, -m_hm_height->get_value());
|
||||
};
|
||||
|
||||
m_hm_preview = find<NodeImageTexture>("grid-heightmap-preview");
|
||||
m_hm_load = find<NodeButton>("grid-heightmap-load");
|
||||
m_hm_offset = find<NodeSliderH>("grid-heightmap-offset");
|
||||
m_hm_height = find<NodeSliderH>("grid-heightmap-height");
|
||||
|
||||
m_hm_height->on_value_changed = update_hm;
|
||||
m_hm_preview->SetHeight(0);
|
||||
|
||||
//m_hm_plane.create(1, 1);
|
||||
|
||||
m_hm_load->on_click = [this](Node*) {
|
||||
App::I.pick_image([this](std::string path) {
|
||||
ui::Image img;
|
||||
if (img.load_file(path))
|
||||
{
|
||||
m_hm_image = img.resize(128, 128);
|
||||
m_hm_preview->tex.create(m_hm_image);
|
||||
m_hm_preview->tex.create_mipmaps();
|
||||
auto sz = m_hm_preview->tex.size();
|
||||
m_hm_preview->SetAspectRatio(sz.x / sz.y);
|
||||
m_hm_plane.create(1, 1, m_hm_image, -m_hm_height->get_value());
|
||||
m_hm_preview->SetHeight(100);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user