create terrain mode and start working on the UI for minimap generator
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#include <noggit/ui/texturing_tool.hpp>
|
#include <noggit/ui/texturing_tool.hpp>
|
||||||
#include <noggit/ui/hole_tool.hpp>
|
#include <noggit/ui/hole_tool.hpp>
|
||||||
#include <noggit/ui/texture_palette_small.hpp>
|
#include <noggit/ui/texture_palette_small.hpp>
|
||||||
|
#include <noggit/ui/MinimapCreator.hpp>
|
||||||
#include <opengl/scoped.hpp>
|
#include <opengl/scoped.hpp>
|
||||||
|
|
||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
@@ -62,8 +63,6 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <thread>
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
|
|
||||||
static const float XSENS = 15.0f;
|
static const float XSENS = 15.0f;
|
||||||
@@ -128,6 +127,9 @@ void MapView::setToolPropertyWidgetVisibility(editing_mode mode)
|
|||||||
case editing_mode::holes:
|
case editing_mode::holes:
|
||||||
_hole_tool_dock->setVisible(!ui_hidden);
|
_hole_tool_dock->setVisible(!ui_hidden);
|
||||||
break;
|
break;
|
||||||
|
case editing_mode::minimap:
|
||||||
|
_minimap_tool_dock->setVisible(!ui_hidden);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -194,7 +196,6 @@ QWidgetAction* MapView::createTextSeparator(const QString& text)
|
|||||||
void MapView::createGUI()
|
void MapView::createGUI()
|
||||||
{
|
{
|
||||||
// create tool widgets
|
// create tool widgets
|
||||||
|
|
||||||
_terrain_tool_dock = new QDockWidget("Raise / Lower", this);
|
_terrain_tool_dock = new QDockWidget("Raise / Lower", this);
|
||||||
terrainTool = new noggit::ui::terrain_tool(_terrain_tool_dock);
|
terrainTool = new noggit::ui::terrain_tool(_terrain_tool_dock);
|
||||||
_terrain_tool_dock->setWidget(terrainTool);
|
_terrain_tool_dock->setWidget(terrainTool);
|
||||||
@@ -267,6 +268,11 @@ void MapView::createGUI()
|
|||||||
_vertex_shading_dock->setWidget(shaderTool);
|
_vertex_shading_dock->setWidget(shaderTool);
|
||||||
_tool_properties_docks.insert(_vertex_shading_dock);
|
_tool_properties_docks.insert(_vertex_shading_dock);
|
||||||
|
|
||||||
|
_minimap_tool_dock = new QDockWidget("Minimap Creator", this);
|
||||||
|
minimapTool = new noggit::ui::MinimapCreator(this);
|
||||||
|
_minimap_tool_dock->setWidget(minimapTool);
|
||||||
|
_tool_properties_docks.insert(_minimap_tool_dock);
|
||||||
|
|
||||||
_object_editor_dock = new QDockWidget("Object", this);
|
_object_editor_dock = new QDockWidget("Object", this);
|
||||||
objectEditor = new noggit::ui::object_editor(this
|
objectEditor = new noggit::ui::object_editor(this
|
||||||
, _world.get()
|
, _world.get()
|
||||||
@@ -1528,41 +1534,88 @@ void MapView::initializeGL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MapView::saveMinimap(noggit::MinimapRenderSettings* settings)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (settings->export_mode)
|
||||||
|
{
|
||||||
|
case noggit::MinimapGenMode::CURRENT_ADT:
|
||||||
|
{
|
||||||
|
tile_index tile = tile_index(_camera.position);
|
||||||
|
|
||||||
|
if (_world->mapIndex.hasTile(tile))
|
||||||
|
{
|
||||||
|
mmap_render_success = _world->saveMinimap(512, 512, tile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Saving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mmap_render_success)
|
||||||
|
{
|
||||||
|
Saving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case noggit::MinimapGenMode::MAP:
|
||||||
|
{
|
||||||
|
// increment tile indices here
|
||||||
|
if (mmap_render_success)
|
||||||
|
{
|
||||||
|
mmap_render_index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
tile_index tile = tile_index(mmap_render_index / 64, mmap_render_index % 64);
|
||||||
|
|
||||||
|
if (_world->mapIndex.hasTile(tile))
|
||||||
|
{
|
||||||
|
mmap_render_success = _world->saveMinimap(512, 512, tile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
mmap_render_index++;
|
||||||
|
tile.x = mmap_render_index / 64;
|
||||||
|
tile.z = mmap_render_index % 64;
|
||||||
|
|
||||||
|
} while (!_world->mapIndex.hasTile(tile) && mmap_render_index != 4095 );
|
||||||
|
|
||||||
|
if (mmap_render_success)
|
||||||
|
{
|
||||||
|
mmap_render_index--;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mmap_render_success && mmap_render_index >= 4095)
|
||||||
|
{
|
||||||
|
Saving = false;
|
||||||
|
mmap_render_index = 0;
|
||||||
|
mmap_render_success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case noggit::MinimapGenMode::SELECTED_ADTS:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::paintGL()
|
void MapView::paintGL()
|
||||||
{
|
{
|
||||||
opengl::context::scoped_setter const _ (::gl, context());
|
opengl::context::scoped_setter const _ (::gl, context());
|
||||||
|
|
||||||
if (Saving)
|
if (Saving)
|
||||||
{
|
{
|
||||||
// increment tile indices here
|
saveMinimap(minimapTool->getMinimapRenderSettings());
|
||||||
if (mmap_render_success)
|
|
||||||
{
|
|
||||||
mmap_render_index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
tile_index tile = tile_index(mmap_render_index / 64, mmap_render_index % 64);
|
|
||||||
|
|
||||||
if (_world->mapIndex.hasTile(tile))
|
|
||||||
{
|
|
||||||
mmap_render_success = _world->saveMinimap(512, 512, tile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
mmap_render_index++;
|
|
||||||
tile.x = mmap_render_index / 64;
|
|
||||||
tile.z = mmap_render_index % 64;
|
|
||||||
|
|
||||||
} while (!_world->mapIndex.hasTile(tile) && mmap_render_index != 4095);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mmap_render_success && mmap_render_index == 4095)
|
|
||||||
{
|
|
||||||
Saving = false;
|
|
||||||
mmap_render_index = 0;
|
|
||||||
mmap_render_success = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal now(_startup_time.elapsed() / 1000.0);
|
const qreal now(_startup_time.elapsed() / 1000.0);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <noggit/camera.hpp>
|
#include <noggit/camera.hpp>
|
||||||
#include <noggit/tool_enums.hpp>
|
#include <noggit/tool_enums.hpp>
|
||||||
#include <noggit/ui/ObjectEditor.h>
|
#include <noggit/ui/ObjectEditor.h>
|
||||||
|
#include <noggit/ui/MinimapCreator.hpp>
|
||||||
#include <noggit/ui/uid_fix_window.hpp>
|
#include <noggit/ui/uid_fix_window.hpp>
|
||||||
#include <noggit/unsigned_int_property.hpp>
|
#include <noggit/unsigned_int_property.hpp>
|
||||||
|
|
||||||
@@ -198,6 +199,8 @@ public:
|
|||||||
void tick (float dt);
|
void tick (float dt);
|
||||||
void selectModel(std::string const& model);
|
void selectModel(std::string const& model);
|
||||||
void change_selected_wmo_doodadset(int set);
|
void change_selected_wmo_doodadset(int set);
|
||||||
|
void saveMinimap(noggit::MinimapRenderSettings* settings);
|
||||||
|
void initMinimapSave() { Saving = true; };
|
||||||
|
|
||||||
void set_editing_mode (editing_mode);
|
void set_editing_mode (editing_mode);
|
||||||
|
|
||||||
@@ -312,4 +315,6 @@ private:
|
|||||||
QDockWidget* _texturing_dock;
|
QDockWidget* _texturing_dock;
|
||||||
noggit::ui::hole_tool* holeTool;
|
noggit::ui::hole_tool* holeTool;
|
||||||
QDockWidget* _hole_tool_dock;
|
QDockWidget* _hole_tool_dock;
|
||||||
|
noggit::ui::MinimapCreator* minimapTool;
|
||||||
|
QDockWidget* _minimap_tool_dock;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ enum class editing_mode
|
|||||||
water,
|
water,
|
||||||
mccv,
|
mccv,
|
||||||
object,
|
object,
|
||||||
|
minimap
|
||||||
};
|
};
|
||||||
|
|
||||||
enum water_opacity
|
enum water_opacity
|
||||||
|
|||||||
162
src/noggit/ui/MinimapCreator.cpp
Normal file
162
src/noggit/ui/MinimapCreator.cpp
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||||
|
|
||||||
|
#include "MinimapCreator.hpp"
|
||||||
|
|
||||||
|
#include <noggit/MapView.h>
|
||||||
|
|
||||||
|
#include <util/qt/overload.hpp>
|
||||||
|
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QCheckBox>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QTabWidget>
|
||||||
|
|
||||||
|
|
||||||
|
namespace noggit
|
||||||
|
{
|
||||||
|
namespace ui
|
||||||
|
{
|
||||||
|
MinimapCreator::MinimapCreator (
|
||||||
|
MapView* mapView,
|
||||||
|
QWidget* parent ) : QWidget(parent)
|
||||||
|
{
|
||||||
|
auto layout = new QHBoxLayout(this);
|
||||||
|
|
||||||
|
auto layout_left = new QFormLayout (this);
|
||||||
|
|
||||||
|
layout->addItem(layout_left);
|
||||||
|
|
||||||
|
auto settings_tabs = new QTabWidget (this);
|
||||||
|
layout->addWidget(settings_tabs);
|
||||||
|
|
||||||
|
// Generate
|
||||||
|
auto generate_widget = new QWidget(this);
|
||||||
|
auto generate_layout = new QFormLayout(generate_widget);
|
||||||
|
settings_tabs->addTab(generate_widget, "Generate");
|
||||||
|
|
||||||
|
_radius_spin = new QDoubleSpinBox (generate_widget);
|
||||||
|
_radius_spin->setRange (0.0f, 100.0f);
|
||||||
|
_radius_spin->setDecimals (2);
|
||||||
|
_radius_spin->setValue (_radius);
|
||||||
|
|
||||||
|
generate_layout->addRow ("Radius:", _radius_spin);
|
||||||
|
|
||||||
|
_radius_slider = new QSlider (Qt::Orientation::Horizontal, generate_widget);
|
||||||
|
_radius_slider->setRange (0, 100);
|
||||||
|
_radius_slider->setSliderPosition (_radius);
|
||||||
|
|
||||||
|
generate_layout->addRow (_radius_slider);
|
||||||
|
|
||||||
|
auto cur_adt_btn = new QPushButton("Current ADT", generate_widget);
|
||||||
|
auto sel_adts_btn = new QPushButton("Selected ADTs", generate_widget);
|
||||||
|
auto all_adts_btn = new QPushButton("Map", generate_widget);
|
||||||
|
|
||||||
|
generate_layout->addRow (cur_adt_btn);
|
||||||
|
generate_layout->addRow (sel_adts_btn);
|
||||||
|
generate_layout->addRow (all_adts_btn);
|
||||||
|
|
||||||
|
// Render settings box
|
||||||
|
auto render_settings_box = new QGroupBox("Render options", generate_widget);
|
||||||
|
generate_layout->addRow (render_settings_box);
|
||||||
|
|
||||||
|
auto render_settings_box_layout = new QFormLayout (render_settings_box);
|
||||||
|
|
||||||
|
auto draw_models = new QCheckBox("Draw models", render_settings_box);
|
||||||
|
draw_models->setChecked(_render_settings.draw_m2);
|
||||||
|
render_settings_box_layout->addRow (draw_models);
|
||||||
|
|
||||||
|
auto draw_wmos = new QCheckBox("Draw WMOs", render_settings_box);
|
||||||
|
draw_wmos->setChecked(_render_settings.draw_wmo);
|
||||||
|
render_settings_box_layout->addRow (draw_wmos);
|
||||||
|
|
||||||
|
auto draw_water = new QCheckBox("Draw water", render_settings_box);
|
||||||
|
draw_water->setChecked(_render_settings.draw_water);
|
||||||
|
render_settings_box_layout->addRow (draw_water);
|
||||||
|
|
||||||
|
auto draw_adt = new QCheckBox("Draw ADT grid", render_settings_box);
|
||||||
|
draw_adt->setChecked(_render_settings.draw_adt_grid);
|
||||||
|
render_settings_box_layout->addRow (draw_adt);
|
||||||
|
|
||||||
|
auto draw_elevation = new QCheckBox("Draw elevation lines", render_settings_box);
|
||||||
|
draw_elevation->setChecked(_render_settings.draw_elevation);
|
||||||
|
render_settings_box_layout->addRow (draw_elevation);
|
||||||
|
|
||||||
|
// Connections
|
||||||
|
|
||||||
|
connect ( _radius_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
|
||||||
|
, [&] (double v)
|
||||||
|
{
|
||||||
|
_radius = v;
|
||||||
|
QSignalBlocker const blocker(_radius_slider);
|
||||||
|
_radius_slider->setSliderPosition ((int)std::round (v));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
connect ( _radius_slider, &QSlider::valueChanged
|
||||||
|
, [&] (int v)
|
||||||
|
{
|
||||||
|
_radius = v;
|
||||||
|
QSignalBlocker const blocker(_radius_spin);
|
||||||
|
_radius_spin->setValue(v);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Render settings
|
||||||
|
|
||||||
|
connect (draw_models, &QCheckBox::stateChanged, [this] (int s)
|
||||||
|
{
|
||||||
|
_render_settings.draw_m2 = s;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect (draw_wmos, &QCheckBox::stateChanged, [this] (int s)
|
||||||
|
{
|
||||||
|
_render_settings.draw_wmo = s;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect (draw_water, &QCheckBox::stateChanged, [this] (int s)
|
||||||
|
{
|
||||||
|
_render_settings.draw_water = s;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect (draw_adt, &QCheckBox::stateChanged, [this] (int s)
|
||||||
|
{
|
||||||
|
_render_settings.draw_adt_grid = s;
|
||||||
|
});
|
||||||
|
|
||||||
|
connect (draw_elevation, &QCheckBox::stateChanged, [this] (int s)
|
||||||
|
{
|
||||||
|
_render_settings.draw_elevation = s;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
connect(cur_adt_btn, &QPushButton::clicked, [=]() {
|
||||||
|
_render_settings.export_mode = MinimapGenMode::CURRENT_ADT;
|
||||||
|
mapView->initMinimapSave();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(sel_adts_btn, &QPushButton::clicked, [=]() {
|
||||||
|
_render_settings.export_mode = MinimapGenMode::SELECTED_ADTS;
|
||||||
|
mapView->initMinimapSave();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(all_adts_btn, &QPushButton::clicked, [=]() {
|
||||||
|
_render_settings.export_mode = MinimapGenMode::MAP;
|
||||||
|
mapView->initMinimapSave();
|
||||||
|
});
|
||||||
|
|
||||||
|
setMinimumWidth(sizeHint().width());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MinimapCreator::changeRadius(float change)
|
||||||
|
{
|
||||||
|
_radius_spin->setValue (_radius + change);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize MinimapCreator::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(215, height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/noggit/ui/MinimapCreator.hpp
Normal file
69
src/noggit/ui/MinimapCreator.hpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QtWidgets/QDoubleSpinBox>
|
||||||
|
#include <QtWidgets/QSlider>
|
||||||
|
|
||||||
|
#include <boost/optional.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class MapView;
|
||||||
|
|
||||||
|
namespace noggit
|
||||||
|
{
|
||||||
|
|
||||||
|
enum MinimapGenMode
|
||||||
|
{
|
||||||
|
CURRENT_ADT,
|
||||||
|
SELECTED_ADTS,
|
||||||
|
MAP
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MinimapRenderSettings
|
||||||
|
{
|
||||||
|
MinimapGenMode export_mode; // Export mode
|
||||||
|
|
||||||
|
// Render settings
|
||||||
|
bool draw_m2 = false;
|
||||||
|
bool draw_wmo = true;
|
||||||
|
bool draw_water = true;
|
||||||
|
bool draw_adt_grid = false;
|
||||||
|
bool draw_elevation = false;
|
||||||
|
|
||||||
|
// Filtering
|
||||||
|
std::unordered_map<std::string, float> m2_model_filter_include; // filename, size category
|
||||||
|
std::vector<uint32_t> m2_instance_filter_include; // include specific M2 instances
|
||||||
|
std::vector<std::string> wmo_model_filter_exclude; // exclude WMOs by filename
|
||||||
|
std::vector<uint32_t> wmo_instance_filter_exclude; // exclude specific WMO instances
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace ui
|
||||||
|
{
|
||||||
|
class MinimapCreator : public QWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MinimapCreator (MapView* mapView, QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
void changeRadius(float change);
|
||||||
|
|
||||||
|
float brushRadius() const { return _radius; }
|
||||||
|
|
||||||
|
MinimapRenderSettings* getMinimapRenderSettings() { return &_render_settings; };
|
||||||
|
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
float _radius = 0.01f;
|
||||||
|
MinimapRenderSettings _render_settings;
|
||||||
|
QSlider* _radius_slider;
|
||||||
|
QDoubleSpinBox* _radius_spin;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,13 +12,14 @@ namespace noggit
|
|||||||
{
|
{
|
||||||
add_tool_icon (editing_mode::ground, tr("Raise / Lower"), font_awesome::chartarea);
|
add_tool_icon (editing_mode::ground, tr("Raise / Lower"), font_awesome::chartarea);
|
||||||
add_tool_icon (editing_mode::flatten_blur, tr("Flatten / Blur"), font_awesome::bacon);
|
add_tool_icon (editing_mode::flatten_blur, tr("Flatten / Blur"), font_awesome::bacon);
|
||||||
add_tool_icon (editing_mode::paint, tr("3D Paint"), font_awesome::paintbrush);
|
add_tool_icon (editing_mode::paint, tr("Texturing editor"),font_awesome::paintbrush);
|
||||||
add_tool_icon (editing_mode::holes, tr("Holes"), font_awesome::cut);
|
add_tool_icon (editing_mode::holes, tr("Holes"), font_awesome::cut);
|
||||||
add_tool_icon (editing_mode::areaid, tr("AreaID Paint"), font_awesome::objectgroup);
|
add_tool_icon (editing_mode::areaid, tr("Area ID"), font_awesome::objectgroup);
|
||||||
add_tool_icon (editing_mode::flags, tr("Impassible Flag"), font_awesome::ban);
|
add_tool_icon (editing_mode::flags, tr("Impassible flag"), font_awesome::ban);
|
||||||
add_tool_icon (editing_mode::water, tr("Water edit"), font_awesome::water);
|
add_tool_icon (editing_mode::water, tr("Water editor"), font_awesome::water);
|
||||||
add_tool_icon (editing_mode::mccv, tr("Shader editor"), font_awesome::eyedropper);
|
add_tool_icon (editing_mode::mccv, tr("Shader editor"), font_awesome::eyedropper);
|
||||||
add_tool_icon (editing_mode::object, tr("Object editor"), font_awesome::cube);
|
add_tool_icon (editing_mode::object, tr("Object editor"), font_awesome::cube);
|
||||||
|
add_tool_icon (editing_mode::minimap, tr("Minimap сreator"), font_awesome::cube);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toolbar::add_tool_icon(editing_mode mode, const QString& name, const font_awesome::icons& icon)
|
void toolbar::add_tool_icon(editing_mode mode, const QString& name, const font_awesome::icons& icon)
|
||||||
|
|||||||
Reference in New Issue
Block a user